diff --git a/docfx.json b/docfx.json index cceca40203e..269725313ef 100644 --- a/docfx.json +++ b/docfx.json @@ -88,6 +88,7 @@ "api/Microsoft.Activities**.yml": "microsoft.activities", "api/Microsoft.Build**.yml": "microsoft.build", "api/Microsoft.CSharp**.yml": "microsoft.csharp", + "api/Microsoft.Extensions**.yml": "microsoft.extensions", "api/Microsoft.JScript**.yml": "microsoft.jscript", "api/Microsoft.SqlServer**.yml": "microsoft.sqlserver", "api/Microsoft.VisualBasic**.yml": "microsoft.visualbasic", @@ -100,6 +101,7 @@ "api/System.Buffers**.yml": "system.buffers", "api/System.CodeDom**.yml": "system.codedom", "api/System.Collections**.yml": "system.collections", + "api/System.CommandLine**.yml": "system.commandline", "api/System.ComponentModel**.yml": "system.componentmodel", "api/System.Composition**.yml": "system.composition", "api/System.Configuration**.yml": "system.configuration", @@ -111,6 +113,7 @@ "api/System.Drawing**.yml": "system.drawing", "api/System.Dynamic**.yml": "system.dynamic", "api/System.EnterpriseServices**.yml": "system.enterpriseservices", + "api/System.Formats**.yml": "system.formats", "api/System.Globalization**.yml": "system.globalization", "api/System.IdentityModel**.yml": "system.identitymodel", "api/System.IO**.yml": "system.io", @@ -139,6 +142,7 @@ "api/System.Xaml**.yml": "system.xaml", "api/System.Xml**.yml": "system.xml", "api/UIAutomationClientsideProviders**.yml": "uiautomationclientsideproviders", + "api/Windows.UI**.yml": "windows.ui", "api/XamlGeneratedNamespace**.yml": "xamlgeneratednamespace" }, "langs": { diff --git a/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp b/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp deleted file mode 100644 index d20aed62b38..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Permissions; -using namespace System::IO; -using namespace System::Security::Cryptography::X509Certificates; - -//Reads a file. -array^ ReadFile( String^ fileName ) -{ - FileStream^ f = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - int size = (int)f->Length; - array^data = gcnew array(size); - size = f->Read( data, 0, size ); - f->Close(); - return data; -} - -[SecurityPermissionAttribute(SecurityAction::LinkDemand, Unrestricted = true)] -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - //Test for correct number of arguments. - if ( args->Length < 2 ) - { - Console::WriteLine( "Usage: CertInfo " ); - return -1; - } - - try - { - System::Security::Cryptography::X509Certificates::X509Certificate2 ^ x509 = - gcnew System::Security::Cryptography::X509Certificates::X509Certificate2; - - //Create X509Certificate2 object from .cer file. - array^rawData = ReadFile( args[ 1 ] ); - - x509->Import(rawData); - - //Print to console information contained in the certificate. - Console::WriteLine( "{0}Subject: {1}{0}", Environment::NewLine, x509->Subject ); - Console::WriteLine( "{0}Issuer: {1}{0}", Environment::NewLine, x509->Issuer ); - Console::WriteLine( "{0}Version: {1}{0}", Environment::NewLine, x509->Version ); - Console::WriteLine( "{0}Valid Date: {1}{0}", Environment::NewLine, x509->NotBefore ); - Console::WriteLine( "{0}Expiry Date: {1}{0}", Environment::NewLine, x509->NotAfter ); - Console::WriteLine( "{0}Thumbprint: {1}{0}", Environment::NewLine, x509->Thumbprint ); - Console::WriteLine( "{0}Serial Number: {1}{0}", Environment::NewLine, x509->SerialNumber ); - Console::WriteLine( "{0}Friendly Name: {1}{0}", Environment::NewLine, x509->PublicKey->Oid->FriendlyName ); - Console::WriteLine( "{0}Public Key Format: {1}{0}", Environment::NewLine, x509->PublicKey->EncodedKeyValue->Format(true) ); - Console::WriteLine( "{0}Raw Data Length: {1}{0}", Environment::NewLine, x509->RawData->Length ); - Console::WriteLine( "{0}Certificate to string: {1}{0}", Environment::NewLine, x509->ToString( true ) ); - Console::WriteLine( "{0}Certificate to XML String: {1}{0}", Environment::NewLine, x509->PublicKey->Key->ToXmlString( false ) ); - - //Add the certificate to a X509Store. - X509Store ^ store = gcnew X509Store; - store->Open( OpenFlags::MaxAllowed ); - store->Add( x509 ); - store->Close(); - } - catch ( DirectoryNotFoundException^ ) - { - Console::WriteLine( "Error: The directory specified could not be found." ); - } - catch ( IOException^ ) - { - Console::WriteLine( "Error: A file in the directory could not be accessed." ); - } - catch ( NullReferenceException^ ) - { - Console::WriteLine( "File must be a .cer file. Program does not have access to that type of file." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp b/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp deleted file mode 100644 index bbe9ba49645..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Permissions; -using namespace System::IO; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - try - { - X509Store ^ store = gcnew X509Store( "MY",StoreLocation::CurrentUser ); - store->Open( static_cast(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) ); - X509Certificate2Collection ^ collection = dynamic_cast(store->Certificates); - X509Certificate2Collection ^ fcollection = dynamic_cast(collection->Find( X509FindType::FindByTimeValid, DateTime::Now, false )); - X509Certificate2Collection ^ scollection = X509Certificate2UI::SelectFromCollection(fcollection, "Test Certificate Select","Select a certificate from the following list to get information on that certificate",X509SelectionFlag::MultiSelection); - Console::WriteLine( "Number of certificates: {0}{1}", scollection->Count, Environment::NewLine ); - System::Collections::IEnumerator^ myEnum = scollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - X509Certificate2 ^ x509 = safe_cast(myEnum->Current); - array^rawdata = x509->RawData; - Console::WriteLine( "Content Type: {0}{1}", X509Certificate2::GetCertContentType( rawdata ), Environment::NewLine ); - Console::WriteLine( "Friendly Name: {0}{1}", x509->FriendlyName, Environment::NewLine ); - Console::WriteLine( "Certificate Verified?: {0}{1}", x509->Verify(), Environment::NewLine ); - Console::WriteLine( "Simple Name: {0}{1}", x509->GetNameInfo( X509NameType::SimpleName, true ), Environment::NewLine ); - Console::WriteLine( "Signature Algorithm: {0}{1}", x509->SignatureAlgorithm->FriendlyName, Environment::NewLine ); - Console::WriteLine( "Private Key: {0}{1}", x509->PrivateKey->ToXmlString( false ), Environment::NewLine ); - Console::WriteLine( "Public Key: {0}{1}", x509->PublicKey->Key->ToXmlString( false ), Environment::NewLine ); - Console::WriteLine( "Certificate Archived?: {0}{1}", x509->Archived, Environment::NewLine ); - Console::WriteLine( "Length of Raw Data: {0}{1}", x509->RawData->Length, Environment::NewLine ); - x509->Reset(); - } - store->Close(); - } - catch ( CryptographicException^ ) - { - Console::WriteLine( "Information could not be written out for this certificate." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp deleted file mode 100644 index 262a32465c4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography::Xml; -using namespace System::Xml; -using namespace System::IO; - -/// This sample used the GetXml method in the CipherReference class to -/// write the XML values for the CipherReference to the console. - -[STAThread] -int main() -{ - - //Create a URI string. - String^ uri = "http://www.woodgrovebank.com/document.xml"; - - // Create a Base64 transform. The input content retrieved from the - // URI should be Base64-decoded before other processing. - Transform^ base64 = gcnew XmlDsigBase64Transform; - - //Create a transform chain and add the transform to it. - TransformChain^ tc = gcnew TransformChain; - tc->Add( base64 ); - - //Create information. - CipherReference ^ reference = gcnew CipherReference( uri,tc ); - - // Write the CipherReference value to the console. - Console::WriteLine( "Cipher Reference data: {0}", reference->GetXml()->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp b/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp deleted file mode 100644 index 914c8f0a8fb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// Types:System.Globalization.CompareInfo -// -using namespace System; -using namespace System::Text; -using namespace System::Globalization; - -int main() -{ - array^ sign = gcnew array { "<", "=", ">" }; - - // The code below demonstrates how strings compare - // differently for different cultures. - String^ s1 = "Coté"; - String^ s2 = "coté"; - String^ s3 = "côte"; - - // Set sort order of strings for French in France. - CompareInfo^ ci = (gcnew CultureInfo("fr-FR"))->CompareInfo; - Console::WriteLine(L"The LCID for {0} is {1}.", ci->Name, ci->LCID); - - // Display the result using fr-FR Compare of Coté = coté. - Console::WriteLine(L"fr-FR Compare: {0} {2} {1}", - s1, s2, sign[ci->Compare(s1, s2, CompareOptions::IgnoreCase) + 1]); - - // Display the result using fr-FR Compare of coté > côte. - Console::WriteLine(L"fr-FR Compare: {0} {2} {1}", - s2, s3, sign[ci->Compare(s2, s3, CompareOptions::None) + 1]); - - // Set sort order of strings for Japanese as spoken in Japan. - ci = (gcnew CultureInfo("ja-JP"))->CompareInfo; - Console::WriteLine(L"The LCID for {0} is {1}.", ci->Name, ci->LCID); - - // Display the result using ja-JP Compare of coté < côte. - Console::WriteLine("ja-JP Compare: {0} {2} {1}", - s2, s3, sign[ci->Compare(s2, s3) + 1]); -} - -// This code produces the following output. -// -// The LCID for fr-FR is 1036. -// fr-FR Compare: Coté = coté -// fr-FR Compare: coté > côte -// The LCID for ja-JP is 1041. -// ja-JP Compare: coté < côte -// - diff --git a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_AddRange/CPP/countercreationdatacollection_addrange.cpp b/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_AddRange/CPP/countercreationdatacollection_addrange.cpp deleted file mode 100644 index 2c6841d495b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_AddRange/CPP/countercreationdatacollection_addrange.cpp +++ /dev/null @@ -1,65 +0,0 @@ - - -// System::Diagnostics->CounterCreationDataCollection::ctor -// System::Diagnostics->CounterCreationDataCollection->AddRange(CounterCreationDataCollection) -/* -The following program demonstrates 'CounterCreationDataCollection()' constructor and -'AddRange(CounterCreationDataCollection)' method of 'CounterCreationDataCollection' class. -A 'CounterCreationData' Object* is created and added to an instance of 'CounterCreationDataCollection' -class. Then counters in the 'CounterCreationDataCollection' are displayed to the console. -*/ -// -// -#using - -using namespace System; -using namespace System::Diagnostics; -int main() -{ - PerformanceCounter^ myCounter; - try - { - String^ myCategoryName; - int numberOfCounters; - Console::Write( "Enter the number of counters : " ); - numberOfCounters = Int32::Parse( Console::ReadLine() ); - array^myCounterCreationData = gcnew array(numberOfCounters); - for ( int i = 0; i < numberOfCounters; i++ ) - { - Console::Write( "Enter the counter name for {0} counter : ", i ); - myCounterCreationData[ i ] = gcnew CounterCreationData; - myCounterCreationData[ i ]->CounterName = Console::ReadLine(); - } - CounterCreationDataCollection^ myCounterCollection = gcnew CounterCreationDataCollection( myCounterCreationData ); - Console::Write( "Enter the category Name : " ); - myCategoryName = Console::ReadLine(); - - // Check if the category already exists or not. - if ( !PerformanceCounterCategory::Exists( myCategoryName ) ) - { - CounterCreationDataCollection^ myNewCounterCollection = gcnew CounterCreationDataCollection; - - // Add the 'CounterCreationDataCollection' to 'CounterCreationDataCollection' Object*. - myNewCounterCollection->AddRange( myCounterCollection ); - PerformanceCounterCategory::Create( myCategoryName, "Sample Category", myNewCounterCollection ); - for ( int i = 0; i < numberOfCounters; i++ ) - { - myCounter = gcnew PerformanceCounter( myCategoryName,myCounterCreationData[ i ]->CounterName,"",false ); - - } - Console::WriteLine( "The list of counters in CounterCollection are: " ); - for ( int i = 0; i < myNewCounterCollection->Count; i++ ) - Console::WriteLine( "Counter {0} is '{1}'", i + 1, myNewCounterCollection[ i ]->CounterName ); - } - else - { - Console::WriteLine( "The category already exists" ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}.", e->Message ); - } -} -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Contains/CPP/countercreationdatacollection_contains.cpp b/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Contains/CPP/countercreationdatacollection_contains.cpp deleted file mode 100644 index 04c88582196..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Contains/CPP/countercreationdatacollection_contains.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// System::Diagnostics->CounterCreationDataCollection::Contains(CounterCreationData) -// System::Diagnostics->CounterCreationDataCollection::Remove(CounterCreationData) - -/* -The following program demonstrates 'Contains' and 'Remove' methods of -'CounterCreationDataCollection' class. An instance of 'CounterCreationDataCollection' -is created by passing an array of 'CounterCreationData'. A particular instance of -'CounterCreationData' is removed if it exist in the 'CounterCreationDataCollection'. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -void main() -{ - PerformanceCounter^ myCounter; - try - { -// -// - String^ myCategoryName; - int numberOfCounters; - Console::Write( "Enter the category Name :" ); - myCategoryName = Console::ReadLine(); - // Check if the category already exists or not. - if ( !PerformanceCounterCategory::Exists( myCategoryName ) ) - { - Console::Write( "Enter the number of counters : " ); - numberOfCounters = Int32::Parse( Console::ReadLine() ); - array^ myCounterCreationData = - gcnew array(numberOfCounters); - for ( int i = 0; i < numberOfCounters; i++ ) - { - Console::Write( "Enter the counter name for {0} counter : ", i ); - myCounterCreationData[ i ] = gcnew CounterCreationData; - myCounterCreationData[ i ]->CounterName = Console::ReadLine(); - } - CounterCreationDataCollection^ myCounterCollection = - gcnew CounterCreationDataCollection; - // Add the 'CounterCreationData[]' to 'CounterCollection'. - myCounterCollection->AddRange( myCounterCreationData ); - - PerformanceCounterCategory::Create( myCategoryName, - "Sample Category", myCounterCollection ); - - for ( int i = 0; i < numberOfCounters; i++ ) - { - myCounter = gcnew PerformanceCounter( myCategoryName, - myCounterCreationData[ i ]->CounterName, "", false ); - } - if ( myCounterCreationData->Length > 0 ) - { - if ( myCounterCollection->Contains( myCounterCreationData[ 0 ] ) ) - { - myCounterCollection->Remove( myCounterCreationData[ 0 ] ); - Console::WriteLine( "'{0}' counter is removed from the" + - " CounterCreationDataCollection", myCounterCreationData[ 0 ]->CounterName ); - } - } - else - { - Console::WriteLine( "The counters does not exist" ); - } - } - else - { - Console::WriteLine( "The category already exists" ); - } -// -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}.", e->Message ); - return; - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationData/CPP/countercreationdatacollection_ctor.cpp b/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationData/CPP/countercreationdatacollection_ctor.cpp deleted file mode 100644 index 5af877a5275..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationData/CPP/countercreationdatacollection_ctor.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// System::Diagnostics->CounterCreationDataCollection->CounterCreationDataCollection(CounterCreationData->Item[]) - -/* -The following program demonstrates 'CounterCreationDataCollection(CounterCreationData->Item[])' -constructor of 'CounterCreationDataCollection' class. -An instance of 'CounterCreationDataCollection' is created by passing an array of -'CounterCreationData' to the constructor. The counters of the 'CounterCreationDataCollection' -are displayed to the console. - -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -void main() -{ - PerformanceCounter^ myCounter; - try - { - -// - String^ myCategoryName; - int numberOfCounters; - Console::Write( "Enter the category Name : " ); - myCategoryName = Console::ReadLine(); - - // Check if the category already exists or not. - if ( !PerformanceCounterCategory::Exists( myCategoryName ) ) - { - Console::Write( "Enter the number of counters : " ); - numberOfCounters = Int32::Parse( Console::ReadLine() ); - array^myCounterCreationData = gcnew array(numberOfCounters); - for ( int i = 0; i < numberOfCounters; i++ ) - { - Console::Write( "Enter the counter name for {0} counter : ", i ); - myCounterCreationData[ i ] = gcnew CounterCreationData; - myCounterCreationData[ i ]->CounterName = Console::ReadLine(); - - } - CounterCreationDataCollection^ myCounterCollection = gcnew CounterCreationDataCollection( myCounterCreationData ); - - // Create the category. - PerformanceCounterCategory::Create( myCategoryName, "Sample Category", myCounterCollection ); - for ( int i = 0; i < numberOfCounters; i++ ) - { - myCounter = gcnew PerformanceCounter( myCategoryName,myCounterCreationData[ i ]->CounterName,"",false ); - - } - Console::WriteLine( "The list of counters in 'CounterCollection' are :" ); - for ( int i = 0; i < myCounterCollection->Count; i++ ) - Console::WriteLine( "Counter {0} is '{1}'", i, myCounterCollection[ i ]->CounterName ); - } - else - { - Console::WriteLine( "The category already exists" ); - } -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}.", e->Message ); - return; - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationDataCollection/CPP/countercreationdatacollection_ctor.cpp b/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationDataCollection/CPP/countercreationdatacollection_ctor.cpp deleted file mode 100644 index d9619066739..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationDataCollection/CPP/countercreationdatacollection_ctor.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// System::Diagnostics->CounterCreationDataCollection->CounterCreationDataCollection(CounterCreationDataCollection) -/* -The following program demonstrates 'CounterCreationDataCollection(CounterCreationDataCollection)' -constructor of 'CounterCreationDataCollection' class. -An instance of 'CounterCreationDataCollection' is created by passing another instance -of 'CounterCreationDataCollection'. The counters of the 'CounterCreationDataCollection' -are displayed to the console. -*/ -#using - -using namespace System; -using namespace System::Diagnostics; -void main() -{ - PerformanceCounter^ myCounter; - try - { -// - String^ myCategoryName; - int numberOfCounters; - Console::Write( "Enter the number of counters : " ); - numberOfCounters = Int32::Parse( Console::ReadLine() ); - array^myCounterCreationData = gcnew array(numberOfCounters); - for ( int i = 0; i < numberOfCounters; i++ ) - { - Console::Write( "Enter the counter name for {0} counter : ", i ); - myCounterCreationData[ i ] = gcnew CounterCreationData; - myCounterCreationData[ i ]->CounterName = Console::ReadLine(); - - } - CounterCreationDataCollection^ myCounterCollection = gcnew CounterCreationDataCollection( myCounterCreationData ); - Console::Write( "Enter the category Name:" ); - myCategoryName = Console::ReadLine(); - - // Check if the category already exists or not. - if ( !PerformanceCounterCategory::Exists( myCategoryName ) ) - { - CounterCreationDataCollection^ myNewCounterCollection = gcnew CounterCreationDataCollection( myCounterCollection ); - PerformanceCounterCategory::Create( myCategoryName, "Sample Category", myNewCounterCollection ); - for ( int i = 0; i < numberOfCounters; i++ ) - { - myCounter = gcnew PerformanceCounter( myCategoryName,myCounterCreationData[ i ]->CounterName,"",false ); - - } - Console::WriteLine( "The list of counters in 'CounterCollection' are : " ); - for ( int i = 0; i < myNewCounterCollection->Count; i++ ) - Console::WriteLine( "Counter {0} is '{1}'", i, myNewCounterCollection[ i ]->CounterName ); - } - else - { - Console::WriteLine( "The category already exists" ); - } -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}.", e->Message ); - return; - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/CPP/countercreationdatacollection_insert_indexof.cpp b/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/CPP/countercreationdatacollection_insert_indexof.cpp deleted file mode 100644 index e4e097db2f4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/CPP/countercreationdatacollection_insert_indexof.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// System::Diagnostics->CounterCreationDataCollection::Insert(int, CounterCreationData) -// System::Diagnostics->CounterCreationDataCollection::IndexOf(CounterCreationData) - -/* -The following program demonstrates 'IndexOf(CounterCreationData)' and 'Insert(int, CounterCreationData)' -methods of 'CounterCreationDataCollection' class. An instance of 'CounterCreationDataCollection' -is created by passing an array of 'CounterCreationData' to the constructor. A counter is inserted -into the 'CounterCreationDataCollection' at specified index. The inserted counter and -its index are displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -void main() -{ - PerformanceCounter^ myCounter; - try - { -// -// - String^ myCategoryName; - int numberOfCounters; - Console::Write( "Enter the category Name : " ); - myCategoryName = Console::ReadLine(); - // Check if the category already exists or not. - if ( !PerformanceCounterCategory::Exists( myCategoryName ) ) - { - Console::Write( "Enter the number of counters : " ); - numberOfCounters = Int32::Parse( Console::ReadLine() ); - array^ myCounterCreationData = - gcnew array(numberOfCounters); - - for ( int i = 0; i < numberOfCounters; i++ ) - { - Console::Write( "Enter the counter name for {0} counter ", i ); - myCounterCreationData[ i ] = gcnew CounterCreationData; - myCounterCreationData[ i ]->CounterName = Console::ReadLine(); - } - CounterCreationDataCollection^ myCounterCollection = - gcnew CounterCreationDataCollection( myCounterCreationData ); - CounterCreationData^ myInsertCounterCreationData = gcnew CounterCreationData( - "CounterInsert","",PerformanceCounterType::NumberOfItems32 ); - // Insert an instance of 'CounterCreationData' in the 'CounterCreationDataCollection'. - myCounterCollection->Insert( myCounterCollection->Count - 1, - myInsertCounterCreationData ); - Console::WriteLine( "'{0}' counter is inserted into 'CounterCreationDataCollection'", - myInsertCounterCreationData->CounterName ); - // Create the category. - PerformanceCounterCategory::Create( myCategoryName, "Sample Category", - myCounterCollection ); - - for ( int i = 0; i < numberOfCounters; i++ ) - { - myCounter = gcnew PerformanceCounter( myCategoryName, - myCounterCreationData[ i ]->CounterName, "", false ); - } - Console::WriteLine( "The index of '{0}' counter is {1}", - myInsertCounterCreationData->CounterName, myCounterCollection->IndexOf( myInsertCounterCreationData ) ); - } - else - { - Console::WriteLine( "The category already exists" ); - } -// -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}.", e->Message ); - return; - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/CounterSample_Ctor_2/CPP/countersample_ctor_2.cpp b/snippets/cpp/VS_Snippets_CLR/CounterSample_Ctor_2/CPP/countersample_ctor_2.cpp deleted file mode 100644 index 2fe2f7b3082..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CounterSample_Ctor_2/CPP/countersample_ctor_2.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// System::Diagnostics->CounterSample->CounterSample(long, long, long, long, long, long, PerformanceCounterType) -// System::Diagnostics->CounterSample->CounterSample(long, long, long, long, long, long, PerformanceCounterType, long) - -/* The following program demonstrates the constructors of the 'CounterSample' -structure. It creates an instance of performance counter, configures it -to interact with 'Processor' category, '% Processor Time' counter and -'0' instance, creates an instance of 'CounterSample', and displays -the corresponding fields. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -int main() -{ -// - PerformanceCounter^ myPerformanceCounter1 = gcnew PerformanceCounter( - "Processor","% Processor Time","0" ); - CounterSample myCounterSample1( 10L, 20L, 30L, 40L, 50L, 60L, - PerformanceCounterType::AverageCount64 ); - Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample1.CounterTimeStamp ); - - Console::WriteLine( "BaseValue = {0}", myCounterSample1.BaseValue ); - Console::WriteLine( "RawValue = {0}", myCounterSample1.RawValue ); - Console::WriteLine( "CounterFrequency = {0}", myCounterSample1.CounterFrequency ); - Console::WriteLine( "SystemFrequency = {0}", myCounterSample1.SystemFrequency ); - Console::WriteLine( "TimeStamp = {0}", myCounterSample1.TimeStamp ); - Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample1.TimeStamp100nSec ); - Console::WriteLine( "CounterType = {0}", myCounterSample1.CounterType ); - // Hold the results of sample. - myCounterSample1 = myPerformanceCounter1->NextSample(); - Console::WriteLine( "BaseValue = {0}", myCounterSample1.BaseValue ); - Console::WriteLine( "RawValue = {0}", myCounterSample1.RawValue ); - Console::WriteLine( "CounterFrequency = {0}", myCounterSample1.CounterFrequency ); - Console::WriteLine( "SystemFrequency = {0}", myCounterSample1.SystemFrequency ); - Console::WriteLine( "TimeStamp = {0}", myCounterSample1.TimeStamp ); - Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample1.TimeStamp100nSec ); - Console::WriteLine( "CounterType = {0}", myCounterSample1.CounterType ); -// - Console::WriteLine( "" ); - Console::WriteLine( "" ); -// - PerformanceCounter^ myPerformanceCounter2 = - gcnew PerformanceCounter( "Processor","% Processor Time","0" ); - CounterSample myCounterSample2( 10L, 20L, 30L, 40L, 50L, 60L, - PerformanceCounterType::AverageCount64,300); - Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample2.CounterTimeStamp ); - Console::WriteLine( "BaseValue = {0}", myCounterSample2.BaseValue ); - Console::WriteLine( "RawValue = {0}", myCounterSample2.RawValue ); - Console::WriteLine( "CounterFrequency = {0}", myCounterSample2.CounterFrequency ); - Console::WriteLine( "SystemFrequency = {0}", myCounterSample2.SystemFrequency ); - Console::WriteLine( "TimeStamp = {0}", myCounterSample2.TimeStamp ); - Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample2.TimeStamp100nSec ); - Console::WriteLine( "CounterType = {0}", myCounterSample2.CounterType ); - Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample2.CounterTimeStamp ); - // Hold the results of sample. - myCounterSample2 = myPerformanceCounter2->NextSample(); - Console::WriteLine( "BaseValue = {0}", myCounterSample2.BaseValue ); - Console::WriteLine( "RawValue = {0}", myCounterSample2.RawValue ); - Console::WriteLine( "CounterFrequency = {0}", myCounterSample2.CounterFrequency ); - Console::WriteLine( "SystemFrequency = {0}", myCounterSample2.SystemFrequency ); - Console::WriteLine( "TimeStamp = {0}", myCounterSample2.TimeStamp ); - Console::WriteLine( "TimeStamp100nSec = {0}", myCounterSample2.TimeStamp100nSec ); - Console::WriteLine( "CounterType = {0}", myCounterSample2.CounterType ); - Console::WriteLine( "CounterTimeStamp = {0}", myCounterSample2.CounterTimeStamp ); -// -} diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp deleted file mode 100644 index 99c669d9f27..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -using namespace System::Text; - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv); -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new TripleDES object to generate a random key - // and initialization vector (IV). - { - TripleDES^ tripleDes; - - try - { - tripleDes = TripleDES::Create(); - key = tripleDes->Key; - iv = tripleDes->IV; - } - finally - { - delete tripleDes; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - // The name/path of the file to write. - String^ filename = "CText.enc"; - - // Encrypt the string to a file. - EncryptTextToFile(original, filename, key, iv); - - // Decrypt the file back to a string. - String^ decrypted = DecryptTextFromFile(filename, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - TripleDES^ tripleDes = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create or open the specified file. - fStream = File::Open(path, FileMode::Create); - // Create a new TripleDES object. - tripleDes = TripleDES::Create(); - // Create a TripleDES encryptor from the key and IV - encryptor = tripleDes->CreateEncryptor(key, iv); - // Create a CryptoStream using the FileStream and encryptor - cStream = gcnew CryptoStream(fStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (tripleDes != nullptr) - delete tripleDes; - - if (fStream != nullptr) - delete fStream; - } -} - -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - TripleDES^ tripleDes = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - StreamReader^ reader = nullptr; - - try - { - // Open the specified file - fStream = File::OpenRead(path); - // Create a new TripleDES object. - tripleDes = TripleDES::Create(); - // Create a TripleDES decryptor from the key and IV - decryptor = tripleDes->CreateDecryptor(key, iv); - // Create a CryptoStream using the FileStream and decryptor - cStream = gcnew CryptoStream(fStream, decryptor, CryptoStreamMode::Read); - // Create a StreamReader to turn the bytes back into text - reader = gcnew StreamReader(cStream, Encoding::UTF8); - - // Read back all of the text from the StreamReader, which receives - // the decrypted bytes from the CryptoStream, which receives the - // encrypted bytes from the FileStream. - return reader->ReadToEnd(); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (tripleDes != nullptr) - delete tripleDes; - - if (fStream != nullptr) - delete fStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp deleted file mode 100644 index 3f109c53866..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp +++ /dev/null @@ -1,90 +0,0 @@ - -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; - -int main() -{ - - //The following example demonstrates the usage of the AsnEncodedData classes. - // Asn encoded data is read from the extensions of an X509 certificate. - try - { - - // Open the certificate store. - X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser ); - store->Open( static_cast(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) ); - X509Certificate2Collection^ collection = dynamic_cast(store->Certificates); - X509Certificate2Collection^ fcollection = dynamic_cast(collection->Find( X509FindType::FindByTimeValid, DateTime::Now, false )); - - // Select one or more certificates to display extensions information. - X509Certificate2Collection^ scollection = X509Certificate2UI::SelectFromCollection(fcollection, L"Certificate Select",L"Select certificates from the following list to get extension information on that certificate",X509SelectionFlag::MultiSelection); - - // Create a new AsnEncodedDataCollection object. - AsnEncodedDataCollection^ asncoll = gcnew AsnEncodedDataCollection; - for ( int i = 0; i < scollection->Count; i++ ) - { - - // Display certificate information. - Console::ForegroundColor = ConsoleColor::Red; - Console::WriteLine( L"Certificate name: {0}", scollection[i]->GetName() ); - Console::ResetColor(); - - // Display extensions information. - System::Collections::IEnumerator^ myEnum = scollection[i]->Extensions->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - X509Extension^ extension = safe_cast(myEnum->Current); - - // Create an AsnEncodedData object using the extensions information. - AsnEncodedData^ asndata = gcnew AsnEncodedData( extension->Oid,extension->RawData ); - Console::ForegroundColor = ConsoleColor::Green; - Console::WriteLine( L"Extension type: {0}", extension->Oid->FriendlyName ); - Console::WriteLine( L"Oid value: {0}", asndata->Oid->Value ); - Console::WriteLine( L"Raw data length: {0} {1}", asndata->RawData->Length, Environment::NewLine ); - Console::ResetColor(); - Console::WriteLine( asndata->Format(true) ); - Console::WriteLine( Environment::NewLine ); - - // Add the AsnEncodedData object to the AsnEncodedDataCollection object. - asncoll->Add( asndata ); - } - - Console::WriteLine( Environment::NewLine ); - - } - Console::ForegroundColor = ConsoleColor::Red; - Console::WriteLine( L"Number of AsnEncodedData items in the collection: {0} {1}", asncoll->Count, Environment::NewLine ); - Console::ResetColor(); - store->Close(); - - //Create an enumerator for moving through the collection. - AsnEncodedDataEnumerator^ asne = asncoll->GetEnumerator(); - - //You must execute a MoveNext() to get to the first item in the collection. - asne->MoveNext(); - - // Write out AsnEncodedData in the collection. - Console::ForegroundColor = ConsoleColor::Blue; - Console::WriteLine( L"First AsnEncodedData in the collection: {0}", asne->Current->Format(true) ); - Console::ResetColor(); - asne->MoveNext(); - Console::ForegroundColor = ConsoleColor::DarkBlue; - Console::WriteLine( L"Second AsnEncodedData in the collection: {0}", asne->Current->Format(true) ); - Console::ResetColor(); - - //Return index in the collection to the beginning. - asne->Reset(); - } - catch ( CryptographicException^ ) - { - Console::WriteLine( L"Information could not be written out for this certificate." ); - } - - return 1; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp deleted file mode 100644 index e48f4e14aa9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -using namespace System::Text; - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv); -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new DES object to generate a random key - // and initialization vector (IV). - { - DES^ des; - - try - { - des = DES::Create(); - key = des->Key; - iv = des->IV; - } - finally - { - delete des; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - // The name/path of the file to write. - String^ filename = "CText.enc"; - - // Encrypt the string to a file. - EncryptTextToFile(original, filename, key, iv); - - // Decrypt the file back to a string. - String^ decrypted = DecryptTextFromFile(filename, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - DES^ des = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create or open the specified file. - fStream = File::Open(path, FileMode::Create); - // Create a new DES object. - des = DES::Create(); - // Create a DES encryptor from the key and IV - encryptor = des->CreateEncryptor(key, iv); - // Create a CryptoStream using the FileStream and encryptor - cStream = gcnew CryptoStream(fStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (des != nullptr) - delete des; - - if (fStream != nullptr) - delete fStream; - } -} - -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - DES^ des = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - StreamReader^ reader = nullptr; - - try - { - // Open the specified file - fStream = File::OpenRead(path); - // Create a new DES object. - des = DES::Create(); - // Create a DES decryptor from the key and IV - decryptor = des->CreateDecryptor(key, iv); - // Create a CryptoStream using the FileStream and decryptor - cStream = gcnew CryptoStream(fStream, decryptor, CryptoStreamMode::Read); - // Create a StreamReader to turn the bytes back into text - reader = gcnew StreamReader(cStream, Encoding::UTF8); - - // Read back all of the text from the StreamReader, which receives - // the decrypted bytes from the CryptoStream, which receives the - // encrypted bytes from the FileStream. - return reader->ReadToEnd(); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (des != nullptr) - delete des; - - if (fStream != nullptr) - delete fStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp deleted file mode 100644 index 27a8c01000f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp +++ /dev/null @@ -1,170 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; - -array^ EncryptTextToMemory(String^ text, array^ key, array^ iv); -String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new DES object to generate a random key - // and initialization vector (IV). - { - DES^ des; - - try - { - des = DES::Create(); - key = des->Key; - iv = des->IV; - } - finally - { - delete des; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - - // Encrypt the string to an in-memory buffer. - array^ encrypted = EncryptTextToMemory(original, key, iv); - - // Decrypt the buffer back to a string. - String^ decrypted = DecryptTextFromMemory(encrypted, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -array^ EncryptTextToMemory(String^ text, array^ key, array^ iv) -{ - MemoryStream^ mStream = nullptr; - - try - { - // Create a MemoryStream. - mStream = gcnew MemoryStream; - - DES^ des = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create a new DES object. - des = DES::Create(); - // Create a DES encryptor from the key and IV - encryptor = des->CreateEncryptor(key, iv); - // Create a CryptoStream using the MemoryStream and encryptor - cStream = gcnew CryptoStream(mStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - - // Disposing the CryptoStream completes the encryption and flushes the stream. - delete cStream; - - // Get an array of bytes from the MemoryStream that holds the encrypted data. - array^ ret = mStream->ToArray(); - - // Return the encrypted buffer. - return ret; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (des != nullptr) - delete des; - } - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (mStream != nullptr) - delete mStream; - } -} - -String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv) -{ - MemoryStream^ mStream = nullptr; - DES^ des = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create buffer to hold the decrypted data. - // DES-encrypted data will always be slightly bigger than the decrypted data. - array^ decrypted = gcnew array(encrypted->Length); - Int32 offset = 0; - - // Create a new MemoryStream using the provided array of encrypted data. - mStream = gcnew MemoryStream(encrypted); - // Create a new DES object. - des = DES::Create(); - // Create a DES decryptor from the key and IV - decryptor = des->CreateDecryptor(key, iv); - // Create a CryptoStream using the MemoryStream and decryptor - cStream = gcnew CryptoStream(mStream, decryptor, CryptoStreamMode::Read); - - // Keep reading from the CryptoStream until it finishes (returns 0). - Int32 read = 1; - - while (read > 0) - { - read = cStream->Read(decrypted, offset, decrypted->Length - offset); - offset += read; - } - - // Convert the buffer into a string and return it. - return Encoding::UTF8->GetString(decrypted, 0, offset); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (des != nullptr) - delete des; - - if (mStream != nullptr) - delete mStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp deleted file mode 100644 index 0aeedb91f59..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp +++ /dev/null @@ -1,113 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; -void EncryptTextToFile( String^ Data, String^ FileName, array^Key, array^IV ) -{ - try - { - - // Create or open the specified file. - FileStream^ fStream = File::Open( FileName, FileMode::OpenOrCreate ); - - // Create a CryptoStream using the FileStream - // and the passed key and initialization vector (IV). - CryptoStream^ cStream = gcnew CryptoStream( fStream,(gcnew DESCryptoServiceProvider)->CreateEncryptor( Key, IV ),CryptoStreamMode::Write ); - - // Create a StreamWriter using the CryptoStream. - StreamWriter^ sWriter = gcnew StreamWriter( cStream ); - - // Write the data to the stream - // to encrypt it. - sWriter->WriteLine( Data ); - - // Close the streams and - // close the file. - sWriter->Close(); - cStream->Close(); - fStream->Close(); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message ); - } - catch ( UnauthorizedAccessException^ e ) - { - Console::WriteLine( "A file error occurred: {0}", e->Message ); - } - -} - -String^ DecryptTextFromFile( String^ FileName, array^Key, array^IV ) -{ - try - { - - // Create or open the specified file. - FileStream^ fStream = File::Open( FileName, FileMode::OpenOrCreate ); - - // Create a CryptoStream using the FileStream - // and the passed key and initialization vector (IV). - CryptoStream^ cStream = gcnew CryptoStream( fStream,(gcnew DESCryptoServiceProvider)->CreateDecryptor( Key, IV ),CryptoStreamMode::Read ); - - // Create a StreamReader using the CryptoStream. - StreamReader^ sReader = gcnew StreamReader( cStream ); - - // Read the data from the stream - // to decrypt it. - String^ val = sReader->ReadLine(); - - // Close the streams and - // close the file. - sReader->Close(); - cStream->Close(); - fStream->Close(); - - // Return the string. - return val; - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message ); - return nullptr; - } - catch ( UnauthorizedAccessException^ e ) - { - Console::WriteLine( "A file error occurred: {0}", e->Message ); - return nullptr; - } - -} - -int main() -{ - try - { - - // Create a new DESCryptoServiceProvider object - // to generate a key and initialization vector (IV). - DESCryptoServiceProvider^ DESalg = gcnew DESCryptoServiceProvider; - - // Create a string to encrypt. - String^ sData = "Here is some data to encrypt."; - String^ FileName = "CText.txt"; - - // Encrypt text to a file using the file name, key, and IV. - EncryptTextToFile( sData, FileName, DESalg->Key, DESalg->IV ); - - // Decrypt the text from a file using the file name, key, and IV. - String^ Final = DecryptTextFromFile( FileName, DESalg->Key, DESalg->IV ); - - // Display the decrypted string to the console. - Console::WriteLine( Final ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp deleted file mode 100644 index 3fdcdbcd1dd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp +++ /dev/null @@ -1,105 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; -array^ EncryptTextToMemory( String^ Data, array^Key, array^IV ) -{ - try - { - - // Create a MemoryStream. - MemoryStream^ mStream = gcnew MemoryStream; - - // Create a CryptoStream using the MemoryStream - // and the passed key and initialization vector (IV). - CryptoStream^ cStream = gcnew CryptoStream( mStream,(gcnew DESCryptoServiceProvider)->CreateEncryptor( Key, IV ),CryptoStreamMode::Write ); - - // Convert the passed string to a byte array. - array^toEncrypt = (gcnew ASCIIEncoding)->GetBytes( Data ); - - // Write the byte array to the crypto stream and flush it. - cStream->Write( toEncrypt, 0, toEncrypt->Length ); - cStream->FlushFinalBlock(); - - // Get an array of bytes from the - // MemoryStream that holds the - // encrypted data. - array^ret = mStream->ToArray(); - - // Close the streams. - cStream->Close(); - mStream->Close(); - - // Return the encrypted buffer. - return ret; - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message ); - return nullptr; - } - -} - -String^ DecryptTextFromMemory( array^Data, array^Key, array^IV ) -{ - try - { - - // Create a new MemoryStream using the passed - // array of encrypted data. - MemoryStream^ msDecrypt = gcnew MemoryStream( Data ); - - // Create a CryptoStream using the MemoryStream - // and the passed key and initialization vector (IV). - CryptoStream^ csDecrypt = gcnew CryptoStream( msDecrypt,(gcnew DESCryptoServiceProvider)->CreateDecryptor( Key, IV ),CryptoStreamMode::Read ); - - // Create buffer to hold the decrypted data. - array^fromEncrypt = gcnew array(Data->Length); - - // Read the decrypted data out of the crypto stream - // and place it into the temporary buffer. - csDecrypt->Read( fromEncrypt, 0, fromEncrypt->Length ); - - //Convert the buffer into a string and return it. - return (gcnew ASCIIEncoding)->GetString( fromEncrypt ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message ); - return nullptr; - } - -} - -int main() -{ - try - { - - // Create a new DESCryptoServiceProvider object - // to generate a key and initialization vector (IV). - DESCryptoServiceProvider^ DESalg = gcnew DESCryptoServiceProvider; - - // Create a string to encrypt. - String^ sData = "Here is some data to encrypt."; - - // Encrypt the string to an in-memory buffer. - array^Data = EncryptTextToMemory( sData, DESalg->Key, DESalg->IV ); - - // Decrypt the buffer back to a string. - String^ Final = DecryptTextFromMemory( Data, DESalg->Key, DESalg->IV ); - - // Display the decrypted string to the console. - Console::WriteLine( Final ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp deleted file mode 100644 index 7b3ed1ec455..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Security::Cryptography; - -public ref class DataProtectionSample -{ -private: - - // Create byte array for additional entropy when using Protect method. - static array^s_additionalEntropy = {9,8,7,6,5}; - -public: - static void Main() - { - - // Create a simple byte array containing data to be encrypted. - array^secret = {0,1,2,3,4,1,2,3,4}; - - //Encrypt the data. - array^encryptedSecret = Protect( secret ); - Console::WriteLine( "The encrypted byte array is:" ); - PrintValues( encryptedSecret ); - - // Decrypt the data and store in a byte array. - array^originalData = Unprotect( encryptedSecret ); - Console::WriteLine( "{0}The original data is:", Environment::NewLine ); - PrintValues( originalData ); - } - - static array^ Protect( array^data ) - { - try - { - - // Encrypt the data using DataProtectionScope.CurrentUser. The result can be decrypted - // only by the same current user. - return ProtectedData::Protect( data, s_additionalEntropy, DataProtectionScope::CurrentUser ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "Data was not encrypted. An error occurred." ); - Console::WriteLine( e ); - return nullptr; - } - } - - static array^ Unprotect( array^data ) - { - try - { - - //Decrypt the data using DataProtectionScope.CurrentUser. - return ProtectedData::Unprotect( data, s_additionalEntropy, DataProtectionScope::CurrentUser ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "Data was not decrypted. An error occurred." ); - Console::WriteLine( e ); - return nullptr; - } - } - - static void PrintValues( array^myArr ) - { - System::Collections::IEnumerator^ myEnum = myArr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte i = safe_cast(myEnum->Current); - Console::Write( "\t{0}", i ); - } - - Console::WriteLine(); - } -}; - -int main() -{ - DataProtectionSample::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp deleted file mode 100644 index 8bd6a68686f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp +++ /dev/null @@ -1,20 +0,0 @@ -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Security::Cryptography; - -int main() -{ - // - // Create a new CspParameters object. - CspParameters^ cspParams = gcnew CspParameters(); - - // Specify an exchange key. - cspParams->KeyNumber = (int) KeyNumber::Exchange; - - // Initialize the RSACryptoServiceProvider - // with the CspParameters object. - RSACryptoServiceProvider^ RSACSP = gcnew RSACryptoServiceProvider(cspParams); - // -}; - diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp deleted file mode 100644 index 3189ba48a53..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Security::Cryptography; -int main() -{ - - // Assign values to strings. - String^ Value1 = "1.2.840.113549.1.1.1"; - String^ Name1 = "3DES"; - String^ Value2 = "1.3.6.1.4.1.311.20.2"; - String^ InvalidName = "This name is not a valid name"; - String^ InvalidValue = "1.1.1.1.1.1.1.1"; - - // Create new Oid objects using the specified values. - // Note that the corresponding Value or Friendly Name property is automatically added to the object. - Oid ^ o1 = gcnew Oid( Value1 ); - Oid ^ o2 = gcnew Oid( Name1 ); - - // Create a new Oid object using the specified Value and Friendly Name properties. - // Note that the two are not compared to determine if the Value is associated - // with the Friendly Name. - Oid ^ o3 = gcnew Oid( Value2,InvalidName ); - - //Create a new Oid object using the specified Value. Note that if the value - // is invalid or not known, no value is assigned to the Friendly Name property. - Oid ^ o4 = gcnew Oid( InvalidValue ); - - //Write out the property information of the Oid objects. - Console::WriteLine( "Oid1: Automatically assigned Friendly Name: {0}, {1}", o1->FriendlyName, o1->Value ); - Console::WriteLine( "Oid2: Automatically assigned Value: {0}, {1}", o2->FriendlyName, o2->Value ); - Console::WriteLine( "Oid3: Name and Value not compared: {0}, {1}", o3->FriendlyName, o3->Value ); - Console::WriteLine( "Oid4: Invalid Value used: {0}, {1} {2}", o4->FriendlyName, o4->Value, Environment::NewLine ); - - //Create an Oid collection and add several Oid objects. - OidCollection ^ oc = gcnew OidCollection; - oc->Add( o1 ); - oc->Add( o2 ); - oc->Add( o3 ); - Console::WriteLine( "Number of Oids in the collection: {0}", oc->Count ); - Console::WriteLine( "Is synchronized: {0} {1}", oc->IsSynchronized, Environment::NewLine ); - - //Create an enumerator for moving through the collection. - OidEnumerator ^ oe = oc->GetEnumerator(); - - //You must execute a MoveNext() to get to the first item in the collection. - oe->MoveNext(); - - // Write out Oids in the collection. - Console::WriteLine( "First Oid in collection: {0},{1}", oe->Current->FriendlyName, oe->Current->Value ); - oe->MoveNext(); - Console::WriteLine( "Second Oid in collection: {0},{1}", oe->Current->FriendlyName, oe->Current->Value ); - - //Return index in the collection to the beginning. - oe->Reset(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp deleted file mode 100644 index 06b5a8483db..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; - -// Generates a random salt value of the specified length. -array^ CreateRandomSalt(int length) -{ - // Create a buffer - array^ randomBytes; - - if (length >= 1) - { - randomBytes = gcnew array (length); - } - else - { - randomBytes = gcnew array (1); - } - - // Create a new RandomNumberGenerator. - RandomNumberGenerator^ randomNumberGenerator = - RandomNumberGenerator::Create(); - - // Fill the buffer with random bytes. - randomNumberGenerator->GetBytes(randomBytes); - - // return the bytes. - return randomBytes; -} - -// Clears the bytes in a buffer so they can't later be read from memory. -void ClearBytes(array^ buffer) -{ - // Check arguments. - if (buffer == nullptr) - { - throw gcnew ArgumentNullException("buffer"); - } - - // Set each byte in the buffer to 0. - for (int x = 0; x <= buffer->Length - 1; x++) - { - buffer[x] = 0; - } -} - -int main(array^ args) -{ - - // Get a password from the user. - Console::WriteLine("Enter a password to produce a key:"); - - // Security Note: Never hard-code a password within your - // source code. Hard-coded passwords can be retrieved - // from a compiled assembly. - array^ password = Encoding::Unicode->GetBytes(Console::ReadLine()); - - array^ randomSalt = CreateRandomSalt(7); - - // Create a TripleDESCryptoServiceProvider object. - TripleDESCryptoServiceProvider^ cryptoDESProvider = - gcnew TripleDESCryptoServiceProvider(); - - try - { - Console::WriteLine("Creating a key with PasswordDeriveBytes..."); - - // Create a PasswordDeriveBytes object and then create - // a TripleDES key from the password and salt. - PasswordDeriveBytes^ passwordDeriveBytes = gcnew PasswordDeriveBytes - (password->ToString(), randomSalt); - - // - // Create the key and set it to the Key property - // of the TripleDESCryptoServiceProvider object. - // This example uses the SHA1 algorithm. - // Due to collision problems with SHA1, Microsoft recommends SHA256 or better. - cryptoDESProvider->Key = passwordDeriveBytes->CryptDeriveKey - ("TripleDES", "SHA1", 192, cryptoDESProvider->IV); - // - Console::WriteLine("Operation complete."); - } - catch (Exception^ ex) - { - Console::WriteLine(ex->Message); - } - finally - { - // Clear the buffers - ClearBytes(password); - ClearBytes(randomSalt); - - // Clear the key. - cryptoDESProvider->Clear(); - } - - Console::ReadLine(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp deleted file mode 100644 index c6753a5be6f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -using namespace System::Text; - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv); -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new RC2 object to generate a random key - // and initialization vector (IV). - { - RC2^ rc2; - - try - { - rc2 = RC2::Create(); - key = rc2->Key; - iv = rc2->IV; - } - finally - { - delete rc2; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - // The name/path of the file to write. - String^ filename = "CText.enc"; - - // Encrypt the string to a file. - EncryptTextToFile(original, filename, key, iv); - - // Decrypt the file back to a string. - String^ decrypted = DecryptTextFromFile(filename, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - RC2^ rc2 = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create or open the specified file. - fStream = File::Open(path, FileMode::Create); - // Create a new RC2 object. - rc2 = RC2::Create(); - // Create an RC2 encryptor from the key and IV - encryptor = rc2->CreateEncryptor(key, iv); - // Create a CryptoStream using the FileStream and encryptor - cStream = gcnew CryptoStream(fStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (rc2 != nullptr) - delete rc2; - - if (fStream != nullptr) - delete fStream; - } -} - -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - RC2^ rc2 = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - StreamReader^ reader = nullptr; - - try - { - // Open the specified file - fStream = File::OpenRead(path); - // Create a new RC2 object. - rc2 = RC2::Create(); - // Create an RC2 decryptor from the key and IV - decryptor = rc2->CreateDecryptor(key, iv); - // Create a CryptoStream using the FileStream and decryptor - cStream = gcnew CryptoStream(fStream, decryptor, CryptoStreamMode::Read); - // Create a StreamReader to turn the bytes back into text - reader = gcnew StreamReader(cStream, Encoding::UTF8); - - // Read back all of the text from the StreamReader, which receives - // the decrypted bytes from the CryptoStream, which receives the - // encrypted bytes from the FileStream. - return reader->ReadToEnd(); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (rc2 != nullptr) - delete rc2; - - if (fStream != nullptr) - delete fStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp deleted file mode 100644 index 3179ea1bfc1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp +++ /dev/null @@ -1,170 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; - -array^ EncryptTextToMemory(String^ text, array^ key, array^ iv); -String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new RC2 object to generate a random key - // and initialization vector (IV). - { - RC2^ rc2; - - try - { - rc2 = RC2::Create(); - key = rc2->Key; - iv = rc2->IV; - } - finally - { - delete rc2; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - - // Encrypt the string to an in-memory buffer. - array^ encrypted = EncryptTextToMemory(original, key, iv); - - // Decrypt the buffer back to a string. - String^ decrypted = DecryptTextFromMemory(encrypted, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -array^ EncryptTextToMemory(String^ text, array^ key, array^ iv) -{ - MemoryStream^ mStream = nullptr; - - try - { - // Create a MemoryStream. - mStream = gcnew MemoryStream; - - RC2^ rc2 = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create a new RC2 object. - rc2 = RC2::Create(); - // Create an RC2 encryptor from the key and IV - encryptor = rc2->CreateEncryptor(key, iv); - // Create a CryptoStream using the MemoryStream and encryptor - cStream = gcnew CryptoStream(mStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - - // Disposing the CryptoStream completes the encryption and flushes the stream. - delete cStream; - - // Get an array of bytes from the MemoryStream that holds the encrypted data. - array^ ret = mStream->ToArray(); - - // Return the encrypted buffer. - return ret; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (rc2 != nullptr) - delete rc2; - } - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (mStream != nullptr) - delete mStream; - } -} - -String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv) -{ - MemoryStream^ mStream = nullptr; - RC2^ rc2 = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create buffer to hold the decrypted data. - // RC2-encrypted data will always be slightly bigger than the decrypted data. - array^ decrypted = gcnew array(encrypted->Length); - Int32 offset = 0; - - // Create a new MemoryStream using the provided array of encrypted data. - mStream = gcnew MemoryStream(encrypted); - // Create a new RC2 object. - rc2 = RC2::Create(); - // Create an RC2 decryptor from the key and IV - decryptor = rc2->CreateDecryptor(key, iv); - // Create a CryptoStream using the MemoryStream and decryptor - cStream = gcnew CryptoStream(mStream, decryptor, CryptoStreamMode::Read); - - // Keep reading from the CryptoStream until it finishes (returns 0). - Int32 read = 1; - - while (read > 0) - { - read = cStream->Read(decrypted, offset, decrypted->Length - offset); - offset += read; - } - - // Convert the buffer into a string and return it. - return Encoding::UTF8->GetString(decrypted, 0, offset); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (rc2 != nullptr) - delete rc2; - - if (mStream != nullptr) - delete mStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp deleted file mode 100644 index 2c8834fcc20..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Security::Cryptography; - -int main() -{ - array ^ originalBytes = - ASCIIEncoding::ASCII->GetBytes("Here is some data."); - - //Create a new RC2CryptoServiceProvider. - RC2CryptoServiceProvider^ rc2Provider = - gcnew RC2CryptoServiceProvider(); - rc2Provider->UseSalt = true; - - rc2Provider->GenerateKey(); - rc2Provider->GenerateIV(); - - //Encrypt the data. - MemoryStream^ encryptionMemoryStream = gcnew MemoryStream(); - CryptoStream^ encryptionCryptoStream = gcnew CryptoStream( - encryptionMemoryStream, rc2Provider->CreateEncryptor( - rc2Provider->Key, rc2Provider->IV), CryptoStreamMode::Write); - - //Write all data to the crypto stream and flush it. - encryptionCryptoStream->Write(originalBytes, 0, originalBytes->Length); - encryptionCryptoStream->FlushFinalBlock(); - - //Get encrypted array of bytes. - array^ encryptedBytes = encryptionMemoryStream->ToArray(); - - //Decrypt the previously encrypted message. - MemoryStream^ decryptionMemoryStream = - gcnew MemoryStream(encryptedBytes); - CryptoStream^ decryptionCryptoStream = - gcnew CryptoStream(decryptionMemoryStream, - rc2Provider->CreateDecryptor(rc2Provider->Key,rc2Provider->IV), - CryptoStreamMode::Read); - - array^ unencryptedBytes = - gcnew array(originalBytes->Length); - - //Read the data out of the crypto stream. - decryptionCryptoStream->Read(unencryptedBytes, 0, - unencryptedBytes->Length); - - //Convert the byte array back into a string. - String^ plainText = ASCIIEncoding::ASCII->GetString(unencryptedBytes); - - //Display the results. - Console::WriteLine("Unencrypted text: {0}", plainText); - - Console::ReadLine(); -} - -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp deleted file mode 100644 index 97053716b78..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -int main() -{ - try - { - - //Create a UnicodeEncoder to convert between byte array and string. - ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding; - String^ dataString = "Data to Encrypt"; - - //Create byte arrays to hold original, encrypted, and decrypted data. - array^dataToEncrypt = ByteConverter->GetBytes( dataString ); - array^encryptedData; - array^decryptedData; - - //Create a new instance of the RSACryptoServiceProvider class - // and automatically create a new key-pair. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - //Display the origianl data to the console. - Console::WriteLine( "Original Data: {0}", dataString ); - - //Encrypt the byte array and specify no OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - encryptedData = RSAalg->Encrypt( dataToEncrypt, false ); - - //Display the encrypted data to the console. - Console::WriteLine( "Encrypted Data: {0}", ByteConverter->GetString( encryptedData ) ); - - //Pass the data to ENCRYPT and boolean flag specifying - //no OAEP padding. - decryptedData = RSAalg->Decrypt( encryptedData, false ); - - //Display the decrypted plaintext to the console. - Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) ); - } - catch ( CryptographicException^ e ) - { - - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp deleted file mode 100644 index aac2730c2f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp +++ /dev/null @@ -1,81 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -void RSAPersistKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider to generate - //a new key pair. Pass the CspParameters class to persist the - //key in the container. The PersistKeyInCsp property is true by - //default, allowing the key to be persisted. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key was persisted in the container, \"{0}\".", ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -void RSADeleteKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider. - //Pass the CspParameters class to use the - //key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Explicitly set the PersistKeyInCsp property to false - //to delete the key entry in the container. - RSAalg->PersistKeyInCsp = false; - - //Call Clear to release resources and delete the key from the container. - RSAalg->Clear(); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key was deleted from the container, \"{0}\".", ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -int main() -{ - String^ KeyContainerName = "MyKeyContainer"; - - //Create a new key and persist it in - //the key container. - RSAPersistKeyInCSP( KeyContainerName ); - - //Delete the key from the key container. - RSADeleteKeyInCSP( KeyContainerName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp deleted file mode 100644 index cea1dc68672..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp +++ /dev/null @@ -1,107 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -array^ HashAndSignBytes( array^DataToSign, RSAParameters Key, int Index, int Length ) -{ - try - { - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Hash and sign the data. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->SignData( DataToSign, Index, Length, SHA256::Create() ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -bool VerifySignedHash( array^DataToVerify, array^SignedData, RSAParameters Key ) -{ - try - { - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Verify the data using the signature. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->VerifyData( DataToVerify, SHA256::Create(), SignedData ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return false; - } - -} - -int main() -{ - try - { - - // Create a UnicodeEncoder to convert between byte array and string. - ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding; - String^ dataString = "Data to Sign"; - - // Create byte arrays to hold original, encrypted, and decrypted data. - array^originalData = ByteConverter->GetBytes( dataString ); - array^signedData; - array^smallArray; - - // Create a new instance of the RSACryptoServiceProvider class - // and automatically create a new key-pair. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - // Export the key information to an RSAParameters object. - // You must pass true to export the private key for signing. - // However, you do not need to export the private key - // for verification. - RSAParameters Key = RSAalg->ExportParameters( true ); - - // Hash and sign the data. Start at the fifth offset - // only use data from the next 7 bytes. - signedData = HashAndSignBytes( originalData, Key, 5, 7 ); - - // The previous method only signed one segment - // of the array. Create a new array for verification - // that only holds the data that was actually signed. - // - // Initialize the array. - smallArray = gcnew array(7); - - // Copy 7 bytes starting at the 5th index to - // the new array. - Array::Copy( originalData, 5, smallArray, 0, 7 ); - - // Verify the data and display the result to the - // console. - if ( VerifySignedHash( smallArray, signedData, Key ) ) - { - Console::WriteLine( "The data was verified." ); - } - else - { - Console::WriteLine( "The data does not match the signature." ); - } - } - catch ( ArgumentNullException^ ) - { - Console::WriteLine( "The data was not signed or verified" ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp deleted file mode 100644 index aa2a389c449..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -array^ HashAndSignBytes( array^DataToSign, RSAParameters Key ) -{ - try - { - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Hash and sign the data. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->SignData( DataToSign, SHA256::Create() ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -bool VerifySignedHash( array^DataToVerify, array^SignedData, RSAParameters Key ) -{ - try - { - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Verify the data using the signature. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->VerifyData( DataToVerify, SHA256::Create(), SignedData ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return false; - } - -} - -int main() -{ - try - { - - // Create a UnicodeEncoder to convert between byte array and string. - ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding; - String^ dataString = "Data to Sign"; - - // Create byte arrays to hold original, encrypted, and decrypted data. - array^originalData = ByteConverter->GetBytes( dataString ); - array^signedData; - - // Create a new instance of the RSACryptoServiceProvider class - // and automatically create a new key-pair. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - // Export the key information to an RSAParameters object. - // You must pass true to export the private key for signing. - // However, you do not need to export the private key - // for verification. - RSAParameters Key = RSAalg->ExportParameters( true ); - - // Hash and sign the data. - signedData = HashAndSignBytes( originalData, Key ); - - // Verify the data and display the result to the - // console. - if ( VerifySignedHash( originalData, signedData, Key ) ) - { - Console::WriteLine( "The data was verified." ); - } - else - { - Console::WriteLine( "The data does not match the signature." ); - } - } - catch ( ArgumentNullException^ ) - { - Console::WriteLine( "The data was not signed or verified" ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp deleted file mode 100644 index ac322898229..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp +++ /dev/null @@ -1,110 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; -array^ HashAndSignBytes( Stream^ DataStream, RSAParameters Key ) -{ - try - { - - // Reset the current position in the stream to - // the beginning of the stream (0). RSACryptoServiceProvider - // can't verify the data unless the stream position - // is set to the starting position of the data. - DataStream->Position = 0; - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Hash and sign the data. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->SignData( DataStream, SHA256::Create() ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -bool VerifySignedHash( array^DataToVerify, array^SignedData, RSAParameters Key ) -{ - try - { - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Verify the data using the signature. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->VerifyData( DataToVerify, SHA256(), SignedData ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return false; - } - -} - -int main() -{ - try - { - ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding; - - // Create some bytes to be signed. - array^dataBytes = ByteConverter->GetBytes( "Here is some data to sign!" ); - - // Create a buffer for the memory stream. - array^buffer = gcnew array(dataBytes->Length); - - // Create a MemoryStream. - MemoryStream^ mStream = gcnew MemoryStream( buffer ); - - // Write the bytes to the stream and flush it. - mStream->Write( dataBytes, 0, dataBytes->Length ); - mStream->Flush(); - - // Create a new instance of the RSACryptoServiceProvider class - // and automatically create a new key-pair. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - // Export the key information to an RSAParameters object. - // You must pass true to export the private key for signing. - // However, you do not need to export the private key - // for verification. - RSAParameters Key = RSAalg->ExportParameters( true ); - - // Hash and sign the data. - array^signedData = HashAndSignBytes( mStream, Key ); - - // Verify the data and display the result to the - // console. - if ( VerifySignedHash( dataBytes, signedData, Key ) ) - { - Console::WriteLine( "The data was verified." ); - } - else - { - Console::WriteLine( "The data does not match the signature." ); - } - - // Close the MemoryStream. - mStream->Close(); - } - catch ( ArgumentNullException^ ) - { - Console::WriteLine( "The data was not signed or verified" ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp deleted file mode 100644 index 68adc843467..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// -using namespace System; -using namespace System::Security::Cryptography; - -ref class RSAKeyStoreSample -{ -public: - static void Main() - { - // Set the static UseMachineKeyStore property to use the machine key - // store instead of the user profile key store. All CSP instances not - // initialized with CspParameters will use this setting. - RSACryptoServiceProvider::UseMachineKeyStore = true; - try - { - RSACryptoServiceProvider^ RSAalg; - - // This CSP instance will use the Machine Store as set above and is - // initialized with no parameters. - RSAalg = gcnew RSACryptoServiceProvider(); - ShowContainerInfo(RSAalg->CspKeyContainerInfo); - RSAalg->PersistKeyInCsp = false; - delete RSAalg; - - CspParameters^ cspParams = gcnew CspParameters(); - - cspParams->KeyContainerName = "MyKeyContainer"; - - // This CSP instance will use the User Store since cspParams are used. - RSAalg = gcnew RSACryptoServiceProvider(cspParams); - ShowContainerInfo(RSAalg->CspKeyContainerInfo); - RSAalg->PersistKeyInCsp = false; - delete RSAalg; - - cspParams->Flags |= CspProviderFlags::UseMachineKeyStore; - - // This CSP instance will use the Machine Store. Although cspParams are used, - // the cspParams.Flags is set to CspProviderFlags.UseMachineKeyStore. - RSAalg = gcnew RSACryptoServiceProvider(cspParams); - ShowContainerInfo(RSAalg->CspKeyContainerInfo); - RSAalg->PersistKeyInCsp = false; - delete RSAalg; - } - catch (CryptographicException^ e) - { - Console::WriteLine("Exception: {0}", e->GetType()->FullName); - Console::WriteLine(e->Message); - } - } - - static void ShowContainerInfo(CspKeyContainerInfo^ containerInfo) - { - String^ keyStore; - - Console::WriteLine(); - if (containerInfo->MachineKeyStore) - { - keyStore = "Machine Store"; - } - else - { - keyStore = "User Store"; - } - Console::WriteLine("Key Store: {0}", keyStore); - Console::WriteLine("Key Provider: {0}", containerInfo->ProviderName); - Console::WriteLine("Key Container: \"{0}\"", containerInfo->KeyContainerName); - Console::WriteLine("Generated: {0}", containerInfo->RandomlyGenerated); - Console::WriteLine("Key Nubmer: {0}", containerInfo->KeyNumber); - Console::WriteLine("Removable Key: {0}", containerInfo->Removable); - } -}; - -int main() -{ - RSAKeyStoreSample::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp deleted file mode 100644 index b99a174d918..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp +++ /dev/null @@ -1,174 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -void RSAPersistKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider to generate - //a new key pair. Pass the CspParameters class to persist the - //key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key was persisted in the container, \"{0}\".", ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -void RSADeleteKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider. - //Pass the CspParameters class to use the - //key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Delete the key entry in the container. - RSAalg->PersistKeyInCsp = false; - - //Call Clear to release resources and delete the key from the container. - RSAalg->Clear(); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key was deleted from the container, \"{0}\".", ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -array^ RSAEncrypt( array^DataToEncrypt, String^ ContainerName, bool DoOAEPPadding ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider. - //Pass the CspParameters class to use the key - //from the key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Encrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Encrypt( DataToEncrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -array^ RSADecrypt( array^DataToDecrypt, String^ ContainerName, bool DoOAEPPadding ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider. - //Pass the CspParameters class to use the key - //from the key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Decrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Decrypt( DataToDecrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e ); - return nullptr; - } - -} - -int main() -{ - try - { - String^ KeyContainerName = "MyKeyContainer"; - - //Create a new key and persist it in - //the key container. - RSAPersistKeyInCSP( KeyContainerName ); - - //Create a UnicodeEncoder to convert between byte array and string. - UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding; - - //Create byte arrays to hold original, encrypted, and decrypted data. - array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" ); - array^encryptedData; - array^decryptedData; - - //Pass the data to ENCRYPT, the name of the key container, - //and a boolean flag specifying no OAEP padding. - encryptedData = RSAEncrypt( dataToEncrypt, KeyContainerName, false ); - - //Pass the data to DECRYPT, the name of the key container, - //and a boolean flag specifying no OAEP padding. - decryptedData = RSADecrypt( encryptedData, KeyContainerName, false ); - - //Display the decrypted plaintext to the console. - Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) ); - RSADeleteKeyInCSP( KeyContainerName ); - } - catch ( ArgumentNullException^ ) - { - - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( "Encryption failed." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp deleted file mode 100644 index 19f120af03a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp +++ /dev/null @@ -1,104 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -array^ RSAEncrypt( array^DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding ) -{ - try - { - - //Create a new instance of RSACryptoServiceProvider. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - //Import the RSA Key information. This only needs - //toinclude the public key information. - RSAalg->ImportParameters( RSAKeyInfo ); - - //Encrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Encrypt( DataToEncrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -array^ RSADecrypt( array^DataToDecrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding ) -{ - try - { - - //Create a new instance of RSACryptoServiceProvider. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - //Import the RSA Key information. This needs - //to include the private key information. - RSAalg->ImportParameters( RSAKeyInfo ); - - //Decrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Decrypt( DataToDecrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e ); - return nullptr; - } - -} - -int main() -{ - try - { - - //Create a UnicodeEncoder to convert between byte array and string. - UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding; - - //Create byte arrays to hold original, encrypted, and decrypted data. - array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" ); - array^encryptedData; - array^decryptedData; - - //Create a new instance of RSACryptoServiceProvider to generate - //public and private key data. Pass an integer specifying a key- - //length of 2048. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( 2048 ); - - //Display the key-legth to the console. - Console::WriteLine( "A new key pair of legth {0} was created", RSAalg->KeySize ); - - //Pass the data to ENCRYPT, the public key information - //(using RSACryptoServiceProvider.ExportParameters(false), - //and a boolean flag specifying no OAEP padding. - encryptedData = RSAEncrypt( dataToEncrypt, RSAalg->ExportParameters( false ), false ); - - //Pass the data to DECRYPT, the private key information - //(using RSACryptoServiceProvider.ExportParameters(true), - //and a boolean flag specifying no OAEP padding. - decryptedData = RSADecrypt( encryptedData, RSAalg->ExportParameters( true ), false ); - - //Display the decrypted plaintext to the console. - Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) ); - } - catch ( ArgumentNullException^ ) - { - - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( "Encryption failed." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp deleted file mode 100644 index f1f072b4665..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp +++ /dev/null @@ -1,175 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -void RSAPersistKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider to generate - //a new key pair. Pass the CspParameters class to persist the - //key in the container. Pass an intger of 2048 to specify the - //key-size. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( 2048,cspParams ); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key with a key-size of {0} was persisted in the container, \"{1}\".", RSAalg->KeySize, ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -void RSADeleteKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of DSACryptoServiceProvider. - //Pass the CspParameters class to use the - //key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Delete the key entry in the container. - RSAalg->PersistKeyInCsp = false; - - //Call Clear to release resources and delete the key from the container. - RSAalg->Clear(); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key was deleted from the container, \"{0}\".", ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -array^ RSAEncrypt( array^DataToEncrypt, String^ ContainerName, bool DoOAEPPadding ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of DSACryptoServiceProvider. - //Pass the CspParameters class to use the key - //from the key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Encrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Encrypt( DataToEncrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -array^ RSADecrypt( array^DataToDecrypt, String^ ContainerName, bool DoOAEPPadding ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of DSACryptoServiceProvider. - //Pass the CspParameters class to use the key - //from the key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Decrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Decrypt( DataToDecrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e ); - return nullptr; - } - -} - -int main() -{ - try - { - String^ KeyContainerName = "MyKeyContainer"; - - //Create a new key and persist it in - //the key container. - RSAPersistKeyInCSP( KeyContainerName ); - - //Create a UnicodeEncoder to convert between byte array and string. - UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding; - - //Create byte arrays to hold original, encrypted, and decrypted data. - array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" ); - array^encryptedData; - array^decryptedData; - - //Pass the data to ENCRYPT, the name of the key container, - //and a boolean flag specifying no OAEP padding. - encryptedData = RSAEncrypt( dataToEncrypt, KeyContainerName, false ); - - //Pass the data to DECRYPT, the name of the key container, - //and a boolean flag specifying no OAEP padding. - decryptedData = RSADecrypt( encryptedData, KeyContainerName, false ); - - //Display the decrypted plaintext to the console. - Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) ); - RSADeleteKeyInCSP( KeyContainerName ); - } - catch ( ArgumentNullException^ ) - { - - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( "Encryption failed." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp deleted file mode 100644 index 87f5955ad65..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -int main() -{ - RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider; - try - { - - // Note: In cases where a random key is generated, - // a key container is not created until you call - // a method that uses the key. This example calls - // the Encrypt method before calling the - // CspKeyContainerInfo property so that a key - // container is created. - // Create some data to encrypt and display it. - String^ data = L"Here is some data to encrypt."; - Console::WriteLine( L"Data to encrypt: {0}", data ); - - // Convert the data to an array of bytes and - // encrypt it. - array^byteData = Encoding::ASCII->GetBytes( data ); - array^encData = rsa->Encrypt( byteData, false ); - - // Display the encrypted value. - Console::WriteLine( L"Encrypted Data: {0}", Encoding::ASCII->GetString( encData ) ); - Console::WriteLine(); - Console::WriteLine( L"CspKeyContainerInfo information:" ); - Console::WriteLine(); - - // Create a new CspKeyContainerInfo object. - CspKeyContainerInfo^ keyInfo = rsa->CspKeyContainerInfo; - - // Display the value of each property. - Console::WriteLine( L"Accessible property: {0}", keyInfo->Accessible ); - Console::WriteLine( L"Exportable property: {0}", keyInfo->Exportable ); - Console::WriteLine( L"HardwareDevice property: {0}", keyInfo->HardwareDevice ); - Console::WriteLine( L"KeyContainerName property: {0}", keyInfo->KeyContainerName ); - Console::WriteLine( L"KeyNumber property: {0}", keyInfo->KeyNumber ); - Console::WriteLine( L"MachineKeyStore property: {0}", keyInfo->MachineKeyStore ); - Console::WriteLine( L"Protected property: {0}", keyInfo->Protected ); - Console::WriteLine( L"ProviderName property: {0}", keyInfo->ProviderName ); - Console::WriteLine( L"ProviderType property: {0}", keyInfo->ProviderType ); - Console::WriteLine( L"RandomlyGenerated property: {0}", keyInfo->RandomlyGenerated ); - Console::WriteLine( L"Removable property: {0}", keyInfo->Removable ); - Console::WriteLine( L"UniqueKeyContainerName property: {0}", keyInfo->UniqueKeyContainerName ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } - finally - { - - // Clear the key. - rsa->Clear(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp deleted file mode 100644 index ab2873ba3a4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -int main() -{ - - // To idendify the Smart Card CryptoGraphic Providers on your - // computer, use the Microsoft Registry Editor (Regedit.exe). - // The available Smart Card CryptoGraphic Providers are listed - // in HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider. - // Create a new CspParameters object that identifies a - // Smart Card CryptoGraphic Provider. - // The 1st parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider Types. - // The 2nd parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider. - CspParameters^ csp = gcnew CspParameters( 1,L"Schlumberger Cryptographic Service Provider" ); - csp->Flags = CspProviderFlags::UseDefaultKeyContainer; - - // Initialize an RSACryptoServiceProvider object using - // the CspParameters object. - RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( csp ); - - // Create some data to sign. - array^data = gcnew array{ - 0,1,2,3,4,5,6,7 - }; - Console::WriteLine( L"Data : {0}", BitConverter::ToString( data ) ); - - // Sign the data using the Smart Card CryptoGraphic Provider. - array^sig = rsa->SignData( data, L"SHA256" ); - Console::WriteLine( L"Signature : {0}", BitConverter::ToString( sig ) ); - - // Verify the data using the Smart Card CryptoGraphic Provider. - bool verified = rsa->VerifyData( data, L"SHA256", sig ); - Console::WriteLine( L"Verified : {0}", verified ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp deleted file mode 100644 index 99639f7a588..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = L"test.pfx"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = gcnew X509Certificate( Certificate ); - array^certData = cert->Export( X509ContentType::Cert ); - X509Certificate^ newCert = gcnew X509Certificate( certData ); - - // Get the value. - String^ resultsTrue = newCert->ToString( true ); - - // Display the value to the console. - Console::WriteLine( resultsTrue ); - - // Get the value. - String^ resultsFalse = newCert->ToString( false ); - - // Display the value to the console. - Console::WriteLine( resultsFalse ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp deleted file mode 100644 index c67a8cb4a04..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = L"Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = gcnew X509Certificate; - cert->Import(Certificate); - - // Get the value. - String^ resultsTrue = cert->ToString( true ); - - // Display the value to the console. - Console::WriteLine( resultsTrue ); - - // Get the value. - String^ resultsFalse = cert->ToString( false ); - - // Display the value to the console. - Console::WriteLine( resultsFalse ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp deleted file mode 100644 index d2dab6fe3be..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = L"Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = gcnew X509Certificate( Certificate ); - - // Get the value. - String^ resultsTrue = cert->ToString( true ); - - // Display the value to the console. - Console::WriteLine( resultsTrue ); - - // Get the value. - String^ resultsFalse = cert->ToString( false ); - - // Display the value to the console. - Console::WriteLine( resultsFalse ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp deleted file mode 100644 index 574abf906a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - try - { - X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser ); - store->Open( static_cast(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) ); - X509Certificate2Collection^ collection = dynamic_cast(store->Certificates); - for ( int i = 0; i < collection->Count; i++ ) - { - System::Collections::IEnumerator^ myEnum = collection[ i ]->Extensions->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - X509Extension^ extension = safe_cast(myEnum->Current); - Console::WriteLine( L"{0}({1})", extension->Oid->FriendlyName, extension->Oid->Value ); - if ( extension->Oid->FriendlyName == L"Key Usage" ) - { - X509KeyUsageExtension^ ext = dynamic_cast(extension); - Console::WriteLine( ext->KeyUsages ); - } - if ( extension->Oid->FriendlyName == L"Basic Constraints" ) - { - X509BasicConstraintsExtension^ ext = dynamic_cast(extension); - Console::WriteLine( ext->CertificateAuthority ); - Console::WriteLine( ext->HasPathLengthConstraint ); - Console::WriteLine( ext->PathLengthConstraint ); - } - if ( extension->Oid->FriendlyName == L"Subject Key Identifier" ) - { - X509SubjectKeyIdentifierExtension^ ext = dynamic_cast(extension); - Console::WriteLine( ext->SubjectKeyIdentifier ); - } - if ( extension->Oid->FriendlyName == L"Enhanced Key Usage" ) - { - X509EnhancedKeyUsageExtension^ ext = dynamic_cast(extension); - OidCollection^ oids = ext->EnhancedKeyUsages; - System::Collections::IEnumerator^ myEnum1 = oids->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - Oid^ oid = safe_cast(myEnum1->Current); - Console::WriteLine( L"{0}({1})", oid->FriendlyName, oid->Value ); - } - } - } - - } - store->Close(); - } - catch ( CryptographicException^ ) - { - Console::WriteLine( L"Information could not be written out for this certificate." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp deleted file mode 100644 index c7f4f074317..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp +++ /dev/null @@ -1,207 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; - -ref class TrippleDESDocumentEncryption -{ -protected: - XmlDocument^ docValue; - TripleDES^ algValue; - -public: - TrippleDESDocumentEncryption( XmlDocument^ Doc, TripleDES^ Key ) - { - if ( Doc != nullptr ) - { - docValue = Doc; - } - else - { - throw gcnew ArgumentNullException( L"Doc" ); - } - - if ( Key != nullptr ) - { - algValue = Key; - } - else - { - throw gcnew ArgumentNullException( L"Key" ); - } - } - - - property XmlDocument^ Doc - { - XmlDocument^ get() - { - return docValue; - } - - void set( XmlDocument^ value ) - { - docValue = value; - } - - } - - property TripleDES^ Alg - { - TripleDES^ get() - { - return algValue; - } - - void set( TripleDES^ value ) - { - algValue = value; - } - - } - void Clear() - { - if ( algValue != nullptr ) - { - algValue->Clear(); - } - else - { - throw gcnew Exception( L"No TripleDES key was found to clear." ); - } - } - - void Encrypt( String^ Element ) - { - - // Find the element by name and create a new - // XmlElement object. - XmlElement^ inputElement = dynamic_cast(docValue->GetElementsByTagName( Element )->Item( 0 )); - - // If the element was not found, throw an exception. - if ( inputElement == nullptr ) - { - throw gcnew Exception( L"The element was not found." ); - } - - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml( docValue ); - - // Encrypt the element using the symmetric key. - array^rgbOutput = exml->EncryptData( inputElement, algValue, false ); - - // Create an EncryptedData object and populate it. - EncryptedData^ ed = gcnew EncryptedData; - - // Specify the namespace URI for XML encryption elements. - ed->Type = EncryptedXml::XmlEncElementUrl; - - // Specify the namespace URI for the TrippleDES algorithm. - ed->EncryptionMethod = gcnew EncryptionMethod( EncryptedXml::XmlEncTripleDESUrl ); - - // Create a CipherData element. - ed->CipherData = gcnew CipherData; - - // Set the CipherData element to the value of the encrypted XML element. - ed->CipherData->CipherValue = rgbOutput; - - // Replace the plaintext XML elemnt with an EncryptedData element. - EncryptedXml::ReplaceElement( inputElement, ed, false ); - } - - void Decrypt() - { - - // XmlElement object. - XmlElement^ encryptedElement = dynamic_cast(docValue->GetElementsByTagName( L"EncryptedData" )->Item( 0 )); - - // If the EncryptedData element was not found, throw an exception. - if ( encryptedElement == nullptr ) - { - throw gcnew Exception( L"The EncryptedData element was not found." ); - } - - - // Create an EncryptedData object and populate it. - EncryptedData^ ed = gcnew EncryptedData; - ed->LoadXml( encryptedElement ); - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml; - - // Decrypt the element using the symmetric key. - array^rgbOutput = exml->DecryptData( ed, algValue ); - - // Replace the encryptedData element with the plaintext XML elemnt. - exml->ReplaceData( encryptedElement, rgbOutput ); - } - -}; - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - return 0; - } - - - // Create a new TripleDES key. - TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider; - - // Create a new instance of the TrippleDESDocumentEncryption object - // defined in this sample. - TrippleDESDocumentEncryption^ xmlTDES = gcnew TrippleDESDocumentEncryption( xmlDoc,tDESkey ); - try - { - - // Encrypt the "creditcard" element. - xmlTDES->Encrypt( L"creditcard" ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlTDES->Doc->OuterXml ); - - // Decrypt the "creditcard" element. - xmlTDES->Decrypt(); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlTDES->Doc->OuterXml ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear the TripleDES key. - xmlTDES->Clear(); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp deleted file mode 100644 index c1e61870173..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp +++ /dev/null @@ -1,178 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, array^ElementsToSign ) -{ - - // Check the arguments. - if ( FileName == nullptr ) - throw gcnew ArgumentNullException( L"FileName" ); - - if ( SignedFileName == nullptr ) - throw gcnew ArgumentNullException( L"SignedFileName" ); - - if ( Key == nullptr ) - throw gcnew ArgumentNullException( L"Key" ); - - if ( ElementsToSign == nullptr ) - throw gcnew ArgumentNullException( L"ElementsToSign" ); - - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Loop through each passed element to sign - // and create a reference. - System::Collections::IEnumerator^ myEnum = ElementsToSign->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ s = safe_cast(myEnum->Current); - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = s; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - } - - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( dynamic_cast(doc->FirstChild) ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Check the arguments. - if ( Name == nullptr ) - throw gcnew ArgumentNullException( L"Name" ); - - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - -int main() -{ - - // Generate a signing key. - RSA^ Key = RSA::Create(); - try - { - - // Specify an element to sign. - array^elements = {L"#tag1"}; - - // Sign an XML file and save the signature to a - // new file. - SignXmlFile( L"Test.xml", L"SignedExample.xml", Key, elements ); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear resources associated with the - // RSA instance. - Key->Clear(); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp deleted file mode 100644 index cdae3dcaebf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp +++ /dev/null @@ -1,169 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Check the arguments. - if ( FileName == nullptr ) - throw gcnew ArgumentNullException( L"FileName" ); - - if ( SignedFileName == nullptr ) - throw gcnew ArgumentNullException( L"SignedFileName" ); - - if ( Key == nullptr ) - throw gcnew ArgumentNullException( L"Key" ); - - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Get the signature object from the SignedXml object. - Signature^ XMLSignature = signedXml->Signature; - - // Create a reference to be signed. Pass "" - // to specify that all of the current XML - // document should be signed. - Reference^ reference = gcnew Reference( L"" ); - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the Reference object to the Signature object. - XMLSignature->SignedInfo->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - - // Add the KeyInfo object to the Reference object. - XMLSignature->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( dynamic_cast(doc->FirstChild) ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Check the arguments. - if ( Name == nullptr ) - throw gcnew ArgumentNullException( L"Name" ); - - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - -int main() -{ - - // Generate a signing key. - RSA^ Key = RSA::Create(); - try - { - - // Sign an XML file and save the signature to a - // new file. - SignXmlFile( L"Test.xml", L"SignedExample.xml", Key ); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear resources associated with the - // RSA instance. - Key->Clear(); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp deleted file mode 100644 index 97cfce97aee..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp +++ /dev/null @@ -1,179 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, RSA^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( ElementToEncrypt == nullptr ) - throw gcnew ArgumentNullException( L"ElementToEncrypt" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - - //////////////////////////////////////////////// - // Find the specified element in the XmlDocument - // object and create a new XmlElemnt object. - //////////////////////////////////////////////// - XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 )); - - // Throw an XmlException if the element was not found. - if ( elementToEncrypt == nullptr ) - { - throw gcnew XmlException( L"The specified element was not found" ); - } - - - ////////////////////////////////////////////////// - // Create a new instance of the EncryptedXml class - // and use it to encrypt the XmlElement with the - // a new random symmetric key. - ////////////////////////////////////////////////// - // Create a 256 bit Aes key. - Aes^ sessionKey = Aes::Create(); - sessionKey->KeySize = 256; - EncryptedXml^ eXml = gcnew EncryptedXml; - array^encryptedElement = eXml->EncryptData( elementToEncrypt, sessionKey, false ); - - //////////////////////////////////////////////// - // Construct an EncryptedData object and populate - // it with the desired encryption information. - //////////////////////////////////////////////// - EncryptedData^ edElement = gcnew EncryptedData; - edElement->Type = EncryptedXml::XmlEncElementUrl; - - // Create an EncryptionMethod element so that the - // receiver knows which algorithm to use for decryption. - edElement->EncryptionMethod = gcnew EncryptionMethod( EncryptedXml::XmlEncAES256Url ); - - // Encrypt the session key and add it to an EncryptedKey element. - EncryptedKey^ ek = gcnew EncryptedKey; - array^encryptedKey = EncryptedXml::EncryptKey( sessionKey->Key, Alg, false ); - ek->CipherData = gcnew CipherData( encryptedKey ); - ek->EncryptionMethod = gcnew EncryptionMethod( EncryptedXml::XmlEncRSA15Url ); - - // Set the KeyInfo element to specify the - // name of the RSA key. - // Create a new KeyInfo element. - edElement->KeyInfo = gcnew KeyInfo; - - // Create a new KeyInfoName element. - KeyInfoName^ kin = gcnew KeyInfoName; - - // Specify a name for the key. - kin->Value = KeyName; - - // Add the KeyInfoName element to the - // EncryptedKey object. - ek->KeyInfo->AddClause( kin ); - - // Add the encrypted key to the - // EncryptedData object. - edElement->KeyInfo->AddClause( gcnew KeyInfoEncryptedKey( ek ) ); - - // Add the encrypted element data to the - // EncryptedData object. - edElement->CipherData->CipherValue = encryptedElement; - - //////////////////////////////////////////////////// - // Replace the element from the original XmlDocument - // object with the EncryptedData element. - //////////////////////////////////////////////////// - EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false ); -} - -static void Decrypt( XmlDocument^ Doc, RSA^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - if ( KeyName == nullptr ) - throw gcnew ArgumentNullException( L"KeyName" ); - - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml( Doc ); - - // Add a key-name mapping. - // This method can only decrypt documents - // that present the specified key name. - exml->AddKeyNameMapping( KeyName, Alg ); - - // Decrypt the element. - exml->DecryptDocument(); -} - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - return 0; - } - - - // Create a new RSA key. This key will encrypt a symmetric key, - // which will then be imbedded in the XML document. - RSA^ rsaKey = RSA::Create(); - try - { - - // Encrypt the "creditcard" element. - Encrypt( xmlDoc, L"creditcard", rsaKey, L"rsaKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - xmlDoc->Save( L"test.xml" ); - - // Decrypt the "creditcard" element. - Decrypt( xmlDoc, rsaKey, L"rsaKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - xmlDoc->Save( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear the RSA key. - rsaKey->Clear(); - } - - return 1; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp deleted file mode 100644 index 3856ce1b7b3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp +++ /dev/null @@ -1,200 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, SymmetricAlgorithm^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( ElementToEncrypt == nullptr ) - throw gcnew ArgumentNullException( L"ElementToEncrypt" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - - //////////////////////////////////////////////// - // Find the specified element in the XmlDocument - // object and create a new XmlElemnt object. - //////////////////////////////////////////////// - XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 )); - - // Throw an XmlException if the element was not found. - if ( elementToEncrypt == nullptr ) - { - throw gcnew XmlException( L"The specified element was not found" ); - } - - - ////////////////////////////////////////////////// - // Create a new instance of the EncryptedXml class - // and use it to encrypt the XmlElement with the - // symmetric key. - ////////////////////////////////////////////////// - EncryptedXml^ eXml = gcnew EncryptedXml; - array^encryptedElement = eXml->EncryptData( elementToEncrypt, Alg, false ); - - //////////////////////////////////////////////// - // Construct an EncryptedData object and populate - // it with the desired encryption information. - //////////////////////////////////////////////// - EncryptedData^ edElement = gcnew EncryptedData; - edElement->Type = EncryptedXml::XmlEncElementUrl; - - // Create an EncryptionMethod element so that the - // receiver knows which algorithm to use for decryption. - // Determine what kind of algorithm is being used and - // supply the appropriate URL to the EncryptionMethod element. - String^ encryptionMethod = nullptr; - if ( dynamic_cast(Alg) ) - { - encryptionMethod = EncryptedXml::XmlEncTripleDESUrl; - } - else - if ( dynamic_cast(Alg) ) - { - encryptionMethod = EncryptedXml::XmlEncDESUrl; - } - else - if ( dynamic_cast(Alg) ) - { - switch ( Alg->KeySize ) - { - case 128: - encryptionMethod = EncryptedXml::XmlEncAES128Url; - break; - - case 192: - encryptionMethod = EncryptedXml::XmlEncAES192Url; - break; - - case 256: - encryptionMethod = EncryptedXml::XmlEncAES256Url; - break; - } - } - else - { - - // Throw an exception if the transform is not in the previous categories - throw gcnew CryptographicException( L"The specified algorithm is not supported for XML Encryption." ); - } - - - - edElement->EncryptionMethod = gcnew EncryptionMethod( encryptionMethod ); - - // Set the KeyInfo element to specify the - // name of a key. - // Create a new KeyInfo element. - edElement->KeyInfo = gcnew KeyInfo; - - // Create a new KeyInfoName element. - KeyInfoName^ kin = gcnew KeyInfoName; - - // Specify a name for the key. - kin->Value = KeyName; - - // Add the KeyInfoName element. - edElement->KeyInfo->AddClause( kin ); - - // Add the encrypted element data to the - // EncryptedData object. - edElement->CipherData->CipherValue = encryptedElement; - - //////////////////////////////////////////////////// - // Replace the element from the original XmlDocument - // object with the EncryptedData element. - //////////////////////////////////////////////////// - EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false ); -} - -static void Decrypt( XmlDocument^ Doc, SymmetricAlgorithm^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - if ( KeyName == nullptr ) - throw gcnew ArgumentNullException( L"KeyName" ); - - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml( Doc ); - - // Add a key-name mapping. - // This method can only decrypt documents - // that present the specified key name. - exml->AddKeyNameMapping( KeyName, Alg ); - - // Decrypt the element. - exml->DecryptDocument(); -} - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - return 0; - } - - - // Create a new TripleDES key. - TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider; - try - { - - // Encrypt the "creditcard" element. - Encrypt( xmlDoc, L"creditcard", tDESkey, L"tDESKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - - // Decrypt the "creditcard" element. - Decrypt( xmlDoc, tDESkey, L"tDESKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear the TripleDES key. - tDESkey->Clear(); - } - return 1; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp deleted file mode 100644 index 0ed4e81288a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp +++ /dev/null @@ -1,133 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Security::Cryptography::X509Certificates; -static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, X509Certificate2^ Cert ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( ElementToEncrypt == nullptr ) - throw gcnew ArgumentNullException( L"ElementToEncrypt" ); - - if ( Cert == nullptr ) - throw gcnew ArgumentNullException( L"Cert" ); - - - //////////////////////////////////////////////// - // Find the specified element in the XmlDocument - // object and create a new XmlElemnt object. - //////////////////////////////////////////////// - XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 )); - - // Throw an XmlException if the element was not found. - if ( elementToEncrypt == nullptr ) - { - throw gcnew XmlException( L"The specified element was not found" ); - } - - - ////////////////////////////////////////////////// - // Create a new instance of the EncryptedXml class - // and use it to encrypt the XmlElement with the - // X.509 Certificate. - ////////////////////////////////////////////////// - EncryptedXml^ eXml = gcnew EncryptedXml; - - // Encrypt the element. - EncryptedData^ edElement = eXml->Encrypt( elementToEncrypt, Cert ); - - //////////////////////////////////////////////////// - // Replace the element from the original XmlDocument - // object with the EncryptedData element. - //////////////////////////////////////////////////// - EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false ); -} - -static void Decrypt( XmlDocument^ Doc ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml( Doc ); - - // Decrypt the XML document. - exml->DecryptDocument(); -} - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - return 0; - } - - - // Create a new X509Certificate2 object by loading - // an X.509 certificate file. To use XML encryption - // with an X.509 certificate, use an X509Certificate2 - // object to encrypt, but use a certificate in a certificate - // store to decrypt. - // You can create a new test certificate file using the - // makecert.exe tool. - // Create an X509Certificate2 object for encryption. - X509Certificate2^ cert = gcnew X509Certificate2( L"test.pfx" ); - - // Put the certificate in certificate store for decryption. - X509Store^ store = gcnew X509Store( StoreLocation::CurrentUser ); - store->Open( OpenFlags::ReadWrite ); - store->Add( cert ); - store->Close(); - try - { - - // Encrypt the "creditcard" element. - Encrypt( xmlDoc, L"creditcard", cert ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - - // Decrypt the "creditcard" element. - Decrypt( xmlDoc ); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp deleted file mode 100644 index c8b0ef17967..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp +++ /dev/null @@ -1,135 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, SymmetricAlgorithm^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( ElementToEncrypt == nullptr ) - throw gcnew ArgumentNullException( L"ElementToEncrypt" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - - //////////////////////////////////////////////// - // Find the specified element in the XmlDocument - // object and create a new XmlElemnt object. - //////////////////////////////////////////////// - XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 )); - - // Throw an XmlException if the element was not found. - if ( elementToEncrypt == nullptr ) - { - throw gcnew XmlException( L"The specified element was not found" ); - } - - - ////////////////////////////////////////////////// - // Create a new instance of the EncryptedXml class - // and use it to encrypt the XmlElement with the - // symmetric key. - ////////////////////////////////////////////////// - EncryptedXml^ eXml = gcnew EncryptedXml; - - // Add the key mapping. - eXml->AddKeyNameMapping( KeyName, Alg ); - - // Encrypt the element. - EncryptedData^ edElement = eXml->Encrypt( elementToEncrypt, KeyName ); - - //////////////////////////////////////////////////// - // Replace the element from the original XmlDocument - // object with the EncryptedData element. - //////////////////////////////////////////////////// - EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false ); -} - -static void Decrypt( XmlDocument^ Doc, SymmetricAlgorithm^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - if ( KeyName == nullptr ) - throw gcnew ArgumentNullException( L"KeyName" ); - - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml( Doc ); - - // Add the key name mapping. - exml->AddKeyNameMapping( KeyName, Alg ); - - // Decrypt the XML document. - exml->DecryptDocument(); -} - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - - - // Create a new TripleDES key. - TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider; - try - { - - // Encrypt the "creditcard" element. - Encrypt( xmlDoc, L"creditcard", tDESkey, L"tDesKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - - // Decrypt the "creditcard" element. - Decrypt( xmlDoc, tDESkey, L"tDesKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear the TripleDES key. - tDESkey->Clear(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp deleted file mode 100644 index ae795778f31..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp +++ /dev/null @@ -1,196 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, SymmetricAlgorithm^ Alg ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( ElementToEncrypt == nullptr ) - throw gcnew ArgumentNullException( L"ElementToEncrypt" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - - //////////////////////////////////////////////// - // Find the specified element in the XmlDocument - // object and create a new XmlElemnt object. - //////////////////////////////////////////////// - XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 )); - - // Throw an XmlException if the element was not found. - if ( elementToEncrypt == nullptr ) - { - throw gcnew XmlException( L"The specified element was not found" ); - } - - - ////////////////////////////////////////////////// - // Create a new instance of the EncryptedXml class - // and use it to encrypt the XmlElement with the - // symmetric key. - ////////////////////////////////////////////////// - EncryptedXml^ eXml = gcnew EncryptedXml; - array^encryptedElement = eXml->EncryptData( elementToEncrypt, Alg, false ); - - //////////////////////////////////////////////// - // Construct an EncryptedData object and populate - // it with the desired encryption information. - //////////////////////////////////////////////// - EncryptedData^ edElement = gcnew EncryptedData; - edElement->Type = EncryptedXml::XmlEncElementUrl; - - // Create an EncryptionMethod element so that the - // receiver knows which algorithm to use for decryption. - // Determine what kind of algorithm is being used and - // supply the appropriate URL to the EncryptionMethod element. - String^ encryptionMethod = nullptr; - if ( dynamic_cast(Alg) ) - { - encryptionMethod = EncryptedXml::XmlEncTripleDESUrl; - } - else - if ( dynamic_cast(Alg) ) - { - encryptionMethod = EncryptedXml::XmlEncDESUrl; - } - else - if ( dynamic_cast(Alg) ) - { - switch ( Alg->KeySize ) - { - case 128: - encryptionMethod = EncryptedXml::XmlEncAES128Url; - break; - - case 192: - encryptionMethod = EncryptedXml::XmlEncAES192Url; - break; - - case 256: - encryptionMethod = EncryptedXml::XmlEncAES256Url; - break; - } - } - else - { - - // Throw an exception if the transform is not in the previous categories - throw gcnew CryptographicException( L"The specified algorithm is not supported for XML Encryption." ); - } - - - - edElement->EncryptionMethod = gcnew EncryptionMethod( encryptionMethod ); - - // Add the encrypted element data to the - // EncryptedData object. - edElement->CipherData->CipherValue = encryptedElement; - - //////////////////////////////////////////////////// - // Replace the element from the original XmlDocument - // object with the EncryptedData element. - //////////////////////////////////////////////////// - EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false ); -} - -static void Decrypt( XmlDocument^ Doc, SymmetricAlgorithm^ Alg ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - - // Find the EncryptedData element in the XmlDocument. - XmlElement^ encryptedElement = dynamic_cast(Doc->GetElementsByTagName( L"EncryptedData" )->Item( 0 )); - - // If the EncryptedData element was not found, throw an exception. - if ( encryptedElement == nullptr ) - { - throw gcnew XmlException( L"The EncryptedData element was not found." ); - } - - - // Create an EncryptedData object and populate it. - EncryptedData^ edElement = gcnew EncryptedData; - edElement->LoadXml( encryptedElement ); - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml; - - // Decrypt the element using the symmetric key. - array^rgbOutput = exml->DecryptData( edElement, Alg ); - - // Replace the encryptedData element with the plaintext XML element. - exml->ReplaceData( encryptedElement, rgbOutput ); -} - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - return 0; - } - - - // Create a new TripleDES key. - TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider; - try - { - - // Encrypt the "creditcard" element. - Encrypt( xmlDoc, L"creditcard", tDESkey ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - - // Decrypt the "creditcard" element. - Decrypt( xmlDoc, tDESkey ); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear the TripleDES key. - tDESkey->Clear(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp deleted file mode 100644 index 2d4df6a368d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp +++ /dev/null @@ -1,181 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Specify a canonicalization method. - signedXml->SignedInfo->CanonicalizationMethod = SignedXml::XmlDsigExcC14NTransformUrl; - - // Set the InclusiveNamespacesPrefixList property. - XmlDsigExcC14NTransform^ canMethod = dynamic_cast(signedXml->SignedInfo->CanonicalizationMethodObject); - canMethod->InclusiveNamespacesPrefixList = L"Sign"; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = L""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( dynamic_cast(doc->FirstChild) ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// Create example data to sign. -static void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" ); - - // Append the node to the document. - document->AppendChild( node ); - - // Create a new XmlNode object. - XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"TempElement", L"Sign" ); - - // Add some text to the node. - subnode->InnerText = L"Here is some data to sign."; - - // Append the node to the document. - document->DocumentElement->AppendChild( subnode ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( L"Example.xml" ); - Console::WriteLine( L"New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( L"Example.xml", L"SignedExample.xml", Key ); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to \ - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp deleted file mode 100644 index ce578aa7c43..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp +++ /dev/null @@ -1,178 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Specify a canonicalization method. - signedXml->SignedInfo->CanonicalizationMethod = SignedXml::XmlDsigExcC14NWithCommentsTransformUrl; - - // Set the InclusiveNamespacesPrefixList property. - XmlDsigExcC14NWithCommentsTransform^ canMethod = dynamic_cast(signedXml->SignedInfo->CanonicalizationMethodObject); - canMethod->InclusiveNamespacesPrefixList = L"Sign"; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = L""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( dynamic_cast(doc->FirstChild) ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// Create example data to sign. -static void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" ); - - // Append the node to the document. - document->AppendChild( node ); - - // Create a new XmlNode object. - XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"TempElement", L"Sign" ); - - // Add some text to the node. - subnode->InnerText = L"Here is some data to sign."; - - // Append the node to the document. - document->DocumentElement->AppendChild( subnode ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Create an XML file to sign. - CreateSomeXml( L"Example.xml" ); - Console::WriteLine( L"New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - //SignXmlFile("Example.xml", "SignedExample.xml", Key); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp deleted file mode 100644 index 6edd984e6b9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp +++ /dev/null @@ -1,202 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Create the XML that represents the transform. -static XmlDsigXPathTransform^ CreateXPathTransform( String^ XPathString ) -{ - - // Create a new XMLDocument object. - XmlDocument^ doc = gcnew XmlDocument; - - // Create a new XmlElement. - XmlElement^ xPathElem = doc->CreateElement( L"XPath" ); - - // Set the element text to the value - // of the XPath string. - xPathElem->InnerText = XPathString; - - // Create a new XmlDsigXPathTransform object. - XmlDsigXPathTransform^ xForm = gcnew XmlDsigXPathTransform; - - // Load the XPath XML from the element. - xForm->LoadInnerXml( xPathElem->SelectNodes( L"." ) ); - - // Return the XML that represents the transform. - return xForm; -} - - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, String^ XPathString ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = L""; - - // Create an XmlDsigXPathTransform object using - // the helper method 'CreateXPathTransform' defined - // later in this sample. - XmlDsigXPathTransform^ XPathTransform = CreateXPathTransform( XPathString ); - - // Add the transform to the reference. - reference->AddTransform( XPathTransform ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// Create example data to sign. -static void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" ); - - // Append the node to the document. - document->AppendChild( node ); - - // Create a new XmlNode object. - XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"TempElement", L"Sign" ); - - // Add some text to the node. - subnode->InnerText = L"Here is some data to sign."; - - // Append the node to the document. - document->DocumentElement->AppendChild( subnode ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - - // Generate a signing key. - RSA^ Key = RSA::Create(); - try - { - - // Create an XML file to sign. - CreateSomeXml( L"Example.xml" ); - Console::WriteLine( L"New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( L"Example.xml", L"SignedExample.xml", Key, L"ancestor-or-self::TempElement" ); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to \ - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - Key->Clear(); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp deleted file mode 100644 index 6693cd9c0f6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp +++ /dev/null @@ -1,193 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Create the XML that represents the transform. -static XmlDsigXsltTransform^ CreateXsltTransform( String^ xsl ) -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( xsl ); - XmlDsigXsltTransform^ xform = gcnew XmlDsigXsltTransform; - xform->LoadInnerXml( doc->ChildNodes ); - return xform; -} - - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, String^ XSLString ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = L""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Create an XmlDsigXPathTransform object using - // the helper method 'CreateXPathTransform' defined - // later in this sample. - XmlDsigXsltTransform^ XsltTransform = CreateXsltTransform( XSLString ); - - // Add the transform to the reference. - reference->AddTransform( XsltTransform ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// Create example data to sign. -static void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" ); - - // Append the node to the document. - document->AppendChild( node ); - - // Create a new XmlNode object. - XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"ElementToTransform", L"Sign" ); - - // Add some text to the node. - subnode->InnerText = L"Here is some data to sign."; - - // Append the node to the document. - document->DocumentElement->AppendChild( subnode ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - - // Generate a signing key. - RSA^ Key = RSA::Create(); - String^ xsl = L"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n "; - try - { - - // Create an XML file to sign. - CreateSomeXml( L"Example.xml" ); - Console::WriteLine( L"New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( L"Example.xml", L"SignedExample.xml", Key, xsl ); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to \ - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - Key->Clear(); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp deleted file mode 100644 index 4477c20eac3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -#using -#using -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; - -// -void CheckSignatureWithEncryptedGrant( - String^ fileName, IRelDecryptor^ decryptor) -{ - // Create a new XML document. - XmlDocument^ sourceDocument = gcnew XmlDocument(); - XmlNamespaceManager^ namespaceManager = - gcnew XmlNamespaceManager(sourceDocument->NameTable); - - // Format using white spaces. - sourceDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - sourceDocument->Load(fileName); - namespaceManager->AddNamespace("dsig", - SignedXml::XmlDsigNamespaceUrl); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = - sourceDocument->SelectNodes("//dsig:Signature", namespaceManager); - - for (int i = 0, count = nodeList->Count; i < count; i++) - { - XmlDocument^ clone = (XmlDocument^) sourceDocument->Clone(); - XmlNodeList^ signatures = - clone->SelectNodes("//dsig:Signature", namespaceManager); - - // Create a new SignedXml object and pass into it the - // XML document clone. - SignedXml^ signedDocument = gcnew SignedXml(clone); - - // Load the signature node. - signedDocument->LoadXml((XmlElement^)signatures[i]); - - // Set the context for license transform - Transform^ licenseTransform = ((Reference^)signedDocument-> - SignedInfo->References[0])->TransformChain[0]; - - if ((licenseTransform::typeid == XmlLicenseTransform::typeid) - && (decryptor != nullptr)) - { - // Decryptor is used to decrypt encryptedGrant - // elements. - ((XmlLicenseTransform^) licenseTransform)->Decryptor = decryptor; - } - - // Check the signature and display the result. - if (signedDocument->CheckSignature()) - { - Console::WriteLine("SUCCESS: " + - "CheckSignatureWithEncryptedGrant - issuer index #" + i); - } - else - { - Console::WriteLine("FAILURE: " + - "CheckSignatureWithEncryptedGrant - issuer index #" + i); - } - } -} -// - -int main() -{ -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalDigits/CPP/currencydecimaldigits.cpp b/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalDigits/CPP/currencydecimaldigits.cpp deleted file mode 100644 index e5ffc2a58d4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalDigits/CPP/currencydecimaldigits.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// The following code example demonstrates the effect of changing the -// CurrencyDecimalDigits property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a negative value with the default number of decimal digits (2). - Int64 myInt = -1234; - Console::WriteLine( myInt.ToString( "C", nfi ) ); - - // Displays the same value with four decimal digits. - nfi->CurrencyDecimalDigits = 4; - Console::WriteLine( myInt.ToString( "C", nfi ) ); -} - -/* -This code produces the following output. - -($1, 234.00) -($1, 234.0000) -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalSeparator/CPP/currencydecimalseparator.cpp b/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalSeparator/CPP/currencydecimalseparator.cpp deleted file mode 100644 index 9620c7b2591..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalSeparator/CPP/currencydecimalseparator.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// The following code example demonstrates the effect of changing the -// CurrencyDecimalSeparator property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a value with the default separator (S"."). - Int64 myInt = 123456789; - Console::WriteLine( myInt.ToString( "C", nfi ) ); - - // Displays the same value with a blank as the separator. - nfi->CurrencyDecimalSeparator = " "; - Console::WriteLine( myInt.ToString( "C", nfi ) ); -} - -/* -This code produces the following output. - -$123, 456, 789.00 -$123, 456, 789 00 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSeparator/CPP/currencygroupseparator.cpp b/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSeparator/CPP/currencygroupseparator.cpp deleted file mode 100644 index 0421ff605f4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSeparator/CPP/currencygroupseparator.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// The following code example demonstrates the effect of changing the -// CurrencyGroupSeparator property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a value with the default separator (S", "). - Int64 myInt = 123456789; - Console::WriteLine( myInt.ToString( "C", nfi ) ); - - // Displays the same value with a blank as the separator. - nfi->CurrencyGroupSeparator = " "; - Console::WriteLine( myInt.ToString( "C", nfi ) ); -} - -/* -This code produces the following output. - -$123, 456, 789.00 -$123 456 789.00 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSizes/CPP/currencygroupsizes.cpp b/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSizes/CPP/currencygroupsizes.cpp deleted file mode 100644 index a06da3edcbf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSizes/CPP/currencygroupsizes.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// The following code example demonstrates the effect of changing the -// CurrencyGroupSizes property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a value with the default separator (S"."). - Int64 myInt = 123456789012345; - Console::WriteLine( myInt.ToString( "C", nfi ) ); - - // Displays the same value with different groupings. - array^mySizes1 = {2,3,4}; - array^mySizes2 = {2,3,0}; - nfi->CurrencyGroupSizes = mySizes1; - Console::WriteLine( myInt.ToString( "C", nfi ) ); - nfi->CurrencyGroupSizes = mySizes2; - Console::WriteLine( myInt.ToString( "C", nfi ) ); -} - -/* -This code produces the following output. - -$123, 456, 789, 012, 345.00 -$12, 3456, 7890, 123, 45.00 -$1234567890, 123, 45.00 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp deleted file mode 100644 index a0af052a1d7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// The following example starts an instance of Notepad. The example -// then retrieves and displays various properties of the associated -// process. The example detects when the process exits, and displays -// the process's exit code. -// -#using - -using namespace System; -using namespace System::Diagnostics; -int main() -{ - - // Define variables to track the peak - // memory usage of the process. - _int64 peakPagedMem = 0,peakWorkingSet = 0,peakVirtualMem = 0; - Process^ myProcess = nullptr; - try - { - - // Start the process. - myProcess = Process::Start( "NotePad.exe" ); - - // Display the process statistics until - // the user closes the program. - do - { - if ( !myProcess->HasExited ) - { - - // Refresh the current process property values. - myProcess->Refresh(); - Console::WriteLine(); - - // Display current process statistics. - Console::WriteLine( "{0} -", myProcess ); - Console::WriteLine( "-------------------------------------" ); - Console::WriteLine( " physical memory usage: {0}", myProcess->WorkingSet64 ); - Console::WriteLine( " base priority: {0}", myProcess->BasePriority ); - Console::WriteLine( " priority class: {0}", myProcess->PriorityClass ); - Console::WriteLine( " user processor time: {0}", myProcess->UserProcessorTime ); - Console::WriteLine( " privileged processor time: {0}", myProcess->PrivilegedProcessorTime ); - Console::WriteLine( " total processor time: {0}", myProcess->TotalProcessorTime ); - Console::WriteLine(" PagedSystemMemorySize64: {0}", myProcess->PagedSystemMemorySize64); - Console::WriteLine(" PagedMemorySize64: {0}", myProcess->PagedMemorySize64); - - // Update the values for the overall peak memory statistics. - peakPagedMem = myProcess->PeakPagedMemorySize64; - peakVirtualMem = myProcess->PeakVirtualMemorySize64; - peakWorkingSet = myProcess->PeakWorkingSet64; - if ( myProcess->Responding ) - { - Console::WriteLine( "Status = Running" ); - } - else - { - Console::WriteLine( "Status = Not Responding" ); - } - } - } - while ( !myProcess->WaitForExit( 1000 ) ); - Console::WriteLine(); - Console::WriteLine( "Process exit code: {0}", myProcess->ExitCode ); - - // Display peak memory statistics for the process. - Console::WriteLine( "Peak physical memory usage of the process: {0}", peakWorkingSet ); - Console::WriteLine( "Peak paged memory usage of the process: {0}", peakPagedMem ); - Console::WriteLine( "Peak virtual memory usage of the process: {0}", peakVirtualMem ); - } - finally - { - if ( myProcess != nullptr ) - { - myProcess->Close(); - } - } - -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp b/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp deleted file mode 100644 index 1ec20413156..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// System::Diagnostics->CounterCreationData -// System::Diagnostics->CounterCreationData(String*, String*, PerformanceCounterType) -// System::Diagnostics->CounterCreationData() -// System::Diagnostics->CounterCreationData->CounterName -// System::Diagnostics->CounterCreationData->CounterHelp -// System::Diagnostics->CounterCreationData->CounterType - -/* The following program demonstrates 'CounterCreationData' class, -CounterCreationData(String*, String*, PerformanceCounterType)', -'CounterCreationData()', 'CounterName', 'CounterHelp' and -'CounterType' members of 'System::Diagnostics->CounterCreationData' -class. It creates the custom counters with 'CounterCreationData' -and binds them to 'PerformanceCounterCategory' object. */ - -// -// -// -// -// -// -#using - -using namespace System; -using namespace System::Diagnostics; - -int main() -{ - CounterCreationDataCollection^ myCol = gcnew CounterCreationDataCollection; - - // Create two custom counter objects. - CounterCreationData^ myCounter1 = gcnew CounterCreationData( "Counter1","First custom counter",PerformanceCounterType::CounterDelta32 ); - CounterCreationData^ myCounter2 = gcnew CounterCreationData; - - // Set the properties of the 'CounterCreationData' Object*. - myCounter2->CounterName = "Counter2"; - myCounter2->CounterHelp = "Second custom counter"; - myCounter2->CounterType = PerformanceCounterType::NumberOfItemsHEX32; - - // Add custom counter objects to CounterCreationDataCollection. - myCol->Add( myCounter1 ); - myCol->Add( myCounter2 ); - if ( PerformanceCounterCategory::Exists( "New Counter Category" ) ) - PerformanceCounterCategory::Delete( "New Counter Category" ); - - // Bind the counters to a PerformanceCounterCategory. - PerformanceCounterCategory^ myCategory = PerformanceCounterCategory::Create( "New Counter Category", "Category Help", myCol ); - Console::WriteLine( "Counter Information:" ); - Console::WriteLine( "Category Name: {0}", myCategory->CategoryName ); - for ( int i = 0; i < myCol->Count; i++ ) - { - // Display the properties of the CounterCreationData objects. - Console::WriteLine( "CounterName : {0}", myCol[ i ]->CounterName ); - Console::WriteLine( "CounterHelp : {0}", myCol[ i ]->CounterHelp ); - Console::WriteLine( "CounterType : {0}", myCol[ i ]->CounterType ); - } -} - -// -// -// -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp b/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp deleted file mode 100644 index b5b6c7488d8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp +++ /dev/null @@ -1,398 +0,0 @@ -//Types:System.Collections.DictionaryEntry -//Types:System.Collections.IDictionary -//Types:System.Collections.IDictionaryEnumerator -// -using namespace System; -using namespace System::Collections; - -// -// This class implements a simple dictionary using an array of -// DictionaryEntry objects (key/value pairs). -public ref class SimpleDictionary : public IDictionary -{ - // The array of items -private: - array^ items; -private: - int itemsInUse; - - // Construct the SimpleDictionary with the desired number of - // items. The number of items cannot change for the life time of - // this SimpleDictionary. -public: - SimpleDictionary(int size) - { - items = gcnew array(size); - } - - #pragma region IDictionary Members - // -public: - property virtual bool IsReadOnly - { - bool get() - { - return false; - } - } - // - // -public: - virtual bool Contains(Object^ key) - { - int index; - return TryGetIndexOfKey(key, &index); - } - // - // -public: - virtual property bool IsFixedSize - { - bool get() - { - return false; - } - } - // - // -public: - virtual void Remove(Object^ key) - { - if (key == nullptr) - { - throw gcnew ArgumentNullException("key"); - } - // Try to find the key in the DictionaryEntry array - int index; - if (TryGetIndexOfKey(key, &index)) - { - // If the key is found, slide all the items down. - Array::Copy(items, index + 1, items, index, itemsInUse - - index - 1); - itemsInUse--; - } - else - { - // If the key is not in the dictionary, just return. - return; - } - } - // - // -public: - virtual void Clear() - { - itemsInUse = 0; - } - // - // -public: - virtual void Add(Object^ key, Object^ value) - { - // Add the new key/value pair even if this key already exists - // in the dictionary. - if (itemsInUse == items->Length) - { - throw gcnew InvalidOperationException - ("The dictionary cannot hold any more items."); - } - items[itemsInUse++] = gcnew DictionaryEntry(key, value); - } - // - // -public: - virtual property ICollection^ Keys - { - ICollection^ get() - { - // Return an array where each item is a key. - array^ keys = gcnew array(itemsInUse); - for (int i = 0; i < itemsInUse; i++) - { - keys[i] = items[i]->Key; - } - return keys; - } - } - // - // -public: - virtual property ICollection^ Values - { - ICollection^ get() - { - // Return an array where each item is a value. - array^ values = gcnew array(itemsInUse); - for (int i = 0; i < itemsInUse; i++) - { - values[i] = items[i]->Value; - } - return values; - } - } - // - // -public: - virtual property Object^ default[Object^] - { - Object^ get(Object^ key) - { - // If this key is in the dictionary, return its value. - int index; - if (TryGetIndexOfKey(key, &index)) - { - // The key was found; return its value. - return items[index]->Value; - } - else - { - // The key was not found; return null. - return nullptr; - } - } - - void set(Object^ key, Object^ value) - { - // If this key is in the dictionary, change its value. - int index; - if (TryGetIndexOfKey(key, &index)) - { - // The key was found; change its value. - items[index]->Value = value; - } - else - { - // This key is not in the dictionary; add this - // key/value pair. - Add(key, value); - } - } - } - // -private: - bool TryGetIndexOfKey(Object^ key, int* index) - { - for (*index = 0; *index < itemsInUse; *index++) - { - // If the key is found, return true (the index is also - // returned). - if (items[*index]->Key->Equals(key)) - { - return true; - } - } - - // Key not found, return false (index should be ignored by - // the caller). - return false; - } -// -// -private: - ref class SimpleDictionaryEnumerator : public IDictionaryEnumerator - { - // A copy of the SimpleDictionary object's key/value pairs. -private: - array^ items; -private: - int index; - -public: - SimpleDictionaryEnumerator(SimpleDictionary^ sd) - { - // Make a copy of the dictionary entries currently in the - // SimpleDictionary object. - items = gcnew array(sd->Count); - Array::Copy(sd->items, 0, items, 0, sd->Count); - index = -1; - } - - // Return the current item. -public: - virtual property Object^ Current - { - Object^ get() - { - ValidateIndex(); - return items[index]; - } - } - - // Return the current dictionary entry. -public: - virtual property DictionaryEntry Entry - { - DictionaryEntry get() - { - return (DictionaryEntry) Current; - } - } - - // Return the key of the current item. -public: - virtual property Object^ Key - { - Object^ get() - { - ValidateIndex(); - return items[index]->Key; - } - } - - // Return the value of the current item. -public: - virtual property Object^ Value - { - Object^ get() - { - ValidateIndex(); - return items[index]->Value; - } - } - - // Advance to the next item. -public: - virtual bool MoveNext() - { - if (index < items->Length - 1) - { - index++; - return true; - } - return false; - } - - // Validate the enumeration index and throw an exception if - // the index is out of range. -private: - void ValidateIndex() - { - if (index < 0 || index >= items->Length) - { - throw gcnew InvalidOperationException - ("Enumerator is before or after the collection."); - } - } - - // Reset the index to restart the enumeration. -public: - virtual void Reset() - { - index = -1; - } - }; - // -public: - virtual IDictionaryEnumerator^ GetEnumerator() - { - // Construct and return an enumerator. - return gcnew SimpleDictionaryEnumerator(this); - } - // - #pragma endregion - - #pragma region ICollection Members -public: - virtual property bool IsSynchronized - { - bool get() - { - return false; - } - } - -public: - virtual property Object^ SyncRoot - { - Object^ get() - { - throw gcnew NotImplementedException(); - } - } - -public: - virtual property int Count - { - int get() - { - return itemsInUse; - } - } - -public: - virtual void CopyTo(Array^ array, int index) - { - throw gcnew NotImplementedException(); - } - #pragma endregion - - #pragma region IEnumerable Members - - virtual IEnumerator^ IEnumerable_GetEnumerator() - = IEnumerable::GetEnumerator - { - // Construct and return an enumerator. - return ((IDictionary^)this)->GetEnumerator(); - } - #pragma endregion -}; -// - -int main() -{ - // Create a dictionary that contains no more than three - // entries. - IDictionary^ d = gcnew SimpleDictionary(3); - - // Add three people and their ages to the dictionary. - d->Add("Jeff", 40); - d->Add("Kristin", 34); - d->Add("Aidan", 1); - - Console::WriteLine("Number of elements in dictionary = {0}", - d->Count); - - Console::WriteLine("Does dictionary contain 'Jeff'? {0}", - d->Contains("Jeff")); - Console::WriteLine("Jeff's age is {0}", d["Jeff"]); - - // Display every entry's key and value. - for each (DictionaryEntry^ de in d) - { - Console::WriteLine("{0} is {1} years old.", de->Key, - de->Value); - } - - // Remove an entry that exists. - d->Remove("Jeff"); - - // Remove an entry that does not exist, but do not throw an - // exception. - d->Remove("Max"); - - // Show the names (keys) of the people in the dictionary. - for each (String^ s in d->Keys) - { - Console::WriteLine(s); - } - - // Show the ages (values) of the people in the dictionary. - for each (int age in d->Values) - { - Console::WriteLine(age); - } -} - -// This code produces the following output. -// -// Number of elements in dictionary = 3 -// Does dictionary contain 'Jeff'? True -// Jeff's age is 40 -// Jeff is 40 years old. -// Kristin is 34 years old. -// Aidan is 1 years old. -// Kristin -// Aidan -// 34 -// 1 -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/remarks.cpp deleted file mode 100644 index 6d4e4af244c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/remarks.cpp +++ /dev/null @@ -1,44 +0,0 @@ -using namespace System; -using namespace System::Collections; - -public ref class SimpleDictionary : DictionaryBase -{ -}; - -public ref class DictionaySamples -{ -public: - static void Main() - { - // Create a dictionary that contains no more than three entries. - IDictionary^ myDictionary = gcnew SimpleDictionary(); - - // Add three people and their ages to the dictionary. - myDictionary->Add("Jeff", 40); - myDictionary->Add("Kristin", 34); - myDictionary->Add("Aidan", 1); - // Display every entry's key and value. - for each (DictionaryEntry de in myDictionary) - { - Console::WriteLine("{0} is {1} years old.", de.Key, de.Value); - } - - // Remove an entry that exists. - myDictionary->Remove("Jeff"); - - // Remove an entry that does not exist, but do not throw an exception. - myDictionary->Remove("Max"); - - // - for each (DictionaryEntry de in myDictionary) - { - //... - } - // - } -}; - -int main() -{ - DictionaySamples::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR/DirInfo Class Example/CPP/dirinfo class example.cpp b/snippets/cpp/VS_Snippets_CLR/DirInfo Class Example/CPP/dirinfo class example.cpp deleted file mode 100644 index ad273901016..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DirInfo Class Example/CPP/dirinfo class example.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Specify the directories you want to manipulate. - DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\MyDir" ); - try - { - - // Determine whether the directory exists. - if ( di->Exists ) - { - - // Indicate that the directory already exists. - Console::WriteLine( "That path exists already." ); - return 0; - } - - // Try to create the directory. - di->Create(); - Console::WriteLine( "The directory was created successfully." ); - - // Delete the directory. - di->Delete(); - Console::WriteLine( "The directory was deleted successfully." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/DirInfo Create/CPP/dirinfo create.cpp b/snippets/cpp/VS_Snippets_CLR/DirInfo Create/CPP/dirinfo create.cpp deleted file mode 100644 index b172c01236b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DirInfo Create/CPP/dirinfo create.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Specify the directories you want to manipulate. - DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\MyDir" ); - try - { - - // Determine whether the directory exists. - if ( di->Exists ) - { - - // Indicate that it already exists. - Console::WriteLine( "That path exists already." ); - return 0; - } - - // Try to create the directory. - di->Create(); - Console::WriteLine( "The directory was created successfully." ); - - // Delete the directory. - di->Delete(); - Console::WriteLine( "The directory was deleted successfully." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/DirInfo Ctor/CPP/dirinfo ctor.cpp b/snippets/cpp/VS_Snippets_CLR/DirInfo Ctor/CPP/dirinfo ctor.cpp deleted file mode 100644 index 8a3584321aa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DirInfo Ctor/CPP/dirinfo ctor.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Specify the directories you want to manipulate. - DirectoryInfo^ di1 = gcnew DirectoryInfo( "c:\\MyDir" ); - DirectoryInfo^ di2 = gcnew DirectoryInfo( "c:\\MyDir\\temp" ); - try - { - - // Create the directories. - di1->Create(); - di2->Create(); - - // This operation will not be allowed because there are subdirectories. - Console::WriteLine( "I am about to attempt to delete {0}.", di1->Name ); - di1->Delete(); - Console::WriteLine( "The Delete operation was successful, which was unexpected." ); - } - catch ( Exception^ ) - { - Console::WriteLine( "The Delete operation failed as expected." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/DirInfo Delete1/CPP/dirinfo delete1.cpp b/snippets/cpp/VS_Snippets_CLR/DirInfo Delete1/CPP/dirinfo delete1.cpp deleted file mode 100644 index c0751c822f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DirInfo Delete1/CPP/dirinfo delete1.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Specify the directories you want to manipulate. - DirectoryInfo^ di1 = gcnew DirectoryInfo( "c:\\MyDir" ); - try - { - - // Create the directories. - di1->Create(); - di1->CreateSubdirectory( "temp" ); - - //This operation will not be allowed because there are subdirectories. - Console::WriteLine( "I am about to attempt to delete {0}", di1->Name ); - di1->Delete(); - Console::WriteLine( "The Delete operation was successful, which was unexpected." ); - } - catch ( Exception^ ) - { - Console::WriteLine( "The Delete operation failed as expected." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/DirInfo GetDirs2/CPP/dirinfo getdirs2.cpp b/snippets/cpp/VS_Snippets_CLR/DirInfo GetDirs2/CPP/dirinfo getdirs2.cpp deleted file mode 100644 index 7ecd08dfd25..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DirInfo GetDirs2/CPP/dirinfo getdirs2.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\" ); - - // Get only subdirectories that contain the letter "p." - array^dirs = di->GetDirectories( "*p*" ); - Console::WriteLine( "The number of directories containing the letter p is {0}.", dirs->Length ); - Collections::IEnumerator^ myEnum = dirs->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DirectoryInfo^ diNext = safe_cast(myEnum->Current); - Console::WriteLine( "The number of files in {0} is {1}", diNext, diNext->GetFiles()->Length ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetCreation/CPP/dir_getcreation.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetCreation/CPP/dir_getcreation.cpp deleted file mode 100644 index 86cac85e3fc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dir_GetCreation/CPP/dir_getcreation.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - - // Get the creation time of a well-known directory. - DateTime dt = Directory::GetCreationTime( Environment::CurrentDirectory ); - - // Give feedback to the user. - if ( DateTime::Now.Subtract( dt ).TotalDays > 364 ) - { - Console::WriteLine( "This directory is over a year old." ); - } - else - if ( DateTime::Now.Subtract( dt ).TotalDays > 30 ) - { - Console::WriteLine( "This directory is over a month old." ); - } - else - if ( DateTime::Now.Subtract( dt ).TotalDays <= 1 ) - { - Console::WriteLine( "This directory is less than a day old." ); - } - else - { - Console::WriteLine( "This directory was created on {0}", dt ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetCurDir/CPP/dir_getcurdir.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetCurDir/CPP/dir_getcurdir.cpp deleted file mode 100644 index 716792cead5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dir_GetCurDir/CPP/dir_getcurdir.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - - // Get the current directory. - String^ path = Directory::GetCurrentDirectory(); - String^ target = "c:\\temp"; - Console::WriteLine( "The current directory is {0}", path ); - if ( !Directory::Exists( target ) ) - { - Directory::CreateDirectory( target ); - } - - // Change the current directory. - Environment::CurrentDirectory = target; - if ( path->Equals( Directory::GetCurrentDirectory() ) ) - { - Console::WriteLine( "You are in the temp directory." ); - } - else - { - Console::WriteLine( "You are not in the temp directory." ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetDirs2/CPP/dir_getdirs2.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetDirs2/CPP/dir_getdirs2.cpp deleted file mode 100644 index 0896d4ca1b5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dir_GetDirs2/CPP/dir_getdirs2.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - - // Only get subdirectories that begin with the letter "p." - array^dirs = Directory::GetDirectories( "c:\\", "p*" ); - Console::WriteLine( "The number of directories starting with p is {0}.", dirs->Length ); - Collections::IEnumerator^ myEnum = dirs->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Console::WriteLine( myEnum->Current ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetFiles2/CPP/dir_getfiles2.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetFiles2/CPP/dir_getfiles2.cpp deleted file mode 100644 index 95bb8528e02..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dir_GetFiles2/CPP/dir_getfiles2.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - - // Only get files that begin with the letter "c". - array^dirs = Directory::GetFiles( "c:\\", "c*" ); - Console::WriteLine( "The number of files starting with c is {0}.", dirs->Length ); - Collections::IEnumerator^ myEnum = dirs->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Console::WriteLine( myEnum->Current ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetLastAccess/CPP/dir_getlastaccess.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetLastAccess/CPP/dir_getlastaccess.cpp deleted file mode 100644 index d38d877f932..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dir_GetLastAccess/CPP/dir_getlastaccess.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - String^ path = "c:\\MyDir"; - if ( !Directory::Exists( path ) ) - { - Directory::CreateDirectory( path ); - } - Directory::SetLastAccessTime( path, DateTime(1985,5,4) ); - - // Get the creation time of a well-known directory. - DateTime dt = Directory::GetLastAccessTime( path ); - Console::WriteLine( "The last access time for this directory was {0}", dt ); - - // Update the last access time. - Directory::SetLastAccessTime( path, DateTime::Now ); - dt = Directory::GetLastAccessTime( path ); - Console::WriteLine( "The last access time for this directory was {0}", dt ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_GetLastWrite/CPP/dir_getlastwrite.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_GetLastWrite/CPP/dir_getlastwrite.cpp deleted file mode 100644 index 75e5bee709d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dir_GetLastWrite/CPP/dir_getlastwrite.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - String^ path = "c:\\MyDir"; - if ( !Directory::Exists( path ) ) - { - Directory::CreateDirectory( path ); - } - else - { - - // Take an action which will affect the write time. - Directory::SetLastWriteTime( path, DateTime(1985,4,3) ); - } - - // Get the creation time of a well-known directory. - DateTime dt = Directory::GetLastWriteTime( path ); - Console::WriteLine( "The last write time for this directory was {0}", dt ); - - // Update the last write time. - Directory::SetLastWriteTime( path, DateTime::Now ); - dt = Directory::GetLastWriteTime( path ); - Console::WriteLine( "The last write time for this directory was {0}", dt ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_SetLastAccess/CPP/dir_setlastaccess.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_SetLastAccess/CPP/dir_setlastaccess.cpp deleted file mode 100644 index 0da03649338..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dir_SetLastAccess/CPP/dir_setlastaccess.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - String^ path = "c:\\MyDir"; - if ( !Directory::Exists( path ) ) - { - Directory::CreateDirectory( path ); - } - Directory::SetLastAccessTime( path, DateTime(1985,5,4) ); - - // Get the last access time of a well-known directory. - DateTime dt = Directory::GetLastAccessTime( path ); - Console::WriteLine( "The last access time for this directory was {0}", dt ); - - // Update the last access time. - Directory::SetLastAccessTime( path, DateTime::Now ); - dt = Directory::GetLastAccessTime( path ); - Console::WriteLine( "The last access time for this directory was {0}", dt ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_SetLastWrite/CPP/dir_setlastwrite.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_SetLastWrite/CPP/dir_setlastwrite.cpp deleted file mode 100644 index 45c4c45428c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dir_SetLastWrite/CPP/dir_setlastwrite.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -void main() -{ - try - { - String^ path = "c:\\MyDir"; - if ( !Directory::Exists( path ) ) - { - Directory::CreateDirectory( path ); - } - else - { - - // Take an action that will affect the write time. - Directory::SetLastWriteTime( path, DateTime(1985,4,3) ); - } - - // Get the last write time of a well-known directory. - DateTime dt = Directory::GetLastWriteTime( path ); - Console::WriteLine( "The last write time for this directory was {0}", dt ); - - //Update the last write time. - Directory::SetLastWriteTime( path, DateTime::Now ); - dt = Directory::GetLastWriteTime( path ); - Console::WriteLine( "The last write time for this directory was {0}", dt ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/DirectoryInfo Usage Example/CPP/copydirectory.cpp b/snippets/cpp/VS_Snippets_CLR/DirectoryInfo Usage Example/CPP/copydirectory.cpp deleted file mode 100644 index 9647674e17e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DirectoryInfo Usage Example/CPP/copydirectory.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// -using namespace System; -using namespace System::IO; - -// Copy a source directory to a target directory. -void CopyDirectory( String^ SourceDirectory, String^ TargetDirectory ) -{ - DirectoryInfo^ source = gcnew DirectoryInfo( SourceDirectory ); - DirectoryInfo^ target = gcnew DirectoryInfo( TargetDirectory ); - - //Determine whether the source directory exists. - if ( !source->Exists ) - return; - - if ( !target->Exists ) - target->Create(); - - - //Copy files. - array^sourceFiles = source->GetFiles(); - for ( int i = 0; i < sourceFiles->Length; ++i ) - File::Copy( sourceFiles[ i ]->FullName, String::Concat( target->FullName, "\\", sourceFiles[ i ]->Name ), true ); - - //Copy directories. - array^sourceDirectories = source->GetDirectories(); - for ( int j = 0; j < sourceDirectories->Length; ++j ) - CopyDirectory( sourceDirectories[ j ]->FullName, String::Concat( target->FullName, "\\", sourceDirectories[ j ]->Name ) ); -} - -int main() -{ - CopyDirectory( "D:\\Tools", "D:\\NewTools" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/CPP/entrywritteneventargs_ctor1.cpp b/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/CPP/entrywritteneventargs_ctor1.cpp deleted file mode 100644 index 3f5ffdf0349..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/CPP/entrywritteneventargs_ctor1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// System::Diagnostics::EntryWrittenEventArgs::ctor() - -/* -The following example demonstrates 'EntryWrittenEventArgs ()' -constructor of the 'EntryWrittenEventArgs' class. It creates a custom 'EventLog' -and writes an entry into it. Then creates an 'EntryWrittenEventArgs' Object* -using the first entry in the custom eventlog. This Object* is used to notify a message -*/ - -// -#using - -using namespace System; -using namespace System::Diagnostics; - -void MyOnEntry( Object^ source, EntryWrittenEventArgs^ e ) -{ - if ( !e->Entry ) - Console::WriteLine( "A new entry is written in MyNewLog." ); -} - -int main() -{ - try - { - EventLog^ myNewLog = gcnew EventLog; - myNewLog->Log = "MyNewLog"; - myNewLog->Source = "MySource"; - - // Create the source if it does not exist already. - if ( !EventLog::SourceExists( "MySource" ) ) - { - EventLog::CreateEventSource( "MySource", "MyNewLog" ); - Console::WriteLine( "CreatingEventSource" ); - } - - // Write an entry to the EventLog. - myNewLog->WriteEntry( "The Latest entry in the Event Log" ); - int myEntries = myNewLog->Entries->Count; - EventLogEntry^ entry = myNewLog->Entries[ myEntries - 1 ]; - EntryWrittenEventArgs^ myEntryEventArgs = gcnew EntryWrittenEventArgs; - MyOnEntry( myNewLog, myEntryEventArgs ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Raised{0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/CPP/entrywritteneventargs_ctor2.cpp b/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/CPP/entrywritteneventargs_ctor2.cpp deleted file mode 100644 index 96f9f0f008b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/CPP/entrywritteneventargs_ctor2.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// System::Diagnostics::EntryWrittenEventArgs::ctor(EventLogEntry) -// System::Diagnostics::EntryWrittenEventArgs::Entry - -/* -The following example demonstrates the 'Entry' property and EntryWrittenEventArgs (EventLogEntry) -constructor of the 'EntryWrittenEventArgs' class. It creates a custom 'EventLog' and writes an -entry into it. Then creates an 'EntryWrittenEventArgs' Object* using the first entry in the custom -eventlog. This Object* is used to notify a message -*/ - -// -#using - -using namespace System; -using namespace System::Diagnostics; - -// -void MyOnEntry( Object^ source, EntryWrittenEventArgs^ e ) -{ - EventLogEntry^ myEventLogEntry = e->Entry; - if ( myEventLogEntry ) - { - Console::WriteLine( "Current message entry is: '{0}'", myEventLogEntry->Message ); - } - else - { - Console::WriteLine( "The current entry is null" ); - } -} -// - -int main() -{ - try - { - EventLog^ myNewLog = gcnew EventLog; - myNewLog->Log = "MyNewLog"; - myNewLog->Source = "MySource"; - - // Create the source if it does not exist already. - if ( !EventLog::SourceExists( "MySource" ) ) - { - EventLog::CreateEventSource( "MySource", "MyNewLog" ); - Console::WriteLine( "CreatingEventSource" ); - } - - // Write an entry to the EventLog. - myNewLog->WriteEntry( "The Latest entry in the Event Log" ); - int myEntries = myNewLog->Entries->Count; - EventLogEntry^ entry = myNewLog->Entries[ myEntries - 1 ]; - EntryWrittenEventArgs^ myEntryEventArgs = gcnew EntryWrittenEventArgs( entry ); - MyOnEntry( myNewLog, myEntryEventArgs ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Raised {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogEntryType_6/CPP/eventlogentrytype_6.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogEntryType_6/CPP/eventlogentrytype_6.cpp deleted file mode 100644 index 54a15c9b13c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLogEntryType_6/CPP/eventlogentrytype_6.cpp +++ /dev/null @@ -1,110 +0,0 @@ - - -// System::Diagnostics::EventLogEntryType -// System::Diagnostics::EventLogEntryType::Error -// System::Diagnostics::EventLogEntryType::Warning -// System::Diagnostics::EventLogEntryType::Information -// System::Diagnostics::EventLogEntryType::FailureAudit -// System::Diagnostics::EventLogEntryType::SuccessAudit -/* The following program demonstrates 'Error', 'Warning', -'Information', 'FailureAudit' and 'SuccessAudit' members of -'EventLogEntryType' enumerator. It creates new source with a -specified event log, new ID, EventLogEntryType and message, -if does not exist. -*/ -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Runtime::Serialization; -void main() -{ - try - { - EventLog^ myEventLog; - String^ mySource = nullptr; - String^ myLog = nullptr; - String^ myType = nullptr; - String^ myMessage = "A new event is created."; - String^ myEventID = nullptr; - int myIntLog = 0; - int myID = 0; - Console::Write( "Enter source name for new event (eg: Print): " ); - mySource = Console::ReadLine(); - Console::Write( "Enter log name in which to write an event(eg: System): " ); - myLog = Console::ReadLine(); - Console::WriteLine( "" ); - Console::WriteLine( " Select type of event to write:" ); - Console::WriteLine( " 1. Error " ); - Console::WriteLine( " 2. Warning" ); - Console::WriteLine( " 3. Information" ); - Console::WriteLine( " 4. FailureAudit" ); - Console::WriteLine( " 5. SuccessAudit" ); - Console::Write( "Enter the choice(eg. 1): " ); - myType = Console::ReadLine(); - myIntLog = Convert::ToInt32( myType ); - Console::Write( "Enter ID with which to write an event(eg: 0-65535): " ); - myEventID = Console::ReadLine(); - myID = Convert::ToInt32( myEventID ); - - // - // Check whether source exist in event log. - if ( !EventLog::SourceExists( mySource ) ) - { - - // Create a new source in a specified log on a system. - EventLog::CreateEventSource( mySource, myLog ); - } - - // Create an event log instance.* myEventLog = new EventLog(myLog); - // Initialize source property of obtained instance. - myEventLog->Source = mySource; - switch ( myIntLog ) - { - case 1: - - // Write an 'Error' entry in specified log of event log. - myEventLog->WriteEntry( myMessage, EventLogEntryType::Error, myID ); - break; - - case 2: - - // Write a 'Warning' entry in specified log of event log. - myEventLog->WriteEntry( myMessage, EventLogEntryType::Warning, myID ); - break; - - case 3: - - // Write an 'Information' entry in specified log of event log. - myEventLog->WriteEntry( myMessage, EventLogEntryType::Information, myID ); - break; - - case 4: - - // Write a 'FailureAudit' entry in specified log of event log. - myEventLog->WriteEntry( myMessage, EventLogEntryType::FailureAudit, myID ); - break; - - case 5: - - // Write a 'SuccessAudit' entry in specified log of event log. - myEventLog->WriteEntry( myMessage, EventLogEntryType::SuccessAudit, myID ); - break; - - default: - Console::WriteLine( "Error: Failed to create an event in event log." ); - break; - } - Console::WriteLine( "A new event in log '{0}' with ID '{1}' is successfully written into event log.", myEventLog->Log, myID ); - - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_CopyTo/CPP/eventlogentry_copyto.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogEntry_CopyTo/CPP/eventlogentry_copyto.cpp deleted file mode 100644 index 6cb7dbb7107..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_CopyTo/CPP/eventlogentry_copyto.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// System::Diagnostics::EventLogEntryCollection -// System::Diagnostics::EventLogEntryCollection::CopyTo(EventLogEntry->Item[],int) - -/* -The following example demonstrates the EventLogEntryCollection class and the -CopyTo method of EventLogEntryCollection class. A new Source for eventlog 'MyNewLog' -is created. A new entry is created for 'MyNewLog'. The entries of EventLog are copied -to an Array. -*/ - -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Diagnostics; -int main() -{ - try - { - String^ myLogName = "MyNewLog"; - - // Check if the source exists. - if ( !EventLog::SourceExists( "MySource" ) ) - { - //Create source. - EventLog::CreateEventSource( "MySource", myLogName ); - Console::WriteLine( "Creating EventSource" ); - } - else - myLogName = EventLog::LogNameFromSourceName( "MySource", "." ); - - // Get the EventLog associated if the source exists. - // Create an EventLog instance and assign its source. - EventLog^ myEventLog2 = gcnew EventLog; - myEventLog2->Source = "MySource"; - - // Write an informational entry to the event log. - myEventLog2->WriteEntry( "Successfully created a new Entry in the Log" ); - myEventLog2->Close(); - - // Create a new EventLog Object*. - EventLog^ myEventLog1 = gcnew EventLog; - myEventLog1->Log = myLogName; - - // Obtain the Log Entries of S"MyNewLog". - EventLogEntryCollection^ myEventLogEntryCollection = myEventLog1->Entries; - myEventLog1->Close(); - Console::WriteLine( "The number of entries in 'MyNewLog' = {0}", myEventLogEntryCollection->Count ); - - // Display the 'Message' property of EventLogEntry. - for ( int i = 0; i < myEventLogEntryCollection->Count; i++ ) - { - Console::WriteLine( "The Message of the EventLog is : {0}", myEventLogEntryCollection[ i ]->Message ); - } - - // Copy the EventLog entries to Array of type EventLogEntry. - array^myEventLogEntryArray = gcnew array(myEventLogEntryCollection->Count); - myEventLogEntryCollection->CopyTo( myEventLogEntryArray, 0 ); - IEnumerator^ myEnumerator = myEventLogEntryArray->GetEnumerator(); - while ( myEnumerator->MoveNext() ) - { - EventLogEntry^ myEventLogEntry = safe_cast(myEnumerator->Current); - Console::WriteLine( "The LocalTime the Event is generated is {0}", myEventLogEntry->TimeGenerated ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Item/CPP/eventlogentry_item.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Item/CPP/eventlogentry_item.cpp deleted file mode 100644 index 60cc220d29d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Item/CPP/eventlogentry_item.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// System::Diagnostics::EventLogEntryCollection->Count -// System::Diagnostics::EventLogEntryCollection::Item - -/* -The following example demonstrates 'Item','Count' properties of -EventLogEntryCollection class. A new Source for eventlog 'MyNewLog' is created. -The program checks if a Event source exists. If the source already exists, it gets -the Log name associated with it otherwise, creates a new event source. -A new entry is created for 'MyNewLog'.Entries of 'MyNewLog' are obtained and -the count and the messages are displayed. - -*/ - -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Diagnostics; - -void main() -{ - try - { - String^ myLogName = "MyNewLog"; - - // Check if the source exists. - if ( !EventLog::SourceExists( "MySource" ) ) - { - - //Create source. - EventLog::CreateEventSource( "MySource", myLogName ); - Console::WriteLine( "Creating EventSource" ); - } - else - myLogName = EventLog::LogNameFromSourceName( "MySource", "." ); - - // Get the EventLog associated if the source exists. - // Create an EventLog instance and assign its source. - EventLog^ myEventLog2 = gcnew EventLog; - myEventLog2->Source = "MySource"; - - //Write an entry to the event log. - myEventLog2->WriteEntry( "Successfully created a new Entry in the Log. " ); - - // - // - // Create a new EventLog object. - EventLog^ myEventLog1 = gcnew EventLog; - myEventLog1->Log = myLogName; - - // Obtain the Log Entries of the Event Log - EventLogEntryCollection^ myEventLogEntryCollection = myEventLog1->Entries; - Console::WriteLine( "The number of entries in 'MyNewLog' = {0}", myEventLogEntryCollection->Count ); - - // Display the 'Message' property of EventLogEntry. - for ( int i = 0; i < myEventLogEntryCollection->Count; i++ ) - { - Console::WriteLine( "The Message of the EventLog is : {0}", myEventLogEntryCollection[ i ]->Message ); - } - // - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Caught! {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Source/CPP/eventlogentry_source.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Source/CPP/eventlogentry_source.cpp deleted file mode 100644 index 2c9c0d22442..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Source/CPP/eventlogentry_source.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// System::Diagnostics::EventLogEntry::EntryType -// System::Diagnostics::EventLogEntry::Source - -/* -The following example demonstrates the properties 'EntryType' and 'Source' -of the class 'EventLogEntry'. -A new instance of 'EventLog' class is created and is associated to existing -System Log file of local machine. User selects the event type and the latest -entry in the log file of that type and it's source is displayed. -*/ - -// -// -#using - -using namespace System; -using namespace System::Diagnostics; - -int main() -{ - String^ myEventType = nullptr; - - // Associate the instance of 'EventLog' with local System Log. - EventLog^ myEventLog = gcnew EventLog( "System","." ); - Console::WriteLine( "1:Error" ); - Console::WriteLine( "2:Information" ); - Console::WriteLine( "3:Warning" ); - Console::WriteLine( "Select the Event Type" ); - int myOption = Convert::ToInt32( Console::ReadLine() ); - switch ( myOption ) - { - case 1: - myEventType = "Error"; - break; - - case 2: - myEventType = "Information"; - break; - - case 3: - myEventType = "Warning"; - break; - - default: - break; - } - EventLogEntryCollection^ myLogEntryCollection = myEventLog->Entries; - int myCount = myLogEntryCollection->Count; - - // Iterate through all 'EventLogEntry' instances in 'EventLog'. - for ( int i = myCount - 1; i > -1; i-- ) - { - EventLogEntry^ myLogEntry = myLogEntryCollection[ i ]; - - // Select the entry having desired EventType. - if ( myLogEntry->EntryType.Equals( myEventType ) ) - { - // Display Source of the event. - Console::WriteLine( "{0} was the source of last event of type {1}", myLogEntry->Source, myLogEntry->EntryType ); - return 0; - } - } -} -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogInstaller/CPP/eventloginstaller.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogInstaller/CPP/eventloginstaller.cpp deleted file mode 100644 index 24f99e2bd0d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLogInstaller/CPP/eventloginstaller.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// System.Diagnostics.EventLogInstaller - -// The following example demonstrates the EventLogInstaller class. -// It defines the instance MyEventLogInstaller with the -// attribute RunInstallerAttribute. -// -// The Log and Source properties of the new instance are set, -// and the instance is added to the Installers collection. -// -// Note: -// 1) Run this program using the following command: -// InstallUtil.exe -// 2) Uninstall the event log created in step 1 using the -// following command: -// InstallUtil.exe /u - -// -#using -#using - -using namespace System; -using namespace System::Configuration::Install; -using namespace System::Diagnostics; -using namespace System::ComponentModel; - -[RunInstaller(true)] -ref class MyEventLogInstaller: public Installer -{ -private: - EventLogInstaller^ myEventLogInstaller; - -public: - MyEventLogInstaller() - { - // Create an instance of an EventLogInstaller. - myEventLogInstaller = gcnew EventLogInstaller; - - // Set the source name of the event log. - myEventLogInstaller->Source = "NewLogSource"; - - // Set the event log that the source writes entries to. - myEventLogInstaller->Log = "MyNewLog"; - - // Add myEventLogInstaller to the Installer collection. - Installers->Add( myEventLogInstaller ); - } -}; -// - -void main(){} diff --git a/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp deleted file mode 100644 index f89e23b187c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp +++ /dev/null @@ -1,187 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Globalization; -using namespace System::IO; -using namespace System::Data; -using namespace System::Diagnostics; -using namespace Microsoft::Win32; -void GetNewOverflowSetting( OverflowAction * newOverflow, interior_ptr numDays ); -void DisplayEventLogProperties(); -void ChangeEventLogOverflowAction( String^ logName ); - -/// The main entry point for the sample application. - -[STAThread] -int main() -{ - DisplayEventLogProperties(); - Console::WriteLine(); - Console::WriteLine( "Enter the name of an event log to change the" ); - Console::WriteLine( "overflow policy (or press Enter to exit): " ); - String^ input = Console::ReadLine(); - if ( !String::IsNullOrEmpty( input ) ) - { - ChangeEventLogOverflowAction( input ); - } -} - - -// Prompt the user for the overflow policy setting. -void GetNewOverflowSetting( OverflowAction * newOverflow, interior_ptr numDays ) -{ - Console::Write( "Enter the new overflow policy setting [" ); - Console::Write( " OverwriteOlder," ); - Console::Write( " DoNotOverwrite," ); - Console::Write( " OverwriteAsNeeded" ); - Console::WriteLine( "] : " ); - String^ input = Console::ReadLine(); - if ( !String::IsNullOrEmpty( input ) ) - { - String^ INPUT = input->Trim()->ToUpper( CultureInfo::InvariantCulture ); - if ( INPUT->Equals( "OVERWRITEOLDER" ) ) - { - *newOverflow = OverflowAction::OverwriteOlder; - Console::WriteLine( "Enter the number of days to retain events: " ); - input = Console::ReadLine(); - - if ( ( !Int32::TryParse( input, *numDays )) || ( *numDays == 0) ) - { - Console::WriteLine( " Invalid input, defaulting to 7 days." ); - *numDays = 7; - } - } - else - if ( INPUT->Equals( "DONOTOVERWRITE" ) ) - { - *newOverflow = OverflowAction::DoNotOverwrite; - } - else - if ( INPUT->Equals( "OVERWRITEASNEEDED" ) ) - { - *newOverflow = OverflowAction::OverwriteAsNeeded; - } - else - Console::WriteLine( "Unrecognized overflow policy." ); - } - - Console::WriteLine(); -} - - -// -void DisplayEventLogProperties() -{ - - // Iterate through the current set of event log files, - // displaying the property settings for each file. - array^eventLogs = EventLog::GetEventLogs(); - System::Collections::IEnumerator^ myEnum = eventLogs->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLog^ e = safe_cast(myEnum->Current); - Int64 sizeKB = 0; - Console::WriteLine(); - Console::WriteLine( "{0}:", e->LogDisplayName ); - Console::WriteLine( " Log name = \t\t {0}", e->Log ); - Console::WriteLine( " Number of event log entries = {0}", e->Entries->Count ); - - // Determine if there is a file for this event log. - RegistryKey ^ regEventLog = Registry::LocalMachine->OpenSubKey( String::Format( "System\\CurrentControlSet\\Services\\EventLog\\{0}", e->Log ) ); - if ( regEventLog ) - { - Object^ temp = regEventLog->GetValue( "File" ); - if ( temp != nullptr ) - { - Console::WriteLine( " Log file path = \t {0}", temp ); - FileInfo^ file = gcnew FileInfo( temp->ToString() ); - - // Get the current size of the event log file. - if ( file->Exists ) - { - sizeKB = file->Length / 1024; - if ( (file->Length % 1024) != 0 ) - { - sizeKB++; - } - Console::WriteLine( " Current size = \t {0} kilobytes", sizeKB ); - } - } - else - { - Console::WriteLine( " Log file path = \t " ); - } - } - - // Display the maximum size and overflow settings. - sizeKB = e->MaximumKilobytes; - Console::WriteLine( " Maximum size = \t {0} kilobytes", sizeKB ); - Console::WriteLine( " Overflow setting = \t {0}", e->OverflowAction ); - switch ( e->OverflowAction ) - { - case OverflowAction::OverwriteOlder: - Console::WriteLine( "\t Entries are retained a minimum of {0} days.", e->MinimumRetentionDays ); - break; - - case OverflowAction::DoNotOverwrite: - Console::WriteLine( "\t Older entries are not overwritten." ); - break; - - case OverflowAction::OverwriteAsNeeded: - Console::WriteLine( "\t If number of entries equals max size limit, a new event log entry overwrites the oldest entry." ); - break; - - default: - break; - } - } -} - - -// -// -// Display the current event log overflow settings, and -// prompt the user to input a new overflow setting. -void ChangeEventLogOverflowAction( String^ logName ) -{ - if ( EventLog::Exists( logName ) ) - { - - // Display the current overflow setting of the - // specified event log. - EventLog^ inputLog = gcnew EventLog( logName ); - Console::WriteLine( " Event log {0}", inputLog->Log ); - OverflowAction logOverflow = inputLog->OverflowAction; - Int32 numDays = inputLog->MinimumRetentionDays; - Console::WriteLine( " Current overflow setting = {0}", logOverflow ); - if ( logOverflow == OverflowAction::OverwriteOlder ) - { - Console::WriteLine( "\t Entries are retained a minimum of {0} days.", numDays ); - } - - // Prompt user for a new overflow setting. - GetNewOverflowSetting( &logOverflow, &numDays ); - - // Change the overflow setting on the event log. - if ( logOverflow != inputLog->OverflowAction ) - { - inputLog->ModifyOverflowPolicy( logOverflow, numDays ); - Console::WriteLine( "Event log overflow policy was modified successfully!" ); - } - else - { - Console::WriteLine( "Event log overflow policy was not modified." ); - } - } - else - { - Console::WriteLine( "Event log {0} was not found.", logName ); - } -} - -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/CPP/source.cpp deleted file mode 100644 index f61b7647435..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/CPP/source.cpp +++ /dev/null @@ -1,137 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Globalization; -using namespace System::Diagnostics; - -[STAThread] -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // - EventSourceCreationData ^ mySourceData = gcnew EventSourceCreationData( "","" ); - bool registerSource = true; - - // Process input parameters. - if ( args->Length > 1 ) - { - - // Require at least the source name. - mySourceData->Source = args[ 1 ]; - if ( args->Length > 2 ) - { - mySourceData->LogName = args[ 2 ]; - } - - if ( args->Length > 3 ) - { - mySourceData->MachineName = args[ 3 ]; - } - - if ( (args->Length > 4) && (args[ 4 ]->Length > 0) ) - { - mySourceData->MessageResourceFile = args[ 4 ]; - } - } - else - { - - // Display a syntax help message. - Console::WriteLine( "Input:" ); - Console::WriteLine( " source [event log] [machine name] [resource file]" ); - registerSource = false; - } - - - // Set defaults for parameters missing input. - if ( mySourceData->MachineName->Length == 0 ) - { - - // Default to the local computer. - mySourceData->MachineName = "."; - } - - if ( mySourceData->LogName->Length == 0 ) - { - - // Default to the Application log. - mySourceData->LogName = "Application"; - } - - - // - // Determine if the source exists on the specified computer. - if ( !EventLog::SourceExists( mySourceData->Source, mySourceData->MachineName ) ) - { - - // The source does not exist. - // Verify that the message file exists - // and the event log is local. - if ( (mySourceData->MessageResourceFile != nullptr) && (mySourceData->MessageResourceFile->Length > 0) ) - { - if ( mySourceData->MachineName->Equals( "." ) ) - { - if ( !System::IO::File::Exists( mySourceData->MessageResourceFile ) ) - { - Console::WriteLine( "File {0} not found - message file not set for source.", mySourceData->MessageResourceFile ); - registerSource = false; - } - } - else - { - - // For simplicity, do not allow setting the message - // file for a remote event log. To set the message - // for a remote event log, and for source registration, - // the file path should be specified with system-wide - // environment variables that are valid on the remote - // computer, such as - // "%SystemRoot%\system32\myresource.dll". - Console::WriteLine( "Message resource file ignored for remote event log." ); - registerSource = false; - } - } - } - else - { - - // Do not register the source, it already exists. - registerSource = false; - - // Get the event log corresponding to the existing source. - String^ sourceLog; - sourceLog = EventLog::LogNameFromSourceName( mySourceData->Source, mySourceData->MachineName ); - - // Determine if the event source is registered for the - // specified log. - if ( sourceLog->ToUpper( CultureInfo::InvariantCulture ) != mySourceData->LogName->ToUpper( CultureInfo::InvariantCulture ) ) - { - - // An existing source is registered - // to write to a different event log. - Console::WriteLine( "Warning: source {0} is already registered to write to event log {1}", mySourceData->Source, sourceLog ); - } - else - { - - // The source is already registered - // to write to the specified event log. - Console::WriteLine( "Source {0} already registered to write to event log {1}", mySourceData->Source, sourceLog ); - } - } - - if ( registerSource ) - { - - // Register the new event source for the specified event log. - Console::WriteLine( "Registering new source {0} for event log {1}.", mySourceData->Source, mySourceData->LogName ); - EventLog::CreateEventSource( mySourceData ); - Console::WriteLine( "Event source was registered successfully!" ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/EventLog_Exists_1/CPP/eventlog_exists_1.cpp b/snippets/cpp/VS_Snippets_CLR/EventLog_Exists_1/CPP/eventlog_exists_1.cpp deleted file mode 100644 index 07109b189ca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLog_Exists_1/CPP/eventlog_exists_1.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// System::Diagnostics::EventLog::Exists(String) -/* -The following sample demonstrates the 'Exists(String)'method of -'EventLog' class. It checks for the existence of a log and displays -the result accordingly. -*/ -#using - -using namespace System; -using namespace System::Diagnostics; -void main() -{ - try - { - - // - String^ myLog = "myNewLog"; - if ( EventLog::Exists( myLog ) ) - { - Console::WriteLine( "Log '{0}' exists.", myLog ); - } - else - { - Console::WriteLine( "Log '{0}' does not exist.", myLog ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_1_3/CPP/eventlog_writeentry_1_3.cpp b/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_1_3/CPP/eventlog_writeentry_1_3.cpp deleted file mode 100644 index 663444e9b51..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_1_3/CPP/eventlog_writeentry_1_3.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System::Diagnostics::EventLog::WriteEntry(String, String, EventLogEntryType, Int32, Int16) -// System::Diagnostics::EventLog::WriteEntry(String, String, EventLogEntryType, Int32, Int16, Byte->Item[]) -// System::Diagnostics::EventLog::EventLog.WriteEntry(String, EventLogEntryType, Int32, Int16) - -/* The following example demonstrates the method -'WriteEntry(String, String, EventLogEntryType, Int32, Int16)', -'WriteEntry(String, String, EventLogEntryType, Int32, Int16, Byte->Item[]) ' -and 'WriteEntry(String, EventLogEntryType, Int32, Int16)' of class -'EventLog'. The following example writes the information to an event log. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -int main() -{ - // - int myEventID = 20; - short myCategory = 10; - - // Write an informational entry to the event log. - Console::WriteLine( "Write from first source " ); - EventLog::WriteEntry( "FirstSource", "Writing warning to event log.", - EventLogEntryType::Information, myEventID, myCategory ); - // - - // - //Create a byte array for binary data to associate with the entry. - array^myByte = gcnew array(10); - //Populate the byte array with simulated data. - for ( int i = 0; i < 10; i++ ) - { - myByte[ i ] = (Byte)(i % 2); - } - //Write an entry to the event log that includes associated binary data. - Console::WriteLine( "Write from second source " ); - EventLog::WriteEntry( "SecondSource", "Writing warning to event log.", - EventLogEntryType::Error, myEventID, myCategory, myByte ); - // - - // - // Create an EventLog instance and assign its source. - EventLog^ myLog = gcnew EventLog; - myLog->Source = "ThirdSource"; - - // Write an informational entry to the event log. - Console::WriteLine( "Write from third source " ); - myLog->WriteEntry( "Writing warning to event log.", - EventLogEntryType::Warning, myEventID, myCategory ); - // -} diff --git a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_4/CPP/eventlog_writeentry_4.cpp b/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_4/CPP/eventlog_writeentry_4.cpp deleted file mode 100644 index 5d40a7c71c9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_4/CPP/eventlog_writeentry_4.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// System::Diagnostics::EventLog::WriteEntry(String,String,EventLogEntryType,Int32) - -/* -The following sample demonstrates the -'WriteEntry(String,String,EventLogEntryType,Int32)' method of -'EventLog' class. It writes an entry to a custom event log, S"MyNewLog". -It creates the source S"MySource" if the source does not already exist. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -int main() -{ - try - { -// - // Create the source, if it does not already exist. - if ( !EventLog::SourceExists( "MySource" ) ) - { - EventLog::CreateEventSource( "MySource", "myNewLog" ); - Console::WriteLine( "Creating EventSource" ); - } - - // Set the 'description' for the event. - String^ myMessage = "This is my event."; - EventLogEntryType myEventLogEntryType = EventLogEntryType::Warning; - int myApplicationEventId = 100; - - // Write the entry in the event log. - Console::WriteLine( "Writing to EventLog.. " ); - EventLog::WriteEntry( "MySource", myMessage, - myEventLogEntryType, myApplicationEventId ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception:{0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_5/CPP/eventlog_writeentry_5.cpp b/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_5/CPP/eventlog_writeentry_5.cpp deleted file mode 100644 index 4771b4f0eb5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_5/CPP/eventlog_writeentry_5.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// System::Diagnostics::EventLog::WriteEntry(String, EventLogEntryType, Int32, Int16, Byte[]) - -/* -The following sample demonstrates the -'WriteEntry(String, EventLogEntryType, Int32, Int16, Byte->Item[])' method of -'EventLog' class. It writes an entry to a custom event log, S"MyLog". -It creates the source S"MySource" if the source does not already exist. -It creates an 'EventLog' Object* and calls 'WriteEntry' passing the -description, Log entry type, application specific identifier for the event, -application specific subcategory and data to be associated with the entry. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -int main() -{ - try - { -// - // Create the source, if it does not already exist. - String^ myLogName = "myNewLog"; - if ( !EventLog::SourceExists( "MySource" ) ) - { - EventLog::CreateEventSource( "MySource", myLogName ); - Console::WriteLine( "Creating EventSource" ); - } - else - myLogName = EventLog::LogNameFromSourceName( "MySource", "." ); - - // Create an EventLog and assign source. - EventLog^ myEventLog = gcnew EventLog; - myEventLog->Source = "MySource"; - myEventLog->Log = myLogName; - - // Set the 'description' for the event. - String^ myMessage = "This is my event."; - EventLogEntryType myEventLogEntryType = EventLogEntryType::Warning; - int myApplicatinEventId = 1100; - short myApplicatinCategoryId = 1; - - // Set the 'data' for the event. - array^ myRawData = gcnew array(4); - for ( int i = 0; i < 4; i++ ) - { - myRawData[ i ] = 1; - } - Console::WriteLine( "Writing to EventLog.. " ); - myEventLog->WriteEntry( myMessage, myEventLogEntryType, myApplicatinEventId, myApplicatinCategoryId, myRawData ); -// - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception:{0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo AppendText/CPP/finfo appendtext.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo AppendText/CPP/finfo appendtext.cpp deleted file mode 100644 index f18b6e52fe0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo AppendText/CPP/finfo appendtext.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - FileInfo^ fi = gcnew FileInfo( "c:\\MyTest.txt" ); - - // This text is added only once to the file. - if ( !fi->Exists ) - { - //Create a file to write to. - StreamWriter^ sw = fi->CreateText(); - try - { - sw->WriteLine( "Hello" ); - sw->WriteLine( "And" ); - sw->WriteLine( "Welcome" ); - } - finally - { - if ( sw ) - delete (IDisposable^)sw; - } - } - - // This text will always be added, making the file longer over time - // if it is not deleted. - StreamWriter^ sw = fi->AppendText(); - try - { - sw->WriteLine( "This" ); - sw->WriteLine( "is Extra" ); - sw->WriteLine( "Text" ); - } - finally - { - if ( sw ) - delete (IDisposable^)sw; - } - - //Open the file to read from. - StreamReader^ sr = fi->OpenText(); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//Hello -//And -//Welcome -//This -//is Extra -//Text -// -//When you run this application a second time, you will see the following output: -// -//Hello -//And -//Welcome -//This -//is Extra -//Text -//This -//is Extra -//Text -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Class/CPP/finfo class.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Class/CPP/finfo class.cpp deleted file mode 100644 index cd1f26bb6ef..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo Class/CPP/finfo class.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ path = Path::GetTempFileName(); - FileInfo^ fi1 = gcnew FileInfo( path ); - //Create a file to write to. - StreamWriter^ sw = fi1->CreateText(); - try - { - sw->WriteLine( "Hello" ); - sw->WriteLine( "And" ); - sw->WriteLine( "Welcome" ); - } - finally - { - if ( sw ) - delete (IDisposable^)sw; - } - - //Open the file to read from. - StreamReader^ sr = fi1->OpenText(); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } - - try - { - String^ path2 = Path::GetTempFileName(); - FileInfo^ fi2 = gcnew FileInfo( path2 ); - - //Ensure that the target does not exist. - fi2->Delete(); - - //Copy the file. - fi1->CopyTo( path2 ); - Console::WriteLine( "{0} was copied to {1}.", path, path2 ); - - //Delete the newly created file. - fi2->Delete(); - Console::WriteLine( "{0} was successfully deleted.", path2 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo CopyTo2/CPP/finfo copyto2.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo CopyTo2/CPP/finfo copyto2.cpp deleted file mode 100644 index 457a43483a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo CopyTo2/CPP/finfo copyto2.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ path = "c:\\MyTest.txt"; - String^ path2 = "c:\\MyTest.txttemp"; - FileInfo^ fi1 = gcnew FileInfo( path ); - FileInfo^ fi2 = gcnew FileInfo( path2 ); - try - { - // Create the file and clean up handles. - FileStream^ fs = fi1->Create(); - if ( fs ) - delete (IDisposable^)fs; - - //Ensure that the target does not exist. - fi2->Delete(); - - //Copy the file. - fi1->CopyTo( path2 ); - Console::WriteLine( "{0} was copied to {1}.", path, path2 ); - - //Try to copy it again, which should succeed. - fi1->CopyTo( path2, true ); - Console::WriteLine( "The second Copy operation succeeded, which is expected." ); - } - catch ( Exception^ ) - { - Console::WriteLine( "Double copying was not allowed, which is not expected." ); - } -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//The second Copy operation succeeded, which is expected. -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Create/CPP/finfo create.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Create/CPP/finfo create.cpp deleted file mode 100644 index 8533b4ee458..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo Create/CPP/finfo create.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\MyTest.txt"; - FileInfo^ fi = gcnew FileInfo( path ); - - // Delete the file if it exists. - if ( fi->Exists ) - { - fi->Delete(); - } - - //Create the file. - FileStream^ fs = fi->Create(); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - //Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - - //Open the stream and read it back. - StreamReader^ sr = fi->OpenText(); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } -} - -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//This is some text in the file. -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo CreateText/CPP/finfo createtext.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo CreateText/CPP/finfo createtext.cpp deleted file mode 100644 index eecfff022ed..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo CreateText/CPP/finfo createtext.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ path = "c:\\MyTest.txt"; - FileInfo^ fi = gcnew FileInfo( path ); - if ( !fi->Exists ) - { - //Create a file to write to. - StreamWriter^ sw = fi->CreateText(); - try - { - sw->WriteLine( "Hello" ); - sw->WriteLine( "And" ); - sw->WriteLine( "Welcome" ); - } - finally - { - if ( sw ) - delete (IDisposable^)sw; - } - } - - //Open the file to read from. - StreamReader^ sr = fi->OpenText(); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//Hello -//And -//Welcome -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Ctor/CPP/finfo ctor.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Ctor/CPP/finfo ctor.cpp deleted file mode 100644 index d0901ff161a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo Ctor/CPP/finfo ctor.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ path = "c:\\MyTest.txt"; - FileInfo^ fi1 = gcnew FileInfo( path ); - if ( !fi1->Exists ) - { - //Create a file to write to. - StreamWriter^ sw = fi1->CreateText(); - try - { - sw->WriteLine( "Hello" ); - sw->WriteLine( "And" ); - sw->WriteLine( "Welcome" ); - } - finally - { - if ( sw ) - delete (IDisposable^)sw; - } - } - - //Open the file to read from. - StreamReader^ sr = fi1->OpenText(); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } - - try - { - String^ path2 = String::Concat( path, "temp" ); - FileInfo^ fi2 = gcnew FileInfo( path2 ); - - //Ensure that the target does not exist. - fi2->Delete(); - - //Copy the file. - fi1->CopyTo( path2 ); - Console::WriteLine( "{0} was copied to {1}.", path, path2 ); - - //Delete the newly created file. - fi2->Delete(); - Console::WriteLine( "{0} was successfully deleted.", path2 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} - -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//Hello -//And -//Welcome -//c:\MyTest.txt was copied to c:\MyTest.txttemp. -//c:\MyTest.txttemp was successfully deleted. -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Delete/CPP/finfo delete.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Delete/CPP/finfo delete.cpp deleted file mode 100644 index c219e088f8c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo Delete/CPP/finfo delete.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ path = "c:\\MyTest.txt"; - FileInfo^ fi1 = gcnew FileInfo( path ); - try - { - StreamWriter^ sw = fi1->CreateText(); - if ( sw ) - delete (IDisposable^)sw; - - String^ path2 = String::Concat( path, "temp" ); - FileInfo^ fi2 = gcnew FileInfo( path2 ); - - //Ensure that the target does not exist. - fi2->Delete(); - - //Copy the file. - fi1->CopyTo( path2 ); - Console::WriteLine( "{0} was copied to {1}.", path, path2 ); - - //Delete the newly created file. - fi2->Delete(); - Console::WriteLine( "{0} was successfully deleted.", path2 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//c:\MyTest.txt was copied to c:\MyTest.txttemp. -//c:\MyTest.txttemp was successfully deleted. -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Open1/CPP/finfo open1.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Open1/CPP/finfo open1.cpp deleted file mode 100644 index 052607a8faf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo Open1/CPP/finfo open1.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\MyTest.txt"; - FileInfo^ fi = gcnew FileInfo( path ); - - // Delete the file if it exists. - if ( !fi->Exists ) - { - //Create the file. - FileStream^ fs = fi->Create(); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - //Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } - - //Open the stream and read it back. - FileStream^ fs = fi->Open( FileMode::Open ); - try - { - array^b = gcnew array(1024); - UTF8Encoding^ temp = gcnew UTF8Encoding( true ); - while ( fs->Read( b, 0, b->Length ) > 0 ) - { - Console::WriteLine( temp->GetString( b ) ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } -} - -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//This is some text in the file. -// -// -// -// -// -// -// -// -// -// -// -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo Open2/CPP/finfo open2.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo Open2/CPP/finfo open2.cpp deleted file mode 100644 index 7996e15f1cf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo Open2/CPP/finfo open2.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\MyTest.txt"; - FileInfo^ fi = gcnew FileInfo( path ); - - // Delete the file if it exists. - if ( !fi->Exists ) - { - - //Create the file. - FileStream^ fs = fi->Create(); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - //Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } - - //Open the stream and read it back. - FileStream^ fs = fi->Open( FileMode::Open, FileAccess::Read ); - try - { - array^b = gcnew array(1024); - UTF8Encoding^ temp = gcnew UTF8Encoding( true ); - while ( fs->Read( b, 0, b->Length ) > 0 ) - { - Console::WriteLine( temp->GetString( b ) ); - } - try - { - //Try to write to the file. - fs->Write( b, 0, b->Length ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Writing was disallowed, as expected: {0}", e ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//This is some text in the file. -// -// -// -// -// -// -// -// -// -// -// -// -//Writing was disallowed, as expected: System.NotSupportedException: Stream does -//not support writing. -// at System.IO.__Error.WriteNotSupported() -// at System.IO.FileStream.Write(Byte[] array, Int32 offset, Int32 count) -// at main() in c:\documents and settings\MyComputer\my documents\ -//visual studio 2005\projects\finfo open2\finfo open2\ -//cpp_console_application.cpp:line 46 -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo OpenRead/CPP/finfo openread.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo OpenRead/CPP/finfo openread.cpp deleted file mode 100644 index f81348f3afa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo OpenRead/CPP/finfo openread.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\MyTest.txt"; - FileInfo^ fi = gcnew FileInfo( path ); - - // Delete the file if it exists. - if ( !fi->Exists ) - { - //Create the file. - FileStream^ fs = fi->Create(); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - //Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } - - //Open the stream and read it back. - FileStream^ fs = fi->OpenRead(); - try - { - array^b = gcnew array(1024); - UTF8Encoding^ temp = gcnew UTF8Encoding( true ); - while ( fs->Read( b, 0, b->Length ) > 0 ) - { - Console::WriteLine( temp->GetString( b ) ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//This is some text in the file. -// -// -// -// -// -// -// -// -// -// -// -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo OpenText/CPP/file opentext.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo OpenText/CPP/file opentext.cpp deleted file mode 100644 index 3868e7e68fb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo OpenText/CPP/file opentext.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -public ref class OpenTextTest -{ -public: - static void Main() - { - String^ path = "c:\\MyTest.txt"; - - FileInfo^ fi = gcnew FileInfo(path); - - // Check for existing file - if (!fi->Exists) - { - // Create the file. - FileStream^ fs = fi->Create(); - array^ info = - (gcnew UTF8Encoding(true))->GetBytes("This is some text in the file."); - - // Add some information to the file. - fs->Write(info, 0, info->Length); - fs->Close(); - } - - // Open the stream and read it back. - StreamReader^ sr = fi->OpenText(); - String^ s = ""; - while ((s = sr->ReadLine()) != nullptr) - { - Console::WriteLine(s); - } - } -}; - -int main() -{ - OpenTextTest::Main(); -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//This is some text in the file. -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/FInfo OpenWrite/CPP/file openwrite.cpp b/snippets/cpp/VS_Snippets_CLR/FInfo OpenWrite/CPP/file openwrite.cpp deleted file mode 100644 index e4a0ca98bdb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FInfo OpenWrite/CPP/file openwrite.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\Temp\\MyTest.txt"; - FileInfo^ fi = gcnew FileInfo( path ); - - // Open the stream for writing. - { - FileStream^ fs = fi->OpenWrite(); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is to test the OpenWrite method." ); - - // Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } - - // Open the stream and read it back. - { - FileStream^ fs = fi->OpenRead(); - try - { - array^b = gcnew array(1024); - UTF8Encoding^ temp = gcnew UTF8Encoding( true ); - while ( fs->Read( b, 0, b->Length ) > 0 ) - { - Console::WriteLine( temp->GetString( b ) ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//This is to test the OpenWrite method. -// -// -// -// -// -// -// -// -// -// -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/FStream CanSeek/CPP/fstream canseek.cpp b/snippets/cpp/VS_Snippets_CLR/FStream CanSeek/CPP/fstream canseek.cpp deleted file mode 100644 index e79c45b3672..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FStream CanSeek/CPP/fstream canseek.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - // Delete the file if it exists. - if ( File::Exists( path ) ) - { - File::Delete( path ); - } - - //Create the file. - FileStream^ fs = File::Create( path ); - try - { - if ( fs->CanSeek ) - { - Console::WriteLine( "The stream connected to {0} is seekable.", path ); - } - else - { - Console::WriteLine( "The stream connected to {0} is not seekable.", path ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FStream CanWrite/CPP/fstream canwrite.cpp b/snippets/cpp/VS_Snippets_CLR/FStream CanWrite/CPP/fstream canwrite.cpp deleted file mode 100644 index 7dd44acda66..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FStream CanWrite/CPP/fstream canwrite.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - // Ensure that the file is readonly. - File::SetAttributes( path, static_cast(File::GetAttributes( path ) | FileAttributes::ReadOnly) ); - - //Create the file. - FileStream^ fs = gcnew FileStream( path,FileMode::OpenOrCreate,FileAccess::Read ); - try - { - if ( fs->CanWrite ) - { - Console::WriteLine( "The stream for file {0} is writable.", path ); - } - else - { - Console::WriteLine( "The stream for file {0} is not writable.", path ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/FStream Class/CPP/fstream class.cpp b/snippets/cpp/VS_Snippets_CLR/FStream Class/CPP/fstream class.cpp deleted file mode 100644 index cc2e6916562..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FStream Class/CPP/fstream class.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -void AddText( FileStream^ fs, String^ value ) -{ - array^info = (gcnew UTF8Encoding( true ))->GetBytes( value ); - fs->Write( info, 0, info->Length ); -} - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - // Delete the file if it exists. - if ( File::Exists( path ) ) - { - File::Delete( path ); - } - - //Create the file. - { - FileStream^ fs = File::Create( path ); - try - { - AddText( fs, "This is some text" ); - AddText( fs, "This is some more text," ); - AddText( fs, "\r\nand this is on a new line" ); - AddText( fs, "\r\n\r\nThe following is a subset of characters:\r\n" ); - for ( int i = 1; i < 120; i++ ) - { - AddText( fs, Convert::ToChar( i ).ToString() ); - - //Split the output at every 10th character. - if ( Math::IEEERemainder( Convert::ToDouble( i ), 10 ) == 0 ) - { - AddText( fs, "\r\n" ); - } - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } - - //Open the stream and read it back. - { - FileStream^ fs = File::OpenRead( path ); - try - { - array^b = gcnew array(1024); - UTF8Encoding^ temp = gcnew UTF8Encoding( true ); - while ( fs->Read( b, 0, b->Length ) > 0 ) - { - Console::WriteLine( temp->GetString( b ) ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File Class Example/CPP/file class example.cpp b/snippets/cpp/VS_Snippets_CLR/File Class Example/CPP/file class example.cpp deleted file mode 100644 index 1f0ebf4662f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File Class Example/CPP/file class example.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -using namespace System; -using namespace System::IO; -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - if ( !File::Exists( path ) ) - { - - // Create a file to write to. - StreamWriter^ sw = File::CreateText( path ); - try - { - sw->WriteLine( "Hello" ); - sw->WriteLine( "And" ); - sw->WriteLine( "Welcome" ); - } - finally - { - if ( sw ) - delete (IDisposable^)(sw); - } - } - - // Open the file to read from. - StreamReader^ sr = File::OpenText( path ); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)(sr); - } - - try - { - String^ path2 = String::Concat( path, "temp" ); - - // Ensure that the target does not exist. - File::Delete( path2 ); - - // Copy the file. - File::Copy( path, path2 ); - Console::WriteLine( "{0} was copied to {1}.", path, path2 ); - - // Delete the newly created file. - File::Delete( path2 ); - Console::WriteLine( "{0} was successfully deleted.", path2 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File Create1/CPP/file create1.cpp b/snippets/cpp/VS_Snippets_CLR/File Create1/CPP/file create1.cpp deleted file mode 100644 index 9c511bd99e5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File Create1/CPP/file create1.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - // Create the file, or overwrite if the file exists. - FileStream^ fs = File::Create( path ); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - // Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - - // Open the stream and read it back. - StreamReader^ sr = File::OpenText( path ); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File Create2/CPP/file create2.cpp b/snippets/cpp/VS_Snippets_CLR/File Create2/CPP/file create2.cpp deleted file mode 100644 index e79d7bdd9ac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File Create2/CPP/file create2.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - // Create the file, or overwrite if the file exists. - FileStream^ fs = File::Create( path, 1024 ); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - // Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - - // Open the stream and read it back. - StreamReader^ sr = File::OpenText( path ); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File CreateText/CPP/file createtext.cpp b/snippets/cpp/VS_Snippets_CLR/File CreateText/CPP/file createtext.cpp deleted file mode 100644 index e93de3ce721..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File CreateText/CPP/file createtext.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -using namespace System; -using namespace System::IO; -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - if ( !File::Exists( path ) ) - { - - // Create a file to write to. - StreamWriter^ sw = File::CreateText( path ); - try - { - sw->WriteLine( "Hello" ); - sw->WriteLine( "And" ); - sw->WriteLine( "Welcome" ); - } - finally - { - if ( sw ) - delete (IDisposable^)sw; - } - } - - // Open the file to read from. - StreamReader^ sr = File::OpenText( path ); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File GetAttributes/CPP/file getattributes.cpp b/snippets/cpp/VS_Snippets_CLR/File GetAttributes/CPP/file getattributes.cpp deleted file mode 100644 index 502539dd149..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File GetAttributes/CPP/file getattributes.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Text; -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - // Create the file if it does not exist. - if ( !File::Exists( path ) ) - { - File::Create( path ); - } - - if ( (File::GetAttributes( path ) & FileAttributes::Hidden) == FileAttributes::Hidden ) - { - - // Show the file. - File::SetAttributes(path, File::GetAttributes( path ) & ~FileAttributes::Hidden); - Console::WriteLine( "The {0} file is no longer hidden.", path ); - } - else - { - - // Hide the file. - File::SetAttributes( path, static_cast(File::GetAttributes( path ) | FileAttributes::Hidden) ); - Console::WriteLine( "The {0} file is now hidden.", path ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/File GetLastAccess/CPP/file getlastaccess.cpp b/snippets/cpp/VS_Snippets_CLR/File GetLastAccess/CPP/file getlastaccess.cpp deleted file mode 100644 index 80e27831de7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File GetLastAccess/CPP/file getlastaccess.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - String^ path = "c:\\Temp\\MyTest.txt"; - if ( !File::Exists( path ) ) - { - File::Create( path ); - } - File::SetLastAccessTime( path, DateTime(1985,5,4) ); - - // Get the creation time of a well-known directory. - DateTime dt = File::GetLastAccessTime( path ); - Console::WriteLine( "The last access time for this file was {0}.", dt ); - - // Update the last access time. - File::SetLastAccessTime( path, DateTime::Now ); - dt = File::GetLastAccessTime( path ); - Console::WriteLine( "The last access time for this file was {0}.", dt ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/File GetLastWrite/CPP/file getlastwrite.cpp b/snippets/cpp/VS_Snippets_CLR/File GetLastWrite/CPP/file getlastwrite.cpp deleted file mode 100644 index 8b796882ead..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File GetLastWrite/CPP/file getlastwrite.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - String^ path = "c:\\Temp\\MyTest.txt"; - if ( !File::Exists( path ) ) - { - File::Create( path ); - } - else - { - - // Take an action that will affect the write time. - File::SetLastWriteTime( path, DateTime(1985,4,3) ); - } - - // Get the creation time of a well-known directory. - DateTime dt = File::GetLastWriteTime( path ); - Console::WriteLine( "The last write time for this file was {0}.", dt ); - - // Update the last write time. - File::SetLastWriteTime( path, DateTime::Now ); - dt = File::GetLastWriteTime( path ); - Console::WriteLine( "The last write time for this file was {0}.", dt ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/File Move/CPP/file move.cpp b/snippets/cpp/VS_Snippets_CLR/File Move/CPP/file move.cpp deleted file mode 100644 index 38bf0f2cab3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File Move/CPP/file move.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - String^ path2 = "c:\\temp2\\MyTest.txt"; - try - { - if ( !File::Exists( path ) ) - { - - // This statement ensures that the file is created, - // but the handle is not kept. - FileStream^ fs = File::Create( path ); - if ( fs ) - delete (IDisposable^)fs; - } - - // Ensure that the target does not exist. - if ( File::Exists( path2 ) ) - File::Delete( path2 ); - - // Move the file. - File::Move( path, path2 ); - Console::WriteLine( "{0} was moved to {1}.", path, path2 ); - - // See if the original exists now. - if ( File::Exists( path ) ) - { - Console::WriteLine( "The original file still exists, which is unexpected." ); - } - else - { - Console::WriteLine( "The original file no longer exists, which is expected." ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File Open1/CPP/file open1.cpp b/snippets/cpp/VS_Snippets_CLR/File Open1/CPP/file open1.cpp deleted file mode 100644 index 1378629c6eb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File Open1/CPP/file open1.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - // Create a temporary file, and put some data into it. - String^ path = Path::GetTempFileName(); - FileStream^ fs = File::Open( path, FileMode::Open, FileAccess::Write, FileShare::None ); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - // Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - - // Open the stream and read it back. - fs = File::Open( path, FileMode::Open ); - try - { - array^b = gcnew array(1024); - UTF8Encoding^ temp = gcnew UTF8Encoding( true ); - while ( fs->Read( b, 0, b->Length ) > 0 ) - { - Console::WriteLine( temp->GetString( b ) ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File Open2/CPP/file open2.cpp b/snippets/cpp/VS_Snippets_CLR/File Open2/CPP/file open2.cpp deleted file mode 100644 index 09b89e18c7e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File Open2/CPP/file open2.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// - -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - // This sample assumes that you have a folder named "c:\temp" on your computer. - String^ filePath = "c:\\temp\\MyTest.txt"; - // Delete the file if it exists. - if (File::Exists( filePath )) - { - File::Delete( filePath ); - } - // Create the file. - FileStream^ fs = File::Create( filePath ); - try - { - array^ info = ( gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - // Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - - // Open the stream and read it back. - fs = File::Open( filePath, FileMode::Open, FileAccess::Read ); - try - { - array^ b = gcnew array(1024); - UTF8Encoding^ temp = gcnew UTF8Encoding( true ); - while ( fs->Read( b, 0, b->Length ) > 0 ) - { - Console::WriteLine( temp->GetString( b ) ); - } - try - { - // Try to write to the file. - fs->Write( b, 0, b->Length ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Writing was disallowed, as expected: {0}", e->ToString() ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File Open3/CPP/file open3.cpp b/snippets/cpp/VS_Snippets_CLR/File Open3/CPP/file open3.cpp deleted file mode 100644 index c8b21c2f7d7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File Open3/CPP/file open3.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - // Create the file if it does not exist. - if ( !File::Exists( path ) ) - { - // Create the file. - FileStream^ fs = File::Create( path ); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - // Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } - - // Open the stream and read it back. - FileStream^ fs = File::Open( path, FileMode::Open, FileAccess::Read, FileShare::None ); - try - { - array^b = gcnew array(1024); - UTF8Encoding^ temp = gcnew UTF8Encoding( true ); - while ( fs->Read( b, 0, b->Length ) > 0 ) - { - Console::WriteLine( temp->GetString( b ) ); - } - try - { - // Try to get another handle to the same file. - FileStream^ fs2 = File::Open( path, FileMode::Open ); - try - { - // Do some task here. - } - finally - { - if ( fs2 ) - delete (IDisposable^)fs2; - } - } - catch ( Exception^ e ) - { - Console::Write( "Opening the file twice is disallowed." ); - Console::WriteLine( ", as expected: {0}", e ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File OpenRead/CPP/file openread.cpp b/snippets/cpp/VS_Snippets_CLR/File OpenRead/CPP/file openread.cpp deleted file mode 100644 index d257fe26072..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File OpenRead/CPP/file openread.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - if ( !File::Exists( path ) ) - { - // Create the file. - FileStream^ fs = File::Create( path ); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - // Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } - - // Open the stream and read it back. - FileStream^ fs = File::OpenRead( path ); - try - { - array^b = gcnew array(1024); - UTF8Encoding^ temp = gcnew UTF8Encoding( true ); - while ( fs->Read( b, 0, b->Length ) > 0 ) - { - Console::WriteLine( temp->GetString( b ) ); - } - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File OpenText/CPP/file opentext.cpp b/snippets/cpp/VS_Snippets_CLR/File OpenText/CPP/file opentext.cpp deleted file mode 100644 index 8bbd948b4c6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File OpenText/CPP/file opentext.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - if ( !File::Exists( path ) ) - { - // Create the file. - FileStream^ fs = File::Create( path ); - try - { - array^info = (gcnew UTF8Encoding( true ))->GetBytes( "This is some text in the file." ); - - // Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } - - // Open the stream and read it back. - StreamReader^ sr = File::OpenText( path ); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File OpenWrite/CPP/file openwrite.cpp b/snippets/cpp/VS_Snippets_CLR/File OpenWrite/CPP/file openwrite.cpp deleted file mode 100644 index e08318b7bf6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File OpenWrite/CPP/file openwrite.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - // Open the stream and write to it. - { - FileStream^ fs = File::OpenWrite( path ); - try - { - array^info = (gcnew UTF8Encoding( true ))-> - GetBytes( "This is to test the OpenWrite method." ); - - // Add some information to the file. - fs->Write( info, 0, info->Length ); - } - finally - { - if ( fs ) - delete (IDisposable^)fs; - } - } - - // Open the stream and read it back. - { - FileStream^ fs = File::OpenRead( path ); - try - { - array^b = gcnew array(1024); - UTF8Encoding^ temp = gcnew UTF8Encoding( true ); - while ( fs->Read( b, 0, b->Length ) > 0 ) - { - Console::WriteLine( temp->GetString( b ) ); - } - } - finally - { - if ( fs ) - delete(IDisposable^)fs; - } - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/File SetLastAccess/CPP/file setlastaccess.cpp b/snippets/cpp/VS_Snippets_CLR/File SetLastAccess/CPP/file setlastaccess.cpp deleted file mode 100644 index 3fe8c6832a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File SetLastAccess/CPP/file setlastaccess.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - String^ path = "c:\\Temp\\MyTest.txt"; - if ( !File::Exists( path ) ) - { - File::Create( path ); - - // Update the last access time. - } - File::SetLastAccessTime( path, DateTime(1985,5,4) ); - - // Get the creation time of a well-known directory. - DateTime dt = File::GetLastAccessTime( path ); - Console::WriteLine( "The last access time for this file was {0}.", dt ); - - // Update the last access time. - File::SetLastAccessTime( path, DateTime::Now ); - dt = File::GetLastAccessTime( path ); - Console::WriteLine( "The last access time for this file was {0}.", dt ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/File SetLastWrite/CPP/file setlastwrite.cpp b/snippets/cpp/VS_Snippets_CLR/File SetLastWrite/CPP/file setlastwrite.cpp deleted file mode 100644 index 8b796882ead..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File SetLastWrite/CPP/file setlastwrite.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - String^ path = "c:\\Temp\\MyTest.txt"; - if ( !File::Exists( path ) ) - { - File::Create( path ); - } - else - { - - // Take an action that will affect the write time. - File::SetLastWriteTime( path, DateTime(1985,4,3) ); - } - - // Get the creation time of a well-known directory. - DateTime dt = File::GetLastWriteTime( path ); - Console::WriteLine( "The last write time for this file was {0}.", dt ); - - // Update the last write time. - File::SetLastWriteTime( path, DateTime::Now ); - dt = File::GetLastWriteTime( path ); - Console::WriteLine( "The last write time for this file was {0}.", dt ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/FileInfoCopyTo1/CPP/fileinfocopyto1.cpp b/snippets/cpp/VS_Snippets_CLR/FileInfoCopyTo1/CPP/fileinfocopyto1.cpp deleted file mode 100644 index f16d9cbcb6e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FileInfoCopyTo1/CPP/fileinfocopyto1.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - - // Create a reference to a file, which might or might not exist. - // If it does not exist, it is not yet created. - FileInfo^ fi = gcnew FileInfo( "temp.txt" ); - - // Create a writer, ready to add entries to the file. - StreamWriter^ sw = fi->AppendText(); - sw->WriteLine( "Add as many lines as you like..." ); - sw->WriteLine( "Add another line to the output..." ); - sw->Flush(); - sw->Close(); - - // Get the information out of the file and display it. - StreamReader^ sr = gcnew StreamReader( fi->OpenRead() ); - Console::WriteLine( "This is the information in the first file:" ); - while ( sr->Peek() != -1 ) - Console::WriteLine( sr->ReadLine() ); - - // Copy this file to another file. The file will not be overwritten if it already exists. - FileInfo^ newfi = fi->CopyTo( "newTemp.txt" ); - - // Get the information out of the new file and display it.* sr = new StreamReader(newfi->OpenRead()); - Console::WriteLine( "{0}This is the information in the second file:", Environment::NewLine ); - while ( sr->Peek() != -1 ) - Console::WriteLine( sr->ReadLine() ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//This is the information in the first file: -//Add as many lines as you like... -//Add another line to the output... -// -//This is the information in the second file: - -// diff --git a/snippets/cpp/VS_Snippets_CLR/FileLength/CPP/filelength.cpp b/snippets/cpp/VS_Snippets_CLR/FileLength/CPP/filelength.cpp deleted file mode 100644 index 49b2ff55954..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FileLength/CPP/filelength.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// -// The following example displays the names and sizes -// of the files in the specified directory. -using namespace System; -using namespace System::IO; -int main() -{ - - // Make a reference to a directory. - DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\" ); - - // Get a reference to each file in that directory. - array^fiArr = di->GetFiles(); - - // Display the names and sizes of the files. - Console::WriteLine( "The directory {0} contains the following files:", di->Name ); - System::Collections::IEnumerator^ myEnum = fiArr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - FileInfo^ f = safe_cast(myEnum->Current); - Console::WriteLine( "The size of {0} is {1} bytes.", f->Name, f->Length ); - } -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//The directory c:\ contains the following files: -//The size of MyComputer.log is 274 bytes. -//The size of AUTOEXEC.BAT is 0 bytes. -//The size of boot.ini is 211 bytes. -//The size of CONFIG.SYS is 0 bytes. -//The size of hiberfil.sys is 1072775168 bytes. -//The size of IO.SYS is 0 bytes. -//The size of MASK.txt is 2700 bytes. -//The size of mfc80.dll is 1093632 bytes. -//The size of mfc80u.dll is 1079808 bytes. -//The size of MSDOS.SYS is 0 bytes. -//The size of NTDETECT.COM is 47564 bytes. -//The size of ntldr is 250032 bytes. -//The size of pagefile.sys is 1610612736 bytes. -//The size of UpdatePatch.log is 22778 bytes. -//The size of UpdatePatch.txt is 30 bytes. -//The size of wt3d.ini is 234 bytes. -// diff --git a/snippets/cpp/VS_Snippets_CLR/FileSystemInfo/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR/FileSystemInfo/cpp/program.cpp deleted file mode 100644 index c6df18efd4e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/FileSystemInfo/cpp/program.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -using namespace System; -using namespace System::IO; - - -namespace ConsoleApplication2 -{ - public ref class Program - { - public: - static void Main() - { - // Loop through all the immediate subdirectories of C. - for each (String^ entry in Directory::GetDirectories("C:\\")) - { - DisplayFileSystemInfoAttributes(gcnew DirectoryInfo(entry)); - } - // Loop through all the files in C. - for each (String^ entry in Directory::GetFiles("C:\\")) - { - DisplayFileSystemInfoAttributes(gcnew FileInfo(entry)); - } - } - // - static void DisplayFileSystemInfoAttributes(FileSystemInfo^ fsi) - { - // Assume that this entry is a file. - String^ entryType = "File"; - - // Determine if entry is really a directory - if ((fsi->Attributes & FileAttributes::Directory) == FileAttributes::Directory) - { - entryType = "Directory"; - } - // Show this entry's type, name, and creation date. - Console::WriteLine("{0} entry {1} was created on {2:D}", entryType, fsi->FullName, fsi->CreationTime); - } - // - }; -}; - -int main() -{ - ConsoleApplication2::Program::Main(); -} - - // Output will vary based on contents of drive C. - - // Directory entry C:\Documents and Settings was created on Tuesday, November 25, 2003 - // Directory entry C:\Inetpub was created on Monday, January 12, 2004 - // Directory entry C:\Program Files was created on Tuesday, November 25, 2003 - // Directory entry C:\RECYCLER was created on Tuesday, November 25, 2003 - // Directory entry C:\System Volume Information was created on Tuesday, November 2, 2003 - // Directory entry C:\WINDOWS was created on Tuesday, November 25, 2003 - // File entry C:\IO.SYS was created on Tuesday, November 25, 2003 - // File entry C:\MSDOS.SYS was created on Tuesday, November 25, 2003 - // File entry C:\pagefile.sys was created on Saturday, December 27, 2003 -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/File_AppendText/CPP/file_appendtext.cpp b/snippets/cpp/VS_Snippets_CLR/File_AppendText/CPP/file_appendtext.cpp deleted file mode 100644 index 33129302fbb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/File_AppendText/CPP/file_appendtext.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - - // This text is added only once to the file. - if ( !File::Exists( path ) ) - { - // Create a file to write to. - StreamWriter^ sw = File::CreateText( path ); - try - { - sw->WriteLine( "Hello" ); - sw->WriteLine( "And" ); - sw->WriteLine( "Welcome" ); - } - finally - { - if ( sw ) - delete (IDisposable^)sw; - } - } - - // This text is always added, making the file longer over time - // if it is not deleted. - StreamWriter^ sw = File::AppendText( path ); - try - { - sw->WriteLine( "This" ); - sw->WriteLine( "is Extra" ); - sw->WriteLine( "Text" ); - } - finally - { - if ( sw ) - delete (IDisposable^)sw; - } - - // Open the file to read from. - StreamReader^ sr = File::OpenText( path ); - try - { - String^ s = ""; - while ( s = sr->ReadLine() ) - { - Console::WriteLine( s ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp deleted file mode 100644 index 5c9e28f3fbd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp +++ /dev/null @@ -1,184 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -public ref class Example -{ -public: - static void Main() - { - // - // Create a new dictionary of strings, with string keys. - // - Dictionary^ openWith = - gcnew Dictionary(); - - // Add some elements to the dictionary. There are no - // duplicate keys, but some of the values are duplicates. - openWith->Add("txt", "notepad.exe"); - openWith->Add("bmp", "paint.exe"); - openWith->Add("dib", "paint.exe"); - openWith->Add("rtf", "wordpad.exe"); - - // The Add method throws an exception if the new key is - // already in the dictionary. - try - { - openWith->Add("txt", "winword.exe"); - } - catch (ArgumentException^) - { - Console::WriteLine("An element with Key = \"txt\" already exists."); - } - // - - // - // The Item property is another name for the indexer, so you - // can omit its name when accessing elements. - Console::WriteLine("For key = \"rtf\", value = {0}.", - openWith["rtf"]); - - // The indexer can be used to change the value associated - // with a key. - openWith["rtf"] = "winword.exe"; - Console::WriteLine("For key = \"rtf\", value = {0}.", - openWith["rtf"]); - - // If a key does not exist, setting the indexer for that key - // adds a new key/value pair. - openWith["doc"] = "winword.exe"; - // - - // - // The indexer throws an exception if the requested key is - // not in the dictionary. - try - { - Console::WriteLine("For key = \"tif\", value = {0}.", - openWith["tif"]); - } - catch (KeyNotFoundException^) - { - Console::WriteLine("Key = \"tif\" is not found."); - } - // - - // - // When a program often has to try keys that turn out not to - // be in the dictionary, TryGetValue can be a more efficient - // way to retrieve values. - String^ value = ""; - if (openWith->TryGetValue("tif", value)) - { - Console::WriteLine("For key = \"tif\", value = {0}.", value); - } - else - { - Console::WriteLine("Key = \"tif\" is not found."); - } - // - - // - // ContainsKey can be used to test keys before inserting - // them. - if (!openWith->ContainsKey("ht")) - { - openWith->Add("ht", "hypertrm.exe"); - Console::WriteLine("Value added for key = \"ht\": {0}", - openWith["ht"]); - } - // - - // - // When you use foreach to enumerate dictionary elements, - // the elements are retrieved as KeyValuePair objects. - Console::WriteLine(); - for each( KeyValuePair kvp in openWith ) - { - Console::WriteLine("Key = {0}, Value = {1}", - kvp.Key, kvp.Value); - } - // - - // - // To get the values alone, use the Values property. - Dictionary::ValueCollection^ valueColl = - openWith->Values; - - // The elements of the ValueCollection are strongly typed - // with the type that was specified for dictionary values. - Console::WriteLine(); - for each( String^ s in valueColl ) - { - Console::WriteLine("Value = {0}", s); - } - // - - // - // To get the keys alone, use the Keys property. - Dictionary::KeyCollection^ keyColl = - openWith->Keys; - - // The elements of the KeyCollection are strongly typed - // with the type that was specified for dictionary keys. - Console::WriteLine(); - for each( String^ s in keyColl ) - { - Console::WriteLine("Key = {0}", s); - } - // - - // - // Use the Remove method to remove a key/value pair. - Console::WriteLine("\nRemove(\"doc\")"); - openWith->Remove("doc"); - - if (!openWith->ContainsKey("doc")) - { - Console::WriteLine("Key \"doc\" is not found."); - } - // - } -}; - -int main() -{ - Example::Main(); -} - -/* This code example produces the following output: - -An element with Key = "txt" already exists. -For key = "rtf", value = wordpad.exe. -For key = "rtf", value = winword.exe. -Key = "tif" is not found. -Key = "tif" is not found. -Value added for key = "ht": hypertrm.exe - -Key = txt, Value = notepad.exe -Key = bmp, Value = paint.exe -Key = dib, Value = paint.exe -Key = rtf, Value = winword.exe -Key = doc, Value = winword.exe -Key = ht, Value = hypertrm.exe - -Value = notepad.exe -Value = paint.exe -Value = paint.exe -Value = winword.exe -Value = winword.exe -Value = hypertrm.exe - -Key = txt -Key = bmp -Key = dib -Key = rtf -Key = doc -Key = ht - -Remove("doc") -Key "doc" is not found. - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source2.cpp deleted file mode 100644 index b16f6d80b9c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -using namespace System; -using namespace System::Collections::Generic; -//using namespace System::Threading; - -public ref class Example -{ -public: - static void Main() - { - // Create a new dictionary of strings, with string keys. - // - Dictionary^ myDictionary = - gcnew Dictionary(); - - // Add some elements to the dictionary. There are no - // duplicate keys, but some of the values are duplicates. - myDictionary->Add("txt", "notepad.exe"); - myDictionary->Add("bmp", "paint.exe"); - myDictionary->Add("dib", "paint.exe"); - myDictionary->Add("rtf", "wordpad.exe"); - - // - for each(KeyValuePair kvp in myDictionary) - { - Console::WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); - } - // - } -}; - -int main() -{ - Example::Main(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp deleted file mode 100644 index 96a21ffd2f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -public ref class Example -{ -public: - static void Main() - { - // - // Create a new dictionary of strings, with string keys, - // and access it through the IDictionary generic interface. - IDictionary^ openWith = - gcnew Dictionary(); - - // Add some elements to the dictionary. There are no - // duplicate keys, but some of the values are duplicates. - openWith->Add("txt", "notepad.exe"); - openWith->Add("bmp", "paint.exe"); - openWith->Add("dib", "paint.exe"); - openWith->Add("rtf", "wordpad.exe"); - - // The Add method throws an exception if the new key is - // already in the dictionary. - try - { - openWith->Add("txt", "winword.exe"); - } - catch (ArgumentException^) - { - Console::WriteLine("An element with Key = \"txt\" already exists."); - } - // - - // - // The Item property is another name for the indexer, so you - // can omit its name when accessing elements. - Console::WriteLine("For key = \"rtf\", value = {0}.", - openWith["rtf"]); - - // The indexer can be used to change the value associated - // with a key. - openWith["rtf"] = "winword.exe"; - Console::WriteLine("For key = \"rtf\", value = {0}.", - openWith["rtf"]); - - // If a key does not exist, setting the indexer for that key - // adds a new key/value pair. - openWith["doc"] = "winword.exe"; - // - - // - // The indexer throws an exception if the requested key is - // not in the dictionary. - try - { - Console::WriteLine("For key = \"tif\", value = {0}.", - openWith["tif"]); - } - catch (KeyNotFoundException^) - { - Console::WriteLine("Key = \"tif\" is not found."); - } - // - - // - // When a program often has to try keys that turn out not to - // be in the dictionary, TryGetValue can be a more efficient - // way to retrieve values. - String^ value = ""; - if (openWith->TryGetValue("tif", value)) - { - Console::WriteLine("For key = \"tif\", value = {0}.", value); - } - else - { - Console::WriteLine("Key = \"tif\" is not found."); - } - // - - // - // ContainsKey can be used to test keys before inserting - // them. - if (!openWith->ContainsKey("ht")) - { - openWith->Add("ht", "hypertrm.exe"); - Console::WriteLine("Value added for key = \"ht\": {0}", - openWith["ht"]); - } - // - - // - // When you use foreach to enumerate dictionary elements, - // the elements are retrieved as KeyValuePair objects. - Console::WriteLine(); - for each( KeyValuePair kvp in openWith ) - { - Console::WriteLine("Key = {0}, Value = {1}", - kvp.Key, kvp.Value); - } - // - - // - // To get the values alone, use the Values property. - ICollection^ icoll = openWith->Values; - - // The elements of the ValueCollection are strongly typed - // with the type that was specified for dictionary values. - Console::WriteLine(); - for each( String^ s in icoll ) - { - Console::WriteLine("Value = {0}", s); - } - // - - // - // To get the keys alone, use the Keys property. - icoll = openWith->Keys; - - // The elements of the ValueCollection are strongly typed - // with the type that was specified for dictionary values. - Console::WriteLine(); - for each( String^ s in icoll ) - { - Console::WriteLine("Key = {0}", s); - } - // - - // - // Use the Remove method to remove a key/value pair. - Console::WriteLine("\nRemove(\"doc\")"); - openWith->Remove("doc"); - - if (!openWith->ContainsKey("doc")) - { - Console::WriteLine("Key \"doc\" is not found."); - } - // - } -}; - -int main() -{ - Example::Main(); -} - -/* This code example produces the following output: - -An element with Key = "txt" already exists. -For key = "rtf", value = wordpad.exe. -For key = "rtf", value = winword.exe. -Key = "tif" is not found. -Key = "tif" is not found. -Value added for key = "ht": hypertrm.exe - -Key = txt, Value = notepad.exe -Key = bmp, Value = paint.exe -Key = dib, Value = paint.exe -Key = rtf, Value = winword.exe -Key = doc, Value = winword.exe -Key = ht, Value = hypertrm.exe - -Value = notepad.exe -Value = paint.exe -Value = paint.exe -Value = winword.exe -Value = winword.exe -Value = hypertrm.exe - -Key = txt -Key = bmp -Key = dib -Key = rtf -Key = doc -Key = ht - -Remove("doc") -Key "doc" is not found. - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source2.cpp deleted file mode 100644 index d3c038ba91c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source2.cpp +++ /dev/null @@ -1,34 +0,0 @@ -using namespace System; -using namespace System::Collections::Generic; - -public ref class Example -{ -public: - static void Main() - { - // Create a new dictionary of strings, with string keys. - // - Dictionary^ exDictionary = - gcnew Dictionary(); - - // Add some elements to the dictionary. There are no - // duplicate keys, but some of the values are duplicates. - exDictionary->Add(0, "notepad.exe"); - exDictionary->Add(1, "paint.exe"); - exDictionary->Add(2, "paint.exe"); - exDictionary->Add(3, "wordpad.exe"); - IDictionary^ myDictionary = exDictionary; - // - for each(KeyValuePair kvp in myDictionary) - { - Console::WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); - } - // - } -}; - -int main() -{ - Example::Main(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.LinkedList/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.LinkedList/cpp/source.cpp deleted file mode 100644 index 1439a447483..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Generic.LinkedList/cpp/source.cpp +++ /dev/null @@ -1,264 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Text; -using namespace System::Collections::Generic; - -public ref class Example -{ -public: - static void Main() - { - // - // Create the link list. - array^ words = - { "the", "fox", "jumped", "over", "the", "dog" }; - LinkedList^ sentence = gcnew LinkedList(words); - Display(sentence, "The linked list values:"); - Console::WriteLine("sentence.Contains(\"jumped\") = {0}", - sentence->Contains("jumped")); - // - - // Add the word 'today' to the beginning of the linked list. - sentence->AddFirst("today"); - Display(sentence, "Test 1: Add 'today' to beginning of the list:"); - - // - // Move the first node to be the last node. - LinkedListNode^ mark1 = sentence->First; - sentence->RemoveFirst(); - sentence->AddLast(mark1); - // - Display(sentence, "Test 2: Move first node to be last node:"); - - // Change the last node to 'yesterday'. - sentence->RemoveLast(); - sentence->AddLast("yesterday"); - Display(sentence, "Test 3: Change the last node to 'yesterday':"); - - // - // Move the last node to be the first node. - mark1 = sentence->Last; - sentence->RemoveLast(); - sentence->AddFirst(mark1); - // - Display(sentence, "Test 4: Move last node to be first node:"); - - - // - // Indicate the last occurence of 'the'. - sentence->RemoveFirst(); - LinkedListNode^ current = sentence->FindLast("the"); - // - IndicateNode(current, "Test 5: Indicate last occurence of 'the':"); - - // - // Add 'lazy' and 'old' after 'the' (the LinkedListNode named current). - sentence->AddAfter(current, "old"); - sentence->AddAfter(current, "lazy"); - // - IndicateNode(current, "Test 6: Add 'lazy' and 'old' after 'the':"); - - // - // Indicate 'fox' node. - current = sentence->Find("fox"); - IndicateNode(current, "Test 7: Indicate the 'fox' node:"); - - // Add 'quick' and 'brown' before 'fox': - sentence->AddBefore(current, "quick"); - sentence->AddBefore(current, "brown"); - // - IndicateNode(current, "Test 8: Add 'quick' and 'brown' before 'fox':"); - - // Keep a reference to the current node, 'fox', - // and to the previous node in the list. Indicate the 'dog' node. - mark1 = current; - LinkedListNode^ mark2 = current->Previous; - current = sentence->Find("dog"); - IndicateNode(current, "Test 9: Indicate the 'dog' node:"); - - // The AddBefore method throws an InvalidOperationException - // if you try to add a node that already belongs to a list. - Console::WriteLine("Test 10: Throw exception by adding node (fox) already in the list:"); - try - { - sentence->AddBefore(current, mark1); - } - catch (InvalidOperationException^ ex) - { - Console::WriteLine("Exception message: {0}", ex->Message); - } - Console::WriteLine(); - - // - // Remove the node referred to by mark1, and then add it - // before the node referred to by current. - // Indicate the node referred to by current. - sentence->Remove(mark1); - sentence->AddBefore(current, mark1); - // - IndicateNode(current, "Test 11: Move a referenced node (fox) before the current node (dog):"); - - // - // Remove the node referred to by current. - sentence->Remove(current); - // - IndicateNode(current, "Test 12: Remove current node (dog) and attempt to indicate it:"); - - // Add the node after the node referred to by mark2. - sentence->AddAfter(mark2, current); - IndicateNode(current, "Test 13: Add node removed in test 11 after a referenced node (brown):"); - - // The Remove method finds and removes the - // first node that that has the specified value. - sentence->Remove("old"); - Display(sentence, "Test 14: Remove node that has the value 'old':"); - - // - // When the linked list is cast to ICollection(Of String), - // the Add method adds a node to the end of the list. - sentence->RemoveLast(); - ICollection^ icoll = sentence; - icoll->Add("rhinoceros"); - // - Display(sentence, "Test 15: Remove last node, cast to ICollection, and add 'rhinoceros':"); - - Console::WriteLine("Test 16: Copy the list to an array:"); - // - // Create an array with the same number of - // elements as the inked list. - array^ sArray = gcnew array(sentence->Count); - sentence->CopyTo(sArray, 0); - - for each (String^ s in sArray) - { - Console::WriteLine(s); - } - // - - - // - // Release all the nodes. - sentence->Clear(); - - Console::WriteLine(); - Console::WriteLine("Test 17: Clear linked list. Contains 'jumped' = {0}", - sentence->Contains("jumped")); - // - - Console::ReadLine(); - } - -private: - static void Display(LinkedList^ words, String^ test) - { - Console::WriteLine(test); - for each (String^ word in words) - { - Console::Write(word + " "); - } - Console::WriteLine(); - Console::WriteLine(); - } - - static void IndicateNode(LinkedListNode^ node, String^ test) - { - Console::WriteLine(test); - if (node->List == nullptr) - { - Console::WriteLine("Node '{0}' is not in the list.\n", - node->Value); - return; - } - - StringBuilder^ result = gcnew StringBuilder("(" + node->Value + ")"); - LinkedListNode^ nodeP = node->Previous; - - while (nodeP != nullptr) - { - result->Insert(0, nodeP->Value + " "); - nodeP = nodeP->Previous; - } - - node = node->Next; - while (node != nullptr) - { - result->Append(" " + node->Value); - node = node->Next; - } - - Console::WriteLine(result); - Console::WriteLine(); - } -}; - -int main() -{ - Example::Main(); -} - -//This code example produces the following output: -// -//The linked list values: -//the fox jumped over the dog - -//Test 1: Add 'today' to beginning of the list: -//today the fox jumped over the dog - -//Test 2: Move first node to be last node: -//the fox jumped over the dog today - -//Test 3: Change the last node to 'yesterday': -//the fox jumped over the dog yesterday - -//Test 4: Move last node to be first node: -//yesterday the fox jumped over the dog - -//Test 5: Indicate last occurence of 'the': -//the fox jumped over (the) dog - -//Test 6: Add 'lazy' and 'old' after 'the': -//the fox jumped over (the) lazy old dog - -//Test 7: Indicate the 'fox' node: -//the (fox) jumped over the lazy old dog - -//Test 8: Add 'quick' and 'brown' before 'fox': -//the quick brown (fox) jumped over the lazy old dog - -//Test 9: Indicate the 'dog' node: -//the quick brown fox jumped over the lazy old (dog) - -//Test 10: Throw exception by adding node (fox) already in the list: -//Exception message: The LinkedList node belongs a LinkedList. - -//Test 11: Move a referenced node (fox) before the current node (dog): -//the quick brown jumped over the lazy old fox (dog) - -//Test 12: Remove current node (dog) and attempt to indicate it: -//Node 'dog' is not in the list. - -//Test 13: Add node removed in test 11 after a referenced node (brown): -//the quick brown (dog) jumped over the lazy old fox - -//Test 14: Remove node that has the value 'old': -//the quick brown dog jumped over the lazy fox - -//Test 15: Remove last node, cast to ICollection, and add 'rhinoceros': -//the quick brown dog jumped over the lazy rhinoceros - -//Test 16: Copy the list to an array: -//the -//quick -//brown -//dog -//jumped -//over -//the -//lazy -//rhinoceros - -//Test 17: Clear linked list. Contains 'jumped' = False -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/remarks.cpp deleted file mode 100644 index 8e667bffa93..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/remarks.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#using - -using namespace System; -using namespace System::Collections::Generic; - -public ref class Example -{ -public: - static void Main() - { - // Create a new sorted list of strings, with string - // keys. - SortedList^ mySortedList = - gcnew SortedList(); - - // Add some elements to the list. There are no - // duplicate keys, but some of the values are duplicates. - mySortedList->Add(0, "notepad.exe"); - mySortedList->Add(1, "paint.exe"); - mySortedList->Add(2, "paint.exe"); - mySortedList->Add(3, "wordpad.exe"); - - // - String^ v = mySortedList->Values[3]; - // - - Console::WriteLine("Value at index 3: {0}", v); - - // - for each( KeyValuePair kvp in mySortedList ) - { - Console::WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); - } - // - } -}; - -int main() -{ - Example::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp deleted file mode 100644 index 47488deda3e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Collections::Generic; - -public ref class Example -{ -public: - static void Main() - { - // - // Create a new sorted list of strings, with string - // keys. - SortedList^ openWith = - gcnew SortedList(); - - // Add some elements to the list. There are no - // duplicate keys, but some of the values are duplicates. - openWith->Add("txt", "notepad.exe"); - openWith->Add("bmp", "paint.exe"); - openWith->Add("dib", "paint.exe"); - openWith->Add("rtf", "wordpad.exe"); - - // The Add method throws an exception if the new key is - // already in the list. - try - { - openWith->Add("txt", "winword.exe"); - } - catch (ArgumentException^) - { - Console::WriteLine("An element with Key = \"txt\" already exists."); - } - // - - // - // The Item property is another name for the indexer, so you - // can omit its name when accessing elements. - Console::WriteLine("For key = \"rtf\", value = {0}.", - openWith["rtf"]); - - // The indexer can be used to change the value associated - // with a key. - openWith["rtf"] = "winword.exe"; - Console::WriteLine("For key = \"rtf\", value = {0}.", - openWith["rtf"]); - - // If a key does not exist, setting the indexer for that key - // adds a new key/value pair. - openWith["doc"] = "winword.exe"; - // - - // - // The indexer throws an exception if the requested key is - // not in the list. - try - { - Console::WriteLine("For key = \"tif\", value = {0}.", - openWith["tif"]); - } - catch (KeyNotFoundException^) - { - Console::WriteLine("Key = \"tif\" is not found."); - } - // - - // - // When a program often has to try keys that turn out not to - // be in the list, TryGetValue can be a more efficient - // way to retrieve values. - String^ value = ""; - if (openWith->TryGetValue("tif", value)) - { - Console::WriteLine("For key = \"tif\", value = {0}.", value); - } - else - { - Console::WriteLine("Key = \"tif\" is not found."); - } - // - - // - // ContainsKey can be used to test keys before inserting - // them. - if (!openWith->ContainsKey("ht")) - { - openWith->Add("ht", "hypertrm.exe"); - Console::WriteLine("Value added for key = \"ht\": {0}", - openWith["ht"]); - } - // - - // - // When you use foreach to enumerate list elements, - // the elements are retrieved as KeyValuePair objects. - Console::WriteLine(); - for each( KeyValuePair kvp in openWith ) - { - Console::WriteLine("Key = {0}, Value = {1}", - kvp.Key, kvp.Value); - } - // - - // - // To get the values alone, use the Values property. - IList^ ilistValues = openWith->Values; - - // The elements of the list are strongly typed with the - // type that was specified for the SortedList values. - Console::WriteLine(); - for each( String^ s in ilistValues ) - { - Console::WriteLine("Value = {0}", s); - } - - // The Values property is an efficient way to retrieve - // values by index. - Console::WriteLine("\nIndexed retrieval using the Values " + - "property: Values[2] = {0}", openWith->Values[2]); - // - - // - // To get the keys alone, use the Keys property. - IList^ ilistKeys = openWith->Keys; - - // The elements of the list are strongly typed with the - // type that was specified for the SortedList keys. - Console::WriteLine(); - for each( String^ s in ilistKeys ) - { - Console::WriteLine("Key = {0}", s); - } - - // The Keys property is an efficient way to retrieve - // keys by index. - Console::WriteLine("\nIndexed retrieval using the Keys " + - "property: Keys[2] = {0}", openWith->Keys[2]); - // - - // - // Use the Remove method to remove a key/value pair. - Console::WriteLine("\nRemove(\"doc\")"); - openWith->Remove("doc"); - - if (!openWith->ContainsKey("doc")) - { - Console::WriteLine("Key \"doc\" is not found."); - } - // - } -}; - -int main() -{ - Example::Main(); -} - -/* This code example produces the following output: - -An element with Key = "txt" already exists. -For key = "rtf", value = wordpad.exe. -For key = "rtf", value = winword.exe. -Key = "tif" is not found. -Key = "tif" is not found. -Value added for key = "ht": hypertrm.exe - -Key = bmp, Value = paint.exe -Key = dib, Value = paint.exe -Key = doc, Value = winword.exe -Key = ht, Value = hypertrm.exe -Key = rtf, Value = winword.exe -Key = txt, Value = notepad.exe - -Value = paint.exe -Value = paint.exe -Value = winword.exe -Value = hypertrm.exe -Value = winword.exe -Value = notepad.exe - -Indexed retrieval using the Values property: Values[2] = winword.exe - -Key = bmp -Key = dib -Key = doc -Key = ht -Key = rtf -Key = txt - -Indexed retrieval using the Keys property: Keys[2] = doc - -Remove("doc") -Key "doc" is not found. - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp b/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp deleted file mode 100644 index d26844e8082..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp +++ /dev/null @@ -1,134 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - -// Computes a keyed hash for a source file, creates a target file with the keyed hash -// prepended to the contents of the source file, then decodes the file and compares -// the source and the decoded files. -void EncodeFile( array^key, String^ sourceFile, String^ destFile ) -{ - - // Initialize the keyed hash object. - HMACSHA256^ myhmacsha256 = gcnew HMACSHA256( key ); - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - FileStream^ outStream = gcnew FileStream( destFile,FileMode::Create ); - - // Compute the hash of the input file. - array^hashValue = myhmacsha256->ComputeHash( inStream ); - - // Reset inStream to the beginning of the file. - inStream->Position = 0; - - // Write the computed hash value to the output file. - outStream->Write( hashValue, 0, hashValue->Length ); - - // Copy the contents of the sourceFile to the destFile. - int bytesRead; - - // read 1K at a time - array^buffer = gcnew array(1024); - do - { - - // Read from the wrapping CryptoStream. - bytesRead = inStream->Read( buffer, 0, 1024 ); - outStream->Write( buffer, 0, bytesRead ); - } - while ( bytesRead > 0 ); - - myhmacsha256->Clear(); - - // Close the streams - inStream->Close(); - outStream->Close(); - return; -} // end EncodeFile - - - -// Decode the encoded file and compare to original file. -bool DecodeFile( array^key, String^ sourceFile ) -{ - - // Initialize the keyed hash object. - HMACSHA256^ hmacsha256 = gcnew HMACSHA256( key ); - - // Create an array to hold the keyed hash value read from the file. - array^storedHash = gcnew array(hmacsha256->HashSize / 8); - - // Create a FileStream for the source file. - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - - // Read in the storedHash. - inStream->Read( storedHash, 0, storedHash->Length ); - - // Compute the hash of the remaining contents of the file. - // The stream is properly positioned at the beginning of the content, - // immediately after the stored hash value. - array^computedHash = hmacsha256->ComputeHash( inStream ); - - // compare the computed hash with the stored value - bool err = false; - for ( int i = 0; i < storedHash->Length; i++ ) - { - if ( computedHash[ i ] != storedHash[ i ] ) - { - err = true; - } - } - if (err) - { - Console::WriteLine("Hash values differ! Encoded file has been tampered with!"); - return false; - } - else - { - Console::WriteLine("Hash values agree -- no tampering occurred."); - return true; - } - -} //end DecodeFile - - -int main() -{ - array^Fileargs = Environment::GetCommandLineArgs(); - String^ usageText = "Usage: HMACSHA256 inputfile.txt encodedfile.hsh\nYou must specify the two file names. Only the first file must exist.\n"; - - //If no file names are specified, write usage text. - if ( Fileargs->Length < 3 ) - { - Console::WriteLine( usageText ); - } - else - { - try - { - - // Create a random key using a random number generator. This would be the - // secret key shared by sender and receiver. - array^secretkey = gcnew array(64); - - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - - // The array is now filled with cryptographically strong random bytes. - rng->GetBytes( secretkey ); - - // Use the secret key to encode the message file. - EncodeFile( secretkey, Fileargs[ 1 ], Fileargs[ 2 ] ); - - // Take the encoded file and decode - DecodeFile( secretkey, Fileargs[ 2 ] ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "Error: File not found", e ); - } - - } -} //end main - - -// diff --git a/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp b/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp deleted file mode 100644 index 6dfcd8a29fa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp +++ /dev/null @@ -1,134 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - -// Computes a keyed hash for a source file, creates a target file with the keyed hash -// prepended to the contents of the source file, then decrypts the file and compares -// the source and the decrypted files. -void EncodeFile( array^key, String^ sourceFile, String^ destFile ) -{ - - // Initialize the keyed hash object. - HMACSHA384^ myhmacsha384 = gcnew HMACSHA384( key ); - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - FileStream^ outStream = gcnew FileStream( destFile,FileMode::Create ); - - // Compute the hash of the input file. - array^hashValue = myhmacsha384->ComputeHash( inStream ); - - // Reset inStream to the beginning of the file. - inStream->Position = 0; - - // Write the computed hash value to the output file. - outStream->Write( hashValue, 0, hashValue->Length ); - - // Copy the contents of the sourceFile to the destFile. - int bytesRead; - - // read 1K at a time - array^buffer = gcnew array(1024); - do - { - - // Read from the wrapping CryptoStream. - bytesRead = inStream->Read( buffer, 0, 1024 ); - outStream->Write( buffer, 0, bytesRead ); - } - while ( bytesRead > 0 ); - - myhmacsha384->Clear(); - - // Close the streams - inStream->Close(); - outStream->Close(); - return; -} // end EncodeFile - - - -// Decrypt the encoded file and compare to original file. -bool DecodeFile( array^key, String^ sourceFile ) -{ - - // Initialize the keyed hash object. - HMACSHA384^ hmacsha384 = gcnew HMACSHA384( key ); - - // Create an array to hold the keyed hash value read from the file. - array^storedHash = gcnew array(hmacsha384->HashSize / 8); - - // Create a FileStream for the source file. - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - - // Read in the storedHash. - inStream->Read( storedHash, 0, storedHash->Length ); - - // Compute the hash of the remaining contents of the file. - // The stream is properly positioned at the beginning of the content, - // immediately after the stored hash value. - array^computedHash = hmacsha384->ComputeHash( inStream ); - - // compare the computed hash with the stored value - bool err = false; - for ( int i = 0; i < storedHash->Length; i++ ) - { - if ( computedHash[ i ] != storedHash[ i ] ) - { - err = true; - } - } - if (err) - { - Console::WriteLine("Hash values differ! Encoded file has been tampered with!"); - return false; - } - else - { - Console::WriteLine("Hash values agree -- no tampering occurred."); - return true; - } - -} //end DecodeFile - - -int main() -{ - array^Fileargs = Environment::GetCommandLineArgs(); - String^ usageText = "Usage: HMACSHA384 inputfile.txt encryptedfile.hsh\nYou must specify the two file names. Only the first file must exist.\n"; - - //If no file names are specified, write usage text. - if ( Fileargs->Length < 3 ) - { - Console::WriteLine( usageText ); - } - else - { - try - { - - // Create a random key using a random number generator. This would be the - // secret key shared by sender and receiver. - array^secretkey = gcnew array(64); - - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - - // The array is now filled with cryptographically strong random bytes. - rng->GetBytes( secretkey ); - - // Use the secret key to encode the message file. - EncodeFile( secretkey, Fileargs[ 1 ], Fileargs[ 2 ] ); - - // Take the encoded file and decode - DecodeFile( secretkey, Fileargs[ 2 ] ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "Error: File not found", e ); - } - - } -} //end main - - -// diff --git a/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp b/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp deleted file mode 100644 index 4f83ce4b8b5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp +++ /dev/null @@ -1,134 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - -// Computes a keyed hash for a source file, creates a target file with the keyed hash -// prepended to the contents of the source file, then decrypts the file and compares -// the source and the decrypted files. -void EncodeFile( array^key, String^ sourceFile, String^ destFile ) -{ - - // Initialize the keyed hash object. - HMACSHA512^ myhmacsha512 = gcnew HMACSHA512( key ); - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - FileStream^ outStream = gcnew FileStream( destFile,FileMode::Create ); - - // Compute the hash of the input file. - array^hashValue = myhmacsha512->ComputeHash( inStream ); - - // Reset inStream to the beginning of the file. - inStream->Position = 0; - - // Write the computed hash value to the output file. - outStream->Write( hashValue, 0, hashValue->Length ); - - // Copy the contents of the sourceFile to the destFile. - int bytesRead; - - // read 1K at a time - array^buffer = gcnew array(1024); - do - { - - // Read from the wrapping CryptoStream. - bytesRead = inStream->Read( buffer, 0, 1024 ); - outStream->Write( buffer, 0, bytesRead ); - } - while ( bytesRead > 0 ); - - myhmacsha512->Clear(); - - // Close the streams - inStream->Close(); - outStream->Close(); - return; -} // end EncodeFile - - - -// Decrypt the encoded file and compare to original file. -bool DecodeFile( array^key, String^ sourceFile ) -{ - - // Initialize the keyed hash object. - HMACSHA512^ hmacsha512 = gcnew HMACSHA512( key ); - - // Create an array to hold the keyed hash value read from the file. - array^storedHash = gcnew array(hmacsha512->HashSize / 8); - - // Create a FileStream for the source file. - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - - // Read in the storedHash. - inStream->Read( storedHash, 0, storedHash->Length ); - - // Compute the hash of the remaining contents of the file. - // The stream is properly positioned at the beginning of the content, - // immediately after the stored hash value. - array^computedHash = hmacsha512->ComputeHash( inStream ); - - // compare the computed hash with the stored value - bool err = false; - for ( int i = 0; i < storedHash->Length; i++ ) - { - if ( computedHash[ i ] != storedHash[ i ] ) - { - err = true; - } - } - if (err) - { - Console::WriteLine("Hash values differ! Encoded file has been tampered with!"); - return false; - } - else - { - Console::WriteLine("Hash values agree -- no tampering occurred."); - return true; - } - -} //end DecodeFile - - -int main() -{ - array^Fileargs = Environment::GetCommandLineArgs(); - String^ usageText = "Usage: HMACSHA512 inputfile.txt encryptedfile.hsh\nYou must specify the two file names. Only the first file must exist.\n"; - - //If no file names are specified, write usage text. - if ( Fileargs->Length < 3 ) - { - Console::WriteLine( usageText ); - } - else - { - try - { - - // Create a random key using a random number generator. This would be the - // secret key shared by sender and receiver. - array^secretkey = gcnew array(64); - - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - - // The array is now filled with cryptographically strong random bytes. - rng->GetBytes( secretkey ); - - // Use the secret key to encode the message file. - EncodeFile( secretkey, Fileargs[ 1 ], Fileargs[ 2 ] ); - - // Take the encoded file and decode - DecodeFile( secretkey, Fileargs[ 2 ] ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "Error: File not found", e ); - } - - } -} //end main - - -// diff --git a/snippets/cpp/VS_Snippets_CLR/IO.File.Encrypt-Decrypt/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.File.Encrypt-Decrypt/cpp/sample.cpp deleted file mode 100644 index 506b780b31a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.File.Encrypt-Decrypt/cpp/sample.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ fileName = "test.xml"; - if (!File::Exists(fileName)) - { - Console::WriteLine("The file " + fileName - + " does not exist."); - return 0; - } - try - { - Console::WriteLine("Encrypt " + fileName); - - // Encrypt the file. - File::Encrypt(fileName); - - Console::WriteLine("Decrypt " + fileName); - - // Decrypt the file. - File::Decrypt(fileName); - - Console::WriteLine("Done"); - } - catch (IOException^ ex) - { - Console::WriteLine("There was an IO problem."); - Console::WriteLine(ex->Message); - } - catch (PlatformNotSupportedException^) - { - Console::WriteLine("Encryption is not supported on " + - "this system."); - } - catch (NotSupportedException^) - { - Console::WriteLine("Encryption is not supported on " + - "this system."); - } - catch (UnauthorizedAccessException^) - { - Console::WriteLine("The operation could not be " - + "carried out."); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/IO.File.Replace/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.File.Replace/cpp/sample.cpp deleted file mode 100644 index 4876d14c2dd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.File.Replace/cpp/sample.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -using namespace System; -using namespace System::IO; - - -// Move a file into another file, delete the original, -// and create a backup of the replaced file. - -void ReplaceFile(String^ fileToMoveAndDelete, - String^ fileToReplace, String^ backupOfFileToReplace) -{ - File::Replace(fileToMoveAndDelete, fileToReplace, - backupOfFileToReplace, false); -} - - -int main() -{ - try - { - String^ originalFile = "test.xml"; - String^ fileToReplace = "test2.xml"; - String^ backUpOfFileToReplace = "test2.xml.bac"; - - Console::WriteLine("Move the contents of " + originalFile + " into " - + fileToReplace + ", delete " + originalFile - + ", and create a backup of " + fileToReplace + "."); - - // Replace the file. - ReplaceFile(originalFile, fileToReplace, backUpOfFileToReplace); - - Console::WriteLine("Done"); - } - catch (IOException^ ex) - { - Console::WriteLine(ex->Message); - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/cpp/sample.cpp deleted file mode 100644 index 3cbff62e773..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/cpp/sample.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::AccessControl; - - - static void Addencryption(String^ fileName) -{ - // Create a new FileInfo object. - FileInfo^ fInfo = gcnew FileInfo(fileName); - if (!fInfo->Exists) - { - fInfo->Create(); - } - // Add encryption. - fInfo->Encrypt(); - -} - - - static void Removeencryption(String^ fileName) -{ -// Create a new FileInfo object. - FileInfo^ fInfo = gcnew FileInfo(fileName); - if (!fInfo->Exists) - { - fInfo->Create(); - } - // Remove encryption. - fInfo->Decrypt(); -} - -int main() -{ - try - { - String^ fileName = "c:\\MyTest.txt"; - Console::WriteLine("Encrypt " + fileName); - - // Encrypt the file. - - Addencryption(fileName); - Console::WriteLine("Decrypt " + fileName); - - // Decrypt the file. - Removeencryption(fileName); - Console::WriteLine("Done"); - } - catch (IOException^ ex) - { - Console::WriteLine(ex->Message); - } -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//Encrypt c:\MyTest.txt -//Decrypt c:\MyTest.txt -//Done -// diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Exists/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Exists/cpp/sample.cpp deleted file mode 100644 index 27fb4bdc1ae..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Exists/cpp/sample.cpp +++ /dev/null @@ -1,49 +0,0 @@ -using namespace System; -using namespace System::IO; - -// -array^ Openfile(String^ fileName) -{ - // Check the fileName argument. - if (fileName == nullptr || fileName->Length == 0) - { - throw gcnew ArgumentNullException("fileName"); - } - - // Check to see if the file exists. - FileInfo^ fInfo = gcnew FileInfo(fileName); - - // You can throw a personalized exception if - // the file does not exist. - if (!fInfo->Exists) - { - throw gcnew FileNotFoundException("The file was not found.", - fileName); - } - - try - { - // Open the file. - FileStream^ fStream = gcnew FileStream(fileName, FileMode::Open); - - // Create a buffer. - array^ buffer = gcnew array(fStream->Length); - - // Read the file contents to the buffer. - fStream->Read(buffer, 0, (int)fStream->Length); - - // return the buffer. - return buffer; - } - catch (IOException^ ex) - { - Console::WriteLine(ex->Message); - return nullptr; - } -} -// - -int main() -{ - -}; diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp deleted file mode 100644 index eb8b7aeaec2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// -#using -using namespace System; -using namespace System::IO; -using namespace System::Security::AccessControl; -using namespace System::Security::Principal; - -// Adds an ACL entry on the specified file for the specified account. -static void AddFileSecurity(String^ fileName, String^ account, - FileSystemRights^ rights, - AccessControlType^ controlType) -{ - // Create a new FileInfo object. - FileInfo^ fInfo = gcnew FileInfo(fileName); - if (!fInfo->Exists) - { - fInfo->Create(); - } - - // Get a FileSecurity object that represents the - // current security settings. - FileSecurity^ fSecurity = fInfo->GetAccessControl(); - - // Add the FileSystemAccessRule to the security settings. - fSecurity->AddAccessRule(gcnew FileSystemAccessRule(account, - *rights, *controlType)); - - // Set the new access settings. - fInfo->SetAccessControl(fSecurity); -} - -// Removes an ACL entry on the specified file for the specified account. -static void RemoveFileSecurity(String^ fileName, String^ account, - FileSystemRights^ rights, - AccessControlType^ controlType) -{ - // Create a new FileInfo object. - FileInfo^ fInfo = gcnew FileInfo(fileName); - if (!fInfo->Exists) - { - fInfo->Create(); - } - - // Get a FileSecurity object that represents the - // current security settings. - FileSecurity^ fSecurity = fInfo->GetAccessControl(); - - // Remove the FileSystemAccessRule from the security settings. - fSecurity->RemoveAccessRule(gcnew FileSystemAccessRule(account, - *rights, *controlType)); - - // Set the new access settings. - fInfo->SetAccessControl(fSecurity); -} - -int main() -{ - try - { - String^ fileName = "c:\\test.xml"; - - Console::WriteLine("Adding access control entry for " + - fileName); - - // Add the access control entry to the file. - // Before compiling this snippet, change MyDomain to your - // domain name and MyAccessAccount to the name - // you use to access your domain. - AddFileSecurity(fileName, "MyDomain\\MyAccessAccount", - FileSystemRights::ReadData, AccessControlType::Allow); - - Console::WriteLine("Removing access control entry from " + - fileName); - - // Remove the access control entry from the file. - // Before compiling this snippet, change MyDomain to your - // domain name and MyAccessAccount to the name - // you use to access your domain. - RemoveFileSecurity(fileName, "MyDomain\\MyAccessAccount", - FileSystemRights::ReadData, AccessControlType::Allow); - - Console::WriteLine("Done."); - } - catch (Exception^ e) - { - Console::WriteLine(e); - } - -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//Adding access control entry for c:\test.xml -//Removing access control entry from c:\test.xml -//Done. -// -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Replace/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Replace/cpp/sample.cpp deleted file mode 100644 index f7dbe0f1cb2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Replace/cpp/sample.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// - -using namespace System; -using namespace System::IO; - - -// Move a file into another file, delete the original, -// and create a backup of the replaced file. -void ReplaceFile(String^ fileToMoveAndDelete, - String^ fileToReplace, String^ backupOfFileToReplace) -{ - // Create a new FileInfo object. - FileInfo^ fInfo = gcnew FileInfo(fileToMoveAndDelete); - - // replace the file. - fInfo->Replace(fileToReplace, backupOfFileToReplace, false); -} - - -int main() -{ - try - { - // originalFile and fileToReplace must contain - // the path to files that already exist in the - // file system. backUpOfFileToReplace is created - // during the execution of the Replace method. - - String^ originalFile = "test.xml"; - String^ fileToReplace = "test2.xml"; - String^ backUpOfFileToReplace = "test2.xml.bak"; - - if (File::Exists(originalFile) && (File::Exists(fileToReplace))) - { - Console::WriteLine("Move the contents of {0} into {1}, " + - "delete {0}, and create a backup of {1}", - originalFile, fileToReplace); - - // Replace the file. - ReplaceFile(originalFile, fileToReplace, - backUpOfFileToReplace); - Console::WriteLine("Done"); - } - else - { - Console::WriteLine("Either the file {0} or {1} doesn't " + - "exist.", originalFile, fileToReplace); - } - } - catch (IOException^ ex) - { - Console::WriteLine(ex->Message); - } -} - - -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//Move the contents of c:\test1.xml into c:\test2.xml, delete c:\test1.xml, -//and create a backup of c:\test2.xml -//Done - -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.isReadOnly/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.isReadOnly/cpp/sample.cpp deleted file mode 100644 index e5fb1ade0c8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.isReadOnly/cpp/sample.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - // Create a temporary file. - String^ filePath = Path::GetTempFileName(); - Console::WriteLine("Created a temp file at '{0}.", filePath); - - // Create a new FileInfo object. - FileInfo^ fInfo = gcnew FileInfo(filePath); - - // Get the read-only value for a file. - bool isReadOnly = fInfo->IsReadOnly; - - // Display whether the file is read-only. - Console::WriteLine("The file read-only value for '{0}' is {1}.", fInfo->Name, isReadOnly); - - // Set the file to read-only. - Console::WriteLine("Setting the read-only value for '{0}' to true.", fInfo->Name); - fInfo->IsReadOnly = true; - - // Get the read-only value for a file. - isReadOnly = fInfo->IsReadOnly; - - // Display that the file is now read-only. - Console::WriteLine("The file read-only value for '{0}' is {1}.", fInfo->Name, isReadOnly); - - // Make the file mutable again so it can be deleted. - fInfo->IsReadOnly = false; - - // Delete the temporary file. - fInfo->Delete(); - - return 0; -}; - -// This code produces output similar to the following, -// though results may vary based on the computer, file structure, etc.: -// -// Created a temp file at 'C:\Users\UserName\AppData\Local\Temp\tmpB438.tmp'. -// The file read-only value for 'tmpB438.tmp' is False. -// Setting the read-only value for 'tmpB438.tmp' to true. -// The file read-only value for 'tmpB438.tmp' is True. -// -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor1/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor1/cpp/example.cpp deleted file mode 100644 index d31fd98984e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor1/cpp/example.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Security::AccessControl; - -int main() -{ - try - { - // Create a file and write data to it. - - // Create an array of bytes. - array^ messageByte = - Encoding::ASCII->GetBytes("Here is some data."); - - // Create a file using the FileStream class. - FileStream^ fWrite = gcnew FileStream("test.txt", FileMode::Create, - FileAccess::ReadWrite, FileShare::None, 8, FileOptions::None); - - // Write the number of bytes to the file. - fWrite->WriteByte((Byte)messageByte->Length); - - // Write the bytes to the file. - fWrite->Write(messageByte, 0, messageByte->Length); - - // Close the stream. - fWrite->Close(); - - - // Open a file and read the number of bytes. - - FileStream^ fRead = gcnew FileStream("test.txt", - FileMode::Open); - - // The first byte is the string length. - int length = (int)fRead->ReadByte(); - - // Create a new byte array for the data. - array^ readBytes = gcnew array(length); - - // Read the data from the file. - fRead->Read(readBytes, 0, readBytes->Length); - - // Close the stream. - fRead->Close(); - - // Display the data. - Console::WriteLine(Encoding::ASCII->GetString(readBytes)); - - Console::WriteLine("Done writing and reading data."); - } - catch (IOException^ ex) - { - Console::WriteLine(ex->Message); - } -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor2/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor2/cpp/example.cpp deleted file mode 100644 index 3c25ca60661..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.FileStream.ctor2/cpp/example.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Security::AccessControl; -using namespace System::Security::Principal; - -int main() -{ - try - { - // Create a file and write data to it. - - // Create an array of bytes. - array^ messageByte = - Encoding::ASCII->GetBytes("Here is some data."); - - // Specify an access control list (ACL) - FileSecurity^ fs = gcnew FileSecurity(); - - fs->AddAccessRule( - gcnew FileSystemAccessRule("MYDOMAIN\\MyAccount", - FileSystemRights::Modify, AccessControlType::Allow)); - - // Create a file using the FileStream class. - FileStream^ fWrite = gcnew FileStream("test.txt", - FileMode::Create, FileSystemRights::Modify, - FileShare::None, 8, FileOptions::None, fs); - - // Write the number of bytes to the file. - fWrite->WriteByte((Byte)messageByte->Length); - - // Write the bytes to the file. - fWrite->Write(messageByte, 0, messageByte->Length); - - // Close the stream. - fWrite->Close(); - - // Open a file and read the number of bytes. - - FileStream^ fRead = - gcnew FileStream("test.txt", FileMode::Open); - - // The first byte is the string length. - int length = (int)fRead->ReadByte(); - - // Create a new byte array for the data. - array^ readBytes = gcnew array(length); - - // Read the data from the file. - fRead->Read(readBytes, 0, readBytes->Length); - - // Close the stream. - fRead->Close(); - - // Display the data. - Console::WriteLine(Encoding::ASCII->GetString(readBytes)); - - Console::WriteLine("Done writing and reading data."); - } - - catch (IdentityNotMappedException^) - { - Console::WriteLine("You need to use your own credentials " + - " 'MYDOMAIN\\MyAccount'."); - } - - catch (IOException^ ex) - { - Console::WriteLine(ex->Message); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/IO.Path.GetInvalidFile-PathChars/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/IO.Path.GetInvalidFile-PathChars/cpp/example.cpp deleted file mode 100644 index 98e59f68290..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.Path.GetInvalidFile-PathChars/cpp/example.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -namespace PathExample -{ - public ref class GetCharExample - { - public: - static void Main() - { - // Get a list of invalid path characters. - array^ invalidPathChars = Path::GetInvalidPathChars(); - - Console::WriteLine("The following characters are invalid in a path:"); - ShowChars(invalidPathChars); - Console::WriteLine(); - - // Get a list of invalid file characters. - array^ invalidFileChars = Path::GetInvalidFileNameChars(); - - Console::WriteLine("The following characters are invalid in a filename:"); - ShowChars(invalidFileChars); - } - - static void ShowChars(array^ charArray) - { - Console::WriteLine("Char\tHex Value"); - // Display each invalid character to the console. - for each (Char someChar in charArray) - { - if (Char::IsWhiteSpace(someChar)) - { - Console::WriteLine(",\t{0:X4}", (Int16)someChar); - } - else - { - Console::WriteLine("{0:c},\t{1:X4}", someChar, (Int16)someChar); - } - } - } - }; -}; - -int main() -{ - PathExample::GetCharExample::Main(); -} -// Note: Some characters may not be displayable on the console. -// The output will look something like: -// -// The following characters are invalid in a path: -// Char Hex Value -// ", 0022 -// <, 003C -// >, 003E -// |, 007C -// ... -// -// The following characters are invalid in a filename: -// Char Hex Value -// ", 0022 -// <, 003C -// >, 003E -// |, 007C -// ... -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/IO.Ports.GetPortNames/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/IO.Ports.GetPortNames/cpp/example.cpp deleted file mode 100644 index 47d43906d84..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.Ports.GetPortNames/cpp/example.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO::Ports; -using namespace System::ComponentModel; - -void main() -{ - array^ serialPorts = nullptr; - try - { - // Get a list of serial port names. - serialPorts = SerialPort::GetPortNames(); - } - catch (Win32Exception^ ex) - { - Console::WriteLine(ex->Message); - } - - Console::WriteLine("The following serial ports were found:"); - - // Display each port name to the console. - for each(String^ port in serialPorts) - { - Console::WriteLine(port); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp deleted file mode 100644 index 8997b4e85f5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp +++ /dev/null @@ -1,220 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Collections::ObjectModel; - -// This class represents a simple line item in an order. All the -// values are immutable except quantity. -// -public ref class OrderItem -{ -private: - int _quantity; - -public: - initonly int PartNumber; - initonly String^ Description; - initonly double UnitPrice; - - OrderItem(int partNumber, String^ description, - int quantity, double unitPrice) - { - this->PartNumber = partNumber; - this->Description = description; - this->Quantity = quantity; - this->UnitPrice = unitPrice; - } - - property int Quantity - { - int get() { return _quantity; } - void set(int value) - { - if (value < 0) - throw gcnew ArgumentException("Quantity cannot be negative."); - - _quantity = value; - } - } - - virtual String^ ToString() override - { - return String::Format( - "{0,9} {1,6} {2,-12} at {3,8:#,###.00} = {4,10:###,###.00}", - PartNumber, _quantity, Description, UnitPrice, - UnitPrice * _quantity); - } -}; - -// This class represents a very simple keyed list of OrderItems, -// inheriting most of its behavior from the KeyedCollection and -// Collection classes. The immediate base class is the constructed -// type KeyedCollection. When you inherit -// from KeyedCollection, the second generic type argument is the -// type that you want to store in the collection -- in this case -// OrderItem. The first type argument is the type that you want -// to use as a key. Its values must be calculated from OrderItem; -// in this case it is the int field PartNumber, so SimpleOrder -// inherits KeyedCollection. -// -public ref class SimpleOrder : KeyedCollection -{ - // The parameterless constructor of the base class creates a - // KeyedCollection with an internal dictionary. For this code - // example, no other constructors are exposed. - // -public: - SimpleOrder() {} - - // This is the only method that absolutely must be overridden, - // because without it the KeyedCollection cannot extract the - // keys from the items. The input parameter type is the - // second generic type argument, in this case OrderItem, and - // the return value type is the first generic type argument, - // in this case int. - // -protected: - virtual int GetKeyForItem(OrderItem^ item) override - { - // In this example, the key is the part number. - return item->PartNumber; - } -}; - -public ref class Demo -{ -public: - static void Main() - { - SimpleOrder^ weekly = gcnew SimpleOrder(); - - // The Add method, inherited from Collection, takes OrderItem. - // - weekly->Add(gcnew OrderItem(110072674, "Widget", 400, 45.17)); - weekly->Add(gcnew OrderItem(110072675, "Sprocket", 27, 5.3)); - weekly->Add(gcnew OrderItem(101030411, "Motor", 10, 237.5)); - weekly->Add(gcnew OrderItem(110072684, "Gear", 175, 5.17)); - - Display(weekly); - - // The Contains method of KeyedCollection takes the key, - // type, in this case int. - // - Console::WriteLine("\nContains(101030411): {0}", - weekly->Contains(101030411)); - - // The default Item property of KeyedCollection takes a key. - // - Console::WriteLine("\nweekly(101030411)->Description: {0}", - weekly[101030411]->Description); - - // The Remove method of KeyedCollection takes a key. - // - Console::WriteLine("\nRemove(101030411)"); - weekly->Remove(101030411); - Display(weekly); - - // The Insert method, inherited from Collection, takes an - // index and an OrderItem. - // - Console::WriteLine("\nInsert(2, New OrderItem(...))"); - weekly->Insert(2, gcnew OrderItem(111033401, "Nut", 10, .5)); - Display(weekly); - - // The default Item property is overloaded. One overload comes - // from KeyedCollection; that overload - // is read-only, and takes Integer because it retrieves by key. - // The other overload comes from Collection, the - // base class of KeyedCollection; it - // retrieves by index, so it also takes an Integer. The compiler - // uses the most-derived overload, from KeyedCollection, so the - // only way to access SimpleOrder by index is to cast it to - // Collection. Otherwise the index is interpreted - // as a key, and KeyNotFoundException is thrown. - // - Collection^ coweekly = weekly; - Console::WriteLine("\ncoweekly[2].Description: {0}", - coweekly[2]->Description); - - Console::WriteLine("\ncoweekly[2] = gcnew OrderItem(...)"); - coweekly[2] = gcnew OrderItem(127700026, "Crank", 27, 5.98); - - OrderItem^ temp = coweekly[2]; - - // The IndexOf method inherited from Collection - // takes an OrderItem instead of a key - // - Console::WriteLine("\nIndexOf(temp): {0}", weekly->IndexOf(temp)); - - // The inherited Remove method also takes an OrderItem. - // - Console::WriteLine("\nRemove(temp)"); - weekly->Remove(temp); - Display(weekly); - - Console::WriteLine("\nRemoveAt(0)"); - weekly->RemoveAt(0); - Display(weekly); - - } - -private: - static void Display(SimpleOrder^ order) - { - Console::WriteLine(); - for each( OrderItem^ item in order ) - { - Console::WriteLine(item); - } - } -}; - -void main() -{ - Demo::Main(); -} - -/* This code example produces the following output: - -110072674 400 Widget at 45.17 = 18,068.00 -110072675 27 Sprocket at 5.30 = 143.10 -101030411 10 Motor at 237.50 = 2,375.00 -110072684 175 Gear at 5.17 = 904.75 - -Contains(101030411): True - -weekly(101030411)->Description: Motor - -Remove(101030411) - -110072674 400 Widget at 45.17 = 18,068.00 -110072675 27 Sprocket at 5.30 = 143.10 -110072684 175 Gear at 5.17 = 904.75 - -Insert(2, New OrderItem(...)) - -110072674 400 Widget at 45.17 = 18,068.00 -110072675 27 Sprocket at 5.30 = 143.10 -111033401 10 Nut at .50 = 5.00 -110072684 175 Gear at 5.17 = 904.75 - -coweekly(2)->Description: Nut - -coweekly[2] = gcnew OrderItem(...) - -IndexOf(temp): 2 - -Remove(temp) - -110072674 400 Widget at 45.17 = 18,068.00 -110072675 27 Sprocket at 5.30 = 143.10 -110072684 175 Gear at 5.17 = 904.75 - -RemoveAt(0) - -110072675 27 Sprocket at 5.30 = 143.10 -110072684 175 Gear at 5.17 = 904.75 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp deleted file mode 100644 index 37225c227f3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp +++ /dev/null @@ -1,341 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Collections::ObjectModel; - -public enum class ChangeTypes -{ - Added, - Removed, - Replaced, - Cleared -}; - -ref class SimpleOrderChangedEventArgs; - -// This class represents a simple line item in an order. All the -// values are immutable except quantity. -// -public ref class OrderItem -{ -private: - int _quantity; - -public: - initonly int PartNumber; - initonly String^ Description; - initonly double UnitPrice; - - OrderItem(int partNumber, String^ description, int quantity, - double unitPrice) - { - this->PartNumber = partNumber; - this->Description = description; - this->Quantity = quantity; - this->UnitPrice = unitPrice; - }; - - property int Quantity - { - int get() { return _quantity; }; - void set(int value) - { - if (value < 0) - throw gcnew ArgumentException("Quantity cannot be negative."); - - _quantity = value; - }; - }; - - virtual String^ ToString() override - { - return String::Format( - "{0,9} {1,6} {2,-12} at {3,8:#,###.00} = {4,10:###,###.00}", - PartNumber, _quantity, Description, UnitPrice, - UnitPrice * _quantity); - }; -}; - -// Event argument for the Changed event. -// -public ref class SimpleOrderChangedEventArgs : EventArgs -{ -public: - OrderItem^ ChangedItem; - initonly ChangeTypes ChangeType; - OrderItem^ ReplacedWith; - - SimpleOrderChangedEventArgs(ChangeTypes change, - OrderItem^ item, OrderItem^ replacement) - { - this->ChangeType = change; - this->ChangedItem = item; - this->ReplacedWith = replacement; - } -}; - -// This class derives from KeyedCollection and shows how to override -// the protected ClearItems, InsertItem, RemoveItem, and SetItem -// methods in order to change the behavior of the default Item -// property and the Add, Clear, Insert, and Remove methods. The -// class implements a Changed event, which is raised by all the -// protected methods. -// -// SimpleOrder is a collection of OrderItem objects, and its key -// is the PartNumber field of OrderItem-> PartNumber is an Integer, -// so SimpleOrder inherits KeyedCollection. -// (Note that the key of OrderItem cannot be changed; if it could -// be changed, SimpleOrder would have to override ChangeItemKey.) -// -public ref class SimpleOrder : KeyedCollection -{ -public: - event EventHandler^ Changed; - - // This parameterless constructor calls the base class constructor - // that specifies a dictionary threshold of 0, so that the internal - // dictionary is created as soon as an item is added to the - // collection. - // - SimpleOrder() : KeyedCollection(nullptr, 0) {}; - - // This is the only method that absolutely must be overridden, - // because without it the KeyedCollection cannot extract the - // keys from the items. - // -protected: - virtual int GetKeyForItem(OrderItem^ item) override - { - // In this example, the key is the part number. - return item->PartNumber; - } - - virtual void InsertItem(int index, OrderItem^ newItem) override - { - __super::InsertItem(index, newItem); - - Changed(this, gcnew SimpleOrderChangedEventArgs( - ChangeTypes::Added, newItem, nullptr)); - } - - // - virtual void SetItem(int index, OrderItem^ newItem) override - { - OrderItem^ replaced = this->Items[index]; - __super::SetItem(index, newItem); - - Changed(this, gcnew SimpleOrderChangedEventArgs( - ChangeTypes::Replaced, replaced, newItem)); - } - // - - virtual void RemoveItem(int index) override - { - OrderItem^ removedItem = Items[index]; - __super::RemoveItem(index); - - Changed(this, gcnew SimpleOrderChangedEventArgs( - ChangeTypes::Removed, removedItem, nullptr)); - } - - virtual void ClearItems() override - { - __super::ClearItems(); - - Changed(this, gcnew SimpleOrderChangedEventArgs( - ChangeTypes::Cleared, nullptr, nullptr)); - } - - // - // This method uses the internal reference to the dictionary - // to test fo -public: - void AddOrMerge(OrderItem^ newItem) - { - - int key = this->GetKeyForItem(newItem); - OrderItem^ existingItem = nullptr; - - // The dictionary is not created until the first item is - // added, so it is necessary to test for null. Using - // AndAlso ensures that TryGetValue is not called if the - // dictionary does not exist. - // - if (this->Dictionary != nullptr && - this->Dictionary->TryGetValue(key, existingItem)) - { - existingItem->Quantity += newItem->Quantity; - } - else - { - this->Add(newItem); - } - } - // -}; - -public ref class Demo -{ -public: - static void Main() - { - SimpleOrder^ weekly = gcnew SimpleOrder(); - weekly->Changed += gcnew - EventHandler(ChangedHandler); - - // The Add method, inherited from Collection, takes OrderItem-> - // - weekly->Add(gcnew OrderItem(110072674, "Widget", 400, 45.17)); - weekly->Add(gcnew OrderItem(110072675, "Sprocket", 27, 5.3)); - weekly->Add(gcnew OrderItem(101030411, "Motor", 10, 237.5)); - weekly->Add(gcnew OrderItem(110072684, "Gear", 175, 5.17)); - - Display(weekly); - - // The Contains method of KeyedCollection takes TKey. - // - Console::WriteLine("\nContains(101030411): {0}", - weekly->Contains(101030411)); - - // The default Item property of KeyedCollection takes the key - // type, Integer. The property is read-only. - // - Console::WriteLine("\nweekly[101030411]->Description: {0}", - weekly[101030411]->Description); - - // The Remove method of KeyedCollection takes a key. - // - Console::WriteLine("\nRemove(101030411)"); - weekly->Remove(101030411); - - // The Insert method, inherited from Collection, takes an - // index and an OrderItem. - // - Console::WriteLine("\nInsert(2, gcnew OrderItem(...))"); - weekly->Insert(2, gcnew OrderItem(111033401, "Nut", 10, .5)); - - // The default Item property is overloaded. One overload comes - // from KeyedCollection; that overload - // is read-only, and takes Integer because it retrieves by key. - // The other overload comes from Collection, the - // base class of KeyedCollection; it - // retrieves by index, so it also takes an Integer. The compiler - // uses the most-derived overload, from KeyedCollection, so the - // only way to access SimpleOrder by index is to cast it to - // Collection. Otherwise the index is interpreted - // as a key, and KeyNotFoundException is thrown. - // - Collection^ coweekly = weekly; - Console::WriteLine("\ncoweekly[2].Description: {0}", - coweekly[2]->Description); - - Console::WriteLine("\ncoweekly[2] = gcnew OrderItem(...)"); - coweekly[2] = gcnew OrderItem(127700026, "Crank", 27, 5.98); - - OrderItem^ temp = coweekly[2]; - - // The IndexOf method, inherited from Collection, - // takes an OrderItem instead of a key. - // - Console::WriteLine("\nIndexOf(temp): {0}", weekly->IndexOf(temp)); - - // The inherited Remove method also takes an OrderItem-> - // - Console::WriteLine("\nRemove(temp)"); - weekly->Remove(temp); - - Console::WriteLine("\nRemoveAt(0)"); - weekly->RemoveAt(0); - - weekly->AddOrMerge(gcnew OrderItem(110072684, "Gear", 1000, 5.17)); - - Display(weekly); - - Console::WriteLine(); - weekly->Clear(); - } - -private: - static void Display(SimpleOrder^ order) - { - Console::WriteLine(); - for each( OrderItem^ item in order ) - { - Console::WriteLine(item); - } - } - - static void ChangedHandler(Object^ source, - SimpleOrderChangedEventArgs^ e) - { - OrderItem^ item = e->ChangedItem; - - if (e->ChangeType == ChangeTypes::Replaced) - { - OrderItem^ replacement = e->ReplacedWith; - - Console::WriteLine("{0} (quantity {1}) was replaced " + - "by {2}, (quantity {3}).", item->Description, - item->Quantity, replacement->Description, - replacement->Quantity); - } - else if(e->ChangeType == ChangeTypes::Cleared) - { - Console::WriteLine("The order list was cleared."); - } - else - { - Console::WriteLine("{0} (quantity {1}) was {2}.", - item->Description, item->Quantity, e->ChangeType); - } - } -}; - -void main() -{ - Demo::Main(); -} - -/* This code example produces the following output: - -Widget (quantity 400) was Added. -Sprocket (quantity 27) was Added. -Motor (quantity 10) was Added. -Gear (quantity 175) was Added. - -110072674 400 Widget at 45.17 = 18,068.00 -110072675 27 Sprocket at 5.30 = 143.10 -101030411 10 Motor at 237.50 = 2,375.00 -110072684 175 Gear at 5.17 = 904.75 - -Contains(101030411): True - -weekly[101030411]->Description: Motor - -Remove(101030411) -Motor (quantity 10) was Removed. - -Insert(2, gcnew OrderItem(...)) -Nut (quantity 10) was Added. - -coweekly[2].Description: Nut - -coweekly[2] = gcnew OrderItem(...) -Nut (quantity 10) was replaced by Crank, (quantity 27). - -IndexOf(temp): 2 - -Remove(temp) -Crank (quantity 27) was Removed. - -RemoveAt(0) -Widget (quantity 400) was Removed. - -110072675 27 Sprocket at 5.30 = 143.10 -110072684 1175 Gear at 5.17 = 6,074.75 - -The order list was cleared. - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_AsReadOnly/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_AsReadOnly/cpp/source.cpp deleted file mode 100644 index 8fb5233f28b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_AsReadOnly/cpp/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ - List^ dinosaurs = gcnew List(4); - - Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity); - - dinosaurs->Add("Tyrannosaurus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Mamenchisaurus"); - dinosaurs->Add("Deinonychus"); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nIList^ roDinosaurs = dinosaurs->AsReadOnly()"); - IList^ roDinosaurs = dinosaurs->AsReadOnly(); - - Console::WriteLine("\nElements in the read-only IList:"); - for each(String^ dinosaur in roDinosaurs) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\ndinosaurs[2] = \"Coelophysis\""); - dinosaurs[2] = "Coelophysis"; - - Console::WriteLine("\nElements in the read-only IList:"); - for each(String^ dinosaur in roDinosaurs) - { - Console::WriteLine(dinosaur); - } -} - -/* This code example produces the following output: - -Capacity: 4 - -Tyrannosaurus -Amargasaurus -Mamenchisaurus -Deinonychus - -IList^ roDinosaurs = dinosaurs->AsReadOnly() - -Elements in the read-only IList: -Tyrannosaurus -Amargasaurus -Mamenchisaurus -Deinonychus - -dinosaurs[2] = "Coelophysis" - -Elements in the read-only IList: -Tyrannosaurus -Amargasaurus -Coelophysis -Deinonychus - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp deleted file mode 100644 index df52855da1d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ - List^ dinosaurs = gcnew List(); - - Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity); - - dinosaurs->Add("Tyrannosaurus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Mamenchisaurus"); - dinosaurs->Add("Deinonychus"); - dinosaurs->Add("Compsognathus"); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity); - Console::WriteLine("Count: {0}", dinosaurs->Count); - - Console::WriteLine("\nContains(\"Deinonychus\"): {0}", - dinosaurs->Contains("Deinonychus")); - - Console::WriteLine("\nInsert(2, \"Compsognathus\")"); - dinosaurs->Insert(2, "Compsognathus"); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\ndinosaurs[3]: {0}", dinosaurs[3]); - - Console::WriteLine("\nRemove(\"Compsognathus\")"); - dinosaurs->Remove("Compsognathus"); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - dinosaurs->TrimExcess(); - Console::WriteLine("\nTrimExcess()"); - Console::WriteLine("Capacity: {0}", dinosaurs->Capacity); - Console::WriteLine("Count: {0}", dinosaurs->Count); - - dinosaurs->Clear(); - Console::WriteLine("\nClear()"); - Console::WriteLine("Capacity: {0}", dinosaurs->Capacity); - Console::WriteLine("Count: {0}", dinosaurs->Count); -} - -/* This code example produces the following output: - -Capacity: 0 - -Tyrannosaurus -Amargasaurus -Mamenchisaurus -Deinonychus -Compsognathus - -Capacity: 8 -Count: 5 - -Contains("Deinonychus"): True - -Insert(2, "Compsognathus") - -Tyrannosaurus -Amargasaurus -Compsognathus -Mamenchisaurus -Deinonychus -Compsognathus - -dinosaurs[3]: Mamenchisaurus - -Remove("Compsognathus") - -Tyrannosaurus -Amargasaurus -Mamenchisaurus -Deinonychus -Compsognathus - -TrimExcess() -Capacity: 5 -Count: 5 - -Clear() -Capacity: 5 -Count: 0 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_ConvertAll/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_ConvertAll/cpp/source.cpp deleted file mode 100644 index eb95c6a9af7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_ConvertAll/cpp/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Drawing; -using namespace System::Collections::Generic; - -Point PointFToPoint(PointF pf) -{ - return Point((int) pf.X, (int) pf.Y); -}; - -void main() -{ - List^ lpf = gcnew List(); - - lpf->Add(PointF(27.8F, 32.62F)); - lpf->Add(PointF(99.3F, 147.273F)); - lpf->Add(PointF(7.5F, 1412.2F)); - - Console::WriteLine(); - for each(PointF p in lpf) - { - Console::WriteLine(p); - } - - List^ lp = - lpf->ConvertAll( - gcnew Converter(PointFToPoint) - ); - - Console::WriteLine(); - for each(Point p in lp) - { - Console::WriteLine(p); - } -} - -/* This code example produces the following output: - -{X=27.8, Y=32.62} -{X=99.3, Y=147.273} -{X=7.5, Y=1412.2} - -{X=27,Y=32} -{X=99,Y=147} -{X=7,Y=1412} - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_CopyTo/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_CopyTo/cpp/source.cpp deleted file mode 100644 index ce250927500..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_CopyTo/cpp/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ - List^ dinosaurs = gcnew List(); - - dinosaurs->Add("Tyrannosaurus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Mamenchisaurus"); - dinosaurs->Add("Brachiosaurus"); - dinosaurs->Add("Compsognathus"); - - Console::WriteLine(); - for each(String^ dinosaurs in dinosaurs ) - { - Console::WriteLine(dinosaurs); - } - - // Create an array of 15 strings. - array^ arr = gcnew array(15); - - dinosaurs->CopyTo(arr); - dinosaurs->CopyTo(arr, 6); - dinosaurs->CopyTo(2, arr, 12, 3); - - Console::WriteLine("\nContents of the array:"); - for each(String^ dinosaurs in arr ) - { - Console::WriteLine(dinosaurs); - } -} - -/* This code example produces the following output: - -Tyrannosaurus -Amargasaurus -Mamenchisaurus -Brachiosaurus -Deinonychus -Tyrannosaurus -Compsognathus - -IndexOf("Tyrannosaurus"): 0 - -IndexOf("Tyrannosaurus", 3): 5 - -IndexOf("Tyrannosaurus", 2, 2): -1 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_FindEtAl/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_FindEtAl/cpp/source.cpp deleted file mode 100644 index d4033713e6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_FindEtAl/cpp/source.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -// Search predicate returns true if a string ends in "saurus". -bool EndsWithSaurus(String^ s) -{ - return s->ToLower()->EndsWith("saurus"); -}; - -void main() -{ - List^ dinosaurs = gcnew List(); - - dinosaurs->Add("Compsognathus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Oviraptor"); - dinosaurs->Add("Velociraptor"); - dinosaurs->Add("Deinonychus"); - dinosaurs->Add("Dilophosaurus"); - dinosaurs->Add("Gallimimus"); - dinosaurs->Add("Triceratops"); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nTrueForAll(EndsWithSaurus): {0}", - dinosaurs->TrueForAll(gcnew Predicate(EndsWithSaurus))); - - Console::WriteLine("\nFind(EndsWithSaurus): {0}", - dinosaurs->Find(gcnew Predicate(EndsWithSaurus))); - - Console::WriteLine("\nFindLast(EndsWithSaurus): {0}", - dinosaurs->FindLast(gcnew Predicate(EndsWithSaurus))); - - Console::WriteLine("\nFindAll(EndsWithSaurus):"); - List^ sublist = - dinosaurs->FindAll(gcnew Predicate(EndsWithSaurus)); - - for each(String^ dinosaur in sublist) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine( - "\n{0} elements removed by RemoveAll(EndsWithSaurus).", - dinosaurs->RemoveAll(gcnew Predicate(EndsWithSaurus))); - - Console::WriteLine("\nList now contains:"); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nExists(EndsWithSaurus): {0}", - dinosaurs->Exists(gcnew Predicate(EndsWithSaurus))); -} - -/* This code example produces the following output: - -Compsognathus -Amargasaurus -Oviraptor -Velociraptor -Deinonychus -Dilophosaurus -Gallimimus -Triceratops - -TrueForAll(EndsWithSaurus): False - -Find(EndsWithSaurus): Amargasaurus - -FindLast(EndsWithSaurus): Dilophosaurus - -FindAll(EndsWithSaurus): -Amargasaurus -Dilophosaurus - -2 elements removed by RemoveAll(EndsWithSaurus). - -List now contains: -Compsognathus -Oviraptor -Velociraptor -Deinonychus -Gallimimus -Triceratops - -Exists(EndsWithSaurus): False - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_IndexOf/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_IndexOf/cpp/source.cpp deleted file mode 100644 index 6ca3a08037e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_IndexOf/cpp/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ - List^ dinosaurs = gcnew List(); - - dinosaurs->Add("Tyrannosaurus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Mamenchisaurus"); - dinosaurs->Add("Brachiosaurus"); - dinosaurs->Add("Deinonychus"); - dinosaurs->Add("Tyrannosaurus"); - dinosaurs->Add("Compsognathus"); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nIndexOf(\"Tyrannosaurus\"): {0}", - dinosaurs->IndexOf("Tyrannosaurus")); - - Console::WriteLine("\nIndexOf(\"Tyrannosaurus\", 3): {0}", - dinosaurs->IndexOf("Tyrannosaurus", 3)); - - Console::WriteLine("\nIndexOf(\"Tyrannosaurus\", 2, 2): {0}", - dinosaurs->IndexOf("Tyrannosaurus", 2, 2)); -} - -/* This code example produces the following output: - -Tyrannosaurus -Amargasaurus -Mamenchisaurus -Brachiosaurus -Deinonychus -Tyrannosaurus -Compsognathus - -IndexOf("Tyrannosaurus"): 0 - -IndexOf("Tyrannosaurus", 3): 5 - -IndexOf("Tyrannosaurus", 2, 2): -1 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp deleted file mode 100644 index c6ffc2e2707..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ - List^ dinosaurs = gcnew List(); - - dinosaurs->Add("Tyrannosaurus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Mamenchisaurus"); - dinosaurs->Add("Brachiosaurus"); - dinosaurs->Add("Deinonychus"); - dinosaurs->Add("Tyrannosaurus"); - dinosaurs->Add("Compsognathus"); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nLastIndexOf(\"Tyrannosaurus\"): {0}", - dinosaurs->LastIndexOf("Tyrannosaurus")); - - Console::WriteLine("\nLastIndexOf(\"Tyrannosaurus\", 3): {0}", - dinosaurs->LastIndexOf("Tyrannosaurus", 3)); - - Console::WriteLine("\nLastIndexOf(\"Tyrannosaurus\", 4, 4): {0}", - dinosaurs->LastIndexOf("Tyrannosaurus", 4, 4)); -} - -/* This code example produces the following output: - -Tyrannosaurus -Amargasaurus -Mamenchisaurus -Brachiosaurus -Deinonychus -Tyrannosaurus -Compsognathus - -LastIndexOf("Tyrannosaurus"): 5 - -LastIndexOf("Tyrannosaurus", 3): 0 - -LastIndexOf("Tyrannosaurus", 4, 4): -1 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp deleted file mode 100644 index fbee67ad25b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ - array^ input = { "Brachiosaurus", - "Amargasaurus", - "Mamenchisaurus" }; - - List^ dinosaurs = - gcnew List((IEnumerable^) input); - - Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nAddRange(dinosaurs)"); - dinosaurs->AddRange(dinosaurs); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nRemoveRange(2, 2)"); - dinosaurs->RemoveRange(2, 2); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - input = gcnew array { "Tyrannosaurus", - "Deinonychus", - "Velociraptor"}; - - Console::WriteLine("\nInsertRange(3, (IEnumerable^) input)"); - dinosaurs->InsertRange(3, (IEnumerable^) input); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\noutput = dinosaurs->GetRange(2, 3)->ToArray()"); - array^ output = dinosaurs->GetRange(2, 3)->ToArray(); - - Console::WriteLine(); - for each(String^ dinosaur in output ) - { - Console::WriteLine(dinosaur); - } -} - -/* This code example produces the following output: - -Capacity: 3 - -Brachiosaurus -Amargasaurus -Mamenchisaurus - -AddRange(dinosaurs) - -Brachiosaurus -Amargasaurus -Mamenchisaurus -Brachiosaurus -Amargasaurus -Mamenchisaurus - -RemoveRange(2, 2) - -Brachiosaurus -Amargasaurus -Amargasaurus -Mamenchisaurus - -InsertRange(3, (IEnumerable^) input) - -Brachiosaurus -Amargasaurus -Amargasaurus -Tyrannosaurus -Deinonychus -Velociraptor -Mamenchisaurus - -output = dinosaurs->GetRange(2, 3)->ToArray() - -Amargasaurus -Tyrannosaurus -Deinonychus - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_Reverse/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_Reverse/cpp/source.cpp deleted file mode 100644 index 71c584db785..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_Reverse/cpp/source.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ - List^ dinosaurs = gcnew List(); - - dinosaurs->Add("Pachycephalosaurus"); - dinosaurs->Add("Parasauralophus"); - dinosaurs->Add("Mamenchisaurus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Coelophysis"); - dinosaurs->Add("Oviraptor"); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - dinosaurs->Reverse(); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - dinosaurs->Reverse(1, 4); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } -} - -/* This code example produces the following output: - -Pachycephalosaurus -Parasauralophus -Mamenchisaurus -Amargasaurus -Coelophysis -Oviraptor - -Oviraptor -Coelophysis -Amargasaurus -Mamenchisaurus -Parasauralophus -Pachycephalosaurus - -Oviraptor -Parasauralophus -Mamenchisaurus -Amargasaurus -Coelophysis -Pachycephalosaurus - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_SortComparison/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_SortComparison/cpp/source.cpp deleted file mode 100644 index 4ae53587c2f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_SortComparison/cpp/source.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -int CompareDinosByLength(String^ x, String^ y) -{ - if (x == nullptr) - { - if (y == nullptr) - { - // If x is null and y is null, they're - // equal. - return 0; - } - else - { - // If x is null and y is not null, y - // is greater. - return -1; - } - } - else - { - // If x is not null... - // - if (y == nullptr) - // ...and y is null, x is greater. - { - return 1; - } - else - { - // ...and y is not null, compare the - // lengths of the two strings. - // - int retval = x->Length.CompareTo(y->Length); - - if (retval != 0) - { - // If the strings are not of equal length, - // the longer string is greater. - // - return retval; - } - else - { - // If the strings are of equal length, - // sort them with ordinary string comparison. - // - return x->CompareTo(y); - } - } - } -}; - -void Display(List^ list) -{ - Console::WriteLine(); - for each(String^ s in list) - { - if (s == nullptr) - Console::WriteLine("(null)"); - else - Console::WriteLine("\"{0}\"", s); - } -}; - -void main() -{ - List^ dinosaurs = gcnew List(); - dinosaurs->Add("Pachycephalosaurus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add(""); - dinosaurs->Add(nullptr); - dinosaurs->Add("Mamenchisaurus"); - dinosaurs->Add("Deinonychus"); - Display(dinosaurs); - - Console::WriteLine("\nSort with generic Comparison delegate:"); - dinosaurs->Sort( - gcnew Comparison(CompareDinosByLength)); - Display(dinosaurs); - -} - -/* This code example produces the following output: - -"Pachycephalosaurus" -"Amargasaurus" -"" -(null) -"Mamenchisaurus" -"Deinonychus" - -Sort with generic Comparison delegate: - -(null) -"" -"Deinonychus" -"Amargasaurus" -"Mamenchisaurus" -"Pachycephalosaurus" - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearch/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_SortSearch/cpp/source.cpp deleted file mode 100644 index e37961290a5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearch/cpp/source.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ - List^ dinosaurs = gcnew List(); - - dinosaurs->Add("Pachycephalosaurus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Mamenchisaurus"); - dinosaurs->Add("Deinonychus"); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nSort"); - dinosaurs->Sort(); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nBinarySearch and Insert \"Coelophysis\":"); - int index = dinosaurs->BinarySearch("Coelophysis"); - if (index < 0) - { - dinosaurs->Insert(~index, "Coelophysis"); - } - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nBinarySearch and Insert \"Tyrannosaurus\":"); - index = dinosaurs->BinarySearch("Tyrannosaurus"); - if (index < 0) - { - dinosaurs->Insert(~index, "Tyrannosaurus"); - } - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } -} - -/* This code example produces the following output: - -Pachycephalosaurus -Amargasaurus -Mamenchisaurus -Deinonychus - -Sort - -Amargasaurus -Deinonychus -Mamenchisaurus -Pachycephalosaurus - -BinarySearch and Insert "Coelophysis": - -Amargasaurus -Coelophysis -Deinonychus -Mamenchisaurus -Pachycephalosaurus - -BinarySearch and Insert "Tyrannosaurus": - -Amargasaurus -Coelophysis -Deinonychus -Mamenchisaurus -Pachycephalosaurus -Tyrannosaurus - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparer/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparer/cpp/source.cpp deleted file mode 100644 index 396d3d9f86e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparer/cpp/source.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -public ref class DinoComparer: IComparer -{ -public: - virtual int Compare(String^ x, String^ y) - { - if (x == nullptr) - { - if (y == nullptr) - { - // If x is null and y is null, they're - // equal. - return 0; - } - else - { - // If x is null and y is not null, y - // is greater. - return -1; - } - } - else - { - // If x is not null... - // - if (y == nullptr) - // ...and y is null, x is greater. - { - return 1; - } - else - { - // ...and y is not null, compare the - // lengths of the two strings. - // - int retval = x->Length.CompareTo(y->Length); - - if (retval != 0) - { - // If the strings are not of equal length, - // the longer string is greater. - // - return retval; - } - else - { - // If the strings are of equal length, - // sort them with ordinary string comparison. - // - return x->CompareTo(y); - } - } - } - } -}; - -void SearchAndInsert(List^ list, String^ insert, - DinoComparer^ dc) -{ - Console::WriteLine("\nBinarySearch and Insert \"{0}\":", insert); - - int index = list->BinarySearch(insert, dc); - - if (index < 0) - { - list->Insert(~index, insert); - } -}; - -void Display(List^ list) -{ - Console::WriteLine(); - for each(String^ s in list) - { - Console::WriteLine(s); - } -}; - -void main() -{ - List^ dinosaurs = gcnew List(); - dinosaurs->Add("Pachycephalosaurus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Mamenchisaurus"); - dinosaurs->Add("Deinonychus"); - Display(dinosaurs); - - DinoComparer^ dc = gcnew DinoComparer(); - - Console::WriteLine("\nSort with alternate comparer:"); - dinosaurs->Sort(dc); - Display(dinosaurs); - - SearchAndInsert(dinosaurs, "Coelophysis", dc); - Display(dinosaurs); - - SearchAndInsert(dinosaurs, "Oviraptor", dc); - Display(dinosaurs); - - SearchAndInsert(dinosaurs, "Tyrannosaur", dc); - Display(dinosaurs); - - SearchAndInsert(dinosaurs, nullptr, dc); - Display(dinosaurs); -} - -/* This code example produces the following output: - -Pachycephalosaurus -Amargasaurus -Mamenchisaurus -Deinonychus - -Sort with alternate comparer: - -Deinonychus -Amargasaurus -Mamenchisaurus -Pachycephalosaurus - -BinarySearch and Insert "Coelophysis": - -Coelophysis -Deinonychus -Amargasaurus -Mamenchisaurus -Pachycephalosaurus - -BinarySearch and Insert "Oviraptor": - -Oviraptor -Coelophysis -Deinonychus -Amargasaurus -Mamenchisaurus -Pachycephalosaurus - -BinarySearch and Insert "Tyrannosaur": - -Oviraptor -Coelophysis -Deinonychus -Tyrannosaur -Amargasaurus -Mamenchisaurus -Pachycephalosaurus - -BinarySearch and Insert "": - - -Oviraptor -Coelophysis -Deinonychus -Tyrannosaur -Amargasaurus -Mamenchisaurus -Pachycephalosaurus - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparerRange/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparerRange/cpp/source.cpp deleted file mode 100644 index dbb74dd3f43..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparerRange/cpp/source.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -public ref class DinoComparer: IComparer -{ -public: - virtual int Compare(String^ x, String^ y) - { - if (x == nullptr) - { - if (y == nullptr) - { - // If x is null and y is null, they're - // equal. - return 0; - } - else - { - // If x is null and y is not null, y - // is greater. - return -1; - } - } - else - { - // If x is not null... - // - if (y == nullptr) - // ...and y is null, x is greater. - { - return 1; - } - else - { - // ...and y is not null, compare the - // lengths of the two strings. - // - int retval = x->Length.CompareTo(y->Length); - - if (retval != 0) - { - // If the strings are not of equal length, - // the longer string is greater. - // - return retval; - } - else - { - // If the strings are of equal length, - // sort them with ordinary string comparison. - // - return x->CompareTo(y); - } - } - } - } -}; - -void Display(List^ list) -{ - Console::WriteLine(); - for each(String^ s in list) - { - Console::WriteLine(s); - } -}; - -void main() -{ - List^ dinosaurs = gcnew List(); - - dinosaurs->Add("Pachycephalosaurus"); - dinosaurs->Add("Parasauralophus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Galimimus"); - dinosaurs->Add("Mamenchisaurus"); - dinosaurs->Add("Deinonychus"); - dinosaurs->Add("Oviraptor"); - dinosaurs->Add("Tyrannosaurus"); - - int herbivores = 5; - Display(dinosaurs); - - DinoComparer^ dc = gcnew DinoComparer(); - - Console::WriteLine("\nSort a range with the alternate comparer:"); - dinosaurs->Sort(0, herbivores, dc); - Display(dinosaurs); - - Console::WriteLine("\nBinarySearch a range and Insert \"{0}\":", - "Brachiosaurus"); - - int index = dinosaurs->BinarySearch(0, herbivores, "Brachiosaurus", dc); - - if (index < 0) - { - dinosaurs->Insert(~index, "Brachiosaurus"); - herbivores++; - } - - Display(dinosaurs); -} - -/* This code example produces the following output: - -Pachycephalosaurus -Parasauralophus -Amargasaurus -Galimimus -Mamenchisaurus -Deinonychus -Oviraptor -Tyrannosaurus - -Sort a range with the alternate comparer: - -Galimimus -Amargasaurus -Mamenchisaurus -Parasauralophus -Pachycephalosaurus -Deinonychus -Oviraptor -Tyrannosaurus - -BinarySearch a range and Insert "Brachiosaurus": - -Galimimus -Amargasaurus -Brachiosaurus -Mamenchisaurus -Parasauralophus -Pachycephalosaurus -Deinonychus -Oviraptor -Tyrannosaurus - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp b/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp deleted file mode 100644 index b45d3fbc13a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp +++ /dev/null @@ -1,331 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Threading; -using namespace System::Collections::Generic; -using namespace System::Text; - -generic public ref class SafeQueue -{ -private: - // - // - // A queue that is protected by Monitor. - Queue^ m_inputQueue; - // - -public: - SafeQueue() - { - m_inputQueue = gcnew Queue(); - }; - - // Lock the queue and add an element. - void Enqueue(T qValue) - { - // Request the lock, and block until it is obtained. - Monitor::Enter(m_inputQueue); - try - { - // When the lock is obtained, add an element. - m_inputQueue->Enqueue(qValue); - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - }; - // - - // - // Try to add an element to the queue: Add the element to the queue - // only if the lock is immediately available. - bool TryEnqueue(T qValue) - { - // Request the lock. - if (Monitor::TryEnter(m_inputQueue)) - { - try - { - m_inputQueue->Enqueue(qValue); - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - return true; - } - else - { - return false; - } - }; - // - - // - // Try to add an element to the queue: Add the element to the queue - // only if the lock becomes available during the specified time - // interval. - bool TryEnqueue(T qValue, int waitTime) - { - // Request the lock. - if (Monitor::TryEnter(m_inputQueue, waitTime)) - { - try - { - m_inputQueue->Enqueue(qValue); - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - return true; - } - else - { - return false; - } - }; - // - - // Lock the queue and dequeue an element. - T Dequeue() - { - T retval; - - // Request the lock, and block until it is obtained. - Monitor::Enter(m_inputQueue); - try - { - // When the lock is obtained, dequeue an element. - retval = m_inputQueue->Dequeue(); - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - - return retval; - }; - - // Delete all elements that equal the given object. - int Remove(T qValue) - { - int removedCt = 0; - - // Wait until the lock is available and lock the queue. - Monitor::Enter(m_inputQueue); - try - { - int counter = m_inputQueue->Count; - while (counter > 0) - // Check each element. - { - T elem = m_inputQueue->Dequeue(); - if (!elem->Equals(qValue)) - { - m_inputQueue->Enqueue(elem); - } - else - { - // Keep a count of items removed. - removedCt += 1; - } - counter = counter - 1; - } - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - - return removedCt; - }; - - // Print all queue elements. - String^ PrintAllElements() - { - StringBuilder^ output = gcnew StringBuilder(); - - // Lock the queue. - Monitor::Enter(m_inputQueue); - try - { - for each ( T elem in m_inputQueue ) - { - // Print the next element. - output->AppendLine(elem->ToString()); - } - } - finally - { - // Ensure that the lock is released. - Monitor::Exit(m_inputQueue); - } - - return output->ToString(); - }; -}; - -public ref class Example -{ -private: - static SafeQueue^ q = gcnew SafeQueue(); - static int threadsRunning = 0; - static array^>^ results = gcnew array^>(3); - - static void ThreadProc(Object^ state) - { - DateTime finish = DateTime::Now.AddSeconds(10); - Random^ rand = gcnew Random(); - array^ result = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - int threadNum = (int) state; - - while (DateTime::Now < finish) - - { - int what = rand->Next(250); - int how = rand->Next(100); - - if (how < 16) - { - q->Enqueue(what); - result[(int)ThreadResultIndex::EnqueueCt] += 1; - } - else if (how < 32) - { - if (q->TryEnqueue(what)) - { - result[(int)ThreadResultIndex::TryEnqueueSucceedCt] += 1; - } - else - { - result[(int)ThreadResultIndex::TryEnqueueFailCt] += 1; - } - } - else if (how < 48) - { - // Even a very small wait significantly increases the success - // rate of the conditional enqueue operation. - if (q->TryEnqueue(what, 10)) - { - result[(int)ThreadResultIndex::TryEnqueueWaitSucceedCt] += 1; - } - else - { - result[(int)ThreadResultIndex::TryEnqueueWaitFailCt] += 1; - } - } - else if (how < 96) - { - result[(int)ThreadResultIndex::DequeueCt] += 1; - try - { - q->Dequeue(); - } - catch (Exception^ ex) - { - result[(int)ThreadResultIndex::DequeueExCt] += 1; - } - } - else - { - result[(int)ThreadResultIndex::RemoveCt] += 1; - result[(int)ThreadResultIndex::RemovedCt] += q->Remove(what); - } - } - - results[threadNum] = result; - - if (0 == Interlocked::Decrement(threadsRunning)) - { - StringBuilder^ sb = gcnew StringBuilder( - " Thread 1 Thread 2 Thread 3 Total\n"); - - for (int row = 0; row < 9; row++) - { - int total = 0; - sb->Append(titles[row]); - - for(int col = 0; col < 3; col++) - { - sb->Append(String::Format("{0,9}", results[col][row])); - total += results[col][row]; - } - - sb->AppendLine(String::Format("{0,9}", total)); - } - - Console::WriteLine(sb->ToString()); - } - }; - - static array^ titles = { - "Enqueue ", - "TryEnqueue succeeded ", - "TryEnqueue failed ", - "TryEnqueue(T, wait) succeeded ", - "TryEnqueue(T, wait) failed ", - "Dequeue attempts ", - "Dequeue exceptions ", - "Remove operations ", - "Queue elements removed "}; - - enum class ThreadResultIndex - { - EnqueueCt, - TryEnqueueSucceedCt, - TryEnqueueFailCt, - TryEnqueueWaitSucceedCt, - TryEnqueueWaitFailCt, - DequeueCt, - DequeueExCt, - RemoveCt, - RemovedCt - }; - -public: - static void Demo() - { - Console::WriteLine("Working..."); - - for(int i = 0; i < 3; i++) - { - Thread^ t = gcnew Thread(gcnew ParameterizedThreadStart(Example::ThreadProc)); - t->Start(i); - Interlocked::Increment(threadsRunning); - } - }; -}; - -void main() -{ - Example::Demo(); -} - - -/* This example produces output similar to the following: - -Working... - Thread 1 Thread 2 Thread 3 Total -Enqueue 274718 513514 337895 1126127 -TryEnqueue succeeded 274502 513516 337480 1125498 -TryEnqueue failed 119 235 141 495 -TryEnqueue(T, wait) succeeded 274552 513116 338532 1126200 -TryEnqueue(T, wait) failed 0 1 0 1 -Dequeue attempts 824038 1541866 1015006 3380910 -Dequeue exceptions 12828 23416 14799 51043 -Remove operations 68746 128218 84306 281270 -Queue elements removed 11464 22024 14470 47958 -Queue elements removed 2921 4690 2982 10593 - */ -// - - - diff --git a/snippets/cpp/VS_Snippets_CLR/NumberDecimalDigits/CPP/numberdecimaldigits.cpp b/snippets/cpp/VS_Snippets_CLR/NumberDecimalDigits/CPP/numberdecimaldigits.cpp deleted file mode 100644 index 4836a5745f6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/NumberDecimalDigits/CPP/numberdecimaldigits.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// The following code example demonstrates the effect of changing the NumberDecimalDigits property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a negative value with the default number of decimal digits (2). - Int64 myInt = -1234; - Console::WriteLine( myInt.ToString( "N", nfi ) ); - - // Displays the same value with four decimal digits. - nfi->NumberDecimalDigits = 4; - Console::WriteLine( myInt.ToString( "N", nfi ) ); -} - -/* -This code produces the following output. --1, 234.00 --1, 234.0000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/NumberDecimalSeparator/CPP/numberdecimalseparator.cpp b/snippets/cpp/VS_Snippets_CLR/NumberDecimalSeparator/CPP/numberdecimalseparator.cpp deleted file mode 100644 index 3314e9eab5c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/NumberDecimalSeparator/CPP/numberdecimalseparator.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// The following code example demonstrates the effect of changing the -// NumberDecimalSeparator property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a value with the default separator (S"."). - Int64 myInt = 123456789; - Console::WriteLine( myInt.ToString( "N", nfi ) ); - - // Displays the same value with a blank as the separator. - nfi->NumberDecimalSeparator = " "; - Console::WriteLine( myInt.ToString( "N", nfi ) ); -} - -/* -This code produces the following output. -123, 456, 789.00 -123, 456, 789 00 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/NumberFormatInfo/cpp/NumberFormatInfo.cpp b/snippets/cpp/VS_Snippets_CLR/NumberFormatInfo/cpp/NumberFormatInfo.cpp deleted file mode 100644 index 8211f6d47a8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/NumberFormatInfo/cpp/NumberFormatInfo.cpp +++ /dev/null @@ -1,47 +0,0 @@ -//Types:System.Globalization.NumberFormatInfo -// -using namespace System; -using namespace System::Globalization; -using namespace System::Text; - -int main() -{ - StringBuilder^ builder = gcnew StringBuilder(); - - // Loop through all the specific cultures known to the CLR. - for each(CultureInfo^ culture in - CultureInfo::GetCultures (CultureTypes::SpecificCultures)) - { - // Only show the currency symbols for cultures - // that speak English. - if (culture->TwoLetterISOLanguageName == "en") - { - // - // Display the culture name and currency symbol. - NumberFormatInfo^ numberFormat = culture->NumberFormat; - builder->AppendFormat("The currency symbol for '{0}'"+ - "is '{1}'",culture->DisplayName, - numberFormat->CurrencySymbol); - builder->AppendLine(); - // - } - } - Console::WriteLine(builder); -} - -// This code produces the following output. -// -// The currency symbol for 'English (United States)' is '$' -// The currency symbol for 'English (United Kingdom)' is 'Ј' -// The currency symbol for 'English (Australia)' is '$' -// The currency symbol for 'English (Canada)' is '$' -// The currency symbol for 'English (New Zealand)' is '$' -// The currency symbol for 'English (Ireland)' is '?' -// The currency symbol for 'English (South Africa)' is 'R' -// The currency symbol for 'English (Jamaica)' is 'J$' -// The currency symbol for 'English (Caribbean)' is '$' -// The currency symbol for 'English (Belize)' is 'BZ$' -// The currency symbol for 'English (Trinidad and Tobago)' is 'TT$' -// The currency symbol for 'English (Zimbabwe)' is 'Z$' -// The currency symbol for 'English (Republic of the Philippines)' is 'Php' -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/NumberGroupSeparator/CPP/numbergroupseparator.cpp b/snippets/cpp/VS_Snippets_CLR/NumberGroupSeparator/CPP/numbergroupseparator.cpp deleted file mode 100644 index 96cb476c415..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/NumberGroupSeparator/CPP/numbergroupseparator.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// The following code example demonstrates the effect of changing the NumberGroupSeparator property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a value with the default separator (S", "). - Int64 myInt = 123456789; - Console::WriteLine( myInt.ToString( "N", nfi ) ); - - // Displays the same value with a blank as the separator. - nfi->NumberGroupSeparator = " "; - Console::WriteLine( myInt.ToString( "N", nfi ) ); -} - -/* -This code produces the following output. -123, 456, 789.00 -123 456 789.00 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/NumberGroupSizes/CPP/numbergroupsizes.cpp b/snippets/cpp/VS_Snippets_CLR/NumberGroupSizes/CPP/numbergroupsizes.cpp deleted file mode 100644 index f51cb7d8d13..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/NumberGroupSizes/CPP/numbergroupsizes.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// The following code example demonstrates the effect of changing the NumberGroupSizes property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a value with the default separator (S"."). - Int64 myInt = 123456789012345; - Console::WriteLine( myInt.ToString( "N", nfi ) ); - - // Displays the same value with different groupings. - array^mySizes1 = {2,3,4}; - array^mySizes2 = {2,3,0}; - nfi->NumberGroupSizes = mySizes1; - Console::WriteLine( myInt.ToString( "N", nfi ) ); - nfi->NumberGroupSizes = mySizes2; - Console::WriteLine( myInt.ToString( "N", nfi ) ); -} - -/* -This code produces the following output. -123, 456, 789, 012, 345.00 -12, 3456, 7890, 123, 45.00 -1234567890, 123, 45.00 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/NumberStyles/cpp/NumberStyles.cpp b/snippets/cpp/VS_Snippets_CLR/NumberStyles/cpp/NumberStyles.cpp deleted file mode 100644 index 5fe0650df9b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/NumberStyles/cpp/NumberStyles.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//Types:System.Globalization.NumberStyles (enum) -// -using namespace System; -using namespace System::Text; -using namespace System::Globalization; - - -int main() -{ - // Parse the string as a hex value and display the - // value as a decimal. - String^ numberString = "A"; - int stringValue = Int32::Parse(numberString, NumberStyles::HexNumber); - Console::WriteLine("{0} in hex = {1} in decimal.", - numberString, stringValue); - - // Parse the string, allowing a leading sign, and ignoring - // leading and trailing white spaces. - numberString = " -45 "; - stringValue =Int32::Parse(numberString, NumberStyles::AllowLeadingSign | - NumberStyles::AllowLeadingWhite | NumberStyles::AllowTrailingWhite); - Console::WriteLine("'{0}' parsed to an int is '{1}'.", - numberString, stringValue); - - // Parse the string, allowing parentheses, and ignoring - // leading and trailing white spaces. - numberString = " (37) "; - stringValue = Int32::Parse(numberString, NumberStyles::AllowParentheses | - NumberStyles::AllowLeadingSign | NumberStyles::AllowLeadingWhite | - NumberStyles::AllowTrailingWhite); - - Console::WriteLine("'{0}' parsed to an int is '{1}'.", - numberString, stringValue); -} - -// This code produces the following output. -// -// A in hex = 10 in decimal. -// ' -45 ' parsed to an int is '-45'. -// ' (37) ' parsed to an int is '-37'. -// diff --git a/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp deleted file mode 100644 index 75724099841..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Collections::ObjectModel; - -public ref class Demo -{ -public: - static void Main() - { - Collection^ dinosaurs = gcnew Collection(); - - dinosaurs->Add("Psitticosaurus"); - dinosaurs->Add("Caudipteryx"); - dinosaurs->Add("Compsognathus"); - dinosaurs->Add("Muttaburrasaurus"); - - Console::WriteLine("{0} dinosaurs:", dinosaurs->Count); - Display(dinosaurs); - - Console::WriteLine("\nIndexOf(\"Muttaburrasaurus\"): {0}", - dinosaurs->IndexOf("Muttaburrasaurus")); - - Console::WriteLine("\nContains(\"Caudipteryx\"): {0}", - dinosaurs->Contains("Caudipteryx")); - - Console::WriteLine("\nInsert(2, \"Nanotyrannus\")"); - dinosaurs->Insert(2, "Nanotyrannus"); - Display(dinosaurs); - - Console::WriteLine("\ndinosaurs[2]: {0}", dinosaurs[2]); - - Console::WriteLine("\ndinosaurs[2] = \"Microraptor\""); - dinosaurs[2] = "Microraptor"; - Display(dinosaurs); - - Console::WriteLine("\nRemove(\"Microraptor\")"); - dinosaurs->Remove("Microraptor"); - Display(dinosaurs); - - Console::WriteLine("\nRemoveAt(0)"); - dinosaurs->RemoveAt(0); - Display(dinosaurs); - - Console::WriteLine("\ndinosaurs.Clear()"); - dinosaurs->Clear(); - Console::WriteLine("Count: {0}", dinosaurs->Count); - } - -private: - static void Display(Collection^ cs) - { - Console::WriteLine(); - for each( String^ item in cs ) - { - Console::WriteLine(item); - } - } -}; - -int main() -{ - Demo::Main(); -} - -/* This code example produces the following output: - -4 dinosaurs: - -Psitticosaurus -Caudipteryx -Compsognathus -Muttaburrasaurus - -IndexOf("Muttaburrasaurus"): 3 - -Contains("Caudipteryx"): True - -Insert(2, "Nanotyrannus") - -Psitticosaurus -Caudipteryx -Nanotyrannus -Compsognathus -Muttaburrasaurus - -dinosaurs[2]: Nanotyrannus - -dinosaurs[2] = "Microraptor" - -Psitticosaurus -Caudipteryx -Microraptor -Compsognathus -Muttaburrasaurus - -Remove("Microraptor") - -Psitticosaurus -Caudipteryx -Compsognathus -Muttaburrasaurus - -RemoveAt(0) - -Caudipteryx -Compsognathus -Muttaburrasaurus - -dinosaurs.Clear() -Count: 0 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Path Class/CPP/path class.cpp b/snippets/cpp/VS_Snippets_CLR/Path Class/CPP/path class.cpp deleted file mode 100644 index 08709a04488..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Path Class/CPP/path class.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - String^ path1 = "c:\\temp\\MyTest.txt"; - String^ path2 = "c:\\temp\\MyTest"; - String^ path3 = "temp"; - if ( Path::HasExtension( path1 ) ) - { - Console::WriteLine( "{0} has an extension.", path1 ); - } - - if ( !Path::HasExtension( path2 ) ) - { - Console::WriteLine( "{0} has no extension.", path2 ); - } - - if ( !Path::IsPathRooted( path3 ) ) - { - Console::WriteLine( "The string {0} contains no root information.", path3 ); - } - - Console::WriteLine( "The full path of {0} is {1}.", path3, Path::GetFullPath( path3 ) ); - Console::WriteLine( "{0} is the location for temporary files.", Path::GetTempPath() ); - Console::WriteLine( "{0} is a file available for use.", Path::GetTempFileName() ); - Console::WriteLine( "\r\nThe set of invalid characters in a path is:" ); - Console::WriteLine( "(Note that the wildcard characters '*' and '?' are not invalid.):" ); - Collections::IEnumerator^ myEnum = Path::InvalidPathChars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = *safe_cast(myEnum->Current); - Console::WriteLine( c ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/PercentDecimalDigits/CPP/percentdecimaldigits.cpp b/snippets/cpp/VS_Snippets_CLR/PercentDecimalDigits/CPP/percentdecimaldigits.cpp deleted file mode 100644 index 331d7abbb90..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PercentDecimalDigits/CPP/percentdecimaldigits.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// The following code example demonstrates the effect of changing the PercentDecimalDigits property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a negative value with the default number of decimal digits (2). - Double myInt = 0.1234; - Console::WriteLine( myInt.ToString( "P", nfi ) ); - - // Displays the same value with four decimal digits. - nfi->PercentDecimalDigits = 4; - Console::WriteLine( myInt.ToString( "P", nfi ) ); -} - -/* -This code produces the following output. -12.34 % -12.3400 % -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/PercentDecimalSeparator/CPP/percentdecimalseparator.cpp b/snippets/cpp/VS_Snippets_CLR/PercentDecimalSeparator/CPP/percentdecimalseparator.cpp deleted file mode 100644 index de975569dfb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PercentDecimalSeparator/CPP/percentdecimalseparator.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// The following code example demonstrates the effect of changing the -// PercentDecimalSeparator property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a value with the default separator (S"."). - Double myInt = 0.1234; - Console::WriteLine( myInt.ToString( "P", nfi ) ); - - // Displays the same value with a blank as the separator. - nfi->PercentDecimalSeparator = " "; - Console::WriteLine( myInt.ToString( "P", nfi ) ); -} - -/* -This code produces the following output. -12.34 % -12 34 % -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/PercentGroupSeparator/CPP/percentgroupseparator.cpp b/snippets/cpp/VS_Snippets_CLR/PercentGroupSeparator/CPP/percentgroupseparator.cpp deleted file mode 100644 index 39d7c7a20ca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PercentGroupSeparator/CPP/percentgroupseparator.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// The following code example demonstrates the effect of changing the -// PercentGroupSeparator property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a value with the default separator (S", "). - Double myInt = 1234.5678; - Console::WriteLine( myInt.ToString( "P", nfi ) ); - - // Displays the same value with a blank as the separator. - nfi->PercentGroupSeparator = " "; - Console::WriteLine( myInt.ToString( "P", nfi ) ); -} - -/* -This code produces the following output. -123, 456.78 % -123 456.78 % -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/PercentGroupSizes/CPP/percentgroupsizes.cpp b/snippets/cpp/VS_Snippets_CLR/PercentGroupSizes/CPP/percentgroupsizes.cpp deleted file mode 100644 index 2edc2ec4edf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PercentGroupSizes/CPP/percentgroupsizes.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// The following code example demonstrates the effect of changing the PercentGroupSizes property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets a NumberFormatInfo associated with the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - NumberFormatInfo^ nfi = MyCI->NumberFormat; - - // Displays a value with the default separator (S"."). - Double myInt = 123456789012345.6789; - Console::WriteLine( myInt.ToString( "P", nfi ) ); - - // Displays the same value with different groupings. - array^mySizes1 = {2,3,4}; - array^mySizes2 = {2,3,0}; - nfi->PercentGroupSizes = mySizes1; - Console::WriteLine( myInt.ToString( "P", nfi ) ); - nfi->PercentGroupSizes = mySizes2; - Console::WriteLine( myInt.ToString( "P", nfi ) ); -} - -/* -This code produces the following output. - -12, 345, 678, 901, 234, 600.00 % -1234, 5678, 9012, 346, 00.00 % -123456789012, 346, 00.00 % -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/PerfCounter/CPP/perfcounter.cpp b/snippets/cpp/VS_Snippets_CLR/PerfCounter/CPP/perfcounter.cpp deleted file mode 100644 index ec0c28aeb8c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PerfCounter/CPP/perfcounter.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Drawing; -using namespace System::Collections; -using namespace System::ComponentModel; -using namespace System::Windows::Forms; -using namespace System::Data; -using namespace System::Diagnostics; - -/// -/// Summary description for Form1. -/// -public ref class Form1: public System::Windows::Forms::Form -{ -private: - - /// - /// Required designer variable. - /// - System::ComponentModel::Container^ components; - -public: - Form1() - { - components = nullptr; - - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - // - // TODO: Add any constructor code after InitializeComponent call - // - } - - -protected: - - /// - /// Clean up any resources being used. - /// - ~Form1() - { - if ( components != nullptr ) - { - delete components; - } - } - -private: - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - void InitializeComponent() - { - // - // Form1 - // - this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 ); - this->ClientSize = System::Drawing::Size( 292, 266 ); - this->Name = "Form1"; - this->Text = "Form1"; - this->Load += gcnew System::EventHandler( this, &Form1::Form1_Load ); - } - - void Form1_Load( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - // - PerformanceCounter^ PC = gcnew PerformanceCounter; - PC->CategoryName = "Process"; - PC->CounterName = "Private Bytes"; - PC->InstanceName = "Explorer"; - MessageBox::Show( PC->NextValue().ToString() ); - // - - // - Array^ PerfCat = PerformanceCounterCategory::GetCategories(); - MessageBox::Show( String::Concat( "The number of performance counter categories in the local machine is ", PerfCat->Length ) ); - // - } -}; - -/// -/// The main entry point for the application. -/// - -[STAThread] -int main() -{ - Application::Run( gcnew Form1 ); -} - -//Output: -//11.11 % -//11.11 Percent diff --git a/snippets/cpp/VS_Snippets_CLR/PerfCounter_ccd/CPP/ccd.cpp b/snippets/cpp/VS_Snippets_CLR/PerfCounter_ccd/CPP/ccd.cpp deleted file mode 100644 index 9cdd3a26593..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PerfCounter_ccd/CPP/ccd.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::Diagnostics; -int main() -{ - - // - if ( !PerformanceCounterCategory::Exists( "Orders" ) ) - { - CounterCreationData^ milk = gcnew CounterCreationData; - milk->CounterName = "milk"; - milk->CounterType = PerformanceCounterType::NumberOfItems32; - - CounterCreationData^ milkPerSecond = gcnew CounterCreationData; - milkPerSecond->CounterName = "milk orders/second"; - milkPerSecond->CounterType = PerformanceCounterType::RateOfCountsPerSecond32; - - CounterCreationDataCollection^ ccds = gcnew CounterCreationDataCollection; - ccds->Add( milkPerSecond ); - ccds->Add( milk ); - PerformanceCounterCategory::Create( "Orders", "Number of processed orders", ccds ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterInstaller/CPP/performancecounterinstaller.cpp b/snippets/cpp/VS_Snippets_CLR/PerformanceCounterInstaller/CPP/performancecounterinstaller.cpp deleted file mode 100644 index fe5c4b92d7c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterInstaller/CPP/performancecounterinstaller.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// cpp.cpp : main project file. -// System::Diagnostics.PerformanceCounterInstaller -/* -The following example demonstrates 'PerformanceCounterInstaller' class. -A class is inherited from 'Installer' having 'RunInstallerAttribute' set to true. -A new instance of 'PerformanceCounterInstaller' is created and its 'CategoryName' -is set. Then this instance is added to 'InstallerCollection'. -Note: -1)To run this example use the following command: -InstallUtil::exe PerformanceCounterInstaller::exe -2)To uninstall the perfomance counter use the following command: -InstallUtil::exe /u PerformanceCounterInstaller::exe -*/ -// -#using -#using - -using namespace System; -using namespace System::Configuration::Install; -using namespace System::Diagnostics; -using namespace System::ComponentModel; - -[RunInstaller(true)] -ref class MyPerformanceCounterInstaller: public Installer -{ -public: - MyPerformanceCounterInstaller() - { - try - { - // Create an instance of 'PerformanceCounterInstaller'. - PerformanceCounterInstaller^ myPerformanceCounterInstaller = - gcnew PerformanceCounterInstaller; - // Set the 'CategoryName' for performance counter. - myPerformanceCounterInstaller->CategoryName = - "MyPerformanceCounter"; - CounterCreationData^ myCounterCreation = gcnew CounterCreationData; - myCounterCreation->CounterName = "MyCounter"; - myCounterCreation->CounterHelp = "Counter Help"; - // Add a counter to collection of myPerformanceCounterInstaller. - myPerformanceCounterInstaller->Counters->Add( myCounterCreation ); - Installers->Add( myPerformanceCounterInstaller ); - } - catch ( Exception^ e ) - { - this->Context->LogMessage( "Error occurred : " + e->Message ); - } - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp b/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp deleted file mode 100644 index f51c915deba..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::Diagnostics; - -// Output information about the counter sample. -void OutputSample( CounterSample s ) -{ - Console::WriteLine( "\r\n+++++++++++" ); - Console::WriteLine( "Sample values - \r\n" ); - Console::WriteLine( " BaseValue = {0}", s.BaseValue ); - Console::WriteLine( " CounterFrequency = {0}", s.CounterFrequency ); - Console::WriteLine( " CounterTimeStamp = {0}", s.CounterTimeStamp ); - Console::WriteLine( " CounterType = {0}", s.CounterType ); - Console::WriteLine( " RawValue = {0}", s.RawValue ); - Console::WriteLine( " SystemFrequency = {0}", s.SystemFrequency ); - Console::WriteLine( " TimeStamp = {0}", s.TimeStamp ); - Console::WriteLine( " TimeStamp100nSec = {0}", s.TimeStamp100nSec ); - Console::WriteLine( "++++++++++++++++++++++" ); -} - -//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ -// Description - This counter type shows how many items are processed, on average, -// during an operation. Counters of this type display a ratio of the items -// processed (such as bytes sent) to the number of operations completed. The -// ratio is calculated by comparing the number of items processed during the -// last interval to the number of operations completed during the last interval. -// Generic type - Average -// Formula - (N1 - N0) / (D1 - D0), where the numerator (N) represents the number -// of items processed during the last sample interval and the denominator (D) -// represents the number of operations completed during the last two sample -// intervals. -// Average (Nx - N0) / (Dx - D0) -// Example PhysicalDisk\ Avg. Disk Bytes/Transfer -//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++//++++++++ -float MyComputeCounterValue( CounterSample s0, CounterSample s1 ) -{ - float numerator = (float)s1.RawValue - (float)s0.RawValue; - float denomenator = (float)s1.BaseValue - (float)s0.BaseValue; - float counterValue = numerator / denomenator; - return counterValue; -} - -bool SetupCategory() -{ - if ( !PerformanceCounterCategory::Exists( "AverageCounter64SampleCategory" ) ) - { - CounterCreationDataCollection^ CCDC = gcnew CounterCreationDataCollection; - - // Add the counter. - CounterCreationData^ averageCount64 = gcnew CounterCreationData; - averageCount64->CounterType = PerformanceCounterType::AverageCount64; - averageCount64->CounterName = "AverageCounter64Sample"; - CCDC->Add( averageCount64 ); - - // Add the base counter. - CounterCreationData^ averageCount64Base = gcnew CounterCreationData; - averageCount64Base->CounterType = PerformanceCounterType::AverageBase; - averageCount64Base->CounterName = "AverageCounter64SampleBase"; - CCDC->Add( averageCount64Base ); - - // Create the category. - PerformanceCounterCategory::Create( "AverageCounter64SampleCategory", "Demonstrates usage of the AverageCounter64 performance counter type.", CCDC ); - return (true); - } - else - { - Console::WriteLine( "Category exists - AverageCounter64SampleCategory" ); - return (false); - } -} - -void CreateCounters( PerformanceCounter^% PC, PerformanceCounter^% BPC ) -{ - - // Create the counters. - // - PC = gcnew PerformanceCounter( "AverageCounter64SampleCategory","AverageCounter64Sample",false ); - // - - BPC = gcnew PerformanceCounter( "AverageCounter64SampleCategory","AverageCounter64SampleBase",false ); - PC->RawValue = 0; - BPC->RawValue = 0; -} -// -void CollectSamples( ArrayList^ samplesList, PerformanceCounter^ PC, PerformanceCounter^ BPC ) -{ - Random^ r = gcnew Random( DateTime::Now.Millisecond ); - - // Loop for the samples. - for ( int j = 0; j < 100; j++ ) - { - int value = r->Next( 1, 10 ); - Console::Write( "{0} = {1}", j, value ); - PC->IncrementBy( value ); - BPC->Increment(); - if ( (j % 10) == 9 ) - { - OutputSample( PC->NextSample() ); - samplesList->Add( PC->NextSample() ); - } - else - Console::WriteLine(); - System::Threading::Thread::Sleep( 50 ); - } -} -// - -void CalculateResults( ArrayList^ samplesList ) -{ - for ( int i = 0; i < (samplesList->Count - 1); i++ ) - { - // Output the sample. - OutputSample( *safe_cast(samplesList[ i ]) ); - OutputSample( *safe_cast(samplesList[ i + 1 ]) ); - - // Use .NET to calculate the counter value. - Console::WriteLine( ".NET computed counter value = {0}", CounterSampleCalculator::ComputeCounterValue( *safe_cast(samplesList[ i ]), *safe_cast(samplesList[ i + 1 ]) ) ); - - // Calculate the counter value manually. - Console::WriteLine( "My computed counter value = {0}", MyComputeCounterValue( *safe_cast(samplesList[ i ]), *safe_cast(samplesList[ i + 1 ]) ) ); - } -} - -int main() -{ - ArrayList^ samplesList = gcnew ArrayList; - PerformanceCounter^ PC; - PerformanceCounter^ BPC; - SetupCategory(); - CreateCounters( PC, BPC ); - CollectSamples( samplesList, PC, BPC ); - CalculateResults( samplesList ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/CPP/elapsedtime.cpp b/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/CPP/elapsedtime.cpp deleted file mode 100644 index 0c6d5707320..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/CPP/elapsedtime.cpp +++ /dev/null @@ -1,208 +0,0 @@ -// Notice that the sample is conditionally compiled for Everett vs. -// Whidbey builds. Whidbey introduced new APIs that are not available -// in Everett. Snippet IDs do not overlap between Whidbey and Everett; -// Snippet #1 is Everett, Snippet #2 and #3 are Whidbey. - -#if ( BELOW_WHIDBEY_BUILD ) - -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::Diagnostics; -using namespace System::Runtime::InteropServices; - -void OutputSample( CounterSample s ) -{ - Console::WriteLine( "\r\n+++++++++++" ); - Console::WriteLine( "Sample values - \r\n" ); - Console::WriteLine( " BaseValue = {0}", s.BaseValue ); - Console::WriteLine( " CounterFrequency = {0}", s.CounterFrequency ); - Console::WriteLine( " CounterTimeStamp = {0}", s.CounterTimeStamp ); - Console::WriteLine( " CounterType = {0}", s.CounterType ); - Console::WriteLine( " RawValue = {0}", s.RawValue ); - Console::WriteLine( " SystemFrequency = {0}", s.SystemFrequency ); - Console::WriteLine( " TimeStamp = {0}", s.TimeStamp ); - Console::WriteLine( " TimeStamp100nSec = {0}", s.TimeStamp100nSec ); - Console::WriteLine( "++++++++++++++++++++++" ); -} - -// Reads the counter information to enable setting the RawValue. -[DllImport("Kernel32.dll")] -extern bool QueryPerformanceCounter( [Out]__int64 * value ); - -bool SetupCategory() -{ - if ( !PerformanceCounterCategory::Exists( "ElapsedTimeSampleCategory" ) ) - { - CounterCreationDataCollection^ CCDC = gcnew CounterCreationDataCollection; - - // Add the counter. - CounterCreationData^ ETimeData = gcnew CounterCreationData; - ETimeData->CounterType = PerformanceCounterType::ElapsedTime; - ETimeData->CounterName = "ElapsedTimeSample"; - CCDC->Add( ETimeData ); - - // Create the category. - PerformanceCounterCategory::Create( "ElapsedTimeSampleCategory", - "Demonstrates usage of the ElapsedTime performance counter type.", - CCDC ); - return true; - } - else - { - Console::WriteLine( "Category exists - ElapsedTimeSampleCategory" ); - return false; - } -} - -void CreateCounters( PerformanceCounter^% PC ) -{ - // Create the counter. - PC = gcnew PerformanceCounter( "ElapsedTimeSampleCategory", - "ElapsedTimeSample", - false ); -} - -void CollectSamples( ArrayList^ samplesList, PerformanceCounter^ PC ) -{ - __int64 pcValue; - DateTime Start; - - // Initialize the counter. - QueryPerformanceCounter( &pcValue ); - PC->RawValue = pcValue; - Start = DateTime::Now; - - // Loop for the samples. - for ( int j = 0; j < 1000; j++ ) - { - // Output the values. - if ( (j % 10) == 9 ) - { - Console::WriteLine( "NextValue() = {0}", PC->NextValue() ); - Console::WriteLine( "Actual elapsed time = {0}", DateTime::Now.Subtract( Start ) ); - OutputSample( PC->NextSample() ); - samplesList->Add( PC->NextSample() ); - } - - // reset the counter on 100th iteration. - if ( j % 100 == 0 ) - { - QueryPerformanceCounter( &pcValue ); - PC->RawValue = pcValue; - Start = DateTime::Now; - } - System::Threading::Thread::Sleep( 50 ); - } - - Console::WriteLine( "Elapsed time = {0}", DateTime::Now.Subtract( Start ) ); -} - -void main() -{ - ArrayList^ samplesList = gcnew ArrayList; -// PerformanceCounter^ PC; - SetupCategory(); -// CreateCounters( PC ); - CreateCounters(); - CollectSamples( samplesList, PC ); -} -// - -#else -// Build sample for Whidbey or higher. - -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::Diagnostics; -using namespace System::Runtime::InteropServices; - -void OutputSample( CounterSample s ) -{ - Console::WriteLine( "\r\n+++++++++++" ); - Console::WriteLine( "Sample values - \r\n" ); - Console::WriteLine( " BaseValue = {0}", s.BaseValue ); - Console::WriteLine( " CounterFrequency = {0}", s.CounterFrequency ); - Console::WriteLine( " CounterTimeStamp = {0}", s.CounterTimeStamp ); - Console::WriteLine( " CounterType = {0}", s.CounterType ); - Console::WriteLine( " RawValue = {0}", s.RawValue ); - Console::WriteLine( " SystemFrequency = {0}", s.SystemFrequency ); - Console::WriteLine( " TimeStamp = {0}", s.TimeStamp ); - Console::WriteLine( " TimeStamp100nSec = {0}", s.TimeStamp100nSec ); - Console::WriteLine( "++++++++++++++++++++++" ); -} - -void CollectSamples() -{ - String^ categoryName = "ElapsedTimeSampleCategory"; - String^ counterName = "ElapsedTimeSample"; - - // Create the performance counter category. - if ( !PerformanceCounterCategory::Exists( categoryName ) ) - { - CounterCreationDataCollection^ CCDC = gcnew CounterCreationDataCollection; - - // Add the counter. - CounterCreationData^ ETimeData = gcnew CounterCreationData; - ETimeData->CounterType = PerformanceCounterType::ElapsedTime; - ETimeData->CounterName = counterName; - CCDC->Add( ETimeData ); - - // Create the category. - PerformanceCounterCategory::Create( categoryName, - "Demonstrates ElapsedTime performance counter usage.", - CCDC ); - } - else - { - Console::WriteLine( "Category exists - {0}", categoryName ); - } - - - // - // Create the performance counter. - PerformanceCounter^ PC = gcnew PerformanceCounter( categoryName, - counterName, - false ); - // Initialize the counter. - PC->RawValue = Stopwatch::GetTimestamp(); - // - - DateTime Start = DateTime::Now; - - // Loop for the samples. - for ( int j = 0; j < 100; j++ ) - { - // Output the values. - if ( (j % 10) == 9 ) - { - Console::WriteLine( "NextValue() = {0}", PC->NextValue() ); - Console::WriteLine( "Actual elapsed time = {0}", DateTime::Now.Subtract( Start ) ); - OutputSample( PC->NextSample() ); - } - - // Reset the counter on every 20th iteration. - if ( j % 20 == 0 ) - { - PC->RawValue = Stopwatch::GetTimestamp(); - Start = DateTime::Now; - } - System::Threading::Thread::Sleep( 50 ); - } - - Console::WriteLine( "Elapsed time = {0}", DateTime::Now.Subtract( Start ) ); -} - -int main() -{ - CollectSamples(); -} -// -#endif diff --git a/snippets/cpp/VS_Snippets_CLR/Process.GetProcesses_noexception/CPP/processstaticget.cpp b/snippets/cpp/VS_Snippets_CLR/Process.GetProcesses_noexception/CPP/processstaticget.cpp deleted file mode 100644 index c551e40c3f6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process.GetProcesses_noexception/CPP/processstaticget.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::ComponentModel; -int main() -{ - // Get the current process. - Process^ currentProcess = Process::GetCurrentProcess(); - - // Get all processes running on the local computer. - array^localAll = Process::GetProcesses(); - - // Get all instances of Notepad running on the local computer. - // This will return an empty array if notepad isn't running. - array^localByName = Process::GetProcessesByName("notepad"); - - // Get a process on the local computer, using the process id. - // This will throw an exception if there is no such process. - Process^ localById = Process::GetProcessById(1234); - - - // Get processes running on a remote computer. Note that this - // and all the following calls will timeout and throw an exception - // if "myComputer" and 169.0.0.0 do not exist on your local network. - - // Get all processes on a remote computer. - array^remoteAll = Process::GetProcesses("myComputer"); - - // Get all instances of Notepad running on the specific computer, using machine name. - array^remoteByName = Process::GetProcessesByName( "notepad", "myComputer" ); - - // Get all instances of Notepad running on the specific computer, using IP address. - array^ipByName = Process::GetProcessesByName( "notepad", "169.0.0.0" ); - - // Get a process on a remote computer, using the process id and machine name. - Process^ remoteById = Process::GetProcessById( 2345, "myComputer" ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Process.Start_instance/CPP/processstart.cpp b/snippets/cpp/VS_Snippets_CLR/Process.Start_instance/CPP/processstart.cpp deleted file mode 100644 index b4879144d08..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process.Start_instance/CPP/processstart.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// -#using -using namespace System; -using namespace System::Diagnostics; -using namespace System::ComponentModel; - -int main() -{ - Process^ myProcess = gcnew Process; - - try - { - myProcess->StartInfo->UseShellExecute = false; - // You can start any process, HelloWorld is a do-nothing example. - myProcess->StartInfo->FileName = "C:\\HelloWorld.exe"; - myProcess->StartInfo->CreateNoWindow = true; - myProcess->Start(); - // This code assumes the process you are starting will terminate itself. - // Given that it is started without a window so you cannot terminate it - // on the desktop, it must terminate itself or you can do it programmatically - // from this application using the Kill method. - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp b/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp deleted file mode 100644 index 6db5fa36f59..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::ComponentModel; - -// Opens the Internet Explorer application. -void OpenApplication(String^ myFavoritesPath) -{ - // Start Internet Explorer. Defaults to the home page. - Process::Start("IExplore.exe"); - - // Display the contents of the favorites folder in the browser. - Process::Start(myFavoritesPath); -} - -// Opens urls and .html documents using Internet Explorer. -void OpenWithArguments() -{ - // URLs are not considered documents. They can only be opened - // by passing them as arguments. - Process::Start("IExplore.exe", "www.northwindtraders.com"); - - // Start a Web page using a browser associated with .html and .asp files. - Process::Start("IExplore.exe", "C:\\myPath\\myFile.htm"); - Process::Start("IExplore.exe", "C:\\myPath\\myFile.asp"); -} - -// Uses the ProcessStartInfo class to start new processes, -// both in a minimized mode. -void OpenWithStartInfo() -{ - ProcessStartInfo^ startInfo = gcnew ProcessStartInfo("IExplore.exe"); - startInfo->WindowStyle = ProcessWindowStyle::Minimized; - Process::Start(startInfo); - startInfo->Arguments = "www.northwindtraders.com"; - Process::Start(startInfo); -} - -int main() -{ - // Get the path that stores favorite links. - String^ myFavoritesPath = Environment::GetFolderPath(Environment::SpecialFolder::Favorites); - OpenApplication(myFavoritesPath); - OpenWithArguments(); - OpenWithStartInfo(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic2.cpp b/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic2.cpp deleted file mode 100644 index b84436e8b00..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic2.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Place the following code into a console project called StartArgsEcho. It depends on the -// console application named argsecho.exe. - -using namespace System; -using namespace System::Diagnostics; - -int main() -{ - ProcessStartInfo^ startInfo = gcnew ProcessStartInfo("argsecho.exe"); - startInfo->WindowStyle = ProcessWindowStyle::Normal; - - // Start with one argument. - // Output of ArgsEcho: - // [0]=/a - startInfo->Arguments = "/a"; - Process::Start(startInfo); - - // Start with multiple arguments separated by spaces. - // Output of ArgsEcho: - // [0] = /a - // [1] = /b - // [2] = c:\temp - startInfo->Arguments = "/a /b c:\\temp"; - Process::Start(startInfo); - - // An argument with spaces inside quotes is interpreted as multiple arguments. - // Output of ArgsEcho: - // [0] = /a - // [1] = literal string arg - startInfo->Arguments = "/a \"literal string arg\""; - Process::Start(startInfo); - - // An argument inside double quotes is interpreted as if the quote weren't there, - // that is, as separate arguments. - // Output of ArgsEcho: - // [0] = /a - // [1] = /b:string - // [2] = in - // [3] = double - // [4] = quotes - startInfo->Arguments = "/a /b:\"\"string in double quotes\"\""; - Process::Start(startInfo); - - // Triple-escape quotation marks to include the character in the final argument received - // by the target process. - // [0] = /a - // [1] = /b:"quoted string" - startInfo->Arguments = "/a /b:\"\"\"quoted string\"\"\""; - Process::Start(startInfo); - - return 0; -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic3.cpp b/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic3.cpp deleted file mode 100644 index d4fd5c0b6cd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic3.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// Place this code into a console project called ArgsEcho to build the argsecho.exe target - -using namespace System; - -int main(array ^args) -{ - Console::WriteLine("Received the following arguments:\n"); - - for (int i = 0; i < args->Length; i++) - { - Console::WriteLine("[" + i + "] = " + args[i]); - } - - Console::WriteLine("\nPress any key to exit"); - Console::ReadLine(); - return 0; -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule/CPP/processmodule.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule/CPP/processmodule.cpp deleted file mode 100644 index 57ea4cc3263..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ProcessModule/CPP/processmodule.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// System::Diagnostics::ProcessModule -/* The following program demonstrates the use of 'ProcessModule' class. -It creates a notepad, gets the 'MainModule' and all other modules of -the process 'notepad.exe', displays some of the properties of each modules. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; -void main() -{ - try - { - // - Process^ myProcess = gcnew Process; - - // Get the process start information of notepad. - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" ); - - // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*. - myProcess->StartInfo = myProcessStartInfo; - - // Create a notepad. - myProcess->Start(); - System::Threading::Thread::Sleep( 1000 ); - ProcessModule^ myProcessModule; - - // Get all the modules associated with 'myProcess'. - ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules; - Console::WriteLine( "Properties of the modules associated with 'notepad' are:" ); - - // Display the properties of each of the modules. - for ( int i = 0; i < myProcessModuleCollection->Count; i++ ) - { - myProcessModule = myProcessModuleCollection[ i ]; - Console::WriteLine( "The moduleName is {0}", myProcessModule->ModuleName ); - Console::WriteLine( "The {0}'s base address is: {1}", myProcessModule->ModuleName, myProcessModule->BaseAddress ); - Console::WriteLine( "The {0}'s Entry point address is: {1}", myProcessModule->ModuleName, myProcessModule->EntryPointAddress ); - Console::WriteLine( "The {0}'s File name is: {1}", myProcessModule->ModuleName, myProcessModule->FileName ); - } - myProcessModule = myProcess->MainModule; - - // Display the properties of the main module. - Console::WriteLine( "The process's main moduleName is: {0}", myProcessModule->ModuleName ); - Console::WriteLine( "The process's main module's base address is: {0}", myProcessModule->BaseAddress ); - Console::WriteLine( "The process's main module's Entry point address is: {0}", myProcessModule->EntryPointAddress ); - Console::WriteLine( "The process's main module's File name is: {0}", myProcessModule->FileName ); - myProcess->CloseMainWindow(); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_BaseAddress/CPP/processmodule_baseaddress.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_BaseAddress/CPP/processmodule_baseaddress.cpp deleted file mode 100644 index c941fb56f0d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_BaseAddress/CPP/processmodule_baseaddress.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System::Diagnostics::ProcessModule::BaseAddress - -/* The following program demonstrates the use of 'BaseAddress' property of -'ProcessModule' class. It creates a notepad, gets the 'MainModule' and -all other modules of the process 'notepad.exe', displays 'BaseAddress' -for all the modules and the main module. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; -void main() -{ - try - { - // - Process^ myProcess = gcnew Process; - - // Get the process start information of notepad. - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" ); - - // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*. - myProcess->StartInfo = myProcessStartInfo; - - // Create a notepad. - myProcess->Start(); - System::Threading::Thread::Sleep( 1000 ); - ProcessModule^ myProcessModule; - - // Get all the modules associated with 'myProcess'. - ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules; - Console::WriteLine( "Base addresses of the modules associated with 'notepad' are:" ); - - // Display the 'BaseAddress' of each of the modules. - for ( int i = 0; i < myProcessModuleCollection->Count; i++ ) - { - myProcessModule = myProcessModuleCollection[ i ]; - Console::WriteLine( "{0} : {1}", myProcessModule->ModuleName, myProcessModule->BaseAddress ); - } - myProcessModule = myProcess->MainModule; - - // Display the 'BaseAddress' of the main module. - Console::WriteLine( "The process's main module's base address is: {0}", myProcessModule->BaseAddress ); - myProcess->CloseMainWindow(); - // - - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_EntryPoint/CPP/processmodule_entrypoint.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_EntryPoint/CPP/processmodule_entrypoint.cpp deleted file mode 100644 index a03a38206d4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_EntryPoint/CPP/processmodule_entrypoint.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// System::Diagnostics::ProcessModule::EntryPointAddress - -/* The following program demonstrates the use of 'EntryPointAddress' property of -'ProcessModule' class. It creates a notepad, gets the 'MainModule' and -all other modules of the process 'notepad.exe', displays 'EntryPointAddress' -for all the modules and the main module. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; -void main() -{ - try - { - // - Process^ myProcess = gcnew Process; - - // Get the process start information of notepad. - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" ); - - // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' object. - myProcess->StartInfo = myProcessStartInfo; - - // Create a notepad. - myProcess->Start(); - System::Threading::Thread::Sleep( 1000 ); - ProcessModule^ myProcessModule; - - // Get all the modules associated with 'myProcess'. - ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules; - Console::WriteLine( "Entry point addresses of the modules associated with 'notepad' are:" ); - - // Display the 'EntryPointAddress' of each of the modules. - for ( int i = 0; i < myProcessModuleCollection->Count; i++ ) - { - myProcessModule = myProcessModuleCollection[ i ]; - Console::WriteLine( "{0} : {1}", myProcessModule->ModuleName, myProcessModule->EntryPointAddress ); - } - myProcessModule = myProcess->MainModule; - Console::WriteLine( "The process's main module's EntryPointAddress is: {0}", myProcessModule->EntryPointAddress ); - myProcess->CloseMainWindow(); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileName/CPP/processmodule_filename.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileName/CPP/processmodule_filename.cpp deleted file mode 100644 index a67c20e8412..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileName/CPP/processmodule_filename.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System::Diagnostics::ProcessModule::FileName - -/* The following program demonstrates the use of 'FileName' property of -'ProcessModule' class. It creates a notepad, gets the 'MainModule' and -all other modules of the process 'notepad.exe', displays 'FileName' -for all the modules and the main module. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -void main() -{ - try - { - // - Process^ myProcess = gcnew Process; - - // Get the process start information of notepad. - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" ); - - // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' object. - myProcess->StartInfo = myProcessStartInfo; - - // Create a notepad. - myProcess->Start(); - System::Threading::Thread::Sleep( 1000 ); - ProcessModule^ myProcessModule; - - // Get all the modules associated with 'myProcess'. - ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules; - Console::WriteLine( "File names of the modules associated with 'notepad' are:" ); - - // Display the 'FileName' of each of the modules. - for ( int i = 0; i < myProcessModuleCollection->Count; i++ ) - { - myProcessModule = myProcessModuleCollection[ i ]; - Console::WriteLine( "{0:s} : {1:s}", myProcessModule->ModuleName, myProcessModule->FileName ); - } - myProcessModule = myProcess->MainModule; - - // Display the 'FileName' of the main module. - Console::WriteLine( "The process's main module's FileName is: {0}", myProcessModule->FileName ); - myProcess->CloseMainWindow(); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileVersionInfo/CPP/processmodule_fileversioninfo.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileVersionInfo/CPP/processmodule_fileversioninfo.cpp deleted file mode 100644 index 62a1569e9f3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileVersionInfo/CPP/processmodule_fileversioninfo.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// System::Diagnostics::ProcessModule::FileVersionInfo - -/* The following program demonstrates the use of 'FileVersionInfo' property of -'ProcessModule' class. It creates a notepad, gets the 'MainModule' and -all other modules of the process 'notepad.exe', displays 'FileVersionInfo' -for all the modules and the main module. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; -void main() -{ - try - { - // - Process^ myProcess = gcnew Process; - - // Get the process start information of notepad. - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" ); - - // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*. - myProcess->StartInfo = myProcessStartInfo; - - // Create a notepad. - myProcess->Start(); - System::Threading::Thread::Sleep( 1000 ); - ProcessModule^ myProcessModule; - - // Get all the modules associated with 'myProcess'. - ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules; - Console::WriteLine( "'FileversionInfo' of the modules associated with 'notepad' are:" ); - - // Display the 'FileVersionInfo' of each of the modules. - for ( int i = 0; i < myProcessModuleCollection->Count; i++ ) - { - myProcessModule = myProcessModuleCollection[ i ]; - Console::WriteLine( "{0} : {1}", myProcessModule->ModuleName, myProcessModule->FileVersionInfo ); - } - myProcessModule = myProcess->MainModule; - - // Display the 'FileVersionInfo' of main module. - Console::WriteLine( "The process's main module's FileVersionInfo is: {0}", myProcessModule->FileVersionInfo ); - myProcess->CloseMainWindow(); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleMemorySize/CPP/processmodule_modulememorysize.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleMemorySize/CPP/processmodule_modulememorysize.cpp deleted file mode 100644 index 8d5907528ee..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleMemorySize/CPP/processmodule_modulememorysize.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System::Diagnostics::ProcessModule::ModuleMemorySize - -/* The following program demonstrates the use of 'ModuleMemorySize' property of -'ProcessModule' class. It creates a notepad, gets the 'MainModule' and -all other modules of the process 'notepad.exe', displays 'ModuleMemorySize' -for all the modules and the main module. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -void main() -{ - try - { - // - Process^ myProcess = gcnew Process; - - // Get the process start information of notepad. - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" ); - - // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*. - myProcess->StartInfo = myProcessStartInfo; - - // Create a notepad. - myProcess->Start(); - System::Threading::Thread::Sleep( 1000 ); - ProcessModule^ myProcessModule; - - // Get all the modules associated with 'myProcess'. - ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules; - Console::WriteLine( "Module memory sizes of the modules associated with 'notepad' are:" ); - - // Display the 'ModuleMemorySize' of each of the modules. - for ( int i = 0; i < myProcessModuleCollection->Count; i++ ) - { - myProcessModule = myProcessModuleCollection[ i ]; - Console::WriteLine( "{0} : {1}", myProcessModule->ModuleName, myProcessModule->ModuleMemorySize ); - } - myProcessModule = myProcess->MainModule; - - // Display the 'ModuleMemorySize' of the main module. - Console::WriteLine( "The process's main module's ModuleMemorySize is: {0}", myProcessModule->ModuleMemorySize ); - myProcess->CloseMainWindow(); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleName/CPP/processmodule_modulename.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleName/CPP/processmodule_modulename.cpp deleted file mode 100644 index 96abbee1dab..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleName/CPP/processmodule_modulename.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System::Diagnostics::ProcessModule::ModuleName - -/* The following program demonstrates the use of 'ModuleName' property of -'ProcessModule' class. It creates a notepad, gets the 'MainModule' and -all other modules of the process 'notepad.exe', displays 'ModuleName' -for all the modules and the main module. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -void main() -{ - try - { - // - Process^ myProcess = gcnew Process; - - // Get the process start information of notepad. - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" ); - - // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' object. - myProcess->StartInfo = myProcessStartInfo; - - // Create a notepad. - myProcess->Start(); - System::Threading::Thread::Sleep( 1000 ); - ProcessModule^ myProcessModule; - - // Get all the modules associated with 'myProcess'. - ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules; - Console::WriteLine( "Module names of the modules associated with 'notepad' are:" ); - - // Display the 'ModuleName' of each of the modules. - for ( int i = 0; i < myProcessModuleCollection->Count; i++ ) - { - myProcessModule = myProcessModuleCollection[ i ]; - Console::WriteLine( myProcessModule->ModuleName ); - } - myProcessModule = myProcess->MainModule; - - // Display the 'ModuleName' of the main module. - Console::WriteLine( "The process's main moduleName is: {0}", myProcessModule->ModuleName ); - myProcess->CloseMainWindow(); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ToString/CPP/processmodule_tostring.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessModule_ToString/CPP/processmodule_tostring.cpp deleted file mode 100644 index 9bd9a254aa0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ProcessModule_ToString/CPP/processmodule_tostring.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// System::Diagnostics::ProcessModule::ToString - -/* The following program demonstrates the use of 'ToString' property of -'ProcessModule' class. It creates a notepad, gets the 'MainModule' and -all other modules of the process 'notepad.exe', displays 'ToString' -for all the modules and the main module. -*/ - -#using - -using namespace System; -using namespace System::Diagnostics; - -int main() -{ - try - { - // - Process^ myProcess = gcnew Process; - - // Get the process start information of notepad. - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "notepad.exe" ); - - // Assign 'StartInfo' of notepad to 'StartInfo' of 'myProcess' Object*. - myProcess->StartInfo = myProcessStartInfo; - - // Create a notepad. - myProcess->Start(); - System::Threading::Thread::Sleep( 1000 ); - ProcessModule^ myProcessModule; - - // Get all the modules associated with 'myProcess'. - ProcessModuleCollection^ myProcessModuleCollection = myProcess->Modules; - Console::WriteLine( "ToString properties of the modules associated with 'notepad' are:" ); - - // Display the ToString of each of the modules. - for ( int i = 0; i < myProcessModuleCollection->Count; i++ ) - { - myProcessModule = myProcessModuleCollection[ i ]; - Console::WriteLine( "{0} : {1}", myProcessModuleCollection[ i ]->ModuleName, myProcessModule->ToString() ); - } - myProcessModule = myProcess->MainModule; - - // Display the ToString of the main module. - Console::WriteLine( "The process's main module is : {0}", myProcessModule->ToString() ); - myProcess->CloseMainWindow(); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/ProcessOneStream/CPP/stdstr.cpp b/snippets/cpp/VS_Snippets_CLR/ProcessOneStream/CPP/stdstr.cpp deleted file mode 100644 index dc1a08793ee..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ProcessOneStream/CPP/stdstr.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#using - -using namespace System; -using namespace System::Diagnostics; - -void main() -{ - // - // Run "cl.exe /cld stdstr.cpp /link /out:sample.exe". UseShellExecute is false because we're specifying - // an executable directly and in this case depending on it being in a PATH folder. By setting - // RedirectStandardOutput to true, the output of cl.exe is directed to the Process.StandardOutput stream - // which is then displayed in this console window directly. - Process^ compiler = gcnew Process; - compiler->StartInfo->FileName = "cl.exe"; - compiler->StartInfo->Arguments = "/clr stdstr.cpp /link /out:sample.exe"; - compiler->StartInfo->UseShellExecute = false; - compiler->StartInfo->RedirectStandardOutput = true; - compiler->Start(); - - Console::WriteLine( compiler->StandardOutput->ReadToEnd() ); - - compiler->WaitForExit(); - // -} diff --git a/snippets/cpp/VS_Snippets_CLR/Process_MainWindowTitle/CPP/process_mainwindowtitle.cpp b/snippets/cpp/VS_Snippets_CLR/Process_MainWindowTitle/CPP/process_mainwindowtitle.cpp deleted file mode 100644 index 194770fb873..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process_MainWindowTitle/CPP/process_mainwindowtitle.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// System::Diagnostics::Process::MainWindowTitle -/* The following program demonstrates the property 'MainWindowTitle' of class 'Process'. -It creates a new process notepad on local computer and displays its caption to console. -*/ -// -#using - -using namespace System; -using namespace System::Diagnostics; -int main() -{ - try - { - - // Create an instance of process component. - Process^ myProcess = gcnew Process; - - // Create an instance of 'myProcessStartInfo'. - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo; - myProcessStartInfo->FileName = "notepad"; - myProcess->StartInfo = myProcessStartInfo; - - // Start process. - myProcess->Start(); - - // Allow the process to finish starting. - myProcess->WaitForInputIdle(); - Console::Write( "Main window Title : {0}", myProcess->MainWindowTitle ); - myProcess->CloseMainWindow(); - myProcess->Close(); - } - catch ( Exception^ e ) - { - Console::Write( " Message : {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Process_StandardError/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/Process_StandardError/CPP/source.cpp deleted file mode 100644 index b295733c646..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process_StandardError/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// System::Diagnostics::Process::StandardError -/* -The following example demonstrates property 'StandardError' of -'Process' class. - -It starts a process(net.exe) which writes an error message on to the standard -error when a bad network path is given. This program gets 'StandardError' of -net.exe process and reads output from its stream reader.*/ - -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::ComponentModel; -using namespace System::IO; - -void GetStandardError( array^args ) -{ -// - Process^ myProcess = gcnew Process; - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "net ",String::Concat( "use ", args[ 0 ] ) ); - - myProcessStartInfo->UseShellExecute = false; - myProcessStartInfo->RedirectStandardError = true; - myProcess->StartInfo = myProcessStartInfo; - myProcess->Start(); - - StreamReader^ myStreamReader = myProcess->StandardError; - // Read the standard error of net.exe and write it on to console. - Console::WriteLine( myStreamReader->ReadLine() ); - myProcess->Close(); -// -} - -void main( int argc, char *argv[] ) -{ - if ( argc < 2 ) - { - Console::WriteLine( "\nThis requires a machine name as a parameter which is not on the network." ); - Console::WriteLine( "\nUsage:" ); - Console::WriteLine( "Process_StandardError <\\\\machine name>" ); - } - else - { - GetStandardError( Environment::GetCommandLineArgs() ); - } - return; -} diff --git a/snippets/cpp/VS_Snippets_CLR/Process_StandardInput/CPP/process_standardinput.cpp b/snippets/cpp/VS_Snippets_CLR/Process_StandardInput/CPP/process_standardinput.cpp deleted file mode 100644 index 02249c8a531..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process_StandardInput/CPP/process_standardinput.cpp +++ /dev/null @@ -1,76 +0,0 @@ - - -/// System.Diagnostics.Process.StandardInput -// -// -// The following example illustrates how to redirect the StandardInput -// stream of a process. The example starts the sort command with -// redirected input. It then prompts the user for text, and passes -// that to the sort command by means of the redirected input stream. -// The sort command results are displayed to the user on the console. -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; -using namespace System::ComponentModel; -int main() -{ - Console::WriteLine( "Ready to sort one or more text lines..." ); - - // Start the Sort.exe process with redirected input. - // Use the sort command to sort the input text. - Process^ myProcess = gcnew Process; - if ( myProcess ) - { - myProcess->StartInfo->FileName = "Sort.exe"; - myProcess->StartInfo->UseShellExecute = false; - myProcess->StartInfo->RedirectStandardInput = true; - myProcess->Start(); - StreamWriter^ myStreamWriter = myProcess->StandardInput; - if ( myStreamWriter ) - { - - // Prompt the user for input text lines to sort. - // Write each line to the StandardInput stream of - // the sort command. - String^ inputText; - int numLines = 0; - do - { - Console::WriteLine( "Enter a line of text (or press the Enter key to stop):" ); - inputText = Console::ReadLine(); - if ( inputText && inputText->Length > 0 ) - { - numLines++; - myStreamWriter->WriteLine( inputText ); - } - } - while ( inputText && inputText->Length != 0 ); - - // Write a report header to the console. - if ( numLines > 0 ) - { - Console::WriteLine( " {0} sorted text line(s) ", numLines.ToString() ); - Console::WriteLine( "------------------------" ); - } - else - { - Console::WriteLine( " No input was sorted" ); - } - - // End the input stream to the sort command. - // When the stream closes, the sort command - // writes the sorted text lines to the - // console. - myStreamWriter->Close(); - } - - // Wait for the sort process to write the sorted text lines. - myProcess->WaitForExit(); - myProcess->Close(); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Process_StandardOutput/CPP/process_standardoutput.cpp b/snippets/cpp/VS_Snippets_CLR/Process_StandardOutput/CPP/process_standardoutput.cpp deleted file mode 100644 index 6820437e824..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process_StandardOutput/CPP/process_standardoutput.cpp +++ /dev/null @@ -1,26 +0,0 @@ -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - -int main() -{ - Process^ process = gcnew Process(); - process->StartInfo->FileName = "ipconfig.exe"; - process->StartInfo->UseShellExecute = false; - process->StartInfo->RedirectStandardOutput = true; - process->Start(); - - // Synchronously read the standard output of the spawned process-> - StreamReader^ reader = process->StandardOutput; - String^ output = reader->ReadToEnd(); - - // Write the redirected output to this application's window. - Console::WriteLine(output); - - process->WaitForExit(); - process->Close(); - - Console::WriteLine("\n\nPress any key to exit"); - Console::ReadLine(); - return 0; -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/process_synchronizingobject.cpp b/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/process_synchronizingobject.cpp deleted file mode 100644 index 7494c07f40a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/process_synchronizingobject.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// System::Diagnostics::Process::SynchronizingObject - -/* -The following example demonstrates the property 'SynchronizingObject' -of 'Process' class. - -It starts a process 'mspaint.exe' on button click. -It attaches 'MyProcessExited' method of 'MyButton' class as EventHandler to -'Exited' event of the process. -*/ - -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -ref class Form1: public System::Windows::Forms::Form -{ -private: - System::ComponentModel::Container^ components; - - // - ref class MyButton: public Button - { - public: - void MyProcessExited( Object^ source, EventArgs^ e ) - { - MessageBox::Show( "The process has exited." ); - } - }; - -public: - MyButton^ button1; -private: - void MyProcessExited( Object^ source, EventArgs^ e ) - { - MessageBox::Show( "The process has exited." ); - } - void button1_Click( Object^ sender, EventArgs^ e ) - { - Process^ myProcess = gcnew Process; - ProcessStartInfo^ myProcessStartInfo = gcnew ProcessStartInfo( "mspaint" ); - myProcess->StartInfo = myProcessStartInfo; - myProcess->Start(); - myProcess->Exited += gcnew System::EventHandler( this, &Form1::MyProcessExited ); - - // Set 'EnableRaisingEvents' to true, to raise 'Exited' event when process is terminated. - myProcess->EnableRaisingEvents = true; - - // Set method handling the exited event to be called ; - // on the same thread on which MyButton was created. - myProcess->SynchronizingObject = button1; - MessageBox::Show( "Waiting for the process 'mspaint' to exit...." ); - myProcess->WaitForExit(); - myProcess->Close(); - } - // - - void InitializeComponent() - { - this->button1 = gcnew MyButton; - this->SuspendLayout(); - - // - // button1 - // - this->button1->Location = System::Drawing::Point( 40, 80 ); - this->button1->Name = "button1"; - this->button1->Size = System::Drawing::Size( 168, 32 ); - this->button1->TabIndex = 0; - this->button1->Text = "Click Me"; - this->button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click ); - - // - // Form1 - // - this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 ); - this->ClientSize = System::Drawing::Size( 292, 273 ); - array^newControls = {this->button1}; - this->Controls->AddRange( newControls ); - this->Name = "Form1"; - this->Text = "Form1"; - this->ResumeLayout( false ); - } - -public: - ~Form1() - { - if ( components != nullptr ) - { - delete components; - } - } - -public: - Form1() - : components( nullptr ) - { - InitializeComponent(); - } -}; - -[STAThread] -void main() -{ - Application::Run( gcnew Form1 ); -} diff --git a/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/remarks.cpp deleted file mode 100644 index 70a6c01850b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/remarks.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// This is kind of a ripoff of 'process_synchronizingobject.cs' for use as a znippet -// for the remarks section. - -#using -#using -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Windows::Forms; - -namespace SynchronizingObjectTest -{ - public ref class SyncForm : System::Windows::Forms::Form - { - - public: - SyncForm() : components( nullptr ) - { - InitializeComponent(); - } - - ~SyncForm() - { - if ( components != nullptr ) - { - delete components; - } - } - - static void Main() - { - Application::Run(gcnew SyncForm); - } -#if 0 // Dispose is implicit - protected: - virtual void Dispose( bool disposing ) override - { - if( disposing ) - { - if (components != null) - { - components->Dispose(); - } - } - base->Dispose( disposing ); - } -#endif - - private: - System::ComponentModel::Container^ components; - Process^ process1; - Button^ button1; - Label^ label1; - - void InitializeComponent() - { - this->button1 = gcnew Button(); - this->label1 = gcnew Label(); - this->SuspendLayout(); - // - // button1 - // - this->button1->Location = System::Drawing::Point(20, 20); - this->button1->Name = "button1"; - this->button1->Size = System::Drawing::Size(160, 30); - this->button1->TabIndex = 0; - this->button1->Text = "Click Me"; - this->button1->Click += gcnew EventHandler(this, &SyncForm::button1_Click); - // - // textbox - // - this->label1->Location = System::Drawing::Point(20, 20); - this->label1->Name = "textbox1"; - this->label1->Size = System::Drawing::Size(160, 30); - this->label1->TabIndex = 1; - this->label1->Text = "Waiting for the process 'notepad' to exit...."; - this->label1->ForeColor = System::Drawing::Color::Red; - this->label1->Visible = false; - // - // Form1 - // - this->AutoScaleBaseSize = System::Drawing::Size(5, 13); - this->ClientSize = System::Drawing::Size(200, 70); - this->Controls->Add(this->button1); - this->Controls->Add(this->label1); - this->Name = "SyncForm"; - this->Text = "SyncForm"; - this->ResumeLayout(false); - } - - - - void button1_Click(Object^ sender, System::EventArgs^ e) - { - this->button1->Hide(); - this->label1->Show(); - - process1 = gcnew Process(); - ProcessStartInfo^ process1StartInfo= gcnew ProcessStartInfo("notepad"); - - // - this->process1->StartInfo->Domain = ""; - this->process1->StartInfo->LoadUserProfile = false; - this->process1->StartInfo->Password = nullptr; - this->process1->StartInfo->StandardErrorEncoding = nullptr; - this->process1->StartInfo->StandardOutputEncoding = nullptr; - this->process1->StartInfo->UserName = ""; - this->process1->SynchronizingObject = this; - // - - // Set method handling the exited event to be called - process1->Exited += gcnew EventHandler(this, &SyncForm::TheProcessExited); - // Set 'EnableRaisingEvents' to true, to raise 'Exited' event when process is terminated. - process1->EnableRaisingEvents = true; - - this->Refresh(); - process1->StartInfo = process1StartInfo; - process1->Start(); - - process1->WaitForExit(); - process1->Close(); - } - - void TheProcessExited(Object^ source, EventArgs^ e) - { - this->label1->Hide(); - this->button1->Show(); - MessageBox::Show("The process has exited."); - } - }; -} - -[STAThread] -int main() -{ - SynchronizingObjectTest::SyncForm::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp b/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp deleted file mode 100644 index 743f3c8001f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -//The following sample uses the Cryptography class to simulate the roll of a dice. - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Security::Cryptography; - -ref class RNGCSP -{ -public: - // Main method. - static void Main() - { - const int totalRolls = 25000; - array^ results = gcnew array(6); - - // Roll the dice 25000 times and display - // the results to the console. - for (int x = 0; x < totalRolls; x++) - { - Byte roll = RollDice((Byte)results->Length); - results[roll - 1]++; - } - for (int i = 0; i < results->Length; ++i) - { - Console::WriteLine("{0}: {1} ({2:p1})", i + 1, results[i], (double)results[i] / (double)totalRolls); - } - } - - // This method simulates a roll of the dice. The input parameter is the - // number of sides of the dice. - - static Byte RollDice(Byte numberSides) - { - if (numberSides <= 0) - throw gcnew ArgumentOutOfRangeException("numberSides"); - // Create a new instance of the RNGCryptoServiceProvider. - RNGCryptoServiceProvider^ rngCsp = gcnew RNGCryptoServiceProvider(); - // Create a byte array to hold the random value. - array^ randomNumber = gcnew array(1); - do - { - // Fill the array with a random value. - rngCsp->GetBytes(randomNumber); - } - while (!IsFairRoll(randomNumber[0], numberSides)); - // Return the random number mod the number - // of sides. The possible values are zero- - // based, so we add one. - return (Byte)((randomNumber[0] % numberSides) + 1); - } - -private: - static bool IsFairRoll(Byte roll, Byte numSides) - { - // There are MaxValue / numSides full sets of numbers that can come up - // in a single byte. For instance, if we have a 6 sided die, there are - // 42 full sets of 1-6 that come up. The 43rd set is incomplete. - int fullSetsOfValues = Byte::MaxValue / numSides; - - // If the roll is within this range of fair values, then we let it continue. - // In the 6 sided die case, a roll between 0 and 251 is allowed. (We use - // < rather than <= since the = portion allows through an extra 0 value). - // 252 through 255 would provide an extra 0, 1, 2, 3 so they are not fair - // to use. - return roll < numSides * fullSetsOfValues; - } -}; - -int main() -{ - RNGCSP::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/ReadTextFile/CPP/readtextfile.cpp b/snippets/cpp/VS_Snippets_CLR/ReadTextFile/CPP/readtextfile.cpp deleted file mode 100644 index 327d731d991..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ReadTextFile/CPP/readtextfile.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - try - { - // Create an instance of StreamReader to read from a file. - StreamReader^ sr = gcnew StreamReader( "TestFile.txt" ); - try - { - String^ line; - - // Read and display lines from the file until the end of - // the file is reached. - while ( line = sr->ReadLine() ) - { - Console::WriteLine( line ); - } - } - finally - { - if ( sr ) - delete (IDisposable^)sr; - } - } - catch ( Exception^ e ) - { - // Let the user know what went wrong. - Console::WriteLine( "The file could not be read:" ); - Console::WriteLine( e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Recursive file finder/CPP/directorylisting.cpp b/snippets/cpp/VS_Snippets_CLR/Recursive file finder/CPP/directorylisting.cpp deleted file mode 100644 index abd2bed7dea..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Recursive file finder/CPP/directorylisting.cpp +++ /dev/null @@ -1,69 +0,0 @@ - -// -// For Directory::GetFiles and Directory::GetDirectories -// -// For File::Exists, Directory::Exists -using namespace System; -using namespace System::IO; -using namespace System::Collections; - -// Insert logic for processing found files here. -void ProcessFile( String^ path ) -{ - Console::WriteLine( "Processed file '{0}'.", path ); -} - - -// Process all files in the directory passed in, recurse on any directories -// that are found, and process the files they contain. -void ProcessDirectory( String^ targetDirectory ) -{ - - // Process the list of files found in the directory. - array^fileEntries = Directory::GetFiles( targetDirectory ); - IEnumerator^ files = fileEntries->GetEnumerator(); - while ( files->MoveNext() ) - { - String^ fileName = safe_cast(files->Current); - ProcessFile( fileName ); - } - - - // Recurse into subdirectories of this directory. - array^subdirectoryEntries = Directory::GetDirectories( targetDirectory ); - IEnumerator^ dirs = subdirectoryEntries->GetEnumerator(); - while ( dirs->MoveNext() ) - { - String^ subdirectory = safe_cast(dirs->Current); - ProcessDirectory( subdirectory ); - } -} - -int main( int argc, char *argv[] ) -{ - for ( int i = 1; i < argc; i++ ) - { - String^ path = gcnew String(argv[ i ]); - if ( File::Exists( path ) ) - { - - // This path is a file - ProcessFile( path ); - } - else - if ( Directory::Exists( path ) ) - { - - // This path is a directory - ProcessDirectory( path ); - } - else - { - Console::WriteLine( "{0} is not a valid file or directory.", path ); - } - - } -} - -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp b/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp deleted file mode 100644 index 1cfed0722c1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Text::RegularExpressions; -int main() -{ - // - // Define a regular expression for repeated words. - Regex^ rx = gcnew Regex( "\\b(?\\w+)\\s+(\\k)\\b",static_cast(RegexOptions::Compiled | RegexOptions::IgnoreCase) ); - // - - // Define a test string. - String^ text = "The the quick brown fox fox jumps over the lazy dog dog."; - - // - // Find matches. - MatchCollection^ matches = rx->Matches( text ); - // - - // - // Report the number of matches found. - Console::WriteLine( "{0} matches found.", matches->Count ); - // - - // - // Report on each match. - for each (Match^ match in matches) - { - String^ word = match->Groups["word"]->Value; - int index = match->Index; - Console::WriteLine("{0} repeated at position {1}", word, index); - } - // -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp deleted file mode 100644 index cb616efc570..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - - -class RijndaelMemoryExample -{ -public: - static array^ encryptStringToBytes_AES(String^ plainText, array^ Key, array^ IV) - { - // Check arguments. - if (!plainText || plainText->Length <= 0) - throw gcnew ArgumentNullException("plainText"); - if (!Key || Key->Length <= 0) - throw gcnew ArgumentNullException("Key"); - if (!IV || IV->Length <= 0) - throw gcnew ArgumentNullException("IV"); - - // Declare the streams used - // to encrypt to an in memory - // array of bytes. - MemoryStream^ msEncrypt; - CryptoStream^ csEncrypt; - StreamWriter^ swEncrypt; - - // Declare the RijndaelManaged object - // used to encrypt the data. - RijndaelManaged^ aesAlg; - - try - { - // Create a RijndaelManaged object - // with the specified key and IV. - aesAlg = gcnew RijndaelManaged(); - aesAlg->Padding = PaddingMode::PKCS7; - aesAlg->Key = Key; - aesAlg->IV = IV; - - // Create an encryptor to perform the stream transform. - ICryptoTransform^ encryptor = aesAlg->CreateEncryptor(aesAlg->Key, aesAlg->IV); - - // Create the streams used for encryption. - msEncrypt = gcnew MemoryStream(); - csEncrypt = gcnew CryptoStream(msEncrypt, encryptor, CryptoStreamMode::Write); - swEncrypt = gcnew StreamWriter(csEncrypt); - - //Write all data to the stream. - swEncrypt->Write(plainText); - swEncrypt->Flush(); - csEncrypt->FlushFinalBlock(); - msEncrypt->Flush(); - } - finally - { - // Clean things up. - - // Close the streams. - if(swEncrypt) - swEncrypt->Close(); - if (csEncrypt) - csEncrypt->Close(); - - - // Clear the RijndaelManaged object. - if (aesAlg) - aesAlg->Clear(); - } - - // Return the encrypted bytes from the memory stream. - return msEncrypt->ToArray(); - } - - static String^ decryptStringFromBytes_AES(array^ cipherText, array^ Key, array^ IV) - { - // Check arguments. - if (!cipherText || cipherText->Length <= 0) - throw gcnew ArgumentNullException("cipherText"); - if (!Key || Key->Length <= 0) - throw gcnew ArgumentNullException("Key"); - if (!IV || IV->Length <= 0) - throw gcnew ArgumentNullException("IV"); - - // TDeclare the streams used - // to decrypt to an in memory - // array of bytes. - MemoryStream^ msDecrypt; - CryptoStream^ csDecrypt; - StreamReader^ srDecrypt; - - // Declare the RijndaelManaged object - // used to decrypt the data. - RijndaelManaged^ aesAlg; - - // Declare the string used to hold - // the decrypted text. - String^ plaintext; - - try - { - // Create a RijndaelManaged object - // with the specified key and IV. - aesAlg = gcnew RijndaelManaged(); - aesAlg->Padding = PaddingMode::PKCS7; - aesAlg->Key = Key; - aesAlg->IV = IV; - - // Create a decryptor to perform the stream transform. - ICryptoTransform^ decryptor = aesAlg->CreateDecryptor(aesAlg->Key, aesAlg->IV); - - // Create the streams used for decryption. - msDecrypt = gcnew MemoryStream(cipherText); - csDecrypt = gcnew CryptoStream(msDecrypt, decryptor, CryptoStreamMode::Read); - srDecrypt = gcnew StreamReader(csDecrypt); - - // Read the decrypted bytes from the decrypting stream - // and place them in a string. - plaintext = srDecrypt->ReadToEnd(); - } - finally - { - // Clean things up. - - // Close the streams. - if (srDecrypt) - srDecrypt->Close(); - if (csDecrypt) - csDecrypt->Close(); - if (msDecrypt) - msDecrypt->Close(); - - // Clear the RijndaelManaged object. - if (aesAlg) - aesAlg->Clear(); - } - - return plaintext; - } -}; - -int main() -{ - try - { - String^ original = "Here is some data to encrypt!"; - - // Create a new instance of the RijndaelManaged - // class. This generates a new key and initialization - // vector (IV). - RijndaelManaged^ myRijndael = gcnew RijndaelManaged(); - - // Encrypt the string to an array of bytes. - array^ encrypted = RijndaelMemoryExample::encryptStringToBytes_AES(original, myRijndael->Key, myRijndael->IV); - - // Decrypt the bytes to a string. - String^ roundtrip = RijndaelMemoryExample::decryptStringFromBytes_AES(encrypted, myRijndael->Key, myRijndael->IV); - - //Display the original data and the decrypted data. - Console::WriteLine("Original: {0}", original); - Console::WriteLine("Round Trip: {0}", roundtrip); - } - catch (Exception^ e) - { - Console::WriteLine("Error: {0}", e->Message); - } - - return 0; -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp b/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp deleted file mode 100644 index bdc5fda9a9e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// -using namespace System; -using namespace System::Security; - -void main() -{ - String^ msg = L" The current length of the SecureString object: {0}\n"; - SecureString ^ ss = gcnew SecureString; - - Console::WriteLine(L"1) Instantiate the SecureString object:"); - Console::WriteLine(msg, ss->Length ); - - Console::WriteLine(L"2) Append 'a' to the value:"); - ss->AppendChar('a'); - Console::WriteLine(msg, ss->Length ); - - Console::WriteLine(L"3) Append 'X' to the value:"); - ss->AppendChar('X'); - Console::WriteLine(msg, ss->Length); - - Console::WriteLine(L"4) Append 'c' to the value:"); - ss->AppendChar('c'); - Console::WriteLine(msg, ss->Length); - - Console::WriteLine(L"5) Insert 'd' at the end of the value:"); - ss->InsertAt(ss->Length, 'd'); - Console::WriteLine(msg, ss->Length); - - Console::WriteLine(L"6) Remove the last character ('d') from the value:"); - ss->RemoveAt(3); - Console::WriteLine(msg, ss->Length); - - Console::WriteLine(L"7) Set the second character ('X') of the value to 'b':" ); - ss->SetAt(1, 'b'); - Console::WriteLine(msg, ss->Length ); - - Console::WriteLine(L"8) Delete the value of the SecureString object:"); - ss->Clear(); - Console::WriteLine(msg, ss->Length); - - delete ss; -} - -/* -This code example produces the following results: - -This example demonstrates the effect of the AppendChar, InsertAt, -RemoveAt, SetAt, and Clear methods on the value of a SecureString -object. This example simulates the value of the object because the -actual value is encrypted. - -1) The initial value of the SecureString object: - SecureString = "" - Length = 0 - -2) AppendChar: Append 'a' to the value: - SecureString = "a" - Length = 1 - -3) AppendChar: Append 'X' to the value: - SecureString = "aX" - Length = 2 - -4) AppendChar: Append 'c' to the value: - SecureString = "aXc" - Length = 3 - -5) InsertAt: Insert 'd' at the end of the value (equivalent - to AppendChar): - SecureString = "aXcd" - Length = 4 - -6) RemoveAt: Remove the last character ('d') from the value: - SecureString = "aXc" - Length = 3 - -7) SetAt: Set the second character ('X') of the value to 'b': - SecureString = "abc" - Length = 3 - -8) Clear: Delete the value of the SecureString object: - SecureString = "" - Length = 0 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp b/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp deleted file mode 100644 index 4a5db9f067c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp +++ /dev/null @@ -1,62 +0,0 @@ - -// -using namespace System; -using namespace System::Security; - -void main() -{ - bool go = true; - ConsoleKeyInfo cki; - String^ m = L"\nEnter your password (up to 15 letters, numbers, and underscores)\n" - L"Press BACKSPACE to delete the last character entered. " + - L"\nPress Enter when done, or ESCAPE to quit:"; - SecureString ^ password = gcnew SecureString; - int top; - int left; - - // The Console.TreatControlCAsInput property prevents CTRL+C from - // ending this example. - Console::TreatControlCAsInput = true; - - Console::Clear(); - Console::WriteLine(m); - - top = Console::CursorTop; - left = Console::CursorLeft; - - do { - cki = Console::ReadKey(true); - if (cki.Key == ConsoleKey::Escape) - break; - - if (cki.Key == ConsoleKey::Backspace){ - if (password->Length > 0) { - Console::SetCursorPosition(left + password->Length - 1, top); - Console::Write(' '); - Console::SetCursorPosition(left + password->Length - 1, top); - password->RemoveAt(password->Length - 1); - } - } - else { - if ((password->Length < 15) && - (Char::IsLetterOrDigit( cki.KeyChar ) || - cki.KeyChar == '_') ) { - password->AppendChar( cki.KeyChar ); - Console::SetCursorPosition( left + password->Length - 1, top ); - Console::Write("*"); - } - } - } while (cki.Key != ConsoleKey::Enter & password->Length < 15); - - // Make the password read-only to prevent modification. - password->MakeReadOnly(); - // Dispose of the SecureString instance. - delete password; - -} -// The example displays output like the following: -// Enter your password (up to 15 letters, numbers, and underscores) -// Press BACKSPACE to delete the last character entered. -// Press Enter when done, or ESCAPE to quit: -// ************ -// diff --git a/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp b/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp deleted file mode 100644 index 51ea424f825..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp +++ /dev/null @@ -1,290 +0,0 @@ - -// This sample demonstrates how to use members of the SecurityElement class. -// The sample creates a SecurityElement for the root of the XML tree and -// demonstrates how to add attributes and child elements. -// -using namespace System; -using namespace System::Security; -using namespace System::Collections; -ref class SecurityElementMembers -{ -public: - - [STAThread] - int TestSecurityElementMembers() - { - // - SecurityElement^ xmlRootElement = gcnew SecurityElement( L"RootTag",L"XML security tree" ); - // - - AddAttribute( xmlRootElement, L"creationdate", DateTime::Now.ToString() ); - AddChildElement( xmlRootElement, L"destroytime", DateTime::Now.AddSeconds( 1.0 ).ToString() ); - - // - SecurityElement^ windowsRoleElement = gcnew SecurityElement( L"WindowsMembership.WindowsRole" ); - // - - // - windowsRoleElement->AddAttribute( L"version", L"1.00" ); - // - - // Add a child element and a creationdate attribute. - AddChildElement( windowsRoleElement, L"BabyElement", L"This is a child element" ); - AddAttribute( windowsRoleElement, L"creationdate", DateTime::Now.ToString() ); - - // - xmlRootElement->AddChild( windowsRoleElement ); - // - - CompareAttributes( xmlRootElement, L"creationdate" ); - ConvertToHashTable( xmlRootElement ); - DisplaySummary( xmlRootElement ); - - // Determine if the security element is too old to keep. - xmlRootElement = DestroyTree( xmlRootElement ); - if ( xmlRootElement != nullptr ) - { - // - String^ elementInXml = xmlRootElement->ToString(); - // - - Console::WriteLine( elementInXml ); - } - - Console::WriteLine( L"This sample completed successfully; " - L"press Enter to exit." ); - Console::ReadLine(); - return 1; - } - - -private: - - // Add an attribute to the specified security element. - static SecurityElement^ AddAttribute( SecurityElement^ xmlElement, String^ attributeName, String^ attributeValue ) - { - if ( xmlElement != nullptr ) - { - // Verify that the attribute name and value are valid XML formats. - // - // - if ( SecurityElement::IsValidAttributeName( attributeName ) && - SecurityElement::IsValidAttributeValue( attributeValue ) ) - // - // - { - // Add the attribute to the security element. - // - xmlElement->AddAttribute( attributeName, attributeValue ); - // - } - } - - return xmlElement; - } - - - // Add a child element to the specified security element. - static SecurityElement^ AddChildElement( SecurityElement^ parentElement, String^ tagName, String^ tagText ) - { - if ( parentElement != nullptr ) - { - // Ensure that the tag text is in valid XML format. - // - if ( !SecurityElement::IsValidText( tagText ) ) - // - { - // Replace invalid text with valid XML text - // to enforce proper XML formatting. - // - tagText = SecurityElement::Escape( tagText ); - // - } - - // Determine whether the tag is in valid XML format. - // - if ( SecurityElement::IsValidTag( tagName ) ) - // - { - // - SecurityElement^ childElement; - childElement = parentElement->SearchForChildByTag( tagName ); - // - if ( childElement != nullptr ) - { - // - String^ elementText; - elementText = parentElement->SearchForTextOfTag( tagName ); - // - if ( !elementText->Equals( tagText ) ) - { - // Add child element to the parent security element. - parentElement->AddChild( gcnew SecurityElement( tagName,tagText ) ); - } - } - else - { - // Add child element to the parent security element. - parentElement->AddChild( gcnew SecurityElement( tagName,tagText ) ); - } - } - } - - return parentElement; - } - - - // Create and display a summary sentence - // about the specified security element. - static void DisplaySummary( SecurityElement^ xmlElement ) - { - // Retrieve tag name for the security element. - // - String^ xmlTreeName = xmlElement->Tag->ToString(); - // - // Retrieve tag text for the security element. - // - String^ xmlTreeDescription = xmlElement->Text; - // - // Retrieve value of the creationdate attribute. - // - String^ xmlCreationDate = xmlElement->Attribute(L"creationdate"); - // - // Retrieve the number of children under the security element. - // - String^ childrenCount = xmlElement->Children->Count.ToString(); - // - String^ outputMessage = String::Format( L"The security XML tree named {0}", xmlTreeName ); - outputMessage = String::Concat( outputMessage, String::Format( L"({0})", xmlTreeDescription ) ); - outputMessage = String::Concat( outputMessage, String::Format( L" was created on {0} and ", xmlCreationDate ) ); - outputMessage = String::Concat( outputMessage, String::Format( L"contains {0} child elements.", childrenCount ) ); - Console::WriteLine( outputMessage ); - } - - // Compare the first two occurrences of an attribute - // in the specified security element. - static void CompareAttributes( SecurityElement^ xmlElement, String^ attributeName ) - { - // Create a hash table containing the security element's attributes. - // - Hashtable^ attributeKeys = xmlElement->Attributes; - String^ attributeValue = attributeKeys[ attributeName ]->ToString(); - // - IEnumerator^ myEnum = xmlElement->Children->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - SecurityElement^ xmlChild = safe_cast(myEnum->Current); - if ( attributeValue->Equals( xmlChild->Attribute(attributeName) ) ) - { - // The security elements were created at the exact same time. - } - } - } - - // Convert the contents of the specified security element - // to hash codes stored in a hash table. - static void ConvertToHashTable( SecurityElement^ xmlElement ) - { - // Create a hash table to hold hash codes of the security elements. - // - Hashtable^ xmlAsHash = gcnew Hashtable; - int rootIndex = xmlElement->GetHashCode(); - xmlAsHash->Add( rootIndex, L"root" ); - // - int parentNum = 0; - IEnumerator^ myEnum1 = xmlElement->Children->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - SecurityElement^ xmlParent = safe_cast(myEnum1->Current); - parentNum++; - xmlAsHash->Add( xmlParent->GetHashCode(), String::Format( L"parent{0}", parentNum ) ); - if ( (xmlParent->Children != nullptr) && (xmlParent->Children->Count > 0) ) - { - int childNum = 0; - IEnumerator^ myEnum2 = xmlParent->Children->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - SecurityElement^ xmlChild = safe_cast(myEnum2->Current); - childNum++; - xmlAsHash->Add( xmlChild->GetHashCode(), String::Format( L"child{0}", childNum ) ); - } - } - } - } - - // Delete the specified security element if the current time is past - // the time stored in the destroytime tag. - static SecurityElement^ DestroyTree( SecurityElement^ xmlElement ) - { - SecurityElement^ localXmlElement = xmlElement; - SecurityElement^ destroyElement = localXmlElement->SearchForChildByTag( L"destroytime" ); - - // Verify that a destroytime tag exists. - // - if ( localXmlElement->SearchForChildByTag( L"destroytime" ) != nullptr ) - // - { - // Retrieve the destroytime text to get the time - // the tree can be destroyed. - // - String^ storedDestroyTime = localXmlElement->SearchForTextOfTag( L"destroytime" ); - // - DateTime destroyTime = DateTime::Parse( storedDestroyTime ); - if ( DateTime::Now > destroyTime ) - { - localXmlElement = nullptr; - Console::WriteLine( L"The XML security tree has been deleted." ); - } - } - - - // Verify that xmlElement is of type SecurityElement. - // - if ( xmlElement->GetType()->Equals( System::Security::SecurityElement::typeid ) ) - // - { - // Determine whether the localXmlElement object - // differs from xmlElement. - // - if ( xmlElement->Equals( localXmlElement ) ) - // - { - // Verify that the tags, attributes and children of the - // two security elements are identical. - // - if ( xmlElement->Equal( localXmlElement ) ) - // - { - // Return the original security element. - return xmlElement; - } - } - } - - // Return the modified security element. - return localXmlElement; - } - -}; - -int main() -{ - SecurityElementMembers^ sem = gcnew SecurityElementMembers; - sem->TestSecurityElementMembers(); -} - -// -// This sample produces the following output: -// -// The security XML tree named RootTag(XML security tree) -// was created on 2/23/2004 1:23:00 PM and contains 2 child elements. -//XML security tree -// 2/23/2004 1:23:01 PM -// -// This is a child element. -// -// -// -//This sample completed successfully; press Exit to continue. -// diff --git a/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp deleted file mode 100644 index b873188879c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp +++ /dev/null @@ -1,280 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; - -// This console application illustrates various uses -// of the StackTrace and StackFrame classes. -namespace SampleInternal -{ - public ref class ClassLevel6 - { - public: - void Level6Method() - { - throw gcnew Exception( "An error occurred in the lowest internal class method." ); - } - - }; - - public ref class ClassLevel5 - { - public: - - // - void Level5Method() - { - try - { - ClassLevel6^ nestedClass = gcnew ClassLevel6; - nestedClass->Level6Method(); - } - catch ( Exception^ e ) - { - Console::WriteLine( " Level5Method exception handler" ); - StackTrace^ st = gcnew StackTrace; - - // Display the most recent function call. - StackFrame^ sf = st->GetFrame( 0 ); - Console::WriteLine(); - Console::WriteLine( " Exception in method: " ); - Console::WriteLine( " {0}", sf->GetMethod() ); - if ( st->FrameCount > 1 ) - { - - // Display the highest-level function call - // in the trace. - sf = st->GetFrame( st->FrameCount - 1 ); - Console::WriteLine( " Original function call at top of call stack):" ); - Console::WriteLine( " {0}", sf->GetMethod() ); - } - Console::WriteLine(); - Console::WriteLine( " ... throwing exception to next level ..." ); - Console::WriteLine( "-------------------------------------------------\n" ); - throw e; - } - - } - - // - }; - - public ref class ClassLevel4 - { - public: - void Level4Method() - { - - // - try - { - ClassLevel5^ nestedClass = gcnew ClassLevel5; - nestedClass->Level5Method(); - } - catch ( Exception^ e ) - { - Console::WriteLine( " Level4Method exception handler" ); - - // Build a stack trace from a dummy stack frame. - // Explicitly specify the source file name, line number - // and column number. - StackTrace^ st = gcnew StackTrace( gcnew StackFrame( "source.cs",79,24 ) ); - Console::WriteLine( " Stack trace with dummy stack frame: {0}", st->ToString() ); - - // Access the StackFrames explicitly to display the file - // name, line number and column number properties. - // StackTrace.ToString only includes the method name. - for ( int i = 0; i < st->FrameCount; i++ ) - { - StackFrame^ sf = st->GetFrame( i ); - Console::WriteLine( " File: {0}", sf->GetFileName() ); - Console::WriteLine( " Line Number: {0}", sf->GetFileLineNumber().ToString() ); - Console::WriteLine( " Column Number: {0}", sf->GetFileColumnNumber().ToString() ); - - } - Console::WriteLine(); - Console::WriteLine( " ... throwing exception to next level ..." ); - Console::WriteLine( "-------------------------------------------------\n" ); - throw e; - } - - - // - } - - }; - - public ref class ClassLevel3 - { - public: - - // - void Level3Method() - { - try - { - ClassLevel4^ nestedClass = gcnew ClassLevel4; - nestedClass->Level4Method(); - } - catch ( Exception^ e ) - { - Console::WriteLine( " Level3Method exception handler" ); - - // Build a stack trace from a dummy stack frame. - // Explicitly specify the source file name and line number. - StackTrace^ st = gcnew StackTrace( gcnew StackFrame( "source.cs",60 ) ); - Console::WriteLine( " Stack trace with dummy stack frame: {0}", st->ToString() ); - for ( int i = 0; i < st->FrameCount; i++ ) - { - - // - // Display the stack frame properties. - StackFrame^ sf = st->GetFrame( i ); - Console::WriteLine( " File: {0}", sf->GetFileName() ); - Console::WriteLine( " Line Number: {0}", sf->GetFileLineNumber().ToString() ); - - // Note that the column number defaults to zero - // when not initialized. - Console::WriteLine( " Column Number: {0}", sf->GetFileColumnNumber().ToString() ); - Console::WriteLine( " Intermediate Language Offset: {0}", sf->GetILOffset().ToString() ); - Console::WriteLine( " Native Offset: {0}", sf->GetNativeOffset().ToString() ); - - // - - } - Console::WriteLine(); - Console::WriteLine( " ... throwing exception to next level ..." ); - Console::WriteLine( "-------------------------------------------------\n" ); - throw e; - } - - } - - // - }; - - public ref class ClassLevel2 - { - public: - - // - void Level2Method() - { - try - { - ClassLevel3^ nestedClass = gcnew ClassLevel3; - nestedClass->Level3Method(); - } - catch ( Exception^ e ) - { - Console::WriteLine( " Level2Method exception handler" ); - - // Display the full call stack at this level. - StackTrace^ st1 = gcnew StackTrace( true ); - Console::WriteLine( " Stack trace for this level: {0}", st1->ToString() ); - - // Build a stack trace from one frame, skipping the - // current frame and using the next frame. - StackTrace^ st2 = gcnew StackTrace( gcnew StackFrame( 1,true ) ); - Console::WriteLine( " Stack trace built with next level frame: {0}", st2->ToString() ); - - // Build a stack trace skipping the current frame, and - // including all the other frames. - StackTrace^ st3 = gcnew StackTrace( 1,true ); - Console::WriteLine( " Stack trace built from the next level up: {0}", st3->ToString() ); - Console::WriteLine(); - Console::WriteLine( " ... throwing exception to next level ..." ); - Console::WriteLine( "-------------------------------------------------\n" ); - throw e; - } - - } - - // - }; - - public ref class ClassLevel1 - { - public: - - // - void InternalMethod() - { - try - { - ClassLevel2^ nestedClass = gcnew ClassLevel2; - nestedClass->Level2Method(); - } - catch ( Exception^ e ) - { - Console::WriteLine( " InternalMethod exception handler" ); - - // Build a stack trace from one frame, skipping the - // current frame and using the next frame. By - // default, file and line information are not displayed. - StackTrace^ st = gcnew StackTrace( gcnew StackFrame( 1 ) ); - Console::WriteLine( " Stack trace for next level frame: {0}", st->ToString() ); - Console::WriteLine( " Stack frame for next level: " ); - Console::WriteLine( " {0}", st->GetFrame( 0 )->ToString() ); - Console::WriteLine( " Line Number: {0}", st->GetFrame( 0 )->GetFileLineNumber().ToString() ); - Console::WriteLine(); - Console::WriteLine( " ... throwing exception to next level ..." ); - Console::WriteLine( "-------------------------------------------------\n" ); - throw e; - } - - } - - // - }; - -} - - -using namespace SampleInternal; - -namespace SamplePublic -{ - class ConsoleApp - { - public: - - // - - [STAThread] - static void Main() - { - ClassLevel1 ^ mainClass = gcnew ClassLevel1; - try - { - mainClass->InternalMethod(); - } - catch ( Exception^ e ) - { - Console::WriteLine( " Main method exception handler" ); - - // Display file and line information, if available. - StackTrace^ st = gcnew StackTrace( gcnew StackFrame( true ) ); - Console::WriteLine( " Stack trace for current level: {0}", st->ToString() ); - Console::WriteLine( " File: {0}", st->GetFrame( 0 )->GetFileName() ); - Console::WriteLine( " Line Number: {0}", st->GetFrame( 0 )->GetFileLineNumber().ToString() ); - Console::WriteLine(); - Console::WriteLine( "-------------------------------------------------\n" ); - } - - } - - // - }; - -} - -int main() -{ - SamplePublic::ConsoleApp::Main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/StackTraceSample1/CPP/stacktracesample1.cpp b/snippets/cpp/VS_Snippets_CLR/StackTraceSample1/CPP/stacktracesample1.cpp deleted file mode 100644 index 83e6e596d61..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StackTraceSample1/CPP/stacktracesample1.cpp +++ /dev/null @@ -1,147 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -ref class StackTraceSample -{ -private: - ref class MyInternalClass - { - public: - void ThrowsException() - { - try - { - throw gcnew Exception( "A problem was encountered." ); - } - catch ( Exception^ e ) - { - - // Create a StackTrace that captures - // filename, line number, and column - // information for the current thread. - StackTrace^ st = gcnew StackTrace( true ); - String^ stackIndent = ""; - for ( int i = 0; i < st->FrameCount; i++ ) - { - - // Note that at this level, there are five - // stack frames, one for each method invocation. - StackFrame^ sf = st->GetFrame( i ); - Console::WriteLine(); - Console::WriteLine( "{0}Method: {1}", stackIndent, sf->GetMethod() ); - Console::WriteLine( "{0}File: {1}", stackIndent, sf->GetFileName() ); - Console::WriteLine( "{0}Line Number: {1}", stackIndent, sf->GetFileLineNumber().ToString() ); - stackIndent = String::Concat( stackIndent, " " ); - - } - throw e; - } - - } - - }; - - -protected: - void MyProtectedMethod() - { - MyInternalClass^ mic = gcnew MyInternalClass; - mic->ThrowsException(); - } - - -public: - void MyPublicMethod() - { - MyProtectedMethod(); - } - -}; - -int main() -{ - StackTraceSample^ sample = gcnew StackTraceSample; - try - { - sample->MyPublicMethod(); - } - catch ( Exception^ ) - { - - // Create a StackTrace that captures - // filename, line number, and column - // information for the current thread. - StackTrace^ st = gcnew StackTrace( true ); - for ( int i = 0; i < st->FrameCount; i++ ) - { - - // For an executable built from C++, there - // are two stack frames here: one for main, - // and one for the _mainCRTStartup stub. - StackFrame^ sf = st->GetFrame( i ); - Console::WriteLine(); - Console::WriteLine( "High up the call stack, Method: {0}", sf->GetMethod()->ToString() ); - Console::WriteLine( "High up the call stack, Line Number: {0}", sf->GetFileLineNumber().ToString() ); - - } - } - -} - -/* -This console application produces the following output when -compiled with the Debug configuration. - - Method: Void ThrowsException() - File: c:\samples\stacktraceframe\myclass.cpp - Line Number: 20 - - Method: Void MyProtectedMethod() - File: c:\samples\stacktraceframe\myclass.cpp - Line Number: 45 - - Method: Void MyPublicMethod() - File: c:\samples\stacktraceframe\myclass.cpp - Line Number: 50 - - Method: Int32 main() - File: c:\samples\stacktraceframe\myclass.cpp - Line Number: 56 - - Method: UInt32 _mainCRTStartup() - File: - Line Number: 0 - - High up the call stack, Method: Int32 main() - High up the call stack, Line Number: 62 - - High up the call stack, Method: UInt32 _mainCRTStartup() - High up the call stack, Line Number: 0 - -This console application produces the following output when -compiled with the Release configuration. - - Method: Void ThrowsException() - File: - Line Number: 0 - - Method: Int32 main() - File: - Line Number: 0 - - Method: UInt32 _mainCRTStartup() - File: - Line Number: 0 - - High up the call stack, Method: Int32 main() - High up the call stack, Line Number: 0 - - High up the call stack, Method: UInt32 _mainCRTStartup() - High up the call stack, Line Number: 0 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/StackTraceSample2/CPP/stacktracesample2.cpp b/snippets/cpp/VS_Snippets_CLR/StackTraceSample2/CPP/stacktracesample2.cpp deleted file mode 100644 index 2dcb2ce73fc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StackTraceSample2/CPP/stacktracesample2.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -ref class MyConsoleApp -{ -private: - ref class MyInnerClass - { - public: - void ThrowsException() - { - try - { - throw gcnew Exception( "A problem was encountered." ); - } - catch ( Exception^ ) - { - - // Create a StackTrace starting at the next level - // stack frame. Skip the first frame, the frame of - // this level, which hides the internal implementation - // of the ThrowsException method. Include the line - // number, file name, and column number information - // for each frame. - // - StackTrace^ st = gcnew StackTrace( 1,true ); - array^stFrames = st->GetFrames(); - for ( int i; i < stFrames->Length; i++ ) - { - StackFrame^ sf = stFrames[ i ]; - Console::WriteLine( "Method: {0}", sf->GetMethod() ); - - } - // - } - - } - - }; - - -public: - void MyPublicMethod() - { - MyInnerClass^ helperClass = gcnew MyInnerClass; - helperClass->ThrowsException(); - } - -}; - -void main() -{ - MyConsoleApp^ myApp = gcnew MyConsoleApp; - myApp->MyPublicMethod(); -} - -/* -This console application produces the following output -when compiled with optimization off. - -Note that the ThrowsException() method is not identified in -this stack trace. - - Method: Void MyPublicMethod() - Method: Void Main() - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/StackTraceSample3/CPP/stacktracesample3.cpp b/snippets/cpp/VS_Snippets_CLR/StackTraceSample3/CPP/stacktracesample3.cpp deleted file mode 100644 index 49e44641a2b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StackTraceSample3/CPP/stacktracesample3.cpp +++ /dev/null @@ -1,88 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Diagnostics; -ref class MyConsoleApp -{ -private: - - // - ref class MyInnerClass - { - public: - void ThrowsException() - { - try - { - throw gcnew Exception( "A problem was encountered." ); - } - catch ( Exception^ ) - { - - // Log the Exception. We do not want to reveal the - // inner workings of the class, or be too verbose, so - // we will create a StackTrace with a single - // StackFrame, where the frame is that of the calling - // method. - // - StackFrame^ fr = gcnew StackFrame( 1,true ); - StackTrace^ st = gcnew StackTrace( fr ); - EventLog::WriteEntry( fr->GetMethod()->Name, st->ToString(), EventLogEntryType::Warning ); - // - - // Note that whenever this application is run, the EventLog - // contains an Event similar to the following Event. - // - // Event Type: Warning - // Event Source: MyPublicMethod - // Event Category: None - // Event ID: 0 - // Date: 6/17/2001 - // Time: 6:39:56 PM - // User: N/A - // Computer: MYCOMPUTER - // Description: - // - // at MyConsoleApp.MyPublicMethod() - // - // For more information, see Help and Support Center at - // http://go.microsoft.com/fwlink/events.asp. - } - - } - - }; - // - - -public: - - // - void MyPublicMethod() - { - MyInnerClass^ helperClass = gcnew MyInnerClass; - helperClass->ThrowsException(); - } - -}; - -void main() -{ - MyConsoleApp^ helperClass = gcnew MyConsoleApp; - helperClass->MyPublicMethod(); -} - -/* -This console application produces the following output -when compiled with optimization off. - -Note that the ThrowsException() method is not identified in -this stack trace. - - Method: Void MyPublicMethod() - Method: Void Main() - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp deleted file mode 100644 index 3b2fe7a7575..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp +++ /dev/null @@ -1,201 +0,0 @@ - - -// System.Diagnostics.Stopwatch -// -#using - -using namespace System; -using namespace System::Diagnostics; - -// -void DisplayTimerProperties() -{ - // Display the timer frequency and resolution. - if ( Stopwatch::IsHighResolution ) - { - Console::WriteLine( "Operations timed using the system's high-resolution performance counter." ); - } - else - { - Console::WriteLine( "Operations timed using the DateTime class." ); - } - - Int64 frequency = Stopwatch::Frequency; - Console::WriteLine( " Timer frequency in ticks per second = {0}", frequency ); - Int64 nanosecPerTick = (1000L * 1000L * 1000L) / frequency; - Console::WriteLine( " Timer is accurate within {0} nanoseconds", nanosecPerTick ); -} -// - -// -void TimeOperations() -{ - Int64 nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch::Frequency; - const long numIterations = 10000; - - // Define the operation title names. - array^operationNames = {"Operation: Int32.Parse(\"0\")","Operation: Int32.TryParse(\"0\")","Operation: Int32.Parse(\"a\")","Operation: Int32.TryParse(\"a\")"}; - - // Time four different implementations for parsing - // an integer from a string. - for ( int operation = 0; operation <= 3; operation++ ) - { - // - // Define variables for operation statistics. - Int64 numTicks = 0; - Int64 numRollovers = 0; - Int64 maxTicks = 0; - Int64 minTicks = Int64::MaxValue; - int indexFastest = -1; - int indexSlowest = -1; - Int64 milliSec = 0; - Stopwatch ^ time10kOperations = Stopwatch::StartNew(); - - // Run the current operation 10001 times. - // The first execution time will be tossed - // out, since it can skew the average time. - for ( int i = 0; i <= numIterations; i++ ) - { - // - Int64 ticksThisTime = 0; - int inputNum; - Stopwatch ^ timePerParse; - switch ( operation ) - { - case 0: - - // Parse a valid integer using - // a try-catch statement. - // Start a new stopwatch timer. - timePerParse = Stopwatch::StartNew(); - try - { - inputNum = Int32::Parse( "0" ); - } - catch ( FormatException^ ) - { - inputNum = 0; - } - - // Stop the timer, and save the - // elapsed ticks for the operation. - timePerParse->Stop(); - ticksThisTime = timePerParse->ElapsedTicks; - break; - - case 1: - - // Parse a valid integer using - // the TryParse statement. - // Start a new stopwatch timer. - timePerParse = Stopwatch::StartNew(); - if ( !Int32::TryParse( "0", inputNum ) ) - { - inputNum = 0; - } - - // Stop the timer, and save the - // elapsed ticks for the operation. - timePerParse->Stop(); - ticksThisTime = timePerParse->ElapsedTicks; - break; - - case 2: - - // Parse an invalid value using - // a try-catch statement. - // Start a new stopwatch timer. - timePerParse = Stopwatch::StartNew(); - try - { - inputNum = Int32::Parse( "a" ); - } - catch ( FormatException^ ) - { - inputNum = 0; - } - - // Stop the timer, and save the - // elapsed ticks for the operation. - timePerParse->Stop(); - ticksThisTime = timePerParse->ElapsedTicks; - break; - - case 3: - - // Parse an invalid value using - // the TryParse statement. - // Start a new stopwatch timer. - timePerParse = Stopwatch::StartNew(); - if ( !Int32::TryParse( "a", inputNum ) ) - { - inputNum = 0; - } - - // Stop the timer, and save the - // elapsed ticks for the operation. - timePerParse->Stop(); - ticksThisTime = timePerParse->ElapsedTicks; - break; - - default: - break; - } - // - - // Skip over the time for the first operation, - // just in case it caused a one-time - // performance hit. - if ( i == 0 ) - { - time10kOperations->Reset(); - time10kOperations->Start(); - } - else - { - // Update operation statistics - // for iterations 1-10001. - if ( maxTicks < ticksThisTime ) - { - indexSlowest = i; - maxTicks = ticksThisTime; - } - if ( minTicks > ticksThisTime ) - { - indexFastest = i; - minTicks = ticksThisTime; - } - numTicks += ticksThisTime; - if ( numTicks < ticksThisTime ) - { - // Keep track of rollovers. - numRollovers++; - } - } - } - - // Display the statistics for 10000 iterations. - time10kOperations->Stop(); - milliSec = time10kOperations->ElapsedMilliseconds; - Console::WriteLine(); - Console::WriteLine( "{0} Summary:", operationNames[ operation ] ); - Console::WriteLine( " Slowest time: #{0}/{1} = {2} ticks", indexSlowest, numIterations, maxTicks ); - Console::WriteLine( " Fastest time: #{0}/{1} = {2} ticks", indexFastest, numIterations, minTicks ); - Console::WriteLine( " Average time: {0} ticks = {1} nanoseconds", numTicks / numIterations, (numTicks * nanosecPerTick) / numIterations ); - Console::WriteLine( " Total time looping through {0} operations: {1} milliseconds", numIterations, milliSec ); - // - - } -} -// - -int main() -{ - DisplayTimerProperties(); - Console::WriteLine(); - Console::WriteLine( "Press the Enter key to begin:" ); - Console::ReadLine(); - Console::WriteLine(); - TimeOperations(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp b/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp deleted file mode 100644 index ba044bc83d7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//Code Modification: Removed AppendLine and associated comment after the AppendFormat line. -//The CR/LF bytes introduces by AppendLine made the sb.Length appear incorrect. -// Before -//sb.AppendFormat("GHI{0}{1}", 'J', 'k'); -////APpend a blank line to the end of the StringBuilder. -// sb.AppendLine(); -// After -//sb.AppendFormat("GHI{0}{1}", 'J', 'k'); -//Code Modification: End -//Types:System.Text.StringBuilder -// -using namespace System; -using namespace System::Text; - -int main() -{ - // - // Create a StringBuilder that expects to hold 50 characters. - // Initialize the StringBuilder with "ABC". - StringBuilder^ sb = gcnew StringBuilder("ABC", 50); - // - - // - // Append three characters (D, E, and F) to the end of the - // StringBuilder. - sb->Append(gcnew array{'D', 'E', 'F'}); - // - - // - // Append a format string to the end of the StringBuilder. - sb->AppendFormat("GHI{0}{1}", (Char)'J', (Char)'k'); - // - - // - // Display the number of characters in the StringBuilder - // and its string. - Console::WriteLine("{0} chars: {1}", sb->Length, sb->ToString()); - // - - // - // Insert a string at the beginning of the StringBuilder. - sb->Insert(0, "Alphabet: "); - // - - // - // Replace all lowercase k's with uppercase K's. - sb->Replace('k', 'K'); - // - - // Display the number of characters in the StringBuilder - // and its string. - Console::WriteLine("{0} chars: {1}", sb->Length, sb->ToString()); -} - -// This code produces the following output. -// -// 11 chars: ABCDEFGHIJk -// 21 chars: Alphabet: ABCDEFGHIJK -// diff --git a/snippets/cpp/VS_Snippets_CLR/StringInfo/cpp/StringInfo.cpp b/snippets/cpp/VS_Snippets_CLR/StringInfo/cpp/StringInfo.cpp deleted file mode 100644 index 15c96facbe9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StringInfo/cpp/StringInfo.cpp +++ /dev/null @@ -1,84 +0,0 @@ -//Types:System.Globalization.StringInfo -// -using namespace System; -using namespace System::Text; -using namespace System::Globalization; - - -// Show how to enumerate each real character (honoring surrogates) -// in a string. - -void EnumTextElements(String^ combiningChars) -{ - // This StringBuilder holds the output results. - StringBuilder^ sb = gcnew StringBuilder(); - - // Use the enumerator returned from GetTextElementEnumerator - // method to examine each real character. - TextElementEnumerator^ charEnum = - StringInfo::GetTextElementEnumerator(combiningChars); - while (charEnum->MoveNext()) - { - sb->AppendFormat("Character at index {0} is '{1}'{2}", - charEnum->ElementIndex, charEnum->GetTextElement(), - Environment::NewLine); - } - - // Show the results. - Console::WriteLine("Result of GetTextElementEnumerator:"); - Console::WriteLine(sb); -} - - -// Show how to discover the index of each real character -// (honoring surrogates) in a string. - -void EnumTextElementIndexes(String^ combiningChars) -{ - // This StringBuilder holds the output results. - StringBuilder^ sb = gcnew StringBuilder(); - - // Use the ParseCombiningCharacters method to - // get the index of each real character in the string. - array ^ textElemIndex = - StringInfo::ParseCombiningCharacters(combiningChars); - - // Iterate through each real character showing the character - // and the index where it was found. - for (int i = 0; i < textElemIndex->Length; i++) - { - sb->AppendFormat("Character {0} starts at index {1}{2}", - i, textElemIndex[i], Environment::NewLine); - } - - // Show the results. - Console::WriteLine("Result of ParseCombiningCharacters:"); - Console::WriteLine(sb); -} - -int main() -{ - - // The string below contains combining characters. - String^ combiningChars = L"a\u0304\u0308bc\u0327"; - - // Show each 'character' in the string. - EnumTextElements(combiningChars); - - // Show the index in the string where each 'character' starts. - EnumTextElementIndexes(combiningChars); - -}; - -// This code produces the following output. -// -// Result of GetTextElementEnumerator: -// Character at index 0 is 'a-"' -// Character at index 3 is 'b' -// Character at index 4 is 'c,' -// -// Result of ParseCombiningCharacters: -// Character 0 starts at index 0 -// Character 1 starts at index 3 -// Character 2 starts at index 4 -// diff --git a/snippets/cpp/VS_Snippets_CLR/StrmRdrRead/CPP/strmrdrread.cpp b/snippets/cpp/VS_Snippets_CLR/StrmRdrRead/CPP/strmrdrread.cpp deleted file mode 100644 index 7d915b93810..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StrmRdrRead/CPP/strmrdrread.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - //Create a FileInfo instance representing an existing text file. - FileInfo^ MyFile = gcnew FileInfo( "c:\\csc.txt" ); - - //Instantiate a StreamReader to read from the text file. - StreamReader^ sr = MyFile->OpenText(); - - //Read a single character. - int FirstChar = sr->Read(); - - //Display the ASCII number of the character read in both decimal and hexadecimal format. - Console::WriteLine( "The ASCII number of the first character read is {0:D} in decimal and {1:X} in hexadecimal.", FirstChar, FirstChar ); - - // - sr->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor1/CPP/strmreader ctor1.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor1/CPP/strmreader ctor1.cpp deleted file mode 100644 index 91fe38d447f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor1/CPP/strmreader ctor1.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -using namespace System; -using namespace System::IO; -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - try - { - if ( File::Exists( path ) ) - { - File::Delete( path ); - } - StreamWriter^ sw = gcnew StreamWriter( path ); - try - { - sw->WriteLine( "This" ); - sw->WriteLine( "is some text" ); - sw->WriteLine( "to test" ); - sw->WriteLine( "Reading" ); - } - finally - { - delete sw; - } - - FileStream^ fs = gcnew FileStream( path,FileMode::Open ); - try - { - StreamReader^ sr = gcnew StreamReader( fs ); - try - { - while ( sr->Peek() >= 0 ) - { - Console::WriteLine( sr->ReadLine() ); - } - } - finally - { - delete sr; - } - } - finally - { - delete fs; - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor2/CPP/strmreader ctor2.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor2/CPP/strmreader ctor2.cpp deleted file mode 100644 index 9966a619ccf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor2/CPP/strmreader ctor2.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -using namespace System; -using namespace System::IO; -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - try - { - if ( File::Exists( path ) ) - { - File::Delete( path ); - } - StreamWriter^ sw = gcnew StreamWriter( path ); - try - { - sw->WriteLine( "This" ); - sw->WriteLine( "is some text" ); - sw->WriteLine( "to test" ); - sw->WriteLine( "Reading" ); - } - finally - { - delete sw; - } - - StreamReader^ sr = gcnew StreamReader( path ); - try - { - while ( sr->Peek() >= 0 ) - { - Console::WriteLine( sr->ReadLine() ); - } - } - finally - { - delete sr; - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader CurrentEncoding/CPP/strmreader currentencoding.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader CurrentEncoding/CPP/strmreader currentencoding.cpp deleted file mode 100644 index 2bd7741e9da..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StrmReader CurrentEncoding/CPP/strmreader currentencoding.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - try - { - if ( File::Exists( path ) ) - { - File::Delete( path ); - } - - //Use an encoding other than the default (UTF8). - StreamWriter^ sw = gcnew StreamWriter( path,false,gcnew UnicodeEncoding ); - try - { - sw->WriteLine( "This" ); - sw->WriteLine( "is some text" ); - sw->WriteLine( "to test" ); - sw->WriteLine( "Reading" ); - } - finally - { - delete sw; - } - - StreamReader^ sr = gcnew StreamReader( path,true ); - try - { - while ( sr->Peek() >= 0 ) - { - Console::Write( (Char)sr->Read() ); - } - - //Test for the encoding after reading, or at least - //after the first read. - Console::WriteLine( "The encoding used was {0}.", sr->CurrentEncoding ); - Console::WriteLine(); - } - finally - { - delete sr; - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader Peek/CPP/strmreader peek.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader Peek/CPP/strmreader peek.cpp deleted file mode 100644 index cbfd1711768..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StrmReader Peek/CPP/strmreader peek.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - try - { - if ( File::Exists( path ) ) - { - File::Delete( path ); - } - StreamWriter^ sw = gcnew StreamWriter( path ); - try - { - sw->WriteLine( "This" ); - sw->WriteLine( "is some text" ); - sw->WriteLine( "to test" ); - sw->WriteLine( "Reading" ); - } - finally - { - delete sw; - } - - StreamReader^ sr = gcnew StreamReader( path ); - try - { - while ( sr->Peek() > -1 ) - { - Console::WriteLine( sr->ReadLine() ); - } - } - finally - { - delete sr; - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader Read1/CPP/strmreader read1.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader Read1/CPP/strmreader read1.cpp deleted file mode 100644 index 3b817c31cf1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StrmReader Read1/CPP/strmreader read1.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -using namespace System; -using namespace System::IO; -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - try - { - if ( File::Exists( path ) ) - { - File::Delete( path ); - } - StreamWriter^ sw = gcnew StreamWriter( path ); - try - { - sw->WriteLine( "This" ); - sw->WriteLine( "is some text" ); - sw->WriteLine( "to test" ); - sw->WriteLine( "Reading" ); - } - finally - { - delete sw; - } - - StreamReader^ sr = gcnew StreamReader( path ); - try - { - while ( sr->Peek() >= 0 ) - { - Console::Write( (Char)sr->Read() ); - } - } - finally - { - delete sr; - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader Read2/CPP/strmreader read2.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader Read2/CPP/strmreader read2.cpp deleted file mode 100644 index 5ce83649e21..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StrmReader Read2/CPP/strmreader read2.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - try - { - if ( File::Exists( path ) ) - { - File::Delete( path ); - } - StreamWriter^ sw = gcnew StreamWriter( path ); - try - { - sw->WriteLine( "This" ); - sw->WriteLine( "is some text" ); - sw->WriteLine( "to test" ); - sw->WriteLine( "Reading" ); - } - finally - { - delete sw; - } - - StreamReader^ sr = gcnew StreamReader( path ); - try - { - //This is an arbitrary size for this example. - array^c = nullptr; - while ( sr->Peek() >= 0 ) - { - c = gcnew array(5); - sr->Read( c, 0, c->Length ); - - //The output will look odd, because - //only five characters are read at a time. - Console::WriteLine( c ); - } - } - finally - { - delete sr; - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader ReadLine/CPP/strmreader readline.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader ReadLine/CPP/strmreader readline.cpp deleted file mode 100644 index 5829e1a8108..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StrmReader ReadLine/CPP/strmreader readline.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - try - { - if ( File::Exists( path ) ) - { - File::Delete( path ); - } - StreamWriter^ sw = gcnew StreamWriter( path ); - try - { - sw->WriteLine( "This" ); - sw->WriteLine( "is some text" ); - sw->WriteLine( "to test" ); - sw->WriteLine( "Reading" ); - } - finally - { - delete sw; - } - - StreamReader^ sr = gcnew StreamReader( path ); - try - { - while ( sr->Peek() >= 0 ) - { - Console::WriteLine( sr->ReadLine() ); - } - } - finally - { - delete sr; - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/StrmReader ReadToEnd/CPP/strmreader readtoend.cpp b/snippets/cpp/VS_Snippets_CLR/StrmReader ReadToEnd/CPP/strmreader readtoend.cpp deleted file mode 100644 index 5ae01bcfc2e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StrmReader ReadToEnd/CPP/strmreader readtoend.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// -using namespace System; -using namespace System::IO; -int main() -{ - String^ path = "c:\\temp\\MyTest.txt"; - try - { - if ( File::Exists( path ) ) - { - File::Delete( path ); - } - StreamWriter^ sw = gcnew StreamWriter( path ); - try - { - sw->WriteLine( "This" ); - sw->WriteLine( "is some text" ); - sw->WriteLine( "to test" ); - sw->WriteLine( "Reading" ); - } - finally - { - delete sw; - } - - StreamReader^ sr = gcnew StreamReader( path ); - try - { - //This allows you to do one Read operation. - Console::WriteLine( sr->ReadToEnd() ); - } - finally - { - delete sr; - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "The process failed: {0}", e ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp deleted file mode 100644 index 00fb6116cb7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -void ThreadProc() -{ - Thread::Sleep(2000); -}; - -void main() -{ - Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc)); - Console::WriteLine("Before setting apartment state: {0}", - t->GetApartmentState()); - - t->SetApartmentState(ApartmentState::STA); - Console::WriteLine("After setting apartment state: {0}", - t->GetApartmentState()); - - bool result = t->TrySetApartmentState(ApartmentState::MTA); - Console::WriteLine("Try to change state: {0}", result); - - t->Start(); - - Thread::Sleep(500); - - try - { - t->TrySetApartmentState(ApartmentState::STA); - } - catch (ThreadStateException^) - { - Console::WriteLine("ThreadStateException occurs " + - "if apartment state is set after starting thread."); - } - - t->Join(); -} - -/* This code example produces the following output: - -Before setting apartment state: Unknown -After setting apartment state: STA -Try to change state: False -ThreadStateException occurs if apartment state is set after starting thread. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp b/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp deleted file mode 100644 index b1f06ee79ff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Security::Permissions; -ref class ThreadWork -{ -public: - static void DoWork() - { - try - { - for ( int i = 0; i < 100; i++ ) - { - Console::WriteLine( "Thread - working." ); - Thread::Sleep( 100 ); - - } - } - catch ( ThreadAbortException^ e ) - { - Console::WriteLine( "Thread - caught ThreadAbortException - resetting." ); - Console::WriteLine( "Exception message: {0}", e->Message ); - Thread::ResetAbort(); - } - - Console::WriteLine( "Thread - still alive and working." ); - Thread::Sleep( 1000 ); - Console::WriteLine( "Thread - finished working." ); - } - -}; - -int main() -{ - ThreadStart^ myThreadDelegate = gcnew ThreadStart( ThreadWork::DoWork ); - Thread^ myThread = gcnew Thread( myThreadDelegate ); - myThread->Start(); - Thread::Sleep( 100 ); - Console::WriteLine( "Main - aborting my thread." ); - myThread->Abort(); - myThread->Join(); - Console::WriteLine( "Main ending." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp b/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp deleted file mode 100644 index 45cf4ed9674..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class ThreadWork -{ -public: - static void DoWork() - { - Console::WriteLine( "Working thread..." ); - } - -}; - -int main() -{ - ThreadStart^ myThreadDelegate = gcnew ThreadStart( ThreadWork::DoWork ); - Thread^ myThread = gcnew Thread( myThreadDelegate ); - myThread->Start(); - Thread::Sleep( 0 ); - Console::WriteLine( "In main. Attempting to restart myThread." ); - try - { - myThread->Start(); - } - catch ( ThreadStateException^ e ) - { - Console::WriteLine( "Caught: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp b/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp deleted file mode 100644 index d59246f431a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -public ref class ThreadWork -{ -public: - static void DoWork() - { - for ( int i = 0; i < 3; i++ ) - { - Console::WriteLine( "Working thread..." ); - Thread::Sleep( 100 ); - } - } -}; - -int main() -{ - ThreadStart^ myThreadDelegate = gcnew ThreadStart(&ThreadWork::DoWork); - Thread^ thread1 = gcnew Thread( myThreadDelegate ); - thread1->Start(); - for ( int i = 0; i < 3; i++ ) - { - Console::WriteLine( "In main." ); - Thread::Sleep( 100 ); - } -} -// The example displays output like the following: -// In main. -// Working thread... -// In main. -// Working thread... -// In main. -// Working thread... -// diff --git a/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp b/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp deleted file mode 100644 index a5590808eaa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp +++ /dev/null @@ -1,71 +0,0 @@ -//Types:System.Threading.WaitHandle -// -using namespace System; -using namespace System::Threading; - -public ref class WaitHandleExample -{ - // Define a random number generator for testing. -private: - static Random^ random = gcnew Random(); -public: - static void DoTask(Object^ state) - { - AutoResetEvent^ autoReset = (AutoResetEvent^) state; - int time = 1000 * random->Next(2, 10); - Console::WriteLine("Performing a task for {0} milliseconds.", time); - Thread::Sleep(time); - autoReset->Set(); - } -}; - -// -int main() -{ - // Define an array with two AutoResetEvent WaitHandles. - array^ handles = gcnew array { - gcnew AutoResetEvent(false), gcnew AutoResetEvent(false)}; - - // Queue up two tasks on two different threads; - // wait until all tasks are completed. - DateTime timeInstance = DateTime::Now; - Console::WriteLine("Main thread is waiting for BOTH tasks to " + - "complete."); - ThreadPool::QueueUserWorkItem( - gcnew WaitCallback(WaitHandleExample::DoTask), handles[0]); - ThreadPool::QueueUserWorkItem( - gcnew WaitCallback(WaitHandleExample::DoTask), handles[1]); - WaitHandle::WaitAll(handles); - // The time shown below should match the longest task. - Console::WriteLine("Both tasks are completed (time waited={0})", - (DateTime::Now - timeInstance).TotalMilliseconds); - - // Queue up two tasks on two different threads; - // wait until any tasks are completed. - timeInstance = DateTime::Now; - Console::WriteLine(); - Console::WriteLine("The main thread is waiting for either task to " + - "complete."); - ThreadPool::QueueUserWorkItem( - gcnew WaitCallback(WaitHandleExample::DoTask), handles[0]); - ThreadPool::QueueUserWorkItem( - gcnew WaitCallback(WaitHandleExample::DoTask), handles[1]); - int index = WaitHandle::WaitAny(handles); - // The time shown below should match the shortest task. - Console::WriteLine("Task {0} finished first (time waited={1}).", - index + 1, (DateTime::Now - timeInstance).TotalMilliseconds); -} -// - -// This code produces the following sample output. -// -// Main thread is waiting for BOTH tasks to complete. -// Performing a task for 7000 milliseconds. -// Performing a task for 4000 milliseconds. -// Both tasks are completed (time waited=7064.8052) - -// The main thread is waiting for either task to complete. -// Performing a task for 2000 milliseconds. -// Performing a task for 2000 milliseconds. -// Task 1 finished first (time waited=2000.6528). -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp deleted file mode 100644 index 9772134cfdc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - String^ OtherCertificate = "OtherCertificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Load the certificate into an X509Certificate object. - X509Certificate^ certTwo = X509Certificate::CreateFromCertFile( OtherCertificate ); - - // Get the value. - bool result = cert->Equals( certTwo ); - - // Display the value to the console. - Console::WriteLine( result ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp deleted file mode 100644 index 5af220ab9f7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - array^results = cert->GetCertHash(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp deleted file mode 100644 index 55ab6046d0b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetCertHashString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp deleted file mode 100644 index bdd5c733874..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetEffectiveDateString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp deleted file mode 100644 index 7c7ba844a14..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetExpirationDateString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp deleted file mode 100644 index 478464e28d5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetFormat(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp deleted file mode 100644 index fbd037afed5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - int results = cert->GetHashCode(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp deleted file mode 100644 index c8cc924a1df..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetIssuerName(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp deleted file mode 100644 index 6c0355deedf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetKeyAlgorithm(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp deleted file mode 100644 index 834343b8ca2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - array^results = cert->GetKeyAlgorithmParameters(); - - // Display the value to the console. - System::Collections::IEnumerator^ enum0 = results->GetEnumerator(); - while ( enum0->MoveNext() ) - { - Byte b = safe_cast(enum0->Current); - Console::Write( b ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp deleted file mode 100644 index 3ebc0887b84..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetKeyAlgorithmParametersString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp deleted file mode 100644 index 14cc5940220..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetName(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp deleted file mode 100644 index e30ffdb3735..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - array^results = cert->GetPublicKey(); - - // Display the value to the console. - System::Collections::IEnumerator^ enum0 = results->GetEnumerator(); - while ( enum0->MoveNext() ) - { - Byte b = safe_cast(enum0->Current); - Console::Write( b ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp deleted file mode 100644 index 53861be1cdc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetPublicKeyString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp deleted file mode 100644 index da8eae2d858..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - array^results = cert->GetRawCertData(); - - // Display the value to the console. - System::Collections::IEnumerator^ enum0 = results->GetEnumerator(); - while ( enum0->MoveNext() ) - { - Byte b = safe_cast(enum0->Current); - Console::Write( b ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp deleted file mode 100644 index 17f1ada058c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetRawCertDataString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp deleted file mode 100644 index fe0562f72c8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - array^results = cert->GetSerialNumber(); - - // Display the value to the console. - System::Collections::IEnumerator^ enum0 = results->GetEnumerator(); - while ( enum0->MoveNext() ) - { - Byte b = safe_cast(enum0->Current); - Console::Write( b ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp deleted file mode 100644 index f0bcfd5314f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetSerialNumberString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp deleted file mode 100644 index 311195b9c1b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ resultsTrue = cert->ToString( true ); - - // Display the value to the console. - Console::WriteLine( resultsTrue ); - - // Get the value. - String^ resultsFalse = cert->ToString( false ); - - // Display the value to the console. - Console::WriteLine( resultsFalse ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp deleted file mode 100644 index aa1fd739b5b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// -// -// This example signs a URL using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - - -namespace Sample -{ - public ref class SignVerifyEnvelope - { - public: - static void Work() - { - // Generate a signing key. - RSA^ key = RSA::Create(); - - try - { - - // Sign the detached resource and save the - // signature in an XML file. - SignDetachedResource("http://www.microsoft.com", - "SignedExample.xml", key); - - Console::WriteLine("XML file signed."); - - // Verify the signature of the signed XML. - Console::WriteLine("Verifying signature..."); - - bool result = VerifyXmlFile("SignedExample.xml"); - - // Display the results of the signature verification - // to the console. - if (result) - { - Console::WriteLine("The XML signature" - " is valid."); - } - else - { - Console::WriteLine("The XML signature" - " is not valid."); - } - Console::ReadLine(); - } - - catch (CryptographicException^ ex) - { - Console::WriteLine(ex->Message); - } - finally - { - // Clear resources associated with the - // RSA instance. - key->Clear(); - } - } - - - // Sign an XML file and save the signature in a new file. - static void SignDetachedResource(String^ uri, - String^ xmlFileName, RSA^ key) - { - // Check the arguments. - if (uri->Length == 0) - { - throw gcnew ArgumentException("uri"); - } - if (xmlFileName->Length == 0) - { - throw gcnew ArgumentException("xmlFileName"); - } - if (key->KeySize == 0) - { - throw gcnew ArgumentException("key"); - } - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml(); - - // Assign the key to the SignedXml object. - signedXml->SigningKey = key; - - // Get the signature object from the SignedXml object. - Signature^ xmlSignature = signedXml->Signature; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference(); - - // Add the passed URI to the reference object. - reference->Uri = uri; - - // Add the Reference object to the Signature object. - xmlSignature->SignedInfo->AddReference(reference); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient - // find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo(); - keyInfo->AddClause( - gcnew RSAKeyValue(key)); - - // Add the KeyInfo object to the Reference object. - xmlSignature->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmlTextWriter = gcnew XmlTextWriter( - xmlFileName, gcnew UTF8Encoding(false)); - - xmlDigitalSignature->WriteTo(xmlTextWriter); - xmlTextWriter->Close(); - } - - - // Verify the signature of an XML file and return the result. - static Boolean VerifyXmlFile(String^ documentName) - { - // Check the arguments. - if (documentName->Length == 0) - { - throw gcnew ArgumentException("documentName"); - } - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument(); - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load(documentName); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml(xmlDocument); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = - xmlDocument->GetElementsByTagName("Signature"); - - // Load the signature node. - signedXml->LoadXml( - (XmlElement^) nodeList->Item(0)); - - // Check the signature and return the result. - return signedXml->CheckSignature(); - } - }; -} - - -int main() -{ - Sample::SignVerifyEnvelope::Work(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp deleted file mode 100644 index 95b151171e8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Xml; -int main() -{ - - // Create example data to sign. - XmlDocument^ document = gcnew XmlDocument; - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - node->InnerText = "This is some text"; - document->AppendChild( node ); - Console::Error->WriteLine( "Data to sign:\n{0}\n", document->OuterXml ); - - // Create the SignedXml message. - SignedXml^ signedXml = gcnew SignedXml; - RSA^ key = RSA::Create(); - signedXml->SigningKey = key; - - // Create a data object to hold the data to sign. - DataObject^ dataObject = gcnew DataObject; - dataObject->Data = document->ChildNodes; - dataObject->Id = "MyObjectId"; - - // Add the data object to the signature. - signedXml->AddObject( dataObject ); - - // Create a reference to be able to package everything into the - // message. - Reference^ reference = gcnew Reference; - reference->Uri = "#MyObjectId"; - - // Add it to the message. - signedXml->AddReference( reference ); - - // Add a KeyInfo. - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( key ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature. - XmlElement^ xmlSignature = signedXml->GetXml(); - Console::WriteLine( xmlSignature->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp deleted file mode 100644 index 74689b19c1f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - array^args = System::Environment::GetCommandLineArgs(); - Console::WriteLine( "Verifying {0}...", args[ 1 ] ); - - // Create a SignedXml. - SignedXml^ signedXml = gcnew SignedXml; - - // Load the XML. - XmlDocument^ xmlDocument = gcnew XmlDocument; - xmlDocument->PreserveWhitespace = true; - xmlDocument->Load( gcnew XmlTextReader( args[ 1 ] ) ); - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - signedXml->LoadXml( safe_cast(nodeList[ 0 ]) ); - if ( signedXml->CheckSignature() ) - { - Console::WriteLine( "Signature check OK" ); - } - else - { - Console::WriteLine( "Signature check FAILED" ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp b/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp deleted file mode 100644 index e3a2a599d6d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -int main() -{ - - // creates the CspParameters object and sets the key container name used to store the RSA key pair - CspParameters^ cp = gcnew CspParameters; - cp->KeyContainerName = "MyKeyContainerName"; - - // instantiates the rsa instance accessing the key container MyKeyContainerName - RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( cp ); - - // add the below line to delete the key entry in MyKeyContainerName - // rsa.PersistKeyInCsp = false; - //writes out the current key pair used in the rsa instance - Console::WriteLine( "Key is : \n{0}", rsa->ToXmlString( true ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp b/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp deleted file mode 100644 index 486c6233b75..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::IO; - -/// This sample used the EncryptedData class to create a EncryptedData element -/// and write it to an XML file. -int main() -{ - // - // Create a new CipherData object. - CipherData^ cipher = gcnew CipherData(); - // Assign a byte array to be the CipherValue. This is a - // byte array representing encrypted data. - cipher->CipherValue = gcnew array(8); - // - // - // Create a new EncryptedData object. - EncryptedData^ encryptionRoot = gcnew EncryptedData(); - // - //Add an encryption method to the object. - encryptionRoot->Id = "ED"; - encryptionRoot->EncryptionMethod = gcnew EncryptionMethod( - "http://www.w3.org/2001/04/xmlenc#aes128-cbc"); - encryptionRoot->CipherData = cipher; - - //Add key information to the object. - KeyInfo^ keyDetails = gcnew KeyInfo(); - keyDetails->AddClause(gcnew KeyInfoRetrievalMethod("#EK", - "http://www.w3.org/2001/04/xmlenc#EncryptedKey")); - encryptionRoot->KeyInfo = keyDetails; - - // Create new XML document and put encrypted data into it. - XmlDocument^ doc = gcnew XmlDocument(); - XmlElement^ encryptionPropertyElement = - doc->CreateElement("EncryptionProperty", - EncryptedXml::XmlEncNamespaceUrl); - EncryptionProperty^ property = gcnew EncryptionProperty( - encryptionPropertyElement); - encryptionRoot->AddProperty(property); - - // Output the resulting XML information into a file. - String^ path = "test.xml"; - try - { - File::WriteAllText(path, encryptionRoot->GetXml()->OuterXml); - } - catch (IOException^ ex) - { - Console::WriteLine("There was an error writing to {0}", path); - Console::WriteLine(ex->Message); - } - //Console.WriteLine(ed.GetXml().OuterXml); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp deleted file mode 100644 index e1fe39c2ee1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography::Xml; -using namespace System::Xml; -using namespace System::IO; - -/// This sample used the EncryptedData class to create an encrypted data element -/// and write it to an XML file. It demonstrates the use of CipherReference. - -[STAThread] -int main() -{ - - //Create a URI string. - String^ uri = "http://www.woodgrovebank.com/document.xml"; - - // Create a Base64 transform. The input content retrieved from the - // URI should be Base64-decoded before other processing. - Transform^ base64 = gcnew XmlDsigBase64Transform; - - //Create a transform chain and add the transform to it. - TransformChain^ tc = gcnew TransformChain; - tc->Add( base64 ); - - //Create information. - CipherReference ^ reference = gcnew CipherReference( uri,tc ); - - // Create a new CipherData object using the CipherReference information. - // Note that you cannot assign both a CipherReference and a CipherValue - // to a CipherData object. - CipherData ^ cd = gcnew CipherData( reference ); - - // Create a new EncryptedData object. - EncryptedData^ ed = gcnew EncryptedData; - - //Add an encryption method to the object. - ed->Id = "ED"; - ed->EncryptionMethod = gcnew EncryptionMethod( "http://www.w3.org/2001/04/xmlenc#aes128-cbc" ); - ed->CipherData = cd; - - //Add key information to the object. - KeyInfo^ ki = gcnew KeyInfo; - ki->AddClause( gcnew KeyInfoRetrievalMethod( "#EK","http://www.w3.org/2001/04/xmlenc#EncryptedKey" ) ); - ed->KeyInfo = ki; - - // Create new XML document and put encrypted data into it. - XmlDocument^ doc = gcnew XmlDocument; - XmlElement^ encryptionPropertyElement = dynamic_cast(doc->CreateElement( "EncryptionProperty", EncryptedXml::XmlEncNamespaceUrl )); - EncryptionProperty ^ ep = gcnew EncryptionProperty( encryptionPropertyElement ); - ed->AddProperty( ep ); - - // Output the resulting XML information into a file. - try - { - String^ path = "c:\\test\\MyTest.xml"; - File::WriteAllText( path, ed->GetXml()->OuterXml ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "File IO error. {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp b/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp deleted file mode 100644 index a13819251ee..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography::Xml; -using namespace System::Xml; -using namespace System::IO; - -/// This sample used the EncryptedData class to create a EncryptedData element -/// and write it to an XML file. - -[STAThread] -int main() -{ - - // - // - // Create a new CipherData object using a byte array to represent encrypted data. - array^sampledata = gcnew array(8); - CipherData ^ cd = gcnew CipherData( sampledata ); - - // - // Create a new EncryptedData object. - EncryptedData^ ed = gcnew EncryptedData; - - //Add an encryption method to the object. - ed->Id = "ED"; - ed->EncryptionMethod = gcnew EncryptionMethod( "http://www.w3.org/2001/04/xmlenc#aes128-cbc" ); - ed->CipherData = cd; - - // - // - //Add key information to the object. - KeyInfo^ ki = gcnew KeyInfo; - ki->AddClause( gcnew KeyInfoRetrievalMethod( "#EK","http://www.w3.org/2001/04/xmlenc#EncryptedKey" ) ); - ed->KeyInfo = ki; - - // - // Create new XML document and put encrypted data into it. - XmlDocument^ doc = gcnew XmlDocument; - XmlElement^ encryptionPropertyElement = dynamic_cast(doc->CreateElement( "EncryptionProperty", EncryptedXml::XmlEncNamespaceUrl )); - EncryptionProperty ^ ep = gcnew EncryptionProperty( encryptionPropertyElement ); - ed->AddProperty( ep ); - - // Output the resulting XML information into a file. Change the path variable to point to a directory where - // the XML file should be written. - String^ path = "c:\\test\\MyTest.xml"; - File::WriteAllText( path, ed->GetXml()->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/directoryinfocreatesub/CPP/directoryinfocreatesub.cpp b/snippets/cpp/VS_Snippets_CLR/directoryinfocreatesub/CPP/directoryinfocreatesub.cpp deleted file mode 100644 index ab6a5a558b4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/directoryinfocreatesub/CPP/directoryinfocreatesub.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Create a reference to a directory. - DirectoryInfo^ di = gcnew DirectoryInfo( "TempDir" ); - - // Create the directory only if it does not already exist. - if ( !di->Exists ) - di->Create(); - - - // Create a subdirectory in the directory just created. - DirectoryInfo^ dis = di->CreateSubdirectory( "SubDir" ); - - // Process that directory as required. - // ... - // Delete the subdirectory. - dis->Delete( true ); - - // Delete the directory. - di->Delete( true ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/directoryinfodelete/CPP/directoryinfodelete.cpp b/snippets/cpp/VS_Snippets_CLR/directoryinfodelete/CPP/directoryinfodelete.cpp deleted file mode 100644 index 26deda48521..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/directoryinfodelete/CPP/directoryinfodelete.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Make a reference to a directory. - DirectoryInfo^ di = gcnew DirectoryInfo( "TempDir" ); - - // Create the directory only if it does not already exist. - if ( !di->Exists ) - di->Create(); - - - // Create a subdirectory in the directory just created. - DirectoryInfo^ dis = di->CreateSubdirectory( "SubDir" ); - - // Process that directory as required. - // ... - // Delete the subdirectory. The true indicates that if subdirectories - // or files are in this directory, they are to be deleted as well. - dis->Delete( true ); - - // Delete the directory. - di->Delete( true ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/directoryinfogetdirectories/CPP/directoryinfogetdirectories.cpp b/snippets/cpp/VS_Snippets_CLR/directoryinfogetdirectories/CPP/directoryinfogetdirectories.cpp deleted file mode 100644 index e9e232e4458..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/directoryinfogetdirectories/CPP/directoryinfogetdirectories.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Make a reference to a directory. - DirectoryInfo^ di = gcnew DirectoryInfo( "c:\\" ); - - // Get a reference to each directory in that directory. - array^diArr = di->GetDirectories(); - - // Display the names of the directories. - Collections::IEnumerator^ myEnum = diArr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DirectoryInfo^ dri = safe_cast(myEnum->Current); - Console::WriteLine( dri->Name ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/directoryinfomoveto/CPP/directoryinfomoveto.cpp b/snippets/cpp/VS_Snippets_CLR/directoryinfomoveto/CPP/directoryinfomoveto.cpp deleted file mode 100644 index 3acf01cd274..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/directoryinfomoveto/CPP/directoryinfomoveto.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Make a reference to a directory. - DirectoryInfo^ di = gcnew DirectoryInfo( "TempDir" ); - - // Create the directory only if it does not already exist. - if ( !di->Exists ) - di->Create(); - - - // Create a subdirectory in the directory just created. - DirectoryInfo^ dis = di->CreateSubdirectory( "SubDir" ); - - // Move the main directory. Note that the contents move with the directory. - if ( !Directory::Exists( "NewTempDir" ) ) - di->MoveTo( "NewTempDir" ); - - try - { - - // Attempt to delete the subdirectory. Note that because it has been - // moved, an exception is thrown. - dis->Delete( true ); - } - catch ( Exception^ ) - { - - // Handle this exception in some way, such as with the following code: - // Console::WriteLine(S"That directory does not exist."); - } - - - // Point the DirectoryInfo reference to the new directory. - //di = new DirectoryInfo(S"NewTempDir"); - // Delete the directory. - //di->Delete(true); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/directoryinfoparent/CPP/directoryinfoparent.cpp b/snippets/cpp/VS_Snippets_CLR/directoryinfoparent/CPP/directoryinfoparent.cpp deleted file mode 100644 index 73ca8a192a8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/directoryinfoparent/CPP/directoryinfoparent.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Make a reference to a directory. - DirectoryInfo^ di = gcnew DirectoryInfo( "TempDir" ); - - // Create the directory only if it does not already exist. - if ( !di->Exists ) - di->Create(); - - - // Create a subdirectory in the directory just created. - DirectoryInfo^ dis = di->CreateSubdirectory( "SubDir" ); - - // Get a reference to the parent directory of the subdirectory you just made. - DirectoryInfo^ parentDir = dis->Parent; - Console::WriteLine( "The parent directory of '{0}' is '{1}'", dis->Name, parentDir->Name ); - - // Delete the parent directory. - di->Delete( true ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/eventlogInstaller_Resources/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/eventlogInstaller_Resources/CPP/source.cpp deleted file mode 100644 index becae48d9ab..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/eventlogInstaller_Resources/CPP/source.cpp +++ /dev/null @@ -1,73 +0,0 @@ - - -// System.Diagnostics.EventLogInstaller -// The following example demonstrates the EventLogInstaller class. -// It defines the instance SampleEventLogInstaller with the -// attribute RunInstallerAttribute. -// -// The Log and Source properties of the new instance are set, -// along with the new resource file properties, -// and the instance is added to the collection of installers -// to be run during an installation. -// -// Note: -// 1) Run this program using the following command: -// InstallUtil.exe -// 2) Uninstall the event log created in step 1 using the -// following command: -// InstallUtil.exe /u -// -#using -#using - -using namespace System; -using namespace System::Configuration::Install; -using namespace System::Diagnostics; -using namespace System::ComponentModel; - -[RunInstaller(true)] -public ref class SampleEventLogInstaller : public Installer -{ -private: - EventLogInstaller^ myEventLogInstaller; - -public: - SampleEventLogInstaller() - { - - // Create an instance of an EventLogInstaller. - myEventLogInstaller = gcnew EventLogInstaller; - - // Set the source name of the event log. - myEventLogInstaller->Source = "ApplicationEventSource"; - - // Set the event log into which the source writes entries. - //myEventLogInstaller.Log = "MyCustomLog"; - myEventLogInstaller->Log = "myNewLog"; - - // Set the resource file for the event log. - // The message strings are defined in EventLogMsgs.mc; the message - // identifiers used in the application must match those defined in the - // corresponding message resource file. The messages must be built - // into a Win32 resource library and copied to the target path on the - // system. - myEventLogInstaller->CategoryResourceFile = - Environment::SystemDirectory + "\\eventlogmsgs.dll"; - myEventLogInstaller->CategoryCount = 3; - myEventLogInstaller->MessageResourceFile = - Environment::SystemDirectory + "\\eventlogmsgs.dll"; - myEventLogInstaller->ParameterResourceFile = - Environment::SystemDirectory + "\\eventlogmsgs.dll"; - - // Add myEventLogInstaller to the installer collection. - Installers->Add( myEventLogInstaller ); - } - -}; - -int main() -{ - Console::WriteLine( "Usage: InstallUtil.exe [.exe | .dll]" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp deleted file mode 100644 index 7bfe2badf7e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp +++ /dev/null @@ -1,277 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Diagnostics; -void CleanUp(); -void CreateEventSourceSample1( String^ messageFile ); -void WriteEventSample1(); -void WriteEventSample2(); -void EventInstanceSamples(); - -// -// The following constants match the message definitions -// in the message resource file. They are used to specify -// the resource identifier for a localized string in the -// message resource file. -// The message resource file is an .mc file built into a -// Win32 resource file using the message compiler (MC) tool. -// -const short InstallCategoryMsgId = 1; -const short QueryCategoryMsgId = 2; -const short RefreshCategoryMsgId = 3; -const short CategoryCount = 3; - -// -// -// Define the resource identifiers for the event messages. -// Resource identifiers combine the message ID and the severity field. -const long AuditSuccessMsgId = 1000; -const long AuditFailedMsgId = 1001 + 0x80000000; -const long InformationMsgId = 1002; -const long WarningMsgId = 1003 + 0x80000000; -const long UpdateCycleCompleteMsgId = 1004; -const long ServerConnectionDownMsgId = 1005 + 0x80000000; - -// -// -const long DisplayNameMsgId = 5001; -const long ServiceNameMsgId = 5002; - -// -// - -[STAThread] -int main() -{ - array^args = Environment::GetCommandLineArgs(); - String^ messageFile; - if ( args->Length > 1 ) - { - - // Use the input argument as the message resource file. - messageFile = args[ 1 ]; - } - else - { - - // Use the default message dll. - messageFile = String::Format( "{0}\\{1}", System::Environment::CurrentDirectory, "EventLogMsgs.dll" ); - } - - CleanUp(); - CreateEventSourceSample1( messageFile ); - WriteEventSample1(); - WriteEventSample2(); - EventInstanceSamples(); -} - -void CleanUp() -{ - String^ sourceName = "SampleApplicationSource"; - - // Delete the event source in order to re-register - // the source with the latest configuration properties. - if ( EventLog::SourceExists( sourceName ) ) - { - Console::WriteLine( "Deleting event source {0}.", sourceName ); - EventLog::DeleteEventSource( sourceName ); - } -} -// -void CreateEventSourceSample1( String^ messageFile ) -{ - String^ myLogName; - String^ sourceName = "SampleApplicationSource"; - - // Create the event source if it does not exist. - if ( !EventLog::SourceExists( sourceName ) ) - { - - // Create a new event source for the custom event log - // named "myNewLog." - myLogName = "myNewLog"; - EventSourceCreationData ^ mySourceData = gcnew EventSourceCreationData( sourceName,myLogName ); - - // Set the message resource file that the event source references. - // All event resource identifiers correspond to text in this file. - if ( !System::IO::File::Exists( messageFile ) ) - { - Console::WriteLine( "Input message resource file does not exist - {0}", messageFile ); - messageFile = ""; - } - else - { - - // Set the specified file as the resource - // file for message text, category text, and - // message parameter strings. - mySourceData->MessageResourceFile = messageFile; - mySourceData->CategoryResourceFile = messageFile; - mySourceData->CategoryCount = CategoryCount; - mySourceData->ParameterResourceFile = messageFile; - Console::WriteLine( "Event source message resource file set to {0}", messageFile ); - } - - Console::WriteLine( "Registering new source for event log." ); - EventLog::CreateEventSource( mySourceData ); - } - else - { - - // Get the event log corresponding to the existing source. - myLogName = EventLog::LogNameFromSourceName( sourceName, "." ); - } - - - // Register the localized name of the event log. - // For example, the actual name of the event log is "myNewLog," but - // the event log name displayed in the Event Viewer might be - // "Sample Application Log" or some other application-specific - // text. - EventLog^ myEventLog = gcnew EventLog( myLogName,".",sourceName ); - if ( messageFile->Length > 0 ) - { - myEventLog->RegisterDisplayName( messageFile, DisplayNameMsgId ); - } -} -// - -void WriteEventSample1() -{ - // - // Create the event source if it does not exist. - String^ sourceName = "SampleApplicationSource"; - if ( !EventLog::SourceExists( sourceName ) ) - { - - // Call a local method to register the event log source - // for the event log "myNewLog." Use the resource file - // EventLogMsgs.dll in the current directory for message text. - String^ messageFile = String::Format( "{0}\\{1}", System::Environment::CurrentDirectory, "EventLogMsgs.dll" ); - CreateEventSourceSample1( messageFile ); - } - - // Get the event log corresponding to the existing source. - String^ myLogName = EventLog::LogNameFromSourceName( sourceName, "." ); - EventLog^ myEventLog = gcnew EventLog( myLogName,".",sourceName ); - - // Define two audit events. - // The message identifiers correspond to the message text in the - // message resource file defined for the source. - EventInstance ^ myAuditSuccessEvent = gcnew EventInstance( AuditSuccessMsgId,0,EventLogEntryType::SuccessAudit ); - EventInstance ^ myAuditFailEvent = gcnew EventInstance( AuditFailedMsgId,0,EventLogEntryType::FailureAudit ); - - // Insert the method name into the event log message. - array^insertStrings = {"EventLogSamples.WriteEventSample1"}; - - // Write the events to the event log. - myEventLog->WriteEvent( myAuditSuccessEvent, insertStrings ); - - // Append binary data to the audit failure event entry. - array^binaryData = {3,4,5,6}; - myEventLog->WriteEvent( myAuditFailEvent, binaryData, insertStrings ); - - // -} - -void WriteEventSample2() -{ - // - String^ sourceName = "SampleApplicationSource"; - if ( EventLog::SourceExists( sourceName ) ) - { - - // Define an informational event and a warning event. - // The message identifiers correspond to the message text in the - // message resource file defined for the source. - EventInstance ^ myInfoEvent = gcnew EventInstance( InformationMsgId,0,EventLogEntryType::Information ); - EventInstance ^ myWarningEvent = gcnew EventInstance( WarningMsgId,0,EventLogEntryType::Warning ); - - // Insert the method name into the event log message. - array^insertStrings = {"EventLogSamples.WriteEventSample2"}; - - // Write the events to the event log. - EventLog::WriteEvent( sourceName, myInfoEvent, 0 ); - - // Append binary data to the warning event entry. - array^binaryData = {7,8,9,10}; - EventLog::WriteEvent( sourceName, myWarningEvent, binaryData, insertStrings ); - } - else - { - Console::WriteLine( "Warning - event source {0} not registered", sourceName ); - } - // -} - -void EventInstanceSamples() -{ - - // - // Ensure that the source has already been registered using - // EventLogInstaller or EventLog.CreateEventSource. - String^ sourceName = "SampleApplicationSource"; - if ( EventLog::SourceExists( sourceName ) ) - { - // Define an informational event with no category. - // The message identifier corresponds to the message text in the - // message resource file defined for the source. - EventInstance ^ myEvent = gcnew EventInstance( UpdateCycleCompleteMsgId,0 ); - - // Write the event to the event log using the registered source. - EventLog::WriteEvent( sourceName, myEvent, 0 ); - - // Reuse the event data instance for another event entry. - // Set the entry category and message identifiers for - // the appropriate resource identifiers in the resource files - // for the registered source. Set the event type to Warning. - myEvent->CategoryId = RefreshCategoryMsgId; - myEvent->EntryType = EventLogEntryType::Warning; - myEvent->InstanceId = ServerConnectionDownMsgId; - - // Write the event to the event log using the registered source. - // Insert the machine name into the event message text. - array^ss = {Environment::MachineName}; - EventLog::WriteEvent( sourceName, myEvent, ss ); - } - else - { - Console::WriteLine( "Warning - event source {0} not registered", sourceName ); - } - // - // - - // Get the event log corresponding to the existing source. - String^ myLogName = EventLog::LogNameFromSourceName( sourceName, "." ); - - // Find each instance of a specific event log entry in a - // particular event log. - EventLog^ myEventLog = gcnew EventLog( myLogName,"." ); - int count = 0; - Console::WriteLine( "Searching event log entries for the event ID {0}...", ServerConnectionDownMsgId ); - - // Search for the resource ID, display the event text, - // and display the number of matching entries. - System::Collections::IEnumerator^ myEnum = myEventLog->Entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EventLogEntry^ entry = safe_cast(myEnum->Current); - if ( entry->InstanceId == ServerConnectionDownMsgId ) - { - count++; - Console::WriteLine(); - Console::WriteLine( "Entry ID = {0}", entry->InstanceId ); - Console::WriteLine( "Reported at {0}", entry->TimeWritten ); - Console::WriteLine( "Message text:" ); - Console::WriteLine( "\t{0}", entry->Message ); - } - } - - Console::WriteLine(); - Console::WriteLine( "Found {0} events with ID {1} in event log {2}.", count, ServerConnectionDownMsgId, myLogName ); - // -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfoappendtext/CPP/fileinfoappendtext.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfoappendtext/CPP/fileinfoappendtext.cpp deleted file mode 100644 index 9006e0e4c6d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/fileinfoappendtext/CPP/fileinfoappendtext.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - FileInfo^ fi = gcnew FileInfo( "temp.txt" ); - - // Create a writer, ready to add entries to the file. - StreamWriter^ sw = fi->AppendText(); - sw->WriteLine( "Add as many lines as you like..." ); - sw->WriteLine( "Add another line to the output..." ); - sw->Flush(); - sw->Close(); - - // Get the information out of the file and display it. - // Remember that the file might have other lines if it already existed. - StreamReader^ sr = gcnew StreamReader( fi->OpenRead() ); - while ( sr->Peek() != -1 ) - Console::WriteLine( sr->ReadLine() ); -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -//Add as many lines as you like... -//Add another line to the output... - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfocopyto/CPP/fileinfocopyto.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfocopyto/CPP/fileinfocopyto.cpp deleted file mode 100644 index 3b56ad744a1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/fileinfocopyto/CPP/fileinfocopyto.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Create a reference to a file, which might or might not exist. - // If it does not exist, it is not yet created. - FileInfo^ fi = gcnew FileInfo( "temp.txt" ); - - // Create a writer, ready to add entries to the file. - StreamWriter^ sw = fi->AppendText(); - sw->WriteLine( "Add as many lines as you like..." ); - sw->WriteLine( "Add another line to the output..." ); - sw->Flush(); - sw->Close(); - - // Get the information out of the file and display it. - StreamReader^ sr = gcnew StreamReader( fi->OpenRead() ); - Console::WriteLine( "This is the information in the first file:" ); - while ( sr->Peek() != -1 ) - Console::WriteLine( sr->ReadLine() ); - - - // Copy this file to another file. The true parameter specifies - // that the file will be overwritten if it already exists. - FileInfo^ newfi = fi->CopyTo( "newTemp.txt", true ); - - // Get the information out of the new file and display it.* sr = new StreamReader( newfi->OpenRead() ); - Console::WriteLine( "{0}This is the information in the second file:", Environment::NewLine ); - while ( sr->Peek() != -1 ) - Console::WriteLine( sr->ReadLine() ); -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//This is the information in the first file: -//Add as many lines as you like... -//Add another line to the output... -//This is the information in the second file: -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfodelete/CPP/fileinfodelete.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfodelete/CPP/fileinfodelete.cpp deleted file mode 100644 index a5bcc91ed5d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/fileinfodelete/CPP/fileinfodelete.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Create a reference to a file. - FileInfo^ fi = gcnew FileInfo( "temp.txt" ); - - // Actually create the file. - FileStream^ fs = fi->Create(); - - // Modify the file as required, and then close the file. - fs->Close(); - - // Delete the file. - fi->Delete(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfodirectory/CPP/fileinfodirectory.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfodirectory/CPP/fileinfodirectory.cpp deleted file mode 100644 index 194a71d29f4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/fileinfodirectory/CPP/fileinfodirectory.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Open an existing file, or create a new one. - FileInfo^ fi = gcnew FileInfo( "temp.txt" ); - - // Determine the full path of the file just created. - DirectoryInfo^ di = fi->Directory; - - // Figure out what other entries are in that directory. - array^fsi = di->GetFileSystemInfos(); - Console::WriteLine( "The directory '{0}' contains the following files and directories:", di->FullName ); - - // Print the names of all the files and subdirectories of that directory. - Collections::IEnumerator^ myEnum = fsi->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - FileSystemInfo^ info = safe_cast(myEnum->Current); - Console::WriteLine( info->Name ); - } -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//The directory 'C:\Visual Studio 2005\release' contains the following files -//and directories: -//fileinfodirectory.exe -//fileinfodirectory.pdb -//newTemp.txt -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfomain/CPP/fileinfomain.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfomain/CPP/fileinfomain.cpp deleted file mode 100644 index bdd66b10555..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/fileinfomain/CPP/fileinfomain.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Open an existing file, or create a new one. - FileInfo^ fi = gcnew FileInfo( "temp.txt" ); - - // Create a writer, ready to add entries to the file. - StreamWriter^ sw = fi->AppendText(); - sw->WriteLine( "This is a new entry to add to the file" ); - sw->WriteLine( "This is yet another line to add..." ); - sw->Flush(); - sw->Close(); - - // Get the information out of the file and display it. - StreamReader^ sr = gcnew StreamReader( fi->OpenRead() ); - while ( sr->Peek() != -1 ) - Console::WriteLine( sr->ReadLine() ); -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//This is a new entry to add to the file -//This is yet another line to add... -// diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfoname/CPP/fileinfoname.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfoname/CPP/fileinfoname.cpp deleted file mode 100644 index e29a987391a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/fileinfoname/CPP/fileinfoname.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Create a reference to the current directory. - DirectoryInfo^ di = gcnew DirectoryInfo( Environment::CurrentDirectory ); - - // Create an array representing the files in the current directory. - array^fi = di->GetFiles(); - Console::WriteLine( "The following files exist in the current directory:" ); - - // Print out the names of the files in the current directory. - Collections::IEnumerator^ myEnum = fi->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - FileInfo^ fiTemp = safe_cast(myEnum->Current); - Console::WriteLine( fiTemp->Name ); - } -} - -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//The following files exist in the current directory: -//fileinfoname.exe -//fileinfoname.pdb -//newTemp.txt -// diff --git a/snippets/cpp/VS_Snippets_CLR/fileinfoopen/CPP/fileinfoopen.cpp b/snippets/cpp/VS_Snippets_CLR/fileinfoopen/CPP/fileinfoopen.cpp deleted file mode 100644 index 7919473364a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/fileinfoopen/CPP/fileinfoopen.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Open an existing file, or create a new one. - FileInfo^ fi = gcnew FileInfo( "temp.txt" ); - - // Open the file just specified such that no one else can use it. - FileStream^ fs = fi->Open( FileMode::OpenOrCreate, FileAccess::ReadWrite, FileShare::None ); - - // Create another reference to the same file. - FileInfo^ nextfi = gcnew FileInfo( "temp.txt" ); - try - { - - // Try opening the same file, which was locked by the previous process. - nextfi->Open( FileMode::OpenOrCreate, FileAccess::Read ); - Console::WriteLine( "The file was not locked, and was opened by a second process." ); - } - catch ( IOException^ ) - { - Console::WriteLine( "The file could not be opened because it was locked by another process." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } - - - // Close the file so it can be deleted. - fs->Close(); -} -//This code produces output similar to the following; -//results may vary based on the computer/file structure/etc.: -// -//The file could not be opened because it was locked by another process. -// diff --git a/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp deleted file mode 100644 index feda725012e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Collections::ObjectModel; - -void main() -{ - List^ dinosaurs = gcnew List(); - - dinosaurs->Add("Tyrannosaurus"); - dinosaurs->Add("Amargasaurus"); - dinosaurs->Add("Deinonychus"); - dinosaurs->Add("Compsognathus"); - - ReadOnlyCollection^ readOnlyDinosaurs = - gcnew ReadOnlyCollection(dinosaurs); - - Console::WriteLine(); - for each(String^ dinosaur in readOnlyDinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nCount: {0}", readOnlyDinosaurs->Count); - - Console::WriteLine("\nContains(\"Deinonychus\"): {0}", - readOnlyDinosaurs->Contains("Deinonychus")); - - Console::WriteLine("\nreadOnlyDinosaurs[3]: {0}", - readOnlyDinosaurs[3]); - - Console::WriteLine("\nIndexOf(\"Compsognathus\"): {0}", - readOnlyDinosaurs->IndexOf("Compsognathus")); - - Console::WriteLine("\nInsert into the wrapped List:"); - Console::WriteLine("Insert(2, \"Oviraptor\")"); - dinosaurs->Insert(2, "Oviraptor"); - - Console::WriteLine(); - for each( String^ dinosaur in readOnlyDinosaurs ) - { - Console::WriteLine(dinosaur); - } - - array^ dinoArray = - gcnew array(readOnlyDinosaurs->Count + 2); - readOnlyDinosaurs->CopyTo(dinoArray, 1); - - Console::WriteLine("\nCopied array has {0} elements:", - dinoArray->Length); - for each( String^ dinosaur in dinoArray ) - { - Console::WriteLine("\"{0}\"", dinosaur); - } -} - -/* This code example produces the following output: - -Tyrannosaurus -Amargasaurus -Deinonychus -Compsognathus - -Count: 4 - -Contains("Deinonychus"): True - -readOnlyDinosaurs[3]: Compsognathus - -IndexOf("Compsognathus"): 3 - -Insert into the wrapped List: -Insert(2, "Oviraptor") - -Tyrannosaurus -Amargasaurus -Oviraptor -Deinonychus -Compsognathus - -Copied array has 7 elements: -"" -"Tyrannosaurus" -"Amargasaurus" -"Oviraptor" -"Deinonychus" -"Compsognathus" -"" - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/pathcombine/CPP/pathcombine.cpp b/snippets/cpp/VS_Snippets_CLR/pathcombine/CPP/pathcombine.cpp deleted file mode 100644 index c576f3dc408..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/pathcombine/CPP/pathcombine.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -void CombinePaths( String^ p1, String^ p2 ) -{ - try - { - String^ combination = Path::Combine( p1, p2 ); - Console::WriteLine( "When you combine '{0}' and '{1}', the result is: {2}'{3}'", p1, p2, Environment::NewLine, combination ); - } - catch ( Exception^ e ) - { - if (p1 == nullptr) - p1 = "nullptr"; - if (p2 == nullptr) - p2 = "nullptr"; - Console::WriteLine( "You cannot combine '{0}' and '{1}' because: {2}{3}", p1, p2, Environment::NewLine, e->Message ); - } - - Console::WriteLine(); -} - -int main() -{ - String^ path1 = "c:\\temp"; - String^ path2 = "subdir\\file.txt"; - String^ path3 = "c:\\temp.txt"; - String^ path4 = "c:^*&)(_=@#'\\^.*(.txt"; - String^ path5 = ""; - String^ path6 = nullptr; - CombinePaths( path1, path2 ); - CombinePaths( path1, path3 ); - CombinePaths( path3, path2 ); - CombinePaths( path4, path2 ); - CombinePaths( path5, path2 ); - CombinePaths( path6, path2 ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/datareceivedevent.cpp b/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/datareceivedevent.cpp deleted file mode 100644 index ea3629d178b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/datareceivedevent.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; -using namespace System::Text; - -ref class StandardAsyncOutputExample -{ -private: - static int lineCount = 0; - static StringBuilder^ output = nullptr; - -public: - static void Run() - { - Process^ process = gcnew Process(); - process->StartInfo->FileName = "ipconfig.exe"; - process->StartInfo->UseShellExecute = false; - process->StartInfo->RedirectStandardOutput = true; - output = gcnew StringBuilder(); - process->OutputDataReceived += gcnew DataReceivedEventHandler(OutputHandler); - process->Start(); - - // Asynchronously read the standard output of the spawned process. - // This raises OutputDataReceived events for each line of output. - process->BeginOutputReadLine(); - process->WaitForExit(); - - // Write the redirected output to this application's window. - Console::WriteLine(output); - - process->WaitForExit(); - process->Close(); - - Console::WriteLine("\n\nPress any key to exit"); - Console::ReadLine(); - } - -private: - static void OutputHandler(Object^ sender, DataReceivedEventArgs^ e) - { - // Prepend line numbers to each line of the output. - if (!String::IsNullOrEmpty(e->Data)) - { - lineCount++; - output->Append("\n[" + lineCount + "]: " + e->Data); - } - } -}; - -int main() -{ - StandardAsyncOutputExample::Run(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/net_async.cpp b/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/net_async.cpp deleted file mode 100644 index 6dc1d4e11d3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/net_async.cpp +++ /dev/null @@ -1,227 +0,0 @@ -// System.Diagnostics -// -// Requires .NET Framework version 1.2 or higher. - -// The following example uses the net view command to list the -// available network resources available on a remote computer, -// and displays the results to the console. Specifying the optional -// error log file redirects error output to that file. - -// -// Define the namespaces used by this sample. -#using - -using namespace System; -using namespace System::Text; -using namespace System::Globalization; -using namespace System::IO; -using namespace System::Diagnostics; -using namespace System::Threading; -using namespace System::ComponentModel; - -ref class ProcessNetStreamRedirection -{ -private: - // Define static variables shared by class methods. - static StreamWriter^ streamError = nullptr; - static String^ netErrorFile = ""; - static StringBuilder^ netOutput = nullptr; - static bool errorRedirect = false; - static bool errorsWritten = false; - -public: - static void RedirectNetCommandStreams() - { - String^ netArguments; - Process^ netProcess; - - // Get the input computer name. - Console::WriteLine( "Enter the computer name for the net view command:" ); - netArguments = Console::ReadLine()->ToUpper( CultureInfo::InvariantCulture ); - if ( String::IsNullOrEmpty( netArguments ) ) - { - // Default to the help command if there is not an input argument. - netArguments = "/?"; - } - - // Check if errors should be redirected to a file. - errorsWritten = false; - Console::WriteLine( "Enter a fully qualified path to an error log file" ); - Console::WriteLine( " or just press Enter to write errors to console:" ); - netErrorFile = Console::ReadLine()->ToUpper( CultureInfo::InvariantCulture ); - if ( !String::IsNullOrEmpty( netErrorFile ) ) - { - errorRedirect = true; - } - - // Note that at this point, netArguments and netErrorFile - // are set with user input. If the user did not specify - // an error file, then errorRedirect is set to false. - - // Initialize the process and its StartInfo properties. - netProcess = gcnew Process; - netProcess->StartInfo->FileName = "Net.exe"; - - // Build the net command argument list. - netProcess->StartInfo->Arguments = String::Format( "view {0}", netArguments ); - - // Set UseShellExecute to false for redirection. - netProcess->StartInfo->UseShellExecute = false; - - // Redirect the standard output of the net command. - // This stream is read asynchronously using an event handler. - netProcess->StartInfo->RedirectStandardOutput = true; - netProcess->OutputDataReceived += gcnew DataReceivedEventHandler( NetOutputDataHandler ); - netOutput = gcnew StringBuilder; - if ( errorRedirect ) - { - - // Redirect the error output of the net command. - netProcess->StartInfo->RedirectStandardError = true; - netProcess->ErrorDataReceived += gcnew DataReceivedEventHandler( NetErrorDataHandler ); - } - else - { - - // Do not redirect the error output. - netProcess->StartInfo->RedirectStandardError = false; - } - - Console::WriteLine( "\nStarting process: net {0}", - netProcess->StartInfo->Arguments ); - if ( errorRedirect ) - { - Console::WriteLine( "Errors will be written to the file {0}", netErrorFile ); - } - - // Start the process. - netProcess->Start(); - - // Start the asynchronous read of the standard output stream. - netProcess->BeginOutputReadLine(); - - if ( errorRedirect ) - { - // Start the asynchronous read of the standard - // error stream. - netProcess->BeginErrorReadLine(); - } - - // Let the net command run, collecting the output. - netProcess->WaitForExit(); - - if ( streamError != nullptr ) - { - // Close the error file. - streamError->Close(); - } - else - { - // Set errorsWritten to false if the stream is not - // open. Either there are no errors, or the error - // file could not be opened. - errorsWritten = false; - } - - if ( netOutput->Length > 0 ) - { - // If the process wrote more than just - // white space, write the output to the console. - Console::WriteLine( "\nPublic network shares from net view:\n{0}\n", - netOutput->ToString() ); - } - - if ( errorsWritten ) - { - // Signal that the error file had something - // written to it. - array^errorOutput = File::ReadAllLines( netErrorFile ); - if ( errorOutput->Length > 0 ) - { - Console::WriteLine( "\nThe following error output was appended to {0}.", - netErrorFile ); - System::Collections::IEnumerator^ myEnum = errorOutput->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ errLine = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", errLine ); - } - } - Console::WriteLine(); - } - - netProcess->Close(); - - } - -private: - static void NetOutputDataHandler( Object^ /*sendingProcess*/, - DataReceivedEventArgs^ outLine ) - { - // Collect the net view command output. - if ( !String::IsNullOrEmpty( outLine->Data ) ) - { - // Add the text to the collected output. - netOutput->AppendFormat( "\n {0}", outLine->Data ); - } - } - - static void NetErrorDataHandler( Object^ /*sendingProcess*/, - DataReceivedEventArgs^ errLine ) - { - // Write the error text to the file if there is something to - // write and an error file has been specified. - - if ( !String::IsNullOrEmpty( errLine->Data ) ) - { - if ( !errorsWritten ) - { - if ( streamError == nullptr ) - { - // Open the file. - try - { - streamError = gcnew StreamWriter( netErrorFile,true ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Could not open error file!" ); - Console::WriteLine( e->Message->ToString() ); - } - } - - if ( streamError != nullptr ) - { - // Write a header to the file if this is the first - // call to the error output handler. - streamError->WriteLine(); - streamError->WriteLine( DateTime::Now.ToString() ); - streamError->WriteLine( "Net View error output:" ); - } - errorsWritten = true; - } - - if ( streamError != nullptr ) - { - // Write redirected errors to the file. - streamError->WriteLine( errLine->Data ); - streamError->Flush(); - } - } - } -}; -// - -/// The main entry point for the application. -void main() -{ - try - { - ProcessNetStreamRedirection::RedirectNetCommandStreams(); - } - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( "Exception:" ); - Console::WriteLine( e ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/nmake_async.cpp b/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/nmake_async.cpp deleted file mode 100644 index 037704e8279..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/nmake_async.cpp +++ /dev/null @@ -1,258 +0,0 @@ -// System.Diagnostics -// -// Requires .NET Framework version 1.2 or higher. - -// Define the namespaces used by this sample. -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Diagnostics; -using namespace System::Threading; -using namespace System::ComponentModel; - -// -ref class ProcessNMakeStreamRedirection -{ -private: - // Define static variables shared by class methods. - static StreamWriter^ buildLogStream = nullptr; - static Mutex^ logMutex = gcnew Mutex; - static int maxLogLines = 25; - static int currentLogLines = 0; - -public: - static void RedirectNMakeCommandStreams() - { - String^ nmakeArguments = nullptr; - Process^ nmakeProcess; - - // Get the input nmake command-line arguments. - Console::WriteLine( "Enter the NMake command line arguments (@commandfile or /f makefile, etc):" ); - String^ inputText = Console::ReadLine(); - if ( !String::IsNullOrEmpty( inputText ) ) - { - nmakeArguments = inputText; - } - - Console::WriteLine( "Enter max line limit for log file (default is 25):" ); - inputText = Console::ReadLine(); - if ( !String::IsNullOrEmpty( inputText ) ) - { - if ( !Int32::TryParse( inputText, maxLogLines ) ) - { - maxLogLines = 25; - } - } - Console::WriteLine( "Output beyond {0} lines will be ignored.", - maxLogLines.ToString() ); - - // Initialize the process and its StartInfo properties. - nmakeProcess = gcnew Process; - nmakeProcess->StartInfo->FileName = "NMake.exe"; - - // Build the nmake command argument list. - if ( !String::IsNullOrEmpty( nmakeArguments ) ) - { - nmakeProcess->StartInfo->Arguments = nmakeArguments; - } - - // Set UseShellExecute to false for redirection. - nmakeProcess->StartInfo->UseShellExecute = false; - - // Redirect the standard output of the nmake command. - // Read the stream asynchronously using an event handler. - nmakeProcess->StartInfo->RedirectStandardOutput = true; - nmakeProcess->OutputDataReceived += gcnew DataReceivedEventHandler( NMakeOutputDataHandler ); - - // Redirect the error output of the nmake command. - nmakeProcess->StartInfo->RedirectStandardError = true; - nmakeProcess->ErrorDataReceived += gcnew DataReceivedEventHandler( NMakeErrorDataHandler ); - - logMutex->WaitOne(); - - currentLogLines = 0; - - // Write a header to the log file. - String^ buildLogFile = "NmakeCmd.Txt"; - try - { - buildLogStream = gcnew StreamWriter( buildLogFile,true ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Could not open output file {0}", buildLogFile ); - Console::WriteLine( "Exception = {0}", e->ToString() ); - Console::WriteLine( e->Message->ToString() ); - - buildLogStream = nullptr; - } - - if ( buildLogStream != nullptr ) - { - Console::WriteLine( "Nmake output logged to {0}", buildLogFile ); - - buildLogStream->WriteLine(); - buildLogStream->WriteLine( DateTime::Now.ToString() ); - if ( !String::IsNullOrEmpty( nmakeArguments ) ) - { - buildLogStream->Write( "Command line = NMake {0}", nmakeArguments ); - } - else - { - buildLogStream->Write( "Command line = Nmake" ); - } - buildLogStream->WriteLine(); - buildLogStream->Flush(); - - logMutex->ReleaseMutex(); - - // Start the process. - Console::WriteLine(); - Console::WriteLine( "\nStarting Nmake command" ); - Console::WriteLine(); - nmakeProcess->Start(); - - // Start the asynchronous read of the output stream. - nmakeProcess->BeginOutputReadLine(); - - // Start the asynchronous read of the error stream. - nmakeProcess->BeginErrorReadLine(); - - // Let the nmake command run, collecting the output. - nmakeProcess->WaitForExit(); - - nmakeProcess->Close(); - buildLogStream->Close(); - logMutex->Dispose(); - } - } - -private: - static void NMakeOutputDataHandler( Object^ sendingProcess, - DataReceivedEventArgs^ outLine ) - { - // Collect the output, displaying it to the screen and - // logging it to the output file. Cancel the read - // operation when the maximum line limit is reached. - - if ( !String::IsNullOrEmpty( outLine->Data ) ) - { - logMutex->WaitOne(); - - currentLogLines++; - if ( currentLogLines > maxLogLines ) - { - // Display the line to the console. - // Skip writing the line to the log file. - Console::WriteLine( "StdOut: {0}", outLine->Data->ToString() ); - } - else - if ( currentLogLines == maxLogLines ) - { - LogToFile( "StdOut", "", true ); - - // Stop reading the output streams. - Process^ p = dynamic_cast(sendingProcess); - if ( p != nullptr ) - { - p->CancelOutputRead(); - p->CancelErrorRead(); - } - } - else - { - // Write the line to the log file. - LogToFile( "StdOut", outLine->Data, true ); - } - logMutex->ReleaseMutex(); - } - } - - static void NMakeErrorDataHandler( Object^ sendingProcess, - DataReceivedEventArgs^ errLine ) - { - - // Collect the error output, displaying it to the screen and - // logging it to the output file. Cancel the error output - // read operation when the maximum line limit is reached. - - if ( !String::IsNullOrEmpty( errLine->Data ) ) - { - logMutex->WaitOne(); - - currentLogLines++; - if ( currentLogLines > maxLogLines ) - { - - // Display the line to the console. - // Skip writing the line to the log file. - Console::WriteLine( "StdErr: {0}", errLine->Data->ToString() ); - } - else - if ( currentLogLines == maxLogLines ) - { - LogToFile( "StdOut", "", true ); - - // Stop reading the output streams. - Process^ p = dynamic_cast(sendingProcess); - if ( p != nullptr ) - { - p->CancelOutputRead(); - p->CancelErrorRead(); - } - } - else - { - // Write the line to the log file. - LogToFile( "StdErr", errLine->Data, true ); - } - logMutex->ReleaseMutex(); - } - } - - static void LogToFile( String^ logPrefix, String^ logText, - bool echoToConsole ) - { - // Write the specified line to the log file stream. - StringBuilder^ logString = gcnew StringBuilder; - - if ( !String::IsNullOrEmpty( logPrefix ) ) - { - logString->AppendFormat( "{0}> ", logPrefix ); - } - - if ( !String::IsNullOrEmpty( logText ) ) - { - logString->Append( logText ); - } - - if ( buildLogStream != nullptr ) - { - buildLogStream->WriteLine( "[{0}] {1}", - DateTime::Now.ToString(), logString->ToString() ); - buildLogStream->Flush(); - } - - if ( echoToConsole ) - { - Console::WriteLine( logString->ToString() ); - } - } -}; -// - -/// The main entry point for the application. -void main() -{ - try - { - ProcessNMakeStreamRedirection::RedirectNMakeCommandStreams(); - } - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( "Exception:" ); - Console::WriteLine( e ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/sort_async.cpp b/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/sort_async.cpp deleted file mode 100644 index 87b8730cbc4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/sort_async.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// System.Diagnostics -// -// Requires .NET Framework version 1.2 or higher. - -// The following example uses the sort command to sort a list -// of input text lines, and displays the sorted list to the console. - -// -// Define the namespaces used by this sample. -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Diagnostics; -using namespace System::Threading; -using namespace System::ComponentModel; - -ref class SortOutputRedirection -{ -private: - // Define static variables shared by class methods. - static StringBuilder^ sortOutput = nullptr; - static int numOutputLines = 0; - -public: - static void SortInputListText() - { - // Initialize the process and its StartInfo properties. - // The sort command is a console application that - // reads and sorts text input. - - Process^ sortProcess; - sortProcess = gcnew Process; - sortProcess->StartInfo->FileName = "Sort.exe"; - - // Set UseShellExecute to false for redirection. - sortProcess->StartInfo->UseShellExecute = false; - - // Redirect the standard output of the sort command. - // This stream is read asynchronously using an event handler. - sortProcess->StartInfo->RedirectStandardOutput = true; - sortOutput = gcnew StringBuilder; - - // Set our event handler to asynchronously read the sort output. - sortProcess->OutputDataReceived += gcnew DataReceivedEventHandler( SortOutputHandler ); - - // Redirect standard input as well. This stream - // is used synchronously. - sortProcess->StartInfo->RedirectStandardInput = true; - - // Start the process. - sortProcess->Start(); - - // Use a stream writer to synchronously write the sort input. - StreamWriter^ sortStreamWriter = sortProcess->StandardInput; - - // Start the asynchronous read of the sort output stream. - sortProcess->BeginOutputReadLine(); - - // Prompt the user for input text lines. Write each - // line to the redirected input stream of the sort command. - Console::WriteLine( "Ready to sort up to 50 lines of text" ); - - String^ inputText; - int numInputLines = 0; - do - { - Console::WriteLine( "Enter a text line (or press the Enter key to stop):" ); - - inputText = Console::ReadLine(); - if ( !String::IsNullOrEmpty( inputText ) ) - { - numInputLines++; - sortStreamWriter->WriteLine( inputText ); - } - } - while ( !String::IsNullOrEmpty( inputText ) && (numInputLines < 50) ); - - Console::WriteLine( "" ); - Console::WriteLine(); - - // End the input stream to the sort command. - sortStreamWriter->Close(); - - // Wait for the sort process to write the sorted text lines. - sortProcess->WaitForExit(); - - if ( numOutputLines > 0 ) - { - - // Write the formatted and sorted output to the console. - Console::WriteLine( " Sort results = {0} sorted text line(s) ", - numOutputLines.ToString() ); - Console::WriteLine( "----------" ); - Console::WriteLine( sortOutput->ToString() ); - } - else - { - Console::WriteLine( " No input lines were sorted." ); - } - - sortProcess->Close(); - } - -private: - static void SortOutputHandler( Object^ /*sendingProcess*/, - DataReceivedEventArgs^ outLine ) - { - // Collect the sort command output. - if ( !String::IsNullOrEmpty( outLine->Data ) ) - { - numOutputLines++; - - // Add the text to the collected output. - sortOutput->AppendFormat( "\n[{0}] {1}", - numOutputLines.ToString(), outLine->Data ); - } - } -}; - -/// The main entry point for the application. -void main() -{ - try - { - SortOutputRedirection::SortInputListText(); - } - catch ( InvalidOperationException^ e ) - { - Console::WriteLine( "Exception:" ); - Console::WriteLine( e ); - } -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR/process_refresh/CPP/process_refresh.cpp b/snippets/cpp/VS_Snippets_CLR/process_refresh/CPP/process_refresh.cpp deleted file mode 100644 index 5289fe8f30b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/process_refresh/CPP/process_refresh.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// System::Diagnostics::Process::Refresh -// System::Diagnostics::Process::HasExited -// System::Diagnostics::Process::Close -// System::Diagnostics::Process::CloseMainWindow -// The following example starts an instance of Notepad. It then -// retrieves the physical memory usage of the associated process at -// 2 second intervals for a maximum of 10 seconds. The example detects -// whether the process exits before 10 seconds have elapsed. -// The example closes the process if it is still running after -// 10 seconds. -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - try - { - Process^ myProcess; - myProcess = Process::Start( "Notepad.exe" ); - - // Display physical memory usage 5 times at intervals of 2 seconds. - for ( int i = 0; i < 5; i++ ) - { - if ( !myProcess->HasExited ) - { - - // Discard cached information about the process. - myProcess->Refresh(); - - // Print working set to console. - Console::WriteLine( "Physical Memory Usage : {0}", myProcess->WorkingSet.ToString() ); - - // Wait 2 seconds. - Thread::Sleep( 2000 ); - } - else - { - break; - } - - } - myProcess->CloseMainWindow(); - - // Free resources associated with process. - myProcess->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: " ); - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/process_sample/CPP/process_sample.cpp b/snippets/cpp/VS_Snippets_CLR/process_sample/CPP/process_sample.cpp deleted file mode 100644 index db06be9bee1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/process_sample/CPP/process_sample.cpp +++ /dev/null @@ -1,73 +0,0 @@ - - -// System::Diagnostics::Process::WorkingSet -// System::Diagnostics::Process::BasePriority -// System::Diagnostics::Process::UserProcessorTime -// System::Diagnostics::Process::PrivilegedProcessorTime -// System::Diagnostics::Process::TotalProcessorTime -// System::Diagnostics::Process::ToString -// System::Diagnostics::Process::Responding -// System::Diagnostics::Process::PriorityClass -// System::Diagnostics::Process::ExitCode -// The following example starts an instance of Notepad. The example -// then retrieves and displays various properties of the associated -// process. The example detects when the process exits, and displays the process's exit code. -// -#using - -using namespace System; -using namespace System::Diagnostics; -using namespace System::Threading; -int main() -{ - try - { - Process^ myProcess; - myProcess = Process::Start( "NotePad.exe" ); - while ( !myProcess->HasExited ) - { - Console::WriteLine(); - - // Get physical memory usage of the associated process. - Console::WriteLine( "Process's physical memory usage: {0}", myProcess->WorkingSet.ToString() ); - - // Get base priority of the associated process. - Console::WriteLine( "Base priority of the associated process: {0}", myProcess->BasePriority.ToString() ); - - // Get priority class of the associated process. - Console::WriteLine( "Priority class of the associated process: {0}", myProcess->PriorityClass ); - - // Get user processor time for this process. - Console::WriteLine( "User Processor Time: {0}", myProcess->UserProcessorTime.ToString() ); - - // Get privileged processor time for this process. - Console::WriteLine( "Privileged Processor Time: {0}", myProcess->PrivilegedProcessorTime.ToString() ); - - // Get total processor time for this process. - Console::WriteLine( "Total Processor Time: {0}", myProcess->TotalProcessorTime.ToString() ); - - // Invoke overloaded ToString function. - Console::WriteLine( "Process's Name: {0}", myProcess->ToString() ); - Console::WriteLine( "-------------------------------------" ); - if ( myProcess->Responding ) - { - Console::WriteLine( "Status: Responding to user interface" ); - myProcess->Refresh(); - } - else - { - Console::WriteLine( "Status: Not Responding" ); - } - Thread::Sleep( 1000 ); - } - Console::WriteLine(); - Console::WriteLine( "Process exit code: {0}", myProcess->ExitCode.ToString() ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp b/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp deleted file mode 100644 index 8695804de6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Text::RegularExpressions; -void main() -{ - - String^ text = "One car red car blue car"; - String^ pat = "(\\w+)\\s+(car)"; - - // Compile the regular expression. - Regex^ r = gcnew Regex( pat,RegexOptions::IgnoreCase ); - - // Match the regular expression pattern against a text string. - Match^ m = r->Match(text); - int matchCount = 0; - while ( m->Success ) - { - Console::WriteLine( "Match{0}", ++matchCount ); - for ( int i = 1; i <= 2; i++ ) - { - Group^ g = m->Groups[ i ]; - Console::WriteLine( "Group{0}='{1}'", i, g ); - CaptureCollection^ cc = g->Captures; - for ( int j = 0; j < cc->Count; j++ ) - { - Capture^ c = cc[ j ]; - System::Console::WriteLine( "Capture{0}='{1}', Position={2}", j, c, c->Index ); - } - } - m = m->NextMatch(); - } -} -// This example displays the following output: -// Match1 -// Group1='One' -// Capture0='One', Position=0 -// Group2='car' -// Capture0='car', Position=4 -// Match2 -// Group1='red' -// Capture0='red', Position=8 -// Group2='car' -// Capture0='car', Position=12 -// Match3 -// Group1='blue' -// Capture0='blue', Position=16 -// Group2='car' -// Capture0='car', Position=21 -// - diff --git a/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp b/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp deleted file mode 100644 index 0494e4ad274..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp +++ /dev/null @@ -1,96 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Security::Cryptography; - -// Generate a key k1 with password pwd1 and salt salt1. -// Generate a key k2 with password pwd1 and salt salt1. -// Encrypt data1 with key k1 using symmetric encryption, creating edata1. -// Decrypt edata1 with key k2 using symmetric decryption, creating data2. -// data2 should equal data1. - -int main() -{ - array^passwordargs = Environment::GetCommandLineArgs(); - String^ usageText = "Usage: RFC2898 \nYou must specify the password for encryption.\n"; - - //If no file name is specified, write usage text. - if ( passwordargs->Length == 1 ) - { - Console::WriteLine( usageText ); - } - else - { - // - String^ pwd1 = passwordargs[ 1 ]; - - array^salt1 = gcnew array(8); - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - rng->GetBytes(salt1); - //data1 can be a string or contents of a file. - String^ data1 = "Some test data"; - - // - //The default iteration count is 1000 so the two methods use the same iteration count. - int myIterations = 1000; - // - - // - try - { - // - Rfc2898DeriveBytes ^ k1 = gcnew Rfc2898DeriveBytes( pwd1,salt1,myIterations ); - Rfc2898DeriveBytes ^ k2 = gcnew Rfc2898DeriveBytes( pwd1,salt1 ); - // - - // Encrypt the data. - Aes^ encAlg = Aes::Create(); - encAlg->Key = k1->GetBytes( 16 ); - MemoryStream^ encryptionStream = gcnew MemoryStream; - CryptoStream^ encrypt = gcnew CryptoStream( encryptionStream,encAlg->CreateEncryptor(),CryptoStreamMode::Write ); - array^utfD1 = (gcnew System::Text::UTF8Encoding( false ))->GetBytes( data1 ); - // - - encrypt->Write( utfD1, 0, utfD1->Length ); - encrypt->FlushFinalBlock(); - encrypt->Close(); - array^edata1 = encryptionStream->ToArray(); - k1->Reset(); - - // Try to decrypt, thus showing it can be round-tripped. - Aes^ decAlg = Aes::Create(); - decAlg->Key = k2->GetBytes( 16 ); - decAlg->IV = encAlg->IV; - MemoryStream^ decryptionStreamBacking = gcnew MemoryStream; - CryptoStream^ decrypt = gcnew CryptoStream( decryptionStreamBacking,decAlg->CreateDecryptor(),CryptoStreamMode::Write ); - - // - decrypt->Write( edata1, 0, edata1->Length ); - decrypt->Flush(); - decrypt->Close(); - k2->Reset(); - // - - String^ data2 = (gcnew UTF8Encoding( false ))->GetString( decryptionStreamBacking->ToArray() ); - if ( !data1->Equals( data2 ) ) - { - Console::WriteLine( "Error: The two values are not equal." ); - } - else - { - Console::WriteLine( "The two values are equal." ); - Console::WriteLine( "k1 iterations: {0}", k1->IterationCount ); - Console::WriteLine( "k2 iterations: {0}", k2->IterationCount ); - } - // - } - - catch ( Exception^ e ) - { - Console::WriteLine( "Error: ", e ); - } - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp deleted file mode 100644 index 3cb652fc45a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// This example demonstrates the StringBuilder.AppendFormat method -// -using namespace System; -using namespace System::Text; -using namespace System::Globalization; -void Show( StringBuilder^ sbs ) -{ - Console::WriteLine( sbs ); - sbs->Length = 0; -} - -int main() -{ - StringBuilder^ sb = gcnew StringBuilder; - int var1 = 111; - float var2 = 2.22F; - String^ var3 = "abcd"; - array^var4 = {3,4.4,(Char)'X'}; - Console::WriteLine(); - Console::WriteLine( "StringBuilder.AppendFormat method:" ); - sb->AppendFormat( "1) {0}", var1 ); - Show( sb ); - sb->AppendFormat( "2) {0}, {1}", var1, var2 ); - Show( sb ); - sb->AppendFormat( "3) {0}, {1}, {2}", var1, var2, var3 ); - Show( sb ); - sb->AppendFormat( "4) {0}, {1}, {2}", var4 ); - Show( sb ); - CultureInfo^ ci = gcnew CultureInfo( "es-ES",true ); - array^temp1 = {var2}; - sb->AppendFormat( ci, "5) {0}", temp1 ); - Show( sb ); -} - -/* -This example produces the following results: - -StringBuilder.AppendFormat method: -1) 111 -2) 111, 2.22 -3) 111, 2.22, abcd -4) 3, 4.4, X -5) 2,22 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp deleted file mode 100644 index 8d70a9a85d3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -// This example demonstrates the StringBuilder.AppendLine() -// method. - -using namespace System; -using namespace System::Text; - -int main() -{ - StringBuilder^ sb = gcnew StringBuilder; - String^ line = L"A line of text."; - int number = 123; - - // Append two lines of text. - sb->AppendLine( L"The first line of text." ); - sb->AppendLine( line ); - - // Append a new line, an empty string, and a null cast as a string. - sb->AppendLine(); - sb->AppendLine( L"" ); - sb->AppendLine( L"" ); - - // Append the non-string value, 123, and two new lines. - sb->Append( number )->AppendLine()->AppendLine(); - - // Append two lines of text. - sb->AppendLine( line ); - sb->AppendLine( L"The last line of text." ); - - // Convert the value of the StringBuilder to a string and display the string. - Console::WriteLine( sb ); - - return 0; -} - -/* -This example produces the following results: - -The first line of text. -A line of text. - - - -123 - -A line of text. -The last line of text. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp deleted file mode 100644 index be8fea41b47..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -// This example demonstrates the CopyTo(Int32, Char[], Int32, Int32) method. -// Typically the destination array is small, preallocated, and global while -// the StringBuilder is large with programmatically defined data. -// However, for this example both the array and StringBuilder are small -// and the StringBuilder has predefined data. - -using namespace System; -using namespace System::Text; - -int main() -{ - array^dest = gcnew array(6); - StringBuilder^ src = gcnew StringBuilder( "abcdefghijklmnopqrstuvwxyz!" ); - dest[ 1 ] = ')'; - dest[ 2 ] = ' '; - - // Copy the source to the destination in 9 pieces, 3 characters per piece. - Console::WriteLine( "\nPiece) Data:" ); - for ( int ix = 0; ix < 9; ix++ ) - { - dest[ 0 ] = ix.ToString()[ 0 ]; - src->CopyTo( ix * 3, dest, 3, 3 ); - Console::Write( " " ); - Console::WriteLine( dest ); - } -} - -/* -This example produces the following results: - -Piece) Data: - 0) abc - 1) def - 2) ghi - 3) jkl - 4) mno - 5) pqr - 6) stu - 7) vwx - 8) yz! -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp deleted file mode 100644 index 8043d615414..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -// This example demonstrates StringBuilder.EnsureCapacity -// StringBuilder.Capacity -// StringBuilder.Length -// StringBuilder.Equals -// -using namespace System; -using namespace System::Text; -int main() -{ - StringBuilder^ sb1 = gcnew StringBuilder( "abc" ); - StringBuilder^ sb2 = gcnew StringBuilder( "abc",16 ); - Console::WriteLine(); - Console::WriteLine( "a1) sb1->Length = {0}, sb1->Capacity = {1}", sb1->Length, sb1->Capacity ); - Console::WriteLine( "a2) sb2->Length = {0}, sb2->Capacity = {1}", sb2->Length, sb2->Capacity ); - Console::WriteLine( "a3) sb1 = \"{0}\", sb2 = \"{1}\"", sb1, sb2 ); - Console::WriteLine( "a4) sb1 equals sb2: {0}", sb1->Equals( sb2 ) ); - Console::WriteLine(); - Console::WriteLine( "Ensure sb1 has a capacity of at least 50 characters." ); - sb1->EnsureCapacity( 50 ); - Console::WriteLine(); - Console::WriteLine( "b1) sb1->Length = {0}, sb1->Capacity = {1}", sb1->Length, sb1->Capacity ); - Console::WriteLine( "b2) sb2->Length = {0}, sb2->Capacity = {1}", sb2->Length, sb2->Capacity ); - Console::WriteLine( "b3) sb1 = \"{0}\", sb2 = \"{1}\"", sb1, sb2 ); - Console::WriteLine( "b4) sb1 equals sb2: {0}", sb1->Equals( sb2 ) ); - Console::WriteLine(); - Console::WriteLine( "Set the length of sb1 to zero." ); - Console::WriteLine( "Set the capacity of sb2 to 51 characters." ); - sb1->Length = 0; - sb2->Capacity = 51; - Console::WriteLine(); - Console::WriteLine( "c1) sb1->Length = {0}, sb1->Capacity = {1}", sb1->Length, sb1->Capacity ); - Console::WriteLine( "c2) sb2->Length = {0}, sb2->Capacity = {1}", sb2->Length, sb2->Capacity ); - Console::WriteLine( "c3) sb1 = \"{0}\", sb2 = \"{1}\"", sb1, sb2 ); - Console::WriteLine( "c4) sb1 equals sb2: {0}", sb1->Equals( sb2 ) ); -} - -/* -The example displays the following output: - -a1) sb1->Length = 3, sb1->Capacity = 16 -a2) sb2->Length = 3, sb2->Capacity = 16 -a3) sb1 = "abc", sb2 = "abc" -a4) sb1 equals sb2: True - -Ensure sb1 has a capacity of at least 50 characters. - -b1) sb1->Length = 3, sb1->Capacity = 50 -b2) sb2->Length = 3, sb2->Capacity = 16 -b3) sb1 = "abc", sb2 = "abc" -b4) sb1 equals sb2: False - -Set the length of sb1 to zero. -Set the capacity of sb2 to 51 characters. - -c1) sb1->Length = 0, sb1->Capacity = 50 -c2) sb2->Length = 3, sb2->Capacity = 51 -c3) sb1 = "", sb2 = "abc" -c4) sb1 equals sb2: False -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp deleted file mode 100644 index 03de6cb972e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp +++ /dev/null @@ -1,118 +0,0 @@ - -// This example demonstrates StringBuilder.Insert() -// -using namespace System; -using namespace System::Text; -ref class Sample -{ -private: - - // index: 012345 - static String^ initialValue = "--[]--"; - static StringBuilder^ sb; - -public: - static void Main() - { - String^ xyz = "xyz"; - array^abc = {'a','b','c'}; - Char star = '*'; - Object^ obj = 0; - bool xBool = true; - Byte xByte = 1; - short xInt16 = 2; - int xInt32 = 3; - long xInt64 = 4; - Decimal xDecimal = 5; - float xSingle = 6.6F; - double xDouble = 7.7; - - // The following types are not CLS-compliant. - UInt16 xUInt16 = 8; - UInt32 xUInt32 = 9; - UInt64 xUInt64 = 10; - SByte xSByte = -11; - - // - Console::WriteLine( "StringBuilder.Insert method" ); - sb = gcnew StringBuilder( initialValue ); - sb->Insert( 3, xyz, 2 ); - Show( 1, sb ); - sb->Insert( 3, xyz ); - Show( 2, sb ); - sb->Insert( 3, star ); - Show( 3, sb ); - sb->Insert( 3, abc ); - Show( 4, sb ); - sb->Insert( 3, abc, 1, 2 ); - Show( 5, sb ); - sb->Insert( 3, xBool ); // True - Show( 6, sb ); - sb->Insert( 3, obj ); // 0 - Show( 7, sb ); - sb->Insert( 3, xByte ); // 1 - Show( 8, sb ); - sb->Insert( 3, xInt16 ); // 2 - Show( 9, sb ); - sb->Insert( 3, xInt32 ); // 3 - Show( 10, sb ); - sb->Insert( 3, xInt64 ); // 4 - Show( 11, sb ); - sb->Insert( 3, xDecimal ); // 5 - Show( 12, sb ); - sb->Insert( 3, xSingle ); // 6.6 - Show( 13, sb ); - sb->Insert( 3, xDouble ); // 7.7 - Show( 14, sb ); - - // The following Insert methods are not CLS-compliant. - sb->Insert( 3, xUInt16 ); // 8 - Show( 15, sb ); - sb->Insert( 3, xUInt32 ); // 9 - Show( 16, sb ); - sb->Insert( 3, xUInt64 ); // 10 - Show( 17, sb ); - sb->Insert( 3, xSByte ); // -11 - Show( 18, sb ); - - // - } - - static void Show( int overloadNumber, StringBuilder^ sbs ) - { - Console::WriteLine( "{0,2:G} = {1}", overloadNumber, sbs ); - sb = gcnew StringBuilder( initialValue ); - } - -}; - -int main() -{ - Sample::Main(); -} - -/* -This example produces the following results: - -StringBuilder.Insert method - 1 = --[xyzxyz]-- - 2 = --[xyz]-- - 3 = --[*]-- - 4 = --[abc]-- - 5 = --[bc]-- - 6 = --[True]-- - 7 = --[0]-- - 8 = --[1]-- - 9 = --[2]-- -10 = --[3]-- -11 = --[4]-- -12 = --[5]-- -13 = --[6.6]-- -14 = --[7.7]-- -15 = --[8]-- -16 = --[9]-- -17 = --[10]-- -18 = --[-11]-- - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp deleted file mode 100644 index df36afedca8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// This example demonstrates StringBuilder.Remove() -// -using namespace System; -using namespace System::Text; -int main() -{ - String^ rule1 = "0----+----1----+----2----+----3----+----4---"; - String^ rule2 = "01234567890123456789012345678901234567890123"; - String^ str = "The quick brown fox jumps over the lazy dog."; - StringBuilder^ sb = gcnew StringBuilder( str ); - Console::WriteLine(); - Console::WriteLine( "StringBuilder.Remove method" ); - Console::WriteLine(); - Console::WriteLine( "Original value:" ); - Console::WriteLine( rule1 ); - Console::WriteLine( rule2 ); - Console::WriteLine( "{0}", sb ); - Console::WriteLine(); - sb->Remove( 10, 6 ); // Remove "brown " - Console::WriteLine( "New value:" ); - Console::WriteLine( rule1 ); - Console::WriteLine( rule2 ); - Console::WriteLine( "{0}", sb ); -} - -/* -This example produces the following results: - -StringBuilder.Remove method - -Original value: -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick brown fox jumps over the lazy dog. - -New value: -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick fox jumps over the lazy dog. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp b/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp deleted file mode 100644 index 56420a34a24..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -// This example demonstrates StringBuilder.Replace() -// -using namespace System; -using namespace System::Text; -void Show( StringBuilder^ sbs ) -{ - String^ rule1 = "0----+----1----+----2----+----3----+----4---"; - String^ rule2 = "01234567890123456789012345678901234567890123"; - Console::WriteLine( rule1 ); - Console::WriteLine( rule2 ); - Console::WriteLine( "{0}", sbs ); - Console::WriteLine(); -} - -int main() -{ - - // 0----+----1----+----2----+----3----+----4--- - // 01234567890123456789012345678901234567890123 - String^ str = "The quick br!wn d#g jumps #ver the lazy cat."; - StringBuilder^ sb = gcnew StringBuilder( str ); - Console::WriteLine(); - Console::WriteLine( "StringBuilder.Replace method" ); - Console::WriteLine(); - Console::WriteLine( "Original value:" ); - Show( sb ); - sb->Replace( '#', '!', 15, 29 ); // Some '#' -> '!' - Show( sb ); - sb->Replace( '!', 'o' ); // All '!' -> 'o' - Show( sb ); - sb->Replace( "cat", "dog" ); // All "cat" -> "dog" - Show( sb ); - sb->Replace( "dog", "fox", 15, 20 ); // Some "dog" -> "fox" - Console::WriteLine( "Final value:" ); - Show( sb ); -} - -/* -This example produces the following results: - -StringBuilder.Replace method - -Original value: -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick br!wn d#g jumps #ver the lazy cat. - -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick br!wn d!g jumps !ver the lazy cat. - -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick brown dog jumps over the lazy cat. - -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick brown dog jumps over the lazy dog. - -Final value: -0----+----1----+----2----+----3----+----4--- -01234567890123456789012345678901234567890123 -The quick brown fox jumps over the lazy dog. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.glob.NFI.nativeDigits/cpp/nd.cpp b/snippets/cpp/VS_Snippets_CLR/sys.glob.NFI.nativeDigits/cpp/nd.cpp deleted file mode 100644 index 7af27ada416..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.glob.NFI.nativeDigits/cpp/nd.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -// This example demonstrates the NativeDigits property. - -using namespace System; -using namespace System::Globalization; -using namespace System::Threading; - -int main() -{ - CultureInfo^ currentCI = Thread::CurrentThread->CurrentCulture; - NumberFormatInfo^ nfi = currentCI->NumberFormat; - array^ nativeDigitList = nfi->NativeDigits; - - Console::WriteLine("The native digits for the {0} culture are:", - currentCI->Name); - - for each (String^ nativeDigit in nativeDigitList) - { - Console::Write("\"{0}\" ", nativeDigit); - } - - Console::WriteLine(); -} -/* -This code example produces the following results: - -The native digits for the en-US culture are: -"0" "1" "2" "3" "4" "5" "6" "7" "8" "9" - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.glob.calendartype/CPP/caltype.cpp b/snippets/cpp/VS_Snippets_CLR/sys.glob.calendartype/CPP/caltype.cpp deleted file mode 100644 index 415a49fc640..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.glob.calendartype/CPP/caltype.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -using namespace System; -using namespace System::Globalization; - -namespace CalendarTypeExample -{ - static void Display(Calendar^ genericCalendar) - { - String^ calendarName = - genericCalendar->ToString()->PadRight(50, '.'); - Console::WriteLine("{0} {1}", calendarName, genericCalendar->GetType()); - } -} - -int main() -{ - GregorianCalendar^ gregorianCalendar = gcnew GregorianCalendar(); - HijriCalendar^ hijriCalendar = gcnew HijriCalendar(); - JapaneseLunisolarCalendar^ japaneseCalendar = - gcnew JapaneseLunisolarCalendar(); - CalendarTypeExample::Display(gregorianCalendar); - CalendarTypeExample::Display(hijriCalendar); - CalendarTypeExample::Display(japaneseCalendar); - return 0; -} - -/* This code example produces the following output. - -System.Globalization.GregorianCalendar............ System.Globalization.GregorianCalendar -System.Globalization.HijriCalendar................ System.Globalization.HijriCalendar -System.Globalization.JapaneseLunisolarCalendar.... System.Globalization.JapaneseLunisolarCalendar - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.glob.carib1/CPP/carib.cpp b/snippets/cpp/VS_Snippets_CLR/sys.glob.carib1/CPP/carib.cpp deleted file mode 100644 index 0e754047e7d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.glob.carib1/CPP/carib.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -// This example demonstrates a System.Globalization.Culture- -// AndRegionInfoBuilder constructor and some of the properties -// of a custom culture object created with the constructor. - -#using - -using namespace System; -using namespace System::Globalization; - -int main() -{ - CultureAndRegionInfoBuilder^ builder = - gcnew CultureAndRegionInfoBuilder - ("x-en-US-sample", CultureAndRegionModifiers::None); - - // Display some of the properties - // for the en-US culture. - Console::WriteLine("CultureName:. . . . . . . . . . {0}", - builder->CultureName); - Console::WriteLine("CultureEnglishName: . . . . . . {0}", - builder->CultureEnglishName); - Console::WriteLine("CultureNativeName:. . . . . . . {0}", - builder->CultureNativeName); - Console::WriteLine("GeoId:. . . . . . . . . . . . . {0}", - builder->GeoId); - Console::WriteLine("IsMetric: . . . . . . . . . . . {0}", - builder->IsMetric); - Console::WriteLine("ISOCurrencySymbol:. . . . . . . {0}", - builder->ISOCurrencySymbol); - Console::WriteLine("RegionEnglishName:. . . . . . . {0}", - builder->RegionEnglishName); - Console::WriteLine("RegionName: . . . . . . . . . . {0}", - builder->RegionName); - Console::WriteLine("RegionNativeName: . . . . . . . {0}", - builder->RegionNativeName); - Console::WriteLine("ThreeLetterISOLanguageName: . . {0}", - builder->ThreeLetterISOLanguageName); - Console::WriteLine("ThreeLetterISORegionName: . . . {0}", - builder->ThreeLetterISORegionName); - Console::WriteLine("ThreeLetterWindowsLanguageName: {0}", - builder->ThreeLetterWindowsLanguageName); - Console::WriteLine("ThreeLetterWindowsRegionName: . {0}", - builder->ThreeLetterWindowsRegionName); - Console::WriteLine("TwoLetterISOLanguageName: . . . {0}", - builder->TwoLetterISOLanguageName); - Console::WriteLine("TwoLetterISORegionName: . . . . {0}", - builder->TwoLetterISORegionName); -} - -/* -This code example produces the following results: - -CultureName:. . . . . . . . . . en-US -CultureEnglishName: . . . . . . English (United States) -CultureNativeName:. . . . . . . English (United States) -GeoId:. . . . . . . . . . . . . 244 -IsMetric: . . . . . . . . . . . False -ISOCurrencySymbol:. . . . . . . USD -RegionEnglishName:. . . . . . . United States -RegionName: . . . . . . . . . . US -RegionNativeName: . . . . . . . United States -ThreeLetterISOLanguageName: . . eng -ThreeLetterISORegionName: . . . USA -ThreeLetterWindowsLanguageName: ENU -ThreeLetterWindowsRegionName: . USA -TwoLetterISOLanguageName: . . . en -TwoLetterISORegionName: . . . . US - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.glob.ci.getCFUIC/cpp/cfuic.cpp b/snippets/cpp/VS_Snippets_CLR/sys.glob.ci.getCFUIC/cpp/cfuic.cpp deleted file mode 100644 index 846861d5752..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.glob.ci.getCFUIC/cpp/cfuic.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// -// This example demonstrates the GetConsoleFallbackUICulture() method -using namespace System; -using namespace System::Globalization; - -int main() -{ - CultureInfo^ ci = gcnew CultureInfo("ar-DZ"); - Console::WriteLine("Culture name: . . . . . . . . . {0}", ci->Name); - Console::WriteLine("Console fallback UI culture:. . {0}", - ci->GetConsoleFallbackUICulture()->Name); -} -/* -This code example produces the following results: - -Culture name: . . . . . . . . . ar-DZ -Console fallback UI culture:. . fr-FR - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp b/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp deleted file mode 100644 index 573d82f64eb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -// This example demonstrates the RegionInfo.EnglishName, NativeName, -// CurrencyEnglishName, CurrencyNativeName, and GeoId properties. - -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Regional Info for Sweden - RegionInfo^ ri = gcnew RegionInfo("SE"); - - Console::WriteLine("Region English Name: . . . {0}", ri->EnglishName); - Console::WriteLine("Native Name: . . . . . . . {0}", ri->NativeName); - Console::WriteLine("Currency English Name: . . {0}", - ri->CurrencyEnglishName); - Console::WriteLine("Currency Native Name:. . . {0}", - ri->CurrencyNativeName); - Console::WriteLine("Geographical ID: . . . . . {0}", ri->GeoId); -} -/* -This code example produces the following results: - -Region English Name: . . . Sweden -Native Name: . . . . . . . Sverige -Currency English Name: . . Swedish Krona -Currency Native Name:. . . Svensk krona -Geographical ID: . . . . . 221 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp deleted file mode 100644 index 6728f14abce..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// -// This example demonstrates the DecoderExceptionFallback class. - -using namespace System; -using namespace System::Text; - -int main() -{ - // Create an encoding, which is equivalent to calling the - // ASCIIEncoding class constructor. - // The DecoderExceptionFallback parameter specifies that an exception - // is thrown if a character cannot be encoded. - // An encoder exception fallback is also specified, but in this code - // example the encoding operation cannot fail. - - Encoding^ asciiEncoding = Encoding::GetEncoding("us-ascii", - gcnew EncoderExceptionFallback(), gcnew DecoderExceptionFallback()); - String^ inputString = "XYZ"; - String^ decodedString; - String^ twoNewLines = Environment::NewLine + Environment::NewLine ; - - array^ encodedBytes = - gcnew array(asciiEncoding->GetByteCount(inputString)); - int numberOfEncodedBytes = 0; - - // --------------------------------------------------------------------- - Console::Clear(); - - // Display the name of the encoding. - Console::WriteLine("The name of the encoding is \"{0}\".{1}", - asciiEncoding->WebName, Environment::NewLine); - - // Display the input string in text. - Console::WriteLine("Input string ({0} characters): \"{1}\"", - inputString->Length, inputString); - - // Display the input string in hexadecimal. - Console::Write("Input string in hexadecimal: "); - for each (char c in inputString) - { - Console::Write("0x{0:X2} ", c); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Encode the input string. - - Console::WriteLine("Encode the input string..."); - - numberOfEncodedBytes = asciiEncoding->GetBytes(inputString, 0, - inputString->Length, encodedBytes, 0); - - // Display the encoded bytes. - Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}", - numberOfEncodedBytes, Environment::NewLine); - for each (Byte b in encodedBytes) - { - Console::Write("0x{0:X2} ", b); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - - // Replace the encoded byte sequences for the characters 'X' and 'Z' - // with the value 0xFF, which is outside the valid range of 0x00 to 0x7F - // for ASCIIEncoding. The resulting byte sequence is actually the - // beginning of this code example because it is the input to the decoder - // operation, and is equivalent to a corrupted or improperly encoded - // byte sequence. - - encodedBytes[0] = 0xFF; - encodedBytes[2] = 0xFF; - - Console::WriteLine("Display the corrupted byte sequence..."); - Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}", - numberOfEncodedBytes, Environment::NewLine); - for each (Byte b in encodedBytes) - { - Console::Write("0x{0:X2} ", b); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Attempt to decode the encoded bytes. However, an exception is thrown - // before the byte sequence can be decoded. - - Console::WriteLine("Compare the decoded bytes to the input string..."); - - try - { - decodedString = asciiEncoding->GetString(encodedBytes); - // This statement is never executed. - Console::WriteLine("This statement is never executed."); - } - catch (DecoderFallbackException^ ex) - { - Console::WriteLine(ex); - Console::WriteLine( - "{0}*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. ***", - Environment::NewLine); - } -} - - -/* -This code example produces the following results: - -The name of the encoding is "us-ascii". - -Input string (3 characters): "XYZ" -Input string in hexadecimal: 0x58 0x59 0x5A - -Encode the input string... -Encoded bytes in hexadecimal (3 bytes): - -0x58 0x59 0x5A - -Display the corrupted byte sequence... -Encoded bytes in hexadecimal (3 bytes): - -0xFF 0x59 0xFF - -Compare the decoded bytes to the input string... -System.Text.DecoderFallbackException: Unable to translate bytes [FF] at index 0 from speci -fied code page to Unicode. -at System.Text.DecoderExceptionFallbackBuffer.Throw(Byte[] bytesUnknown, Int32 index) -at System.Text.DecoderExceptionFallbackBuffer.Fallback(Byte[] bytesUnknown, Int32 index -) -at System.Text.DecoderFallbackBuffer.InternalFallback(Byte[] bytes, Byte* pBytes) -at System.Text.ASCIIEncoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS decoder) - -at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encod -ing) -at System.Text.ASCIIEncoding.GetString(Byte[] bytes, Int32 byteIndex, Int32 byteCount) -at System.Text.Encoding.GetString(Byte[] bytes) -at Sample.Main() - -*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. *** - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp deleted file mode 100644 index 332c5a91b7d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// -// This example demonstrates the DecoderReplacementFallback class. - -using namespace System; -using namespace System::Text; - -int main() -{ - // Create an encoding, which is equivalent to calling the - // ASCIIEncoding class constructor. - // The DecoderReplacementFallback parameter specifies that the - // string "(error)" is to replace characters that cannot be decoded. - // An encoder replacement fallback is also specified, but in this code - // example the encoding operation cannot fail. - - Encoding^ asciiEncoding = Encoding::GetEncoding("us-ascii", - gcnew EncoderReplacementFallback("(unknown)"), - gcnew DecoderReplacementFallback("(error)")); - String^ inputString = "XYZ"; - String^ decodedString; - String^ twoNewLines = Environment::NewLine + Environment::NewLine; - array^ encodedBytes = gcnew array( - asciiEncoding->GetByteCount(inputString)); - int numberOfEncodedBytes = 0; - - // --------------------------------------------------------------------- - Console::Clear(); - - // Display the name of the encoding. - Console::WriteLine("The name of the encoding is \"{0}\".{1}", - asciiEncoding->WebName, Environment::NewLine); - - // Display the input string in text. - Console::WriteLine("Input string ({0} characters): \"{1}\"", - inputString->Length, inputString); - - // Display the input string in hexadecimal. - Console::Write("Input string in hexadecimal: "); - for each (char c in inputString) - { - Console::Write("0x{0:X2} ", c); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Encode the input string. - - Console::WriteLine("Encode the input string..."); - numberOfEncodedBytes = asciiEncoding->GetBytes(inputString, 0, - inputString->Length, encodedBytes, 0); - - // Display the encoded bytes. - Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}", - numberOfEncodedBytes, Environment::NewLine); - for each (Byte b in encodedBytes) - { - Console::Write("0x{0:X2} ", b); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - - // Replace the encoded byte sequences for the characters 'X' and 'Z' - // with the value 0xFF, which is outside the valid range of 0x00 to 0x7F - // for ASCIIEncoding. The resulting byte sequence is actually the - // beginning of this code example because it is the input to the decoder - // operation, and is equivalent to a corrupted or improperly encoded - // byte sequence. - - encodedBytes[0] = 0xFF; - encodedBytes[2] = 0xFF; - - Console::WriteLine("Display the corrupted byte sequence..."); - Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}", - numberOfEncodedBytes, Environment::NewLine); - for each (Byte b in encodedBytes) - { - Console::Write("0x{0:X2} ", b); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Decode the encoded bytes. - - Console::WriteLine("Compare the decoded bytes to the input string..."); - decodedString = asciiEncoding->GetString(encodedBytes); - - // Display the input string and the decoded string for comparison. - Console::WriteLine("Input string: \"{0}\"", inputString); - Console::WriteLine("Decoded string:\"{0}\"", decodedString); -} -/* -This code example produces the following results: - -The name of the encoding is "us-ascii". - -Input string (3 characters): "XYZ" -Input string in hexadecimal: 0x58 0x59 0x5A - -Encode the input string... -Encoded bytes in hexadecimal (3 bytes): - -0x58 0x59 0x5A - -Display the corrupted byte sequence... -Encoded bytes in hexadecimal (3 bytes): - -0xFF 0x59 0xFF - -Compare the decoded bytes to the input string... -Input string: "XYZ" -Decoded string:"(error)Y(error)" - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp deleted file mode 100644 index 3207d7a7fb2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// -// This example demonstrates the EncoderExceptionFallback class. - -using namespace System; -using namespace System::Text; - -int main() -{ - // Create an encoding, which is equivalent to calling the - // ASCIIEncoding class constructor. - // The EncoderExceptionFallback parameter causes an exception to - // be thrown when a character cannot be encoded. - // A decoder exception fallback is also specified, but it is not - // used because this example terminates during the encoding operation. - - Encoding^ asciiEncoding = Encoding::GetEncoding("us-ascii", - gcnew EncoderExceptionFallback(), gcnew DecoderExceptionFallback()); - - // The input string consists of the Unicode characters LEFT POINTING - // DOUBLE ANGLE QUOTATION MARK (U+00AB), 'X' (U+0058), and RIGHT - // POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB). - // The encoding can only encode characters in the US-ASCII range of - // U+0000 through U+007F. Consequently, the characters bracketing the - // 'X' character cause an exception. - String^ inputString = L"\u00abX\u00bb"; - - String^ twoNewLines = Environment::NewLine + Environment::NewLine; - array^ encodedBytes = gcnew array( - asciiEncoding->GetMaxByteCount(inputString->Length)); - int numberOfEncodedBytes = 0; - - // --------------------------------------------------------------------- - Console::Clear(); - - // Display the name of the encoding. - Console::WriteLine("The name of the encoding is \"{0}\".{1}", - asciiEncoding->WebName, Environment::NewLine); - - // Display the input string in text. - Console::WriteLine("Input string ({0} characters): \"{1}\"", - inputString->Length, inputString); - - // Display the input string in hexadecimal. - Console::Write("Input string in hexadecimal: "); - for each (char c in inputString) - { - Console::Write("0x{0:X2} ", c); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Attempt to encode the input string. However, an exception is thrown - // before the input string can be encoded. - - Console::WriteLine("Encode the input string..."); - - // The code example terminates during the call to the GetBytes() method. - try - { - numberOfEncodedBytes = asciiEncoding->GetBytes(inputString, 0, - inputString->Length, encodedBytes, 0); - // This statement is never executed. - Console::WriteLine("This statement is never executed."); - } - catch (EncoderFallbackException^ ex) - { - Console::WriteLine(ex); - Console::WriteLine( - "{0}*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. ***", - Environment::NewLine); - } -} - -/* -This code example produces the following results: - -The name of the encoding is "us-ascii". - -Input string (3 characters): "X" -Input string in hexadecimal: 0xAB 0x58 0xBB - -Encode the input string... -System.Text.EncoderFallbackException: Unable to translate Unicode character \u00AB at inde -x 0 to specified code page. -at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index) -at System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars) -at System.Text.ASCIIEncoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 -byteCount, EncoderNLS encoder) -at System.Text.ASCIIEncoding.GetBytes(String chars, Int32 charIndex, Int32 charCount, B -yte[] bytes, Int32 byteIndex) -at Sample.Main() - -*** THE CODE EXAMPLE TERMINATES HERE AS INTENDED. *** - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp b/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp deleted file mode 100644 index ec4a3456bd1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// -// This example demonstrates the EncoderReplacementFallback class. - -using namespace System; -using namespace System::Text; - -int main() -{ - // Create an encoding, which is equivalent to calling the - // ASCIIEncoding class constructor. - // The EncoderReplacementFallback parameter specifies that the - // string, "(unknown)", replace characters that cannot be encoded. - // A decoder replacement fallback is also specified, but in this - // code example the decoding operation cannot fail. - - Encoding^ ascii = Encoding::GetEncoding("us-ascii", - gcnew EncoderReplacementFallback("(unknown)"), - gcnew DecoderReplacementFallback("(error)")); - - // The input string consists of the Unicode characters LEFT POINTING - // DOUBLE ANGLE QUOTATION MARK (U+00AB), 'X' (U+0058), and RIGHT - // POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB). - // The encoding can only encode characters in the US-ASCII range of - // U+0000 through U+007F. Consequently, the characters bracketing the - // 'X' character are replaced with the fallback replacement string, - // "(unknown)". - - String^ inputString = "\u00abX\u00bb"; - String^ decodedString; - String^ twoNewLines = Environment::NewLine + Environment::NewLine; - array ^ encodedBytes = - gcnew array(ascii->GetByteCount(inputString)); - int numberOfEncodedBytes = 0; - - // --------------------------------------------------------------------- - // Display the name of the encoding. - Console::WriteLine("The name of the encoding is \"{0}\".{1}", - ascii->WebName, Environment::NewLine); - - // Display the input string in text. - Console::WriteLine("Input string ({0} characters): \"{1}\"", - inputString->Length, inputString); - - // Display the input string in hexadecimal. - Console::Write("Input string in hexadecimal: "); - for each (char c in inputString) - { - Console::Write("0x{0:X2} ", c); - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Encode the input string. - - Console::WriteLine("Encode the input string..."); - numberOfEncodedBytes = ascii->GetBytes(inputString, 0, inputString->Length, - encodedBytes, 0); - - // Display the encoded bytes. - Console::WriteLine("Encoded bytes in hexadecimal ({0} bytes):{1}", - numberOfEncodedBytes, Environment::NewLine); - for(int i = 0; i < encodedBytes->Length; i++) - { - Console::Write("0x{0:X2} ", encodedBytes[i]); - if(((i + 1) % 6) == 0) - { - Console::WriteLine(); - } - } - Console::Write(twoNewLines); - - // --------------------------------------------------------------------- - // Decode the encoded bytes, yielding a reconstituted string. - - Console::WriteLine("Decode the encoded bytes..."); - decodedString = ascii->GetString(encodedBytes); - - // Display the input string and the decoded string for comparison. - Console::WriteLine("Input string: \"{0}\"", inputString); - Console::WriteLine("Decoded string:\"{0}\"", decodedString); -} - - - -/* -This code example produces the following results: - -The name of the encoding is "us-ascii". - -Input string (3 characters): "X" -Input string in hexadecimal: 0xAB 0x58 0xBB - -Encode the input string... -Encoded bytes in hexadecimal (19 bytes): - -0x28 0x75 0x6E 0x6B 0x6E 0x6F -0x77 0x6E 0x29 0x58 0x28 0x75 -0x6E 0x6B 0x6E 0x6F 0x77 0x6E -0x29 - -Decode the encoded bytes... -Input string: "X" -Decoded string:"(unknown)X(unknown)" - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp deleted file mode 100644 index 79399d8f51e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -int main() -{ - for (int i = 0; i < 5; i++) - { - Console::WriteLine("Sleep for 2 seconds."); - Thread::Sleep(2000); - } - - Console::WriteLine("Main thread exits."); -} - -/* This example produces the following output: - -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Main thread exits. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp deleted file mode 100644 index 4f50e318256..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -int main() -{ - TimeSpan interval = TimeSpan(0, 0, 2); - - for (int i = 0; i < 5; i++) - { - Console::WriteLine("Sleep for 2 seconds."); - Thread::Sleep(interval); - } - - Console::WriteLine("Main thread exits."); -} - -/* This example produces the following output: - -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Sleep for 2 seconds. -Main thread exits. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/remarks.cpp deleted file mode 100644 index fbbf07e7429..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/remarks.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; - -int main() -{ -// - X509Chain^ ch = gcnew X509Chain(); - ch->ChainPolicy->ApplicationPolicy->Add(gcnew Oid("1.2.1.1")); -// - //Output chain information about the chain. - Console::WriteLine("Chain Information"); - ch->ChainPolicy->RevocationMode = X509RevocationMode::Online; - Console::WriteLine("Chain revocation flag: {0}", ch->ChainPolicy->RevocationFlag); - Console::WriteLine("Chain revocation mode: {0}", ch->ChainPolicy->RevocationMode); - Console::WriteLine("Chain verification flag: {0}", ch->ChainPolicy->VerificationFlags); - Console::WriteLine("Chain verification time: {0}", ch->ChainPolicy->VerificationTime); - Console::WriteLine("Chain status length: {0}", ch->ChainStatus->Length); - Console::WriteLine("Chain application policy count: {0}", ch->ChainPolicy->ApplicationPolicy->Count); - Console::WriteLine("Chain certificate policy count: {0} {1}", ch->ChainPolicy->CertificatePolicy->Count, Environment::NewLine); -} diff --git a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp b/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp deleted file mode 100644 index 7b57914985d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; - -int main() -{ - // - //Create new X509 store from local certificate store. - X509Store ^ store = gcnew X509Store( "MY",StoreLocation::CurrentUser ); - store->Open( static_cast(OpenFlags::OpenExistingOnly | OpenFlags::ReadWrite) ); - - //Output store information. - Console::WriteLine( "Store Information" ); - Console::WriteLine( "Number of certificates in the store: {0}", store->Certificates->Count ); - Console::WriteLine( "Store location: {0}", store->Location ); - Console::WriteLine( "Store name: {0} {1}", store->Name, Environment::NewLine ); - - //Put certificates from the store into a collection so user can select one. - X509Certificate2Collection ^ fcollection = dynamic_cast(store->Certificates); - X509Certificate2Collection ^ collection = X509Certificate2UI::SelectFromCollection(fcollection, "Select an X509 Certificate","Choose a certificate to examine.",X509SelectionFlag::SingleSelection); - X509Certificate2 ^ certificate = collection[ 0 ]; - X509Certificate2UI::DisplayCertificate(certificate); - // - - // - //Output chain information of the selected certificate. - X509Chain ^ ch = gcnew X509Chain; - ch->ChainPolicy->RevocationMode = X509RevocationMode::Online; - ch->Build( certificate ); - Console::WriteLine( "Chain Information" ); - Console::WriteLine( "Chain revocation flag: {0}", ch->ChainPolicy->RevocationFlag ); - Console::WriteLine( "Chain revocation mode: {0}", ch->ChainPolicy->RevocationMode ); - Console::WriteLine( "Chain verification flag: {0}", ch->ChainPolicy->VerificationFlags ); - Console::WriteLine( "Chain verification time: {0}", ch->ChainPolicy->VerificationTime ); - Console::WriteLine( "Chain status length: {0}", ch->ChainStatus->Length ); - Console::WriteLine( "Chain application policy count: {0}", ch->ChainPolicy->ApplicationPolicy->Count ); - Console::WriteLine( "Chain certificate policy count: {0} {1}", ch->ChainPolicy->CertificatePolicy->Count, Environment::NewLine ); - // - - // - //Output chain element information. - Console::WriteLine( "Chain Element Information" ); - Console::WriteLine( "Number of chain elements: {0}", ch->ChainElements->Count ); - Console::WriteLine( "Chain elements synchronized? {0} {1}", ch->ChainElements->IsSynchronized, Environment::NewLine ); - System::Collections::IEnumerator^ myEnum = ch->ChainElements->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - X509ChainElement ^ element = safe_cast(myEnum->Current); - Console::WriteLine( "Element issuer name: {0}", element->Certificate->Issuer ); - Console::WriteLine( "Element certificate valid until: {0}", element->Certificate->NotAfter ); - Console::WriteLine( "Element certificate is valid: {0}", element->Certificate->Verify() ); - Console::WriteLine( "Element error status length: {0}", element->ChainElementStatus->Length ); - Console::WriteLine( "Element information: {0}", element->Information ); - Console::WriteLine( "Number of element extensions: {0}{1}", element->Certificate->Extensions->Count, Environment::NewLine ); - if ( ch->ChainStatus->Length > 1 ) - { - for ( int index = 0; index < element->ChainElementStatus->Length; index++ ) - { - Console::WriteLine( element->ChainElementStatus[ index ].Status ); - Console::WriteLine( element->ChainElementStatus[ index ].StatusInformation ); - } - } - } - - store->Close(); - // -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp b/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp deleted file mode 100644 index e1db565ed35..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp +++ /dev/null @@ -1,79 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; -int main() -{ - - //Create new X509 store called teststore from the local certificate store. - X509Store ^ store = gcnew X509Store( "teststore",StoreLocation::CurrentUser ); - store->Open( OpenFlags::ReadWrite ); - X509Certificate2 ^ certificate = gcnew X509Certificate2; - - //Create certificates from certificate files. - //You must put in a valid path to three certificates in the following constructors. - X509Certificate2 ^ certificate1 = gcnew X509Certificate2( "c:\\mycerts\\*****.cer" ); - X509Certificate2 ^ certificate2 = gcnew X509Certificate2( "c:\\mycerts\\*****.cer" ); - X509Certificate2 ^ certificate5 = gcnew X509Certificate2( "c:\\mycerts\\*****.cer" ); - - //Create a collection and add two of the certificates. - X509Certificate2Collection ^ collection = gcnew X509Certificate2Collection; - collection->Add( certificate2 ); - collection->Add( certificate5 ); - - //Add certificates to the store. - store->Add( certificate1 ); - store->AddRange( collection ); - X509Certificate2Collection ^ storecollection = dynamic_cast(store->Certificates); - Console::WriteLine( "Store name: {0}", store->Name ); - Console::WriteLine( "Store location: {0}", store->Location ); - System::Collections::IEnumerator^ myEnum = storecollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - X509Certificate2 ^ x509 = safe_cast(myEnum->Current); - Console::WriteLine( "certificate name: {0}", x509->Subject ); - } - - - //Remove a certificate. - store->Remove( certificate1 ); - X509Certificate2Collection ^ storecollection2 = dynamic_cast(store->Certificates); - Console::WriteLine( "{1}Store name: {0}", store->Name, Environment::NewLine ); - System::Collections::IEnumerator^ myEnum1 = storecollection2->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - X509Certificate2 ^ x509 = safe_cast(myEnum1->Current); - Console::WriteLine( "certificate name: {0}", x509->Subject ); - } - - - //Remove a range of certificates. - store->RemoveRange( collection ); - X509Certificate2Collection ^ storecollection3 = dynamic_cast(store->Certificates); - Console::WriteLine( "{1}Store name: {0}", store->Name, Environment::NewLine ); - if ( storecollection3->Count == 0 ) - { - Console::WriteLine( "Store contains no certificates." ); - } - else - { - System::Collections::IEnumerator^ myEnum2 = storecollection3->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - X509Certificate2 ^ x509 = safe_cast(myEnum2->Current); - Console::WriteLine( "certificate name: {0}", x509->Subject ); - } - } - - - //Close the store. - store->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp deleted file mode 100644 index d67485dbd80..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::ComponentModel; -using namespace System::Security::Cryptography; - -// -void EncryptData( String^ inName, String^ outName, array^aesKey, array^aesIV ) -{ - - //Create the file streams to handle the input and output files. - FileStream^ fin = gcnew FileStream( inName,FileMode::Open,FileAccess::Read ); - FileStream^ fout = gcnew FileStream( outName,FileMode::OpenOrCreate,FileAccess::Write ); - fout->SetLength( 0 ); - - //Create variables to help with read and write. - array^bin = gcnew array(100); - long rdlen = 0; //This is the total number of bytes written. - - long totlen = (long)fin->Length; //This is the total length of the input file. - - int len; //This is the number of bytes to be written at a time. - - Aes^ aes = Aes::Create(); - - CryptoStream^ encStream = gcnew CryptoStream( fout,aes->CreateEncryptor( aesKey, aesIV ),CryptoStreamMode::Write ); - Console::WriteLine( "Encrypting..." ); - - //Read from the input file, then encrypt and write to the output file. - while ( rdlen < totlen ) - { - len = fin->Read( bin, 0, 100 ); - encStream->Write( bin, 0, len ); - rdlen = rdlen + len; - Console::WriteLine( "{0} bytes processed", rdlen ); - } - - encStream->Close(); - fout->Close(); - fin->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp deleted file mode 100644 index 505973f52b6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Windows::Forms; -using namespace System::Security::Cryptography; - -// -void EncryptData( String^ inName, String^ outName, array^desKey, array^desIV ) -{ - - //Create the file streams to handle the input and output files. - FileStream^ fin = gcnew FileStream( inName,FileMode::Open,FileAccess::Read ); - FileStream^ fout = gcnew FileStream( outName,FileMode::OpenOrCreate,FileAccess::Write ); - fout->SetLength( 0 ); - - //Create variables to help with read and write. - array^bin = gcnew array(100); - long rdlen = 0; //This is the total number of bytes written. - - long totlen = (long)fin->Length; //This is the total length of the input file. - - int len; //This is the number of bytes to be written at a time. - - DES^ des = gcnew DESCryptoServiceProvider; - CryptoStream^ encStream = gcnew CryptoStream( fout,des->CreateEncryptor( desKey, desIV ),CryptoStreamMode::Write ); - Console::WriteLine( "Encrypting..." ); - - //Read from the input file, then encrypt and write to the output file. - while ( rdlen < totlen ) - { - len = fin->Read( bin, 0, 100 ); - encStream->Write( bin, 0, len ); - rdlen = rdlen + len; - Console::WriteLine( "{0} bytes processed", rdlen ); - } - - encStream->Close(); - fout->Close(); - fin->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp deleted file mode 100644 index 56512d92aca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // These bytes in UTF-8 correspond to 3 different Unicode - // characters: space (U+0020), # (U+0023), and the biohazard - // symbol (U+2623). Note the biohazard symbol requires 3 bytes - // in UTF-8 (hexadecimal e2, 98, a3). Decoders store state across - // multiple calls to GetChars, handling the case when one char - // is in multiple byte arrays. - array^bytes1 = {0x20,0x23,0xe2}; - array^bytes2 = {0x98,0xa3}; - array^chars = gcnew array(3); - Decoder^ d = Encoding::UTF8->GetDecoder(); - int charLen = d->GetChars( bytes1, 0, bytes1->Length, chars, 0 ); - - // The value of charLen should be 2 now. - charLen += d->GetChars( bytes2, 0, bytes2->Length, chars, charLen ); - for ( UInt16 index(0); index < chars->Length; ++index ) - { - Console::Write( "U+{0:X4} ", static_cast(chars[ index ]) ); - - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp deleted file mode 100644 index df797ae34f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -// Use this code inside a project created with the Visual C++ > CLR > CLR Console Application template. -// Replace the code in the default .cpp file with this code. - -#include "stdafx.h" -#using - -using namespace System; - -// To avoid confusion with other Timer classes, this sample always uses the fully-qualified -// name of System::Timers::Timer instead of a using statement for System::Timer. - -public ref class Example -{ -private: - static System::Timers::Timer^ aTimer; - -public: - static void Demo() - { - // Normally, the timer is declared at the class level, so that it stays in scope as long as it - // is needed. If the timer is declared in a long-running method, KeepAlive must be used to prevent - // the JIT compiler from allowing aggressive garbage collection to occur before the method ends. - // You can experiment with this by commenting out the class-level declaration and uncommenting - // the declaration below; then uncomment the GC.KeepAlive(aTimer) at the end of the method. - //System::Timers::Timer^ aTimer; - - // Create a timer and set a two second interval. - aTimer = gcnew System::Timers::Timer(); - aTimer->Interval = 2000; - - // Alternate method: create a Timer with an interval argument to the constructor. - //aTimer = gcnew System::Timers::Timer(2000); - - // Hook up the Elapsed event for the timer. - aTimer->Elapsed += gcnew System::Timers::ElapsedEventHandler(Example::OnTimedEvent); - - // Have the timer fire repeated events (true is the default) - aTimer->AutoReset = true; - - // Start the timer - aTimer->Enabled = true; - - Console::WriteLine("Press the Enter key to exit the program at any time... "); - Console::ReadLine(); - - // If the timer is declared in a long-running method, use KeepAlive to prevent garbage collection - // from occurring before the method ends. - //GC::KeepAlive(aTimer); - } - -private: - static void OnTimedEvent(Object^ source, System::Timers::ElapsedEventArgs^ e) - { - Console::WriteLine("The Elapsed event was raised at {0}", e->SignalTime); - } - -}; - -int main() -{ - Example::Demo(); -} - -// This example displays output like the following: -// Press the Enter key to exit the program at any time... -// The Elapsed event was raised at 5/20/2015 8:48:58 PM -// The Elapsed event was raised at 5/20/2015 8:49:00 PM -// The Elapsed event was raised at 5/20/2015 8:49:02 PM -// The Elapsed event was raised at 5/20/2015 8:49:04 PM -// The Elapsed event was raised at 5/20/2015 8:49:06 PM - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp deleted file mode 100644 index 6f843e8ba21..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Timers; - -public ref class Timer2 -{ -private: - static System::Timers::Timer^ aTimer; - -public: - static void Main() - { - // Create a new Timer with Interval set to 1.5 seconds. - double interval = 1500.0; - aTimer = gcnew System::Timers::Timer(interval); - - // Hook up the event handler for the Elapsed event. - aTimer->Elapsed += gcnew ElapsedEventHandler( OnTimedEvent ); - - // Only raise the event the first time Interval elapses. - aTimer->AutoReset = false; - aTimer->Enabled = true; - - // Ensure the event fires before the exit message appears. - System::Threading::Thread::Sleep((int) interval * 2); - Console::WriteLine("Press the Enter key to exit the program."); - Console::ReadLine(); - - // If the timer is declared in a long-running method, use - // KeepAlive to prevent garbage collection from occurring - // before the method ends. - //GC::KeepAlive(aTimer); - } - -private: - // Handle the Elapsed event. - static void OnTimedEvent( Object^ /*source*/, ElapsedEventArgs^ /*e*/ ) - { - Console::WriteLine( "Hello World!" ); - } - -}; - -int main() -{ - Timer2::Main(); -} -// The example displays the following output: -// Hello World! -// Press the Enter key to exit the program. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp deleted file mode 100644 index f17fb57cbb7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp +++ /dev/null @@ -1,153 +0,0 @@ - - -// -// This example uses the SHA1 algorithm. -// Due to collision problems with SHA1, Microsoft recommends SHA256 or better. -#using - -using namespace System; -using namespace System::Text; -using namespace System::Security::Cryptography; -ref class Sender -{ -private: - RSAParameters rsaPubParams; - RSAParameters rsaPrivateParams; - -public: - Sender() - { - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - - //Generate public and private key data. - rsaPrivateParams = rsaCSP->ExportParameters( true ); - rsaPubParams = rsaCSP->ExportParameters( false ); - } - - - property RSAParameters PublicParameters - { - RSAParameters get() - { - return rsaPubParams; - } - - } - - //Manually performs hash and then signs hashed value. - array^ HashAndSign( array^encrypted ) - { - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - SHA1Managed^ hash = gcnew SHA1Managed; - array^hashedData; - rsaCSP->ImportParameters( rsaPrivateParams ); - hashedData = hash->ComputeHash( encrypted ); - return rsaCSP->SignHash( hashedData, CryptoConfig::MapNameToOID( "SHA1" ) ); - } - - - //Encrypts using only the public key data. - array^ EncryptData( RSAParameters rsaParams, array^toEncrypt ) - { - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - rsaCSP->ImportParameters( rsaParams ); - return rsaCSP->Encrypt( toEncrypt, false ); - } - -}; - -ref class Receiver -{ -private: - RSAParameters rsaPubParams; - RSAParameters rsaPrivateParams; - -public: - Receiver() - { - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - - //Generate public and private key data. - rsaPrivateParams = rsaCSP->ExportParameters( true ); - rsaPubParams = rsaCSP->ExportParameters( false ); - } - - - property RSAParameters PublicParameters - { - RSAParameters get() - { - return rsaPubParams; - } - - } - - //Manually performs hash and then verifies hashed value. - // - bool VerifyHash( RSAParameters rsaParams, array^signedData, array^signature ) - { - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - SHA1Managed^ hash = gcnew SHA1Managed; - array^hashedData; - rsaCSP->ImportParameters( rsaParams ); - bool dataOK = rsaCSP->VerifyData(signedData, CryptoConfig::MapNameToOID("SHA1"), signature); - hashedData = hash->ComputeHash( signedData ); - return rsaCSP->VerifyHash( hashedData, CryptoConfig::MapNameToOID( "SHA1" ), signature ); - } - // - - - //Decrypt using the private key data. - void DecryptData( array^encrypted ) - { - array^fromEncrypt; - String^ roundTrip; - ASCIIEncoding^ myAscii = gcnew ASCIIEncoding; - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - rsaCSP->ImportParameters( rsaPrivateParams ); - fromEncrypt = rsaCSP->Decrypt( encrypted, false ); - roundTrip = myAscii->GetString( fromEncrypt ); - Console::WriteLine( "RoundTrip: {0}", roundTrip ); - } - -}; - -int main() -{ - array^toEncrypt; - array^encrypted; - array^signature; - - //Choose a small amount of data to encrypt. - String^ original = "Hello"; - ASCIIEncoding^ myAscii = gcnew ASCIIEncoding; - - //Create a sender and receiver. - Sender^ mySender = gcnew Sender; - Receiver^ myReceiver = gcnew Receiver; - - //Convert the data string to a byte array. - toEncrypt = myAscii->GetBytes( original ); - - //Encrypt data using receiver's public key. - encrypted = mySender->EncryptData( myReceiver->PublicParameters, toEncrypt ); - - //Hash the encrypted data and generate a signature on the hash - // using the sender's private key. - signature = mySender->HashAndSign( encrypted ); - Console::WriteLine( "Original: {0}", original ); - - //Verify the signature is authentic using the sender's public key. - if ( myReceiver->VerifyHash( mySender->PublicParameters, encrypted, signature ) ) - { - - //Decrypt the data using the receiver's private key. - myReceiver->DecryptData( encrypted ); - } - else - { - Console::WriteLine( "Invalid signature" ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/source2.cpp deleted file mode 100644 index de9be7b2fe4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/source2.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::Threading; - -public ref class SamplesStringDictionary -{ -public: - static void Main() - { - // - StringDictionary^ myCollection = gcnew StringDictionary(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection) - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesStringDictionary::Main(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/stringdictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/stringdictionary.cpp deleted file mode 100644 index 5423aa171ec..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/stringdictionary.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// The following code example demonstrates several of the properties and methods of StringDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintKeysAndValues2( StringDictionary^ myCol ); -void PrintKeysAndValues3( StringDictionary^ myCol ); - -int main() -{ - // Creates and initializes a new StringDictionary. - StringDictionary^ myCol = gcnew StringDictionary; - myCol->Add( "red", "rojo" ); - myCol->Add( "green", "verde" ); - myCol->Add( "blue", "azul" ); - - // Display the contents of the collection using the enumerator. - Console::WriteLine( "Displays the elements using the IEnumerator:" ); - PrintKeysAndValues2( myCol ); - - // Display the contents of the collection using the Keys, Values, Count, and Item properties. - Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" ); - PrintKeysAndValues3( myCol ); - - // Copies the StringDictionary to an array with DictionaryEntry elements. - array^myArr = gcnew array(myCol->Count); - myCol->CopyTo( myArr, 0 ); - - // Displays the values in the array. - Console::WriteLine( "Displays the elements in the array:" ); - Console::WriteLine( " KEY VALUE" ); - for ( int i = 0; i < myArr->Length; i++ ) - Console::WriteLine( " {0,-10} {1}", myArr[ i ].Key, myArr[ i ].Value ); - Console::WriteLine(); - - // Searches for a value. - if ( myCol->ContainsValue( "amarillo" ) ) - Console::WriteLine( "The collection contains the value \"amarillo\"." ); - else - Console::WriteLine( "The collection does not contain the value \"amarillo\"." ); - - Console::WriteLine(); - - // Searches for a key and deletes it. - if ( myCol->ContainsKey( "green" ) ) - myCol->Remove( "green" ); - - Console::WriteLine( "The collection contains the following elements after removing \"green\":" ); - PrintKeysAndValues2( myCol ); - - // Clears the entire collection. - myCol->Clear(); - Console::WriteLine( "The collection contains the following elements after it is cleared:" ); - PrintKeysAndValues2( myCol ); -} - -// Uses the enumerator. -void PrintKeysAndValues2( StringDictionary^ myCol ) -{ - IEnumerator^ myEnumerator = myCol->GetEnumerator(); - DictionaryEntry de; - Console::WriteLine( " KEY VALUE" ); - while ( myEnumerator->MoveNext() ) - { - de = *dynamic_cast(myEnumerator->Current); - Console::WriteLine( " {0,-25} {1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -// Uses the Keys, Values, Count, and Item properties. -void PrintKeysAndValues3( StringDictionary^ myCol ) -{ - array^myKeys = gcnew array(myCol->Count); - myCol->Keys->CopyTo( myKeys, 0 ); - Console::WriteLine( " INDEX KEY VALUE" ); - for ( int i = 0; i < myCol->Count; i++ ) - Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] ); - Console::WriteLine(); -} - -/* -This code produces the following output. - -Displays the elements using the IEnumerator: - KEY VALUE - red rojo - blue azul - green verde - -Displays the elements using the Keys, Values, Count, and Item properties: - INDEX KEY VALUE - 0 red rojo - 1 blue azul - 2 green verde - -Displays the elements in the array: - KEY VALUE - red rojo - blue azul - green verde - -The collection does not contain the value "amarillo". - -The collection contains the following elements after removing "green": - KEY VALUE - red rojo - blue azul - -The collection contains the following elements after it is cleared: - KEY VALUE - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/CPP/stringdictionary_addremove.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/CPP/stringdictionary_addremove.cpp deleted file mode 100644 index c477bb3710f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/CPP/stringdictionary_addremove.cpp +++ /dev/null @@ -1,65 +0,0 @@ - - -// The following code example demonstrates how to add and remove elements from a StringDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintKeysAndValues( StringDictionary^ myCol ) -{ - Console::WriteLine( " KEY VALUE" ); - IEnumerator^ enum0 = myCol->GetEnumerator(); - while ( enum0->MoveNext() ) - { - DictionaryEntry^ de = safe_cast(enum0->Current); - Console::WriteLine( " {0,-10} {1}", de->Key, de->Value ); - } - - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new StringDictionary. - StringDictionary^ myCol = gcnew StringDictionary; - myCol->Add( "red", "rojo" ); - myCol->Add( "green", "verde" ); - myCol->Add( "blue", "azul" ); - - // Displays the values in the StringDictionary. - Console::WriteLine( "Initial contents of the StringDictionary:" ); - PrintKeysAndValues( myCol ); - - // Deletes an element. - myCol->Remove( "green" ); - Console::WriteLine( "The collection contains the following elements after removing \"green\":" ); - PrintKeysAndValues( myCol ); - - // Clears the entire collection. - myCol->Clear(); - Console::WriteLine( "The collection contains the following elements after it is cleared:" ); - PrintKeysAndValues( myCol ); -} - -/* -This code produces the following output. - -Initial contents of the StringDictionary: - KEY VALUE - green verde - red rojo - blue azul - -The collection contains the following elements after removing "green": - KEY VALUE - red rojo - blue azul - -The collection contains the following elements after it is cleared: - KEY VALUE - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/CPP/stringdictionary_contains.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/CPP/stringdictionary_contains.cpp deleted file mode 100644 index 854a898a04a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/CPP/stringdictionary_contains.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// The following code example searches for an element in a StringDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintKeysAndValues( StringDictionary^ myCol ) -{ - Console::WriteLine( " KEY VALUE" ); - IEnumerator^ enum0 = myCol->GetEnumerator(); - while ( enum0->MoveNext() ) - { - DictionaryEntry^ de = safe_cast(enum0->Current); - Console::WriteLine( " {0,-10} {1}", de->Key, de->Value ); - } - - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new StringDictionary. - StringDictionary^ myCol = gcnew StringDictionary; - myCol->Add( "red", "rojo" ); - myCol->Add( "green", "verde" ); - myCol->Add( "blue", "azul" ); - - // Displays the values in the StringDictionary. - Console::WriteLine( "Initial contents of the StringDictionary:" ); - PrintKeysAndValues( myCol ); - - // Searches for a key. - if ( myCol->ContainsKey( "red" ) ) - Console::WriteLine( "The collection contains the key \"red\"." ); - else - Console::WriteLine( "The collection does not contain the key \"red\"." ); - - Console::WriteLine(); - - // Searches for a value. - if ( myCol->ContainsValue( "amarillo" ) ) - Console::WriteLine( "The collection contains the value \"amarillo\"." ); - else - Console::WriteLine( "The collection does not contain the value \"amarillo\"." ); - - Console::WriteLine(); -} - -/* -This code produces the following output. - -Initial contents of the StringDictionary: - KEY VALUE - green verde - red rojo - blue azul - -The collection contains the key "red". - -The collection does not contain the value "amarillo". - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/stringdictionary_enumeration.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/stringdictionary_enumeration.cpp deleted file mode 100644 index a7c20a92885..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/stringdictionary_enumeration.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// The following code example enumerates the elements of a StringDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -void PrintKeysAndValues1( StringDictionary^ myCol ); -void PrintKeysAndValues2( StringDictionary^ myCol ); -void PrintKeysAndValues3( StringDictionary^ myCol ); - -int main() -{ - // Creates and initializes a new StringDictionary. - StringDictionary^ myCol = gcnew StringDictionary; - myCol->Add( "red", "rojo" ); - myCol->Add( "green", "verde" ); - myCol->Add( "blue", "azul" ); - - // Display the contents of the collection using for each. This is the preferred method. - Console::WriteLine( "Displays the elements using for each:" ); - PrintKeysAndValues1( myCol ); - - // Display the contents of the collection using the enumerator. - Console::WriteLine( "Displays the elements using the IEnumerator:" ); - PrintKeysAndValues2( myCol ); - - // Display the contents of the collection using the Keys, Values, Count, and Item properties. - Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" ); - PrintKeysAndValues3( myCol ); -} - -// Uses the for each statement which hides the complexity of the enumerator. -// NOTE: The for each statement is the preferred way of enumerating the contents of a collection. -void PrintKeysAndValues1( StringDictionary^ myCol ) { - Console::WriteLine( " KEY VALUE" ); - for each ( DictionaryEntry^ de in myCol ) - Console::WriteLine( " {0,-25} {1}", de->Key, de->Value ); - Console::WriteLine(); -} - -// Uses the enumerator. -void PrintKeysAndValues2( StringDictionary^ myCol ) -{ - IEnumerator^ myEnumerator = myCol->GetEnumerator(); - DictionaryEntry^ de; - Console::WriteLine( " KEY VALUE" ); - while ( myEnumerator->MoveNext() ) - { - de = (DictionaryEntry^)(myEnumerator->Current); - Console::WriteLine( " {0,-25} {1}", de->Key, de->Value ); - } - Console::WriteLine(); -} - -// Uses the Keys, Values, Count, and Item properties. -void PrintKeysAndValues3( StringDictionary^ myCol ) -{ - array^myKeys = gcnew array(myCol->Count); - myCol->Keys->CopyTo( myKeys, 0 ); - Console::WriteLine( " INDEX KEY VALUE" ); - for ( int i = 0; i < myCol->Count; i++ ) - Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] ); - Console::WriteLine(); -} - -/* -This code produces the following output. - -Displays the elements using for each: - KEY VALUE - red rojo - blue azul - green verde - -Displays the elements using the IEnumerator: - KEY VALUE - red rojo - blue azul - green verde - -Displays the elements using the Keys, Values, Count, and Item properties: - INDEX KEY VALUE - 0 red rojo - 1 blue azul - 2 green verde - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/values.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/values.cpp deleted file mode 100644 index b62ad64ac50..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/values.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// The following code example enumerates the elements of a StringDictionary. - -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class SamplesStringDictionary -{ -public: - static void Main() - { - // Creates and initializes a new StringDictionary. - StringDictionary^ myCol = gcnew StringDictionary(); - myCol->Add( "red", "rojo" ); - myCol->Add( "green", "verde" ); - myCol->Add( "blue", "azul" ); - - Console::WriteLine("VALUES"); - for each (String^ val in myCol->Values) - { - Console::WriteLine(val); - } - } -}; - -int main() -{ - SamplesStringDictionary::Main(); -} -// This code produces the following output. -// VALUES -// verde -// rojo -// azul -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source.cpp deleted file mode 100644 index a412d7c2739..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// -using namespace System; -using namespace System::Collections; - -public ref class Example -{ -public: - static void Main() - { - // Create an empty ArrayList, and add some elements. - ArrayList^ stringList = gcnew ArrayList(); - - stringList->Add("a"); - stringList->Add("abc"); - stringList->Add("abcdef"); - stringList->Add("abcdefg"); - - // The Item property is an indexer, so the property name is - // not required. - Console::WriteLine("Element {0} is \"{1}\"", 2, stringList[2]); - - // Assigning a value to the property changes the value of - // the indexed element. - stringList[2] = "abcd"; - Console::WriteLine("Element {0} is \"{1}\"", 2, stringList[2]); - - // Accessing an element outside the current element count - // causes an exception. - Console::WriteLine("Number of elements in the list: {0}", - stringList->Count); - try - { - Console::WriteLine("Element {0} is \"{1}\"", - stringList->Count, stringList[stringList->Count]); - } - catch (ArgumentOutOfRangeException^ aoore) - { - Console::WriteLine("stringList({0}) is out of range.", - stringList->Count); - } - - // You cannot use the Item property to add new elements. - try - { - stringList[stringList->Count] = "42"; - } - catch (ArgumentOutOfRangeException^ aoore) - { - Console::WriteLine("stringList({0}) is out of range.", - stringList->Count); - } - - Console::WriteLine(); - for (int i = 0; i < stringList->Count; i++) - { - Console::WriteLine("Element {0} is \"{1}\"", i, - stringList[i]); - } - - Console::WriteLine(); - for each (Object^ o in stringList) - { - Console::WriteLine(o); - } - } -}; - -int main() -{ - Example::Main(); -} -/* - This code example produces the following output: - -Element 2 is "abcdef" -Element 2 is "abcd" -Number of elements in the list: 4 -stringList(4) is out of range. -stringList(4) is out of range. - -Element 0 is "a" -Element 1 is "abc" -Element 2 is "abcd" -Element 3 is "abcdefg" - -a -abc -abcd -abcdefg - */ -// - - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source2.cpp deleted file mode 100644 index 5a66b7c3b74..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source2.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// -using namespace System; -using namespace System::Collections; - -public ref class ScrambleList : public ArrayList -{ -public: - static void Main() - { - // Create an empty ArrayList, and add some elements. - ScrambleList^ integerList = gcnew ScrambleList(); - - for (int i = 0; i < 10; i++) - { - integerList->Add(i); - } - - Console::WriteLine("Ordered:\n"); - for each (int value in integerList) - { - Console::Write("{0}, ", value); - } - Console::WriteLine("\n\nScrambled:\n"); - - // Scramble the order of the items in the list. - integerList->Scramble(); - - for each (int value in integerList) - { - Console::Write("{0}, ", value); - } - Console::WriteLine("\n"); - } - - void Scramble() - { - int limit = this->Count; - int temp; - int swapindex; - Random^ rnd = gcnew Random(); - for (int i = 0; i < limit; i++) - { - // The Item property of ArrayList is the default indexer. Thus, - // this->default[i] and this[i] are used interchangeably. - temp = (int)this->default[i]; - swapindex = rnd->Next(0, limit - 1); - this[i] = this->default[swapindex]; - this[swapindex] = temp; - } - } -}; - -int main() -{ - ScrambleList::Main(); -} -// The program produces output similar to the following: -// -// Ordered: -// -// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -// -// Scrambled: -// -// 5, 2, 8, 9, 6, 1, 7, 0, 4, 3, -// - - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_2/CPP/arraylist_sort2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_2/CPP/arraylist_sort2.cpp deleted file mode 100644 index c56559204dd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_2/CPP/arraylist_sort2.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// The following example shows how to sort the values in an using the default comparer and a custom comparer which reverses the sort order. -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndValues( IEnumerable^ myList ); -ref class myReverserClass: public IComparer -{ -private: - - // Calls CaseInsensitiveComparer.Compare with the parameters reversed. - virtual int Compare( Object^ x, Object^ y ) sealed = IComparer::Compare - { - return ((gcnew CaseInsensitiveComparer)->Compare( y, x )); - } - -}; - -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList initially contains the following values:" ); - PrintIndexAndValues( myAL ); - - // Sorts the values of the ArrayList using the default comparer. - myAL->Sort(); - Console::WriteLine( "After sorting with the default comparer:" ); - PrintIndexAndValues( myAL ); - - // Sorts the values of the ArrayList using the reverse case-insensitive comparer. - IComparer^ myComparer = gcnew myReverserClass; - myAL->Sort( myComparer ); - Console::WriteLine( "After sorting with the reverse case-insensitive comparer:" ); - PrintIndexAndValues( myAL ); -} - -void PrintIndexAndValues( IEnumerable^ myList ) -{ - int i = 0; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( "\t[{0}]:\t{1}", i++, obj ); - } - - Console::WriteLine(); -} - -/* -This code produces the following output. -The ArrayList initially contains the following values: - [0]: The - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - -After sorting with the default comparer: - [0]: brown - [1]: dog - [2]: fox - [3]: jumps - [4]: lazy - [5]: over - [6]: quick - [7]: the - [8]: The - -After sorting with the reverse case-insensitive comparer: - [0]: the - [1]: The - [2]: quick - [3]: over - [4]: lazy - [5]: jumps - [6]: fox - [7]: dog - [8]: brown -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_3/CPP/arraylist_sort3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_3/CPP/arraylist_sort3.cpp deleted file mode 100644 index 41bde08602c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_3/CPP/arraylist_sort3.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// The following example shows how to sort the values in a section of an using the default comparer and a custom comparer which reverses the sort order. -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndValues( IEnumerable^ myList ); -ref class myReverserClass: public IComparer -{ -private: - - // Calls CaseInsensitiveComparer.Compare with the parameters reversed. - virtual int Compare( Object^ x, Object^ y ) = IComparer::Compare - { - return ((gcnew CaseInsensitiveComparer)->Compare( y, x )); - } - -}; - -int main() -{ - - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "QUICK" ); - myAL->Add( "BROWN" ); - myAL->Add( "FOX" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList initially contains the following values:" ); - PrintIndexAndValues( myAL ); - - // Sorts the values of the ArrayList using the default comparer. - myAL->Sort( 1, 3, nullptr ); - Console::WriteLine( "After sorting from index 1 to index 3 with the default comparer:" ); - PrintIndexAndValues( myAL ); - - // Sorts the values of the ArrayList using the reverse case-insensitive comparer. - IComparer^ myComparer = gcnew myReverserClass; - myAL->Sort( 1, 3, myComparer ); - Console::WriteLine( "After sorting from index 1 to index 3 with the reverse case-insensitive comparer:" ); - PrintIndexAndValues( myAL ); -} - -void PrintIndexAndValues( IEnumerable^ myList ) -{ - int i = 0; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( "\t[{0}]:\t{1}", i++, obj ); - } - - Console::WriteLine(); -} - -/* -This code produces the following output. -The ArrayList initially contains the following values: - [0]: The - [1]: QUICK - [2]: BROWN - [3]: FOX - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - -After sorting from index 1 to index 3 with the default comparer: - [0]: The - [1]: BROWN - [2]: FOX - [3]: QUICK - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - -After sorting from index 1 to index 3 with the reverse case-insensitive comparer: - [0]: The - [1]: QUICK - [2]: FOX - [3]: BROWN - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/CPP/arraylist_toarray.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/CPP/arraylist_toarray.cpp deleted file mode 100644 index 4ffd521bcd4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/CPP/arraylist_toarray.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -// The following example shows how to copy the elements of an ArrayList to a string array. -// -using namespace System; -using namespace System::Collections; -void PrintIndexAndValues( ArrayList^ myList ); -void PrintIndexAndValues( array^myArr ); -int main() -{ - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "The" ); - myAL->Add( "quick" ); - myAL->Add( "brown" ); - myAL->Add( "fox" ); - myAL->Add( "jumps" ); - myAL->Add( "over" ); - myAL->Add( "the" ); - myAL->Add( "lazy" ); - myAL->Add( "dog" ); - - // Displays the values of the ArrayList. - Console::WriteLine( "The ArrayList contains the following values:" ); - PrintIndexAndValues( myAL ); - - // Copies the elements of the ArrayList to a string array. - array^myArr = reinterpret_cast^>(myAL->ToArray( String::typeid )); - - // Displays the contents of the string array. - Console::WriteLine( "The string array contains the following values:" ); - PrintIndexAndValues( myArr ); -} - -void PrintIndexAndValues( ArrayList^ myList ) -{ - int i = 0; - IEnumerator^ myEnum = myList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::WriteLine( "\t[{0}]:\t{1}", i++, o ); - } - - Console::WriteLine(); -} - -void PrintIndexAndValues( array^myArr ) -{ - for ( int i = 0; i < myArr->Length; i++ ) - Console::WriteLine( "\t[{0}]:\t{1}", i, myArr[ i ] ); - Console::WriteLine(); -} - -/* -This code produces the following output. - -The ArrayList contains the following values: - [0]: The - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - -The string array contains the following values: - [0]: The - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp deleted file mode 100644 index 352f55da5ea..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// The following code example creates a case-sensitive hashtable and a case-insensitive hashtable -// and demonstrates the difference in their behavior, even if both contain the same elements. -// -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; -int main() -{ - - // Create a Hashtable using the default hash code provider and the default comparer. - Hashtable^ myHT1 = gcnew Hashtable; - myHT1->Add( "FIRST", "Hello" ); - myHT1->Add( "SECOND", "World" ); - myHT1->Add( "THIRD", "!" ); - - // Create a Hashtable using a case-insensitive code provider and a case-insensitive comparer, - // based on the culture of the current thread. - Hashtable^ myHT2 = gcnew Hashtable( gcnew CaseInsensitiveHashCodeProvider,gcnew CaseInsensitiveComparer ); - myHT2->Add( "FIRST", "Hello" ); - myHT2->Add( "SECOND", "World" ); - myHT2->Add( "THIRD", "!" ); - - // Create a Hashtable using a case-insensitive code provider and a case-insensitive comparer, - // based on the InvariantCulture. - Hashtable^ myHT3 = gcnew Hashtable( CaseInsensitiveHashCodeProvider::DefaultInvariant,CaseInsensitiveComparer::DefaultInvariant ); - myHT3->Add( "FIRST", "Hello" ); - myHT3->Add( "SECOND", "World" ); - myHT3->Add( "THIRD", "!" ); - - // Create a Hashtable using a case-insensitive code provider and a case-insensitive comparer, - // based on the Turkish culture (tr-TR), where "I" is not the uppercase version of "i". - CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" ); - Hashtable^ myHT4 = gcnew Hashtable( gcnew CaseInsensitiveHashCodeProvider( myCul ),gcnew CaseInsensitiveComparer( myCul ) ); - myHT4->Add( "FIRST", "Hello" ); - myHT4->Add( "SECOND", "World" ); - myHT4->Add( "THIRD", "!" ); - - // Search for a key in each hashtable. - Console::WriteLine( "first is in myHT1: {0}", myHT1->ContainsKey( "first" ) ); - Console::WriteLine( "first is in myHT2: {0}", myHT2->ContainsKey( "first" ) ); - Console::WriteLine( "first is in myHT3: {0}", myHT3->ContainsKey( "first" ) ); - Console::WriteLine( "first is in myHT4: {0}", myHT4->ContainsKey( "first" ) ); -} - -/* -This code produces the following output. Results vary depending on the system's culture settings. - -first is in myHT1: False -first is in myHT2: True -first is in myHT3: True -first is in myHT4: False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp deleted file mode 100644 index c12910d57c1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp +++ /dev/null @@ -1,183 +0,0 @@ - - -// The following code example implements the CollectionBase class and uses that implementation to create a collection of Int16 objects. -// -#using - -using namespace System; -using namespace System::Collections; - -public ref class Int16Collection: public CollectionBase -{ -public: - - property Int16 Item [int] - { - Int16 get( int index ) - { - return ( (Int16)(List[ index ])); - } - - void set( int index, Int16 value ) - { - List[ index ] = value; - } - } - int Add( Int16 value ) - { - return (List->Add( value )); - } - - int IndexOf( Int16 value ) - { - return (List->IndexOf( value )); - } - - void Insert( int index, Int16 value ) - { - List->Insert( index, value ); - } - - void Remove( Int16 value ) - { - List->Remove( value ); - } - - bool Contains( Int16 value ) - { - // If value is not of type Int16, this will return false. - return (List->Contains( value )); - } - -protected: - virtual void OnInsert( int /*index*/, Object^ /*value*/ ) override - { - // Insert additional code to be run only when inserting values. - } - - virtual void OnRemove( int /*index*/, Object^ /*value*/ ) override - { - // Insert additional code to be run only when removing values. - } - - virtual void OnSet( int /*index*/, Object^ /*oldValue*/, Object^ /*newValue*/ ) override - { - // Insert additional code to be run only when setting values. - } - - virtual void OnValidate( Object^ value ) override - { - if ( value->GetType() != Type::GetType( "System.Int16" ) ) - throw gcnew ArgumentException( "value must be of type Int16.","value" ); - } - -}; - -void PrintIndexAndValues( Int16Collection^ myCol ); -void PrintValues2( Int16Collection^ myCol ); -int main() -{ - // Create and initialize a new CollectionBase. - Int16Collection^ myI16 = gcnew Int16Collection; - - // Add elements to the collection. - myI16->Add( (Int16)1 ); - myI16->Add( (Int16)2 ); - myI16->Add( (Int16)3 ); - myI16->Add( (Int16)5 ); - myI16->Add( (Int16)7 ); - - // Display the contents of the collection using the enumerator. - Console::WriteLine( "Contents of the collection (using enumerator):" ); - PrintValues2( myI16 ); - - // Display the contents of the collection using the Count property and the Item property. - Console::WriteLine( "Initial contents of the collection (using Count and Item):" ); - PrintIndexAndValues( myI16 ); - - // Search the collection with Contains and IndexOf. - Console::WriteLine( "Contains 3: {0}", myI16->Contains( 3 ) ); - Console::WriteLine( "2 is at index {0}.", myI16->IndexOf( 2 ) ); - Console::WriteLine(); - - // Insert an element into the collection at index 3. - myI16->Insert( 3, (Int16)13 ); - Console::WriteLine( "Contents of the collection after inserting at index 3:" ); - PrintIndexAndValues( myI16 ); - - // Get and set an element using the index. - myI16->Item[ 4 ] = 123; - Console::WriteLine( "Contents of the collection after setting the element at index 4 to 123:" ); - PrintIndexAndValues( myI16 ); - - // Remove an element from the collection. - myI16->Remove( (Int16)2 ); - - // Display the contents of the collection using the Count property and the Item property. - Console::WriteLine( "Contents of the collection after removing the element 2:" ); - PrintIndexAndValues( myI16 ); -} - -// Uses the Count property and the Item property. -void PrintIndexAndValues( Int16Collection^ myCol ) -{ - for ( int i = 0; i < myCol->Count; i++ ) - Console::WriteLine( " [{0}]: {1}", i, myCol->Item[ i ] ); - Console::WriteLine(); -} - -// Uses the enumerator. -void PrintValues2( Int16Collection^ myCol ) -{ - System::Collections::IEnumerator^ myEnumerator = myCol->GetEnumerator(); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( " {0}", myEnumerator->Current ); - - Console::WriteLine(); -} - -/* -This code produces the following output. - -Contents of the collection (using enumerator): - 1 - 2 - 3 - 5 - 7 - -Initial contents of the collection (using Count and Item): - [0]: 1 - [1]: 2 - [2]: 3 - [3]: 5 - [4]: 7 - -Contains 3: True -2 is at index 1. - -Contents of the collection after inserting at index 3: - [0]: 1 - [1]: 2 - [2]: 3 - [3]: 13 - [4]: 5 - [5]: 7 - -Contents of the collection after setting the element at index 4 to 123: - [0]: 1 - [1]: 2 - [2]: 3 - [3]: 13 - [4]: 123 - [5]: 7 - -Contents of the collection after removing the element 2: - [0]: 1 - [1]: 3 - [2]: 13 - [3]: 123 - [4]: 7 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/remarks.cpp deleted file mode 100644 index 5c672dbc203..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/remarks.cpp +++ /dev/null @@ -1,118 +0,0 @@ - - -// The following code example implements the CollectionBase class and uses that implementation to create a collection of Int16 objects. -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class Int16Collection: public CollectionBase -{ -public: - - property Int16 Item [int] - { - Int16 get( int index ) - { - return ( (Int16)(List[ index ])); - } - - void set( int index, Int16 value ) - { - List[ index ] = value; - } - } - int Add( Int16 value ) - { - return (List->Add( value )); - } - - int IndexOf( Int16 value ) - { - return (List->IndexOf( value )); - } - - void Insert( int index, Int16 value ) - { - List->Insert( index, value ); - } - - void Remove( Int16 value ) - { - List->Remove( value ); - } - - bool Contains( Int16 value ) - { - // If value is not of type Int16, this will return false. - return (List->Contains( value )); - } - -protected: - virtual void OnInsert( int /*index*/, Object^ /*value*/ ) override - { - // Insert additional code to be run only when inserting values. - } - - virtual void OnRemove( int /*index*/, Object^ /*value*/ ) override - { - // Insert additional code to be run only when removing values. - } - - virtual void OnSet( int /*index*/, Object^ /*oldValue*/, Object^ /*newValue*/ ) override - { - // Insert additional code to be run only when setting values. - } - - virtual void OnValidate( Object^ value ) override - { - if ( value->GetType() != Type::GetType( "System.Int16" ) ) - throw gcnew ArgumentException( "value must be of type Int16.","value" ); - } - -}; - -public ref class SamplesCollectionBase -{ -public: - static void Main() - { - // Create and initialize a new CollectionBase. - Int16Collection^ myCollectionBase = gcnew Int16Collection(); - - // Add elements to the collection. - myCollectionBase->Add( (Int16) 1 ); - myCollectionBase->Add( (Int16) 2 ); - myCollectionBase->Add( (Int16) 3 ); - myCollectionBase->Add( (Int16) 5 ); - myCollectionBase->Add( (Int16) 7 ); - - // - // Get the ICollection interface from the CollectionBase - // derived class. - ICollection^ myCollection = myCollectionBase; - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesCollectionBase::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Comparer/CPP/comparercultures.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Comparer/CPP/comparercultures.cpp deleted file mode 100644 index 8103ba2ad12..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Comparer/CPP/comparercultures.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// The following code example shows how Compare returns different values depending on the culture associated with the Comparer. -// -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; -int main() -{ - - // Creates the strings to compare. - String^ str1 = "llegar"; - String^ str2 = "lugar"; - Console::WriteLine( "Comparing \"{0}\" and \"{1}\" ...", str1, str2 ); - - // Uses the DefaultInvariant Comparer. - Console::WriteLine( " Invariant Comparer: {0}", Comparer::DefaultInvariant->Compare( str1, str2 ) ); - - // Uses the Comparer based on the culture "es-ES" (Spanish - Spain, international sort). - Comparer^ myCompIntl = gcnew Comparer( gcnew CultureInfo( "es-ES",false ) ); - Console::WriteLine( " International Sort: {0}", myCompIntl->Compare( str1, str2 ) ); - - // Uses the Comparer based on the culture identifier 0x040A (Spanish - Spain, traditional sort). - Comparer^ myCompTrad = gcnew Comparer( gcnew CultureInfo( 0x040A,false ) ); - Console::WriteLine( " Traditional Sort : {0}", myCompTrad->Compare( str1, str2 ) ); -} - -/* -This code produces the following output. - -Comparing "llegar" and "lugar" ... - Invariant Comparer: -1 - International Sort: -1 - Traditional Sort : 1 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp deleted file mode 100644 index f22de93e8e7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp +++ /dev/null @@ -1,258 +0,0 @@ - -// The following code example implements the DictionaryBase class and uses that implementation to create a dictionary of String keys and values that have a Length of 5 or less. -// -using namespace System; -using namespace System::Collections; - -public ref class ShortStringDictionary: public DictionaryBase -{ -public: - - property String^ Item [String^] - { - String^ get( String^ key ) - { - return (dynamic_cast(Dictionary[ key ])); - } - - void set( String^ value, String^ key ) - { - Dictionary[ key ] = value; - } - } - - property ICollection^ Keys - { - ICollection^ get() - { - return (Dictionary->Keys); - } - } - - property ICollection^ Values - { - ICollection^ get() - { - return (Dictionary->Values); - } - } - void Add( String^ key, String^ value ) - { - Dictionary->Add( key, value ); - } - - bool Contains( String^ key ) - { - return (Dictionary->Contains( key )); - } - - void Remove( String^ key ) - { - Dictionary->Remove( key ); - } - - -protected: - virtual void OnInsert( Object^ key, Object^ value ) override - { - if ( key->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "key must be of type String.","key" ); - else - { - String^ strKey = dynamic_cast(key); - if ( strKey->Length > 5 ) - throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" ); - } - - if ( value->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "value must be of type String.","value" ); - else - { - String^ strValue = dynamic_cast(value); - if ( strValue->Length > 5 ) - throw gcnew ArgumentException( "value must be no more than 5 characters in length.","value" ); - } - } - - virtual void OnRemove( Object^ key, Object^ /*value*/ ) override - { - if ( key->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "key must be of type String.","key" ); - else - { - String^ strKey = dynamic_cast(key); - if ( strKey->Length > 5 ) - throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" ); - } - } - - virtual void OnSet( Object^ key, Object^ /*oldValue*/, Object^ newValue ) override - { - if ( key->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "key must be of type String.","key" ); - else - { - String^ strKey = dynamic_cast(key); - if ( strKey->Length > 5 ) - throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" ); - } - - if ( newValue->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "newValue must be of type String.","newValue" ); - else - { - String^ strValue = dynamic_cast(newValue); - if ( strValue->Length > 5 ) - throw gcnew ArgumentException( "newValue must be no more than 5 characters in length.","newValue" ); - } - } - - virtual void OnValidate( Object^ key, Object^ value ) override - { - if ( key->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "key must be of type String.","key" ); - else - { - String^ strKey = dynamic_cast(key); - if ( strKey->Length > 5 ) - throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" ); - } - - if ( value->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "value must be of type String.","value" ); - else - { - String^ strValue = dynamic_cast(value); - if ( strValue->Length > 5 ) - throw gcnew ArgumentException( "value must be no more than 5 characters in length.","value" ); - } - } - -}; - -void PrintKeysAndValues2( ShortStringDictionary^ myCol ); -void PrintKeysAndValues3( ShortStringDictionary^ myCol ); -int main() -{ - // Creates and initializes a new DictionaryBase. - ShortStringDictionary^ mySSC = gcnew ShortStringDictionary; - - // Adds elements to the collection. - mySSC->Add( "One", "a" ); - mySSC->Add( "Two", "ab" ); - mySSC->Add( "Three", "abc" ); - mySSC->Add( "Four", "abcd" ); - mySSC->Add( "Five", "abcde" ); - - // Display the contents of the collection using the enumerator. - Console::WriteLine( "Contents of the collection (using enumerator):" ); - PrintKeysAndValues2( mySSC ); - - // Display the contents of the collection using the Keys property and the Item property. - Console::WriteLine( "Initial contents of the collection (using Keys and Item):" ); - PrintKeysAndValues3( mySSC ); - - // Tries to add a value that is too long. - try - { - mySSC->Add( "Ten", "abcdefghij" ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - // Tries to add a key that is too long. - try - { - mySSC->Add( "Eleven", "ijk" ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - Console::WriteLine(); - - // Searches the collection with Contains. - Console::WriteLine( "Contains \"Three\": {0}", mySSC->Contains( "Three" ) ); - Console::WriteLine( "Contains \"Twelve\": {0}", mySSC->Contains( "Twelve" ) ); - Console::WriteLine(); - - // Removes an element from the collection. - mySSC->Remove( "Two" ); - - // Displays the contents of the collection. - Console::WriteLine( "After removing \"Two\":" ); - PrintKeysAndValues2( mySSC ); -} - -// Uses the enumerator. -void PrintKeysAndValues2( ShortStringDictionary^ myCol ) -{ - DictionaryEntry myDE; - System::Collections::IEnumerator^ myEnumerator = myCol->GetEnumerator(); - while ( myEnumerator->MoveNext() ) - if ( myEnumerator->Current != nullptr ) - { - myDE = *dynamic_cast(myEnumerator->Current); - Console::WriteLine( " {0,-5} : {1}", myDE.Key, myDE.Value ); - } - - Console::WriteLine(); -} - - -// Uses the Keys property and the Item property. -void PrintKeysAndValues3( ShortStringDictionary^ myCol ) -{ - ICollection^ myKeys = myCol->Keys; - IEnumerator^ myEnum1 = myKeys->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - String^ k = safe_cast(myEnum1->Current); - Console::WriteLine( " {0,-5} : {1}", k, myCol->Item[ k ] ); - } - - Console::WriteLine(); -} - -/* -This code produces the following output. - -Contents of the collection (using enumerator): - Three : abc - Five : abcde - Two : ab - One : a - Four : abcd - -Initial contents of the collection (using Keys and Item): - Three : abc - Five : abcde - Two : ab - One : a - Four : abcd - -System.ArgumentException: value must be no more than 5 characters in length. -Parameter name: value - at ShortStringDictionary.OnValidate(Object key, Object value) - at System.Collections.DictionaryBase.System.Collections.IDictionary.Add(Object key, Object value) - at SamplesDictionaryBase.Main() -System.ArgumentException: key must be no more than 5 characters in length. -Parameter name: key - at ShortStringDictionary.OnValidate(Object key, Object value) - at System.Collections.DictionaryBase.System.Collections.IDictionary.Add(Object key, Object value) - at SamplesDictionaryBase.Main() - -Contains "Three": True -Contains "Twelve": False - -After removing "Two": - Three : abc - Five : abcde - One : a - Four : abcd - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/source2.cpp deleted file mode 100644 index 6d4bc281691..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/source2.cpp +++ /dev/null @@ -1,171 +0,0 @@ - -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class ShortStringDictionary: public DictionaryBase -{ -public: - - property String^ Item [String^] - { - String^ get( String^ key ) - { - return (dynamic_cast(Dictionary[ key ])); - } - - void set( String^ value, String^ key ) - { - Dictionary[ key ] = value; - } - } - - property ICollection^ Keys - { - ICollection^ get() - { - return (Dictionary->Keys); - } - } - - property ICollection^ Values - { - ICollection^ get() - { - return (Dictionary->Values); - } - } - void Add( String^ key, String^ value ) - { - Dictionary->Add( key, value ); - } - - bool Contains( String^ key ) - { - return (Dictionary->Contains( key )); - } - - void Remove( String^ key ) - { - Dictionary->Remove( key ); - } - - -protected: - virtual void OnInsert( Object^ key, Object^ value ) override - { - if ( key->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "key must be of type String.","key" ); - else - { - String^ strKey = dynamic_cast(key); - if ( strKey->Length > 5 ) - throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" ); - } - - if ( value->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "value must be of type String.","value" ); - else - { - String^ strValue = dynamic_cast(value); - if ( strValue->Length > 5 ) - throw gcnew ArgumentException( "value must be no more than 5 characters in length.","value" ); - } - } - - virtual void OnRemove( Object^ key, Object^ /*value*/ ) override - { - if ( key->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "key must be of type String.","key" ); - else - { - String^ strKey = dynamic_cast(key); - if ( strKey->Length > 5 ) - throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" ); - } - } - - virtual void OnSet( Object^ key, Object^ /*oldValue*/, Object^ newValue ) override - { - if ( key->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "key must be of type String.","key" ); - else - { - String^ strKey = dynamic_cast(key); - if ( strKey->Length > 5 ) - throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" ); - } - - if ( newValue->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "newValue must be of type String.","newValue" ); - else - { - String^ strValue = dynamic_cast(newValue); - if ( strValue->Length > 5 ) - throw gcnew ArgumentException( "newValue must be no more than 5 characters in length.","newValue" ); - } - } - - virtual void OnValidate( Object^ key, Object^ value ) override - { - if ( key->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "key must be of type String.","key" ); - else - { - String^ strKey = dynamic_cast(key); - if ( strKey->Length > 5 ) - throw gcnew ArgumentException( "key must be no more than 5 characters in length.","key" ); - } - - if ( value->GetType() != Type::GetType( "System.String" ) ) - throw gcnew ArgumentException( "value must be of type String.","value" ); - else - { - String^ strValue = dynamic_cast(value); - if ( strValue->Length > 5 ) - throw gcnew ArgumentException( "value must be no more than 5 characters in length.","value" ); - } - } - -}; - -public ref class SamplesDictionaryBase -{ -public: - static void Main() - { - DictionaryBase^ myDictionary = gcnew ShortStringDictionary(); - - // - for each (DictionaryEntry de in myDictionary) - { - //... - } - // - - // - ICollection^ myCollection = gcnew ShortStringDictionary(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesDictionaryBase::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/cpp/dictionaryentrysample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/cpp/dictionaryentrysample.cpp deleted file mode 100644 index e7587a1e80f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/cpp/dictionaryentrysample.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// A simple example for the DictionaryEntry structure. -using namespace System; -using namespace System::Collections; - -public ref class Example -{ -public: - static void Main() - { - // Create a new hash table. - // - Hashtable^ openWith = gcnew Hashtable(); - - // Add some elements to the hash table. There are no - // duplicate keys, but some of the values are duplicates. - openWith->Add("txt", "notepad.exe"); - openWith->Add("bmp", "paint.exe"); - openWith->Add("dib", "paint.exe"); - openWith->Add("rtf", "wordpad.exe"); - - // When you use foreach to enumerate hash table elements, - // the elements are retrieved as DictionaryEntry objects. - Console::WriteLine(); - // - for each (DictionaryEntry de in openWith) - { - Console::WriteLine("Key = {0}, Value = {1}", de.Key, de.Value); - } - // - } -}; - -int main() -{ - Example::Main(); -} - -/* This code example produces output similar to the following: - -Key = rtf, Value = wordpad.exe -Key = txt, Value = notepad.exe -Key = dib, Value = paint.exe -Key = bmp, Value = paint.exe - */ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/program.cpp deleted file mode 100644 index 4378b0f208a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/program.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Collections::Generic; - -ref class Program -{ -public: - // - static void Main() - { - HashSet^ lowNumbers = gcnew HashSet(); - HashSet^ highNumbers = gcnew HashSet(); - - for (int i = 0; i < 6; i++) - { - lowNumbers->Add(i); - } - - for (int i = 3; i < 10; i++) - { - highNumbers->Add(i); - } - - Console::Write("lowNumbers contains {0} elements: ", lowNumbers->Count); - DisplaySet(lowNumbers); - - Console::Write("highNumbers contains {0} elements: ", highNumbers->Count); - DisplaySet(highNumbers); - - Console::WriteLine("highNumbers ExceptWith lowNumbers..."); - highNumbers->ExceptWith(lowNumbers); - - Console::Write("highNumbers contains {0} elements: ", highNumbers->Count); - DisplaySet(highNumbers); - } - /* This example provides output similar to the following: - * lowNumbers contains 6 elements: { 0 1 2 3 4 5 } - * highNumbers contains 7 elements: { 3 4 5 6 7 8 9 } - * highNumbers ExceptWith lowNumbers... - * highNumbers contains 4 elements: { 6 7 8 9 } - */ - // - -private: - static void DisplaySet(HashSet^ set) - { - Console::Write("{"); - for each (int i in set) - { - Console::Write(" {0}", i); - } - Console::WriteLine(" }"); - } -}; - -int main() -{ - Program::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/source2.cpp deleted file mode 100644 index 2ff29223cc6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/source2.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Collections::Generic; - -ref class Program -{ -public: - static void Main() - { - HashSet ^allVehicles = gcnew HashSet(StringComparer::OrdinalIgnoreCase); - List^ someVehicles = gcnew List(); - - someVehicles->Add("Planes"); - someVehicles->Add("Trains"); - someVehicles->Add("Automobiles"); - - // Add in the vehicles contained in the someVehicles list. - allVehicles->UnionWith(someVehicles); - - Console::WriteLine("The current HashSet contains:\n"); - for each (String^ vehicle in allVehicles) - { - Console::WriteLine(vehicle); - } - - allVehicles->Add("Ships"); - allVehicles->Add("Motorcycles"); - allVehicles->Add("Rockets"); - allVehicles->Add("Helicopters"); - allVehicles->Add("Submarines"); - - Console::WriteLine("\nThe updated HashSet contains:\n"); - for each (String^ vehicle in allVehicles) - { - Console::WriteLine(vehicle); - } - - // Verify that the 'All Vehicles' set contains at least the vehicles in - // the 'Some Vehicles' list. - if (allVehicles->IsSupersetOf(someVehicles)) - { - Console::Write("\nThe 'All' vehicles set contains everything in "); - Console::WriteLine("'Some' vechicles list."); - } - - // Check for Rockets. Here the OrdinalIgnoreCase comparer will compare - // true for the mixed-case vehicle type. - if (allVehicles->Contains("roCKeTs")) - { - Console::WriteLine("\nThe 'All' vehicles set contains 'roCKeTs'"); - } - - allVehicles->ExceptWith(someVehicles); - Console::WriteLine("\nThe excepted HashSet contains:\n"); - for each (String^ vehicle in allVehicles) - { - Console::WriteLine(vehicle); - } - - // Remove all the vehicles that are not 'super cool'. - allVehicles->RemoveWhere(gcnew Predicate(&isNotSuperCool)); - - Console::WriteLine("\nThe super cool vehicles are:\n"); - for each (String^ vehicle in allVehicles) - { - Console::WriteLine(vehicle); - } - } - -private: - // Predicate to determine vehicle 'coolness'. - static bool isNotSuperCool(String^ vehicle) - { - bool superCool = (vehicle == "Helicopters") || (vehicle == "Motorcycles"); - - return !superCool; - } -}; - -int main() -{ - Program::Main(); -} - -// The program writes the following output to the console:: -// -// The current HashSet contains: -// -// Planes -// Trains -// Automobiles -// -// The updated HashSet contains: -// -// Planes -// Trains -// Automobiles -// Ships -// Motorcycles -// Rockets -// Helicopters -// Submarines -// -// The 'All' vehicles set contains everything in 'Some' vechicles list. -// -// The 'All' vehicles set contains 'roCKeTs' -// -// The excepted HashSet contains: -// -// Ships -// Motorcycles -// Rockets -// Helicopters -// Submarines -// -// The super cool vehicles are: -// -// Motorcycles -// Helicopters -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedList.ctor/CPP/llctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedList.ctor/CPP/llctor.cpp deleted file mode 100644 index 3533f81fe87..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedList.ctor/CPP/llctor.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// The following code example creates and initializes a LinkedList of type String and then displays its contents. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Generic; - -void main() -{ - // Create and initialize a new LinkedList. - LinkedList< String^ > ^ ll = gcnew LinkedList< String^ >; - ll->AddLast(L"red"); - ll->AddLast(L"orange"); - ll->AddLast(L"yellow"); - ll->AddLast(L"orange"); - - // Display the contents of the LinkedList. - if (ll->Count > 0) - { - Console::WriteLine(L"The first item in the list is {0}.", ll->First->Value); - Console::WriteLine(L"The last item in the list is {0}.", ll->Last->Value); - Console::WriteLine(L"The LinkedList contains:"); - - for each (String^ s in ll) - { - Console::WriteLine(L" {0}", s); - } - } - else - { - Console::WriteLine(L"The LinkedList is empty."); - } -} - -/* This code produces the following output. - -The first item in the list is red. -The last item in the list is orange. -The LinkedList contains: - red - orange - yellow - orange -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp deleted file mode 100644 index e6f279e12f3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// The following code example creates a LinkedList node, adds it to a LinkedList, and tracks the values of its properties as the LinkedList changes. - - -// -#using - -using namespace System; -using namespace System::Collections::Generic; - -public ref class GenericCollection { - -public: - static void Main() { - - // Create a new LinkedListNode of type String and displays its properties. - LinkedListNode^ lln = gcnew LinkedListNode( "orange" ); - Console::WriteLine( "After creating the node ...." ); - DisplayProperties( lln ); - - // Create a new LinkedList. - LinkedList^ ll = gcnew LinkedList(); - - // Add the "orange" node and display its properties. - ll->AddLast( lln ); - Console::WriteLine( "After adding the node to the empty LinkedList ...." ); - DisplayProperties( lln ); - - // Add nodes before and after the "orange" node and display the "orange" node's properties. - ll->AddFirst( "red" ); - ll->AddLast( "yellow" ); - Console::WriteLine( "After adding red and yellow ...." ); - DisplayProperties( lln ); - - } - - static void DisplayProperties( LinkedListNode^ lln ) { - if ( lln->List == nullptr ) - Console::WriteLine( " Node is not linked." ); - else - Console::WriteLine( " Node belongs to a linked list with {0} elements.", lln->List->Count ); - - if ( lln->Previous == nullptr ) - Console::WriteLine( " Previous node is null." ); - else - Console::WriteLine( " Value of previous node: {0}", lln->Previous->Value ); - - Console::WriteLine( " Value of current node: {0}", lln->Value ); - - if ( lln->Next == nullptr ) - Console::WriteLine( " Next node is null." ); - else - Console::WriteLine( " Value of next node: {0}", lln->Next->Value ); - - Console::WriteLine(); - } - -}; - -int main() -{ - GenericCollection::Main(); -} - -/* - -This code produces the following output. - -After creating the node .... - Node is not linked. - Previous node is null. - Value of current node: orange - Next node is null. - -After adding the node to the empty LinkedList .... - Node belongs to a linked list with 1 elements. - Previous node is null. - Value of current node: orange - Next node is null. - -After adding red and yellow .... - Node belongs to a linked list with 3 elements. - Value of previous node: red - Value of current node: orange - Value of next node: yellow - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/hashtable_example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/hashtable_example.cpp deleted file mode 100644 index 987e041929f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/hashtable_example.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// -using namespace System; -using namespace System::Collections; - -public ref class Example -{ -public: - static void Main() - { - // Create a new hash table. - // - Hashtable^ openWith = gcnew Hashtable(); - - // Add some elements to the hash table. There are no - // duplicate keys, but some of the values are duplicates. - openWith->Add("txt", "notepad.exe"); - openWith->Add("bmp", "paint.exe"); - openWith->Add("dib", "paint.exe"); - openWith->Add("rtf", "wordpad.exe"); - - // The Add method throws an exception if the new key is - // already in the hash table. - try - { - openWith->Add("txt", "winword.exe"); - } - catch(...) - { - Console::WriteLine("An element with Key = \"txt\" already exists."); - } - - // The Item property is the default property, so you - // can omit its name when accessing elements. - Console::WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]); - - // The default Item property can be used to change the value - // associated with a key. - openWith["rtf"] = "winword.exe"; - Console::WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]); - - // If a key does not exist, setting the default Item property - // for that key adds a new key/value pair. - openWith["doc"] = "winword.exe"; - - // ContainsKey can be used to test keys before inserting - // them. - if (!openWith->ContainsKey("ht")) - { - openWith->Add("ht", "hypertrm.exe"); - Console::WriteLine("Value added for key = \"ht\": {0}", openWith["ht"]); - } - - // When you use foreach to enumerate hash table elements, - // the elements are retrieved as KeyValuePair objects. - Console::WriteLine(); - for each( DictionaryEntry de in openWith ) - { - Console::WriteLine("Key = {0}, Value = {1}", de.Key, de.Value); - } - - // To get the values alone, use the Values property. - ICollection^ valueColl = openWith->Values; - - // The elements of the ValueCollection are strongly typed - // with the type that was specified for hash table values. - Console::WriteLine(); - for each( String^ s in valueColl ) - { - Console::WriteLine("Value = {0}", s); - } - - // To get the keys alone, use the Keys property. - ICollection^ keyColl = openWith->Keys; - - // The elements of the KeyCollection are strongly typed - // with the type that was specified for hash table keys. - Console::WriteLine(); - for each( String^ s in keyColl ) - { - Console::WriteLine("Key = {0}", s); - } - - // Use the Remove method to remove a key/value pair. - Console::WriteLine("\nRemove(\"doc\")"); - openWith->Remove("doc"); - - if (!openWith->ContainsKey("doc")) - { - Console::WriteLine("Key \"doc\" is not found."); - } - } -}; - -int main() -{ - Example::Main(); -} - -/* This code example produces the following output: - -An element with Key = "txt" already exists. -For key = "rtf", value = wordpad.exe. -For key = "rtf", value = winword.exe. -Value added for key = "ht": hypertrm.exe - -Key = dib, Value = paint.exe -Key = txt, Value = notepad.exe -Key = ht, Value = hypertrm.exe -Key = bmp, Value = paint.exe -Key = rtf, Value = winword.exe -Key = doc, Value = winword.exe - -Value = paint.exe -Value = notepad.exe -Value = hypertrm.exe -Value = paint.exe -Value = winword.exe -Value = winword.exe - -Key = dib -Key = txt -Key = ht -Key = bmp -Key = rtf -Key = doc - -Remove("doc") -Key "doc" is not found. - */ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/remarks.cpp deleted file mode 100644 index 5b410769391..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/remarks.cpp +++ /dev/null @@ -1,36 +0,0 @@ -using namespace System; -using namespace System::Collections; - -public ref class Remarks -{ -public: - static void Main() - { - // Create a new hash table. - // - Hashtable^ myHashtable = gcnew Hashtable(); - - // Add some elements to the hash table. There are no - // duplicate keys, but some of the values are duplicates. - myHashtable->Add("txt", "notepad.exe"); - myHashtable->Add("bmp", "paint.exe"); - myHashtable->Add("dib", "paint.exe"); - myHashtable->Add("rtf", "wordpad.exe"); - - - // When you use foreach to enumerate hash table elements, - // the elements are retrieved as KeyValuePair objects. - // - for each(DictionaryEntry de in myHashtable) - { - // ... - } - // - } -}; - -int main() -{ - Remarks::Main(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp deleted file mode 100644 index a614056e17b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp +++ /dev/null @@ -1,110 +0,0 @@ - -// The following code example creates hash tables using different Hashtable constructors -// and demonstrates the differences in the behavior of the hash tables, -// even if each one contains the same elements. -// -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; - -ref class myComparer : IEqualityComparer -{ -public: - virtual bool Equals(Object^ x, Object^ y) - { - return x->Equals(y); - } - - virtual int GetHashCode(Object^ obj) - { - return obj->ToString()->ToLower()->GetHashCode(); - } -}; - -// -ref class myCultureComparer : IEqualityComparer -{ -private: - CaseInsensitiveComparer^ myComparer; - -public: - myCultureComparer() - { - myComparer = CaseInsensitiveComparer::DefaultInvariant; - } - - myCultureComparer(CultureInfo^ myCulture) - { - myComparer = gcnew CaseInsensitiveComparer(myCulture); - } - - virtual bool Equals(Object^ x, Object^ y) - { - if (myComparer->Compare(x, y) == 0) - { - return true; - } - else - { - return false; - } - } - - virtual int GetHashCode(Object^ obj) - { - return obj->ToString()->ToLower()->GetHashCode(); - } -}; -// - -int main() -{ - - // Create a hash table using the default hash code provider and the default comparer. - Hashtable^ myHT1 = gcnew Hashtable((IEqualityComparer^)nullptr); - myHT1->Add( "FIRST", "Hello" ); - myHT1->Add( "SECOND", "World" ); - myHT1->Add( "THIRD", "!" ); - - // Create a hash table using the specified IEqualityComparer that uses - // the default Object.Equals to determine equality. - Hashtable^ myHT2 = gcnew Hashtable(gcnew myComparer()); - myHT2->Add( "FIRST", "Hello" ); - myHT2->Add( "SECOND", "World" ); - myHT2->Add( "THIRD", "!" ); - - // Create a hash table using a case-insensitive hash code provider and - // case-insensitive comparer based on the InvariantCulture. - Hashtable^ myHT3 = gcnew Hashtable( - CaseInsensitiveHashCodeProvider::DefaultInvariant, - CaseInsensitiveComparer::DefaultInvariant); - myHT3->Add( "FIRST", "Hello" ); - myHT3->Add( "SECOND", "World" ); - myHT3->Add( "THIRD", "!" ); - - // Create a hash table using an IEqualityComparer that is based on - // the Turkish culture (tr-TR) where "I" is not the uppercase - // version of "i". - CultureInfo^ myCul = gcnew CultureInfo("tr-TR"); - Hashtable^ myHT4 = gcnew Hashtable( gcnew myCultureComparer(myCul) ); - myHT4->Add( "FIRST", "Hello" ); - myHT4->Add( "SECOND", "World" ); - myHT4->Add( "THIRD", "!" ); - - // Search for a key in each hash table. - Console::WriteLine( "first is in myHT1: {0}", myHT1->ContainsKey( "first" ) ); - Console::WriteLine( "first is in myHT2: {0}", myHT2->ContainsKey( "first" ) ); - Console::WriteLine( "first is in myHT3: {0}", myHT3->ContainsKey( "first" ) ); - Console::WriteLine( "first is in myHT4: {0}", myHT4->ContainsKey( "first" ) ); -} - -/* -This code produces the following output. Results vary depending on the system's culture settings. - -first is in myHT1: False -first is in myHT2: False -first is in myHT3: True -first is in myHT4: False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/CPP/hashtable_ctordictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/CPP/hashtable_ctordictionary.cpp deleted file mode 100644 index ddc083162d8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/CPP/hashtable_ctordictionary.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// The following code example creates hash tables using different Hashtable -// constructors and demonstrates the differences in the behavior of the hash -// tables, even if each one contains the same elements. - -// -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; - -ref class myCultureComparer : public IEqualityComparer -{ -public: - CaseInsensitiveComparer^ myComparer; - -public: - myCultureComparer() - { - myComparer = CaseInsensitiveComparer::DefaultInvariant; - } - -public: - myCultureComparer(CultureInfo^ myCulture) - { - myComparer = gcnew CaseInsensitiveComparer(myCulture); - } - -public: - virtual bool Equals(Object^ x, Object^ y) - { - if (myComparer->Compare(x, y) == 0) - { - return true; - } - else - { - return false; - } - } - -public: - virtual int GetHashCode(Object^ obj) - { - // Compare the hash code for the lowercase versions of the strings. - return obj->ToString()->ToLower()->GetHashCode(); - } -}; - -public ref class SamplesHashtable -{ - -public: - static void Main() - { - // Create the dictionary. - SortedList^ mySL = gcnew SortedList(); - mySL->Add("FIRST", "Hello"); - mySL->Add("SECOND", "World"); - mySL->Add("THIRD", "!"); - - // Create a hash table using the default comparer. - Hashtable^ myHT1 = gcnew Hashtable(mySL); - - // Create a hash table using the specified IEqualityComparer that uses - // the CaseInsensitiveComparer.DefaultInvariant to determine equality. - Hashtable^ myHT2 = gcnew Hashtable(mySL, gcnew myCultureComparer()); - - // Create a hash table using an IEqualityComparer that is based on - // the Turkish culture (tr-TR) where "I" is not the uppercase - // version of "i". - CultureInfo^ myCul = gcnew CultureInfo("tr-TR"); - Hashtable^ myHT3 = gcnew Hashtable(mySL, gcnew myCultureComparer(myCul)); - - // Search for a key in each hash table. - Console::WriteLine("first is in myHT1: {0}", myHT1->ContainsKey("first")); - Console::WriteLine("first is in myHT2: {0}", myHT2->ContainsKey("first")); - Console::WriteLine("first is in myHT3: {0}", myHT3->ContainsKey("first")); - } -}; - -int main() -{ - SamplesHashtable::Main(); -}; - -/* -This code produces the following output. -Results vary depending on the system's culture settings. - -first is in myHT1: False -first is in myHT2: True -first is in myHT3: False - -*/ -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/CPP/hashtable_ctordictionaryfloat.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/CPP/hashtable_ctordictionaryfloat.cpp deleted file mode 100644 index aeefb15d534..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/CPP/hashtable_ctordictionaryfloat.cpp +++ /dev/null @@ -1,93 +0,0 @@ - -// The following code example creates hash tables using different Hashtable constructors -// and demonstrates the differences in the behavior of the hash tables, -// even if each one contains the same elements. -// -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; - -ref class myCultureComparer : public IEqualityComparer -{ -public: - CaseInsensitiveComparer^ myComparer; - -public: - myCultureComparer() - { - myComparer = CaseInsensitiveComparer::DefaultInvariant; - } - -public: - myCultureComparer(CultureInfo^ myCulture) - { - myComparer = gcnew CaseInsensitiveComparer(myCulture); - } - -public: - virtual bool Equals(Object^ x, Object^ y) - { - if (myComparer->Compare(x, y) == 0) - { - return true; - } - else - { - return false; - } - } - -public: - virtual int GetHashCode(Object^ obj) - { - // Compare the hash code for the lowercase versions of the strings. - return obj->ToString()->ToLower()->GetHashCode(); - } -}; - -public ref class SamplesHashtable -{ - -public: - static void Main() - { - - // Create the dictionary. - SortedList^ mySL = gcnew SortedList; - mySL->Add( "FIRST", "Hello" ); - mySL->Add( "SECOND", "World" ); - mySL->Add( "THIRD", "!" ); - - // Create a hash table using the default hash code provider and the default comparer. - Hashtable^ myHT1 = gcnew Hashtable( mySL, .8f ); - - // Create a hash table using the specified case-insensitive hash code provider and case-insensitive comparer. - Hashtable^ myHT2 = gcnew Hashtable( mySL, .8f, gcnew myCultureComparer() ); - - // Create a hash table using the specified KeyComparer. - // The KeyComparer uses a case-insensitive hash code provider and a case-insensitive comparer, - // which are based on the Turkish culture (tr-TR), where "I" is not the uppercase version of "i". - CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" ); - Hashtable^ myHT3 = gcnew Hashtable( mySL, .8f, gcnew myCultureComparer( myCul ) ); - - // Search for a key in each hash table. - Console::WriteLine( "first is in myHT1: {0}", myHT1->ContainsKey( "first" ) ); - Console::WriteLine( "first is in myHT2: {0}", myHT2->ContainsKey( "first" ) ); - Console::WriteLine( "first is in myHT3: {0}", myHT3->ContainsKey( "first" ) ); - } -}; - -int main() -{ - SamplesHashtable::Main(); -} - -/* -This code produces the following output. Results vary depending on the system's culture settings. - -first is in myHT1: False -first is in myHT2: True -first is in myHT3: False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/CPP/hashtable_ctorint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/CPP/hashtable_ctorint.cpp deleted file mode 100644 index 90be7623a99..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/CPP/hashtable_ctorint.cpp +++ /dev/null @@ -1,97 +0,0 @@ - -// The following code example creates hash tables using different Hashtable constructors -// and demonstrates the differences in the behavior of the hash tables, -// even if each one contains the same elements. -// -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; - -ref class myCultureComparer : public IEqualityComparer -{ -public: - CaseInsensitiveComparer^ myComparer; - -public: - myCultureComparer() - { - myComparer = CaseInsensitiveComparer::DefaultInvariant; - } - -public: - myCultureComparer(CultureInfo^ myCulture) - { - myComparer = gcnew CaseInsensitiveComparer(myCulture); - } - -public: - virtual bool Equals(Object^ x, Object^ y) - { - if (myComparer->Compare(x, y) == 0) - { - return true; - } - else - { - return false; - } - } - -public: - virtual int GetHashCode(Object^ obj) - { - // Compare the hash code for the lowercase versions of the strings. - return obj->ToString()->ToLower()->GetHashCode(); - } -}; - -public ref class SamplesHashtable -{ - -public: - static void Main() - { - // Create a hash table using the default comparer. - Hashtable^ myHT1 = gcnew Hashtable(3); - myHT1->Add("FIRST", "Hello"); - myHT1->Add("SECOND", "World"); - myHT1->Add("THIRD", "!"); - - // Create a hash table using the specified IEqualityComparer that uses - // the CaseInsensitiveComparer.DefaultInvariant to determine equality. - Hashtable^ myHT2 = gcnew Hashtable(3, gcnew myCultureComparer()); - myHT2->Add("FIRST", "Hello"); - myHT2->Add("SECOND", "World"); - myHT2->Add("THIRD", "!"); - - // Create a hash table using an IEqualityComparer that is based on - // the Turkish culture (tr-TR) where "I" is not the uppercase - // version of "i". - CultureInfo^ myCul = gcnew CultureInfo("tr-TR"); - Hashtable^ myHT3 = gcnew Hashtable(3, gcnew myCultureComparer(myCul)); - myHT3->Add("FIRST", "Hello"); - myHT3->Add("SECOND", "World"); - myHT3->Add("THIRD", "!"); - - // Search for a key in each hash table. - Console::WriteLine("first is in myHT1: {0}", myHT1->ContainsKey("first")); - Console::WriteLine("first is in myHT2: {0}", myHT2->ContainsKey("first")); - Console::WriteLine("first is in myHT3: {0}", myHT3->ContainsKey("first")); - - } -}; - -int main() -{ - SamplesHashtable::Main(); -} - -/* -This code produces the following output. Results vary depending on the system's culture settings. - -first is in myHT1: False -first is in myHT2: True -first is in myHT3: False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/CPP/hashtable_ctorintfloat.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/CPP/hashtable_ctorintfloat.cpp deleted file mode 100644 index a55776fd358..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/CPP/hashtable_ctorintfloat.cpp +++ /dev/null @@ -1,97 +0,0 @@ - -// The following code example creates hash tables using different Hashtable constructors -// and demonstrates the differences in the behavior of the hash tables, -// even if each one contains the same elements. -// -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; - -ref class myCultureComparer : public IEqualityComparer -{ -public: - CaseInsensitiveComparer^ myComparer; - -public: - myCultureComparer() - { - myComparer = CaseInsensitiveComparer::DefaultInvariant; - } - -public: - myCultureComparer(CultureInfo^ myCulture) - { - myComparer = gcnew CaseInsensitiveComparer(myCulture); - } - -public: - virtual bool Equals(Object^ x, Object^ y) - { - if (myComparer->Compare(x, y) == 0) - { - return true; - } - else - { - return false; - } - } - -public: - virtual int GetHashCode(Object^ obj) - { - // Compare the hash code for the lowercase versions of the strings. - return obj->ToString()->ToLower()->GetHashCode(); - } -}; - -public ref class SamplesHashtable -{ - -public: - static void Main() - { - // Create a hash table using the default comparer. - Hashtable^ myHT1 = gcnew Hashtable(3, .8f); - myHT1->Add("FIRST", "Hello"); - myHT1->Add("SECOND", "World"); - myHT1->Add("THIRD", "!"); - - // Create a hash table using the specified IEqualityComparer that uses - // the CaseInsensitiveComparer.DefaultInvariant to determine equality. - Hashtable^ myHT2 = gcnew Hashtable(3, .8f, gcnew myCultureComparer()); - myHT2->Add("FIRST", "Hello"); - myHT2->Add("SECOND", "World"); - myHT2->Add("THIRD", "!"); - - // Create a hash table using an IEqualityComparer that is based on - // the Turkish culture (tr-TR) where "I" is not the uppercase - // version of "i". - CultureInfo^ myCul = gcnew CultureInfo("tr-TR"); - Hashtable^ myHT3 = gcnew Hashtable(3, .8f, gcnew myCultureComparer(myCul)); - myHT3->Add("FIRST", "Hello"); - myHT3->Add("SECOND", "World"); - myHT3->Add("THIRD", "!"); - - // Search for a key in each hash table. - Console::WriteLine("first is in myHT1: {0}", myHT1->ContainsKey("first")); - Console::WriteLine("first is in myHT2: {0}", myHT2->ContainsKey("first")); - Console::WriteLine("first is in myHT3: {0}", myHT3->ContainsKey("first")); - - } -}; - -int main() -{ - SamplesHashtable::Main(); -} - -/* -This code produces the following output. Results vary depending on the system's culture settings. - -first is in myHT1: False -first is in myHT2: True -first is in myHT3: False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/readonlycollectionbase.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/readonlycollectionbase.cpp deleted file mode 100644 index f1919addfd6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/readonlycollectionbase.cpp +++ /dev/null @@ -1,107 +0,0 @@ - -// The following code example implements the ReadOnlyCollectionBase class. -// -using namespace System; -using namespace System::Collections; -public ref class ROCollection: public ReadOnlyCollectionBase -{ -public: - ROCollection( IList^ sourceList ) - { - InnerList->AddRange( sourceList ); - } - - property Object^ Item [int] - { - Object^ get( int index ) - { - return (InnerList[ index ]); - } - - } - int IndexOf( Object^ value ) - { - return (InnerList->IndexOf( value )); - } - - bool Contains( Object^ value ) - { - return (InnerList->Contains( value )); - } - -}; - -void PrintIndexAndValues( ROCollection^ myCol ); -void PrintValues2( ROCollection^ myCol ); -int main() -{ - // Create an ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "red" ); - myAL->Add( "blue" ); - myAL->Add( "yellow" ); - myAL->Add( "green" ); - myAL->Add( "orange" ); - myAL->Add( "purple" ); - - // Create a new ROCollection that contains the elements in myAL. - ROCollection^ myCol = gcnew ROCollection( myAL ); - - // Display the contents of the collection using the enumerator. - Console::WriteLine( "Contents of the collection (using enumerator):" ); - PrintValues2( myCol ); - - // Display the contents of the collection using the Count property and the Item property. - Console::WriteLine( "Contents of the collection (using Count and Item):" ); - PrintIndexAndValues( myCol ); - - // Search the collection with Contains and IndexOf. - Console::WriteLine( "Contains yellow: {0}", myCol->Contains( "yellow" ) ); - Console::WriteLine( "orange is at index {0}.", myCol->IndexOf( "orange" ) ); - Console::WriteLine(); -} - - -// Uses the Count property and the Item property. -void PrintIndexAndValues( ROCollection^ myCol ) -{ - for ( int i = 0; i < myCol->Count; i++ ) - Console::WriteLine( " [{0}]: {1}", i, myCol->Item[ i ] ); - Console::WriteLine(); -} - - -// Uses the enumerator. -void PrintValues2( ROCollection^ myCol ) -{ - System::Collections::IEnumerator^ myEnumerator = myCol->GetEnumerator(); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( " {0}", myEnumerator->Current ); - - Console::WriteLine(); -} - -/* -This code produces the following output. - -Contents of the collection (using enumerator): - red - blue - yellow - green - orange - purple - -Contents of the collection (using Count and Item): - [0]: red - [1]: blue - [2]: yellow - [3]: green - [4]: orange - [5]: purple - -Contains yellow: True -orange is at index 4. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/source2.cpp deleted file mode 100644 index aea5c5a39cb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/source2.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -// The following code example implements the ReadOnlyCollectionBase class. -using namespace System; -using namespace System::Collections; -using namespace System::Threading; - -public ref class ROCollection: public ReadOnlyCollectionBase -{ -public: - ROCollection( IList^ sourceList ) - { - InnerList->AddRange( sourceList ); - } - - property Object^ Item [int] - { - Object^ get( int index ) - { - return (InnerList[ index ]); - } - - } - int IndexOf( Object^ value ) - { - return (InnerList->IndexOf( value )); - } - - bool Contains( Object^ value ) - { - return (InnerList->Contains( value )); - } - -}; - -public ref class SamplesCollectionBase -{ -public: - static void Main() - { - - // Create an ArrayList. - ArrayList^ myAL = gcnew ArrayList(); - myAL->Add( "red" ); - myAL->Add( "blue" ); - myAL->Add( "yellow" ); - myAL->Add( "green" ); - myAL->Add( "orange" ); - myAL->Add( "purple" ); - - // Create a new ROCollection that contains the elements in myAL. - ROCollection^ myReadOnlyCollection = gcnew ROCollection( myAL ); - - // - // Get the ICollection interface from the ReadOnlyCollectionBase - // derived class. - ICollection^ myCollection = myReadOnlyCollection; - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection); - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesCollectionBase::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/CPP/sortedlist_ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/CPP/sortedlist_ctor.cpp deleted file mode 100644 index 89c82b72244..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/CPP/sortedlist_ctor.cpp +++ /dev/null @@ -1,116 +0,0 @@ - -// - -// The following code example creates SortedList instances using different constructors -// and demonstrates the differences in the behavior of the SortedList instances. - -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; - -void PrintKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( " -KEY- -VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( " {0,-6}: {1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Create a SortedList using the default comparer. - SortedList^ mySL1 = gcnew SortedList; - Console::WriteLine( "mySL1 (default):" ); - mySL1->Add( "FIRST", "Hello" ); - mySL1->Add( "SECOND", "World" ); - mySL1->Add( "THIRD", "!" ); - - try { mySL1->Add( "first", "Ola!" ); } - catch ( ArgumentException^ e ) { Console::WriteLine( e ); } - - PrintKeysAndValues( mySL1 ); - - // Create a SortedList using the specified case-insensitive comparer. - SortedList^ mySL2 = gcnew SortedList( gcnew CaseInsensitiveComparer ); - Console::WriteLine( "mySL2 (case-insensitive comparer):" ); - mySL2->Add( "FIRST", "Hello" ); - mySL2->Add( "SECOND", "World" ); - mySL2->Add( "THIRD", "!" ); - - try { mySL2->Add( "first", "Ola!" ); } - catch ( ArgumentException^ e ) { Console::WriteLine( e ); } - - PrintKeysAndValues( mySL2 ); - - // Create a SortedList using the specified KeyComparer. - // The KeyComparer uses a case-insensitive hash code provider and a case-insensitive comparer, - // which are based on the Turkish culture (tr-TR), where "I" is not the uppercase version of "i". - CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" ); - SortedList^ mySL3 = gcnew SortedList( gcnew CaseInsensitiveComparer( myCul ) ); - Console::WriteLine( "mySL3 (case-insensitive comparer, Turkish culture):" ); - mySL3->Add( "FIRST", "Hello" ); - mySL3->Add( "SECOND", "World" ); - mySL3->Add( "THIRD", "!" ); - - try { mySL3->Add( "first", "Ola!" ); } - catch ( ArgumentException^ e ) { Console::WriteLine( e ); } - - PrintKeysAndValues( mySL3 ); - - // Create a SortedList using the ComparisonType.InvariantCultureIgnoreCase value. - SortedList^ mySL4 = gcnew SortedList( StringComparer::InvariantCultureIgnoreCase ); - Console::WriteLine( "mySL4 (InvariantCultureIgnoreCase):" ); - mySL4->Add( "FIRST", "Hello" ); - mySL4->Add( "SECOND", "World" ); - mySL4->Add( "THIRD", "!" ); - - try { mySL4->Add( "first", "Ola!" ); } - catch ( ArgumentException^ e ) { Console::WriteLine( e ); } - - PrintKeysAndValues( mySL4 ); - - Console::WriteLine("\n\nHit ENTER to return"); - Console::ReadLine(); -} - -/* -This code produces the following output. Results vary depending on the system's culture settings. - -mySL1 (default): - -KEY- -VALUE- - first : Ola! - FIRST : Hello - SECOND: World - THIRD : ! - -mySL2 (case-insensitive comparer): -System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first' - at System.Collections.SortedList.Add(Object key, Object value) - at SamplesSortedList.Main() - -KEY- -VALUE- - FIRST : Hello - SECOND: World - THIRD : ! - -mySL3 (case-insensitive comparer, Turkish culture): - -KEY- -VALUE- - FIRST : Hello - first : Ola! - SECOND: World - THIRD : ! - -mySL4 (InvariantCultureIgnoreCase): -System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first' - at System.Collections.SortedList.Add(Object key, Object value) - at SamplesSortedList.Main() - -KEY- -VALUE- - FIRST : Hello - SECOND: World - THIRD : ! - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/CPP/sortedlist_ctordictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/CPP/sortedlist_ctordictionary.cpp deleted file mode 100644 index 89748fd1f54..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/CPP/sortedlist_ctordictionary.cpp +++ /dev/null @@ -1,126 +0,0 @@ - -// The following code example creates SortedList instances using different constructors -// and demonstrates the differences in the behavior of the SortedList instances. -// - - -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; -void PrintKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( " -KEY- -VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( " {0,-6}: {1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Create the dictionary. - Hashtable^ myHT = gcnew Hashtable; - myHT->Add( "FIRST", "Hello" ); - myHT->Add( "SECOND", "World" ); - myHT->Add( "THIRD", "!" ); - - // Create a SortedList using the default comparer. - SortedList^ mySL1 = gcnew SortedList( myHT ); - Console::WriteLine( "mySL1 (default):" ); - try - { - mySL1->Add( "first", "Ola!" ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - PrintKeysAndValues( mySL1 ); - - // Create a SortedList using the specified case-insensitive comparer. - SortedList^ mySL2 = gcnew SortedList( myHT,gcnew CaseInsensitiveComparer ); - Console::WriteLine( "mySL2 (case-insensitive comparer):" ); - try - { - mySL2->Add( "first", "Ola!" ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - PrintKeysAndValues( mySL2 ); - - // Create a SortedList using the specified CaseInsensitiveComparer, - // which is based on the Turkish culture (tr-TR), where "I" is not - // the uppercase version of "i". - CultureInfo^ myCul = gcnew CultureInfo( "tr-TR" ); - SortedList^ mySL3 = gcnew SortedList( myHT, gcnew CaseInsensitiveComparer( myCul ) ); - Console::WriteLine( "mySL3 (case-insensitive comparer, Turkish culture):" ); - try - { - mySL3->Add( "first", "Ola!" ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - PrintKeysAndValues( mySL3 ); - - // Create a SortedList using the ComparisonType.InvariantCultureIgnoreCase value. - SortedList^ mySL4 = gcnew SortedList( myHT, StringComparer::InvariantCultureIgnoreCase ); - Console::WriteLine( "mySL4 (InvariantCultureIgnoreCase):" ); - try - { - mySL4->Add( "first", "Ola!" ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - PrintKeysAndValues( mySL4 ); -} - -/* -This code produces the following output. Results vary depending on the system's culture settings. - -mySL1 (default): - -KEY- -VALUE- - first : Ola! - FIRST : Hello - SECOND: World - THIRD : ! - -mySL2 (case-insensitive comparer): -System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first' - at System.Collections.SortedList.Add(Object key, Object value) - at SamplesSortedList.Main() - -KEY- -VALUE- - FIRST : Hello - SECOND: World - THIRD : ! - -mySL3 (case-insensitive comparer, Turkish culture): - -KEY- -VALUE- - FIRST : Hello - first : Ola! - SECOND: World - THIRD : ! - -mySL4 (InvariantCultureIgnoreCase): -System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first' - at System.Collections.SortedList.Add(Object key, Object value) - at SamplesSortedList.Main() - -KEY- -VALUE- - FIRST : Hello - SECOND: World - THIRD : ! - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/CPP/sortedlist_ctorint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/CPP/sortedlist_ctorint.cpp deleted file mode 100644 index 047062c6747..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/CPP/sortedlist_ctorint.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// -// The following code example creates SortedList instances using different constructors -// and demonstrates the differences in the behavior of the SortedList instances. - - - -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; -void PrintKeysAndValues( SortedList^ myList ) -{ - Console::WriteLine( " Capacity is {0}.", myList->Capacity ); - Console::WriteLine( " -KEY- -VALUE-" ); - for ( int i = 0; i < myList->Count; i++ ) - { - Console::WriteLine( " {0,-6}: {1}", myList->GetKey( i ), myList->GetByIndex( i ) ); - - } - Console::WriteLine(); -} - -int main() -{ - - // Create a SortedList using the default comparer. - SortedList^ mySL1 = gcnew SortedList( 3 ); - Console::WriteLine( "mySL1 (default):" ); - mySL1->Add( "FIRST", "Hello" ); - mySL1->Add( "SECOND", "World" ); - mySL1->Add( "THIRD", "!" ); - try - { - mySL1->Add( "first", "Ola!" ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - PrintKeysAndValues( mySL1 ); - - // Create a SortedList using the specified case-insensitive comparer. - SortedList^ mySL2 = gcnew SortedList( gcnew CaseInsensitiveComparer,3 ); - Console::WriteLine( "mySL2 (case-insensitive comparer):" ); - mySL2->Add( "FIRST", "Hello" ); - mySL2->Add( "SECOND", "World" ); - mySL2->Add( "THIRD", "!" ); - try - { - mySL2->Add( "first", "Ola!" ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - PrintKeysAndValues( mySL2 ); - - // Create a SortedList using the specified CaseInsensitiveComparer, - // which is based on the Turkish culture (tr-TR), where "I" is not - // the uppercase version of "i". - CultureInfo^ myCul = gcnew CultureInfo("tr-TR"); - SortedList^ mySL3 = gcnew SortedList(gcnew CaseInsensitiveComparer(myCul), 3); - - Console::WriteLine("mySL3 (case-insensitive comparer, Turkish culture):"); - - mySL3->Add("FIRST", "Hello"); - mySL3->Add("SECOND", "World"); - mySL3->Add("THIRD", "!"); - try - { - mySL3->Add("first", "Ola!"); - } - catch (ArgumentException^ e) - { - Console::WriteLine(e); - } - PrintKeysAndValues(mySL3); - - // Create a SortedList using the - // StringComparer.InvariantCultureIgnoreCase value. - SortedList^ mySL4 = gcnew SortedList( StringComparer::InvariantCultureIgnoreCase, 3 ); - Console::WriteLine( "mySL4 (InvariantCultureIgnoreCase):" ); - mySL4->Add( "FIRST", "Hello" ); - mySL4->Add( "SECOND", "World" ); - mySL4->Add( "THIRD", "!" ); - try - { - mySL4->Add( "first", "Ola!" ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - PrintKeysAndValues( mySL4 ); -} - -/* -This code produces the following output. Results vary depending on the system's culture settings. - -mySL1 (default): - Capacity is 6. - -KEY- -VALUE- - first : Ola! - FIRST : Hello - SECOND: World - THIRD : ! - -mySL2 (case-insensitive comparer): -System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first' - at System.Collections.SortedList.Add(Object key, Object value) - at SamplesSortedList.Main() - Capacity is 3. - -KEY- -VALUE- - FIRST : Hello - SECOND: World - THIRD : ! - -mySL3 (case-insensitive comparer, Turkish culture): - Capacity is 6. - -KEY- -VALUE- - FIRST : Hello - first : Ola! - SECOND: World - THIRD : ! - -mySL4 (InvariantCultureIgnoreCase): -System.ArgumentException: Item has already been added. Key in dictionary: 'FIRST' Key being added: 'first' - at System.Collections.SortedList.Add(Object key, Object value) - at SamplesSortedList.Main() - Capacity is 3. - -KEY- -VALUE- - FIRST : Hello - SECOND: World - THIRD : ! - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.CreateMasks/CPP/bitvector32_createmasks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.CreateMasks/CPP/bitvector32_createmasks.cpp deleted file mode 100644 index a4aa7596eb9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.CreateMasks/CPP/bitvector32_createmasks.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// The following code example shows how to create and use masks. -// -#using - -using namespace System; -using namespace System::Collections::Specialized; -int main() -{ - // Creates and initializes a BitVector32 with all bit flags set to FALSE. - BitVector32 myBV; - - // Creates masks to isolate each of the first five bit flags. - int myBit1 = BitVector32::CreateMask(); - int myBit2 = BitVector32::CreateMask( myBit1 ); - int myBit3 = BitVector32::CreateMask( myBit2 ); - int myBit4 = BitVector32::CreateMask( myBit3 ); - int myBit5 = BitVector32::CreateMask( myBit4 ); - Console::WriteLine( "Initial: \t {0}", myBV ); - - // Sets the third bit to TRUE. - myBV[ myBit3 ] = true; - Console::WriteLine( "myBit3 = TRUE \t {0}", myBV ); - - // Combines two masks to access multiple bits at a time. - myBV[ myBit4 + myBit5 ] = true; - Console::WriteLine( "myBit4 + myBit5 = TRUE \t {0}", myBV ); - myBV[ myBit1 | myBit2 ] = true; - Console::WriteLine( "myBit1 | myBit2 = TRUE \t {0}", myBV ); -} - -/* -This code produces the following output. - -Initial: BitVector32 {00000000000000000000000000000000} -myBit3 = TRUE BitVector32 {00000000000000000000000000000100} -myBit4 + myBit5 = TRUE BitVector32 {00000000000000000000000000011100} -myBit1 | myBit2 = TRUE BitVector32 {00000000000000000000000000011111} - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.Equals/CPP/bitvector32_equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.Equals/CPP/bitvector32_equals.cpp deleted file mode 100644 index e3796e3bdc3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.Equals/CPP/bitvector32_equals.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// The following code example compares a BitVector32 with another BitVector32 and with an Int32. -// -#using - -using namespace System; -using namespace System::Collections::Specialized; - -int main() -{ - // Creates and initializes a BitVector32 with the value 123. - // This is the BitVector32 that will be compared to different types. - BitVector32 myBV(123); - - // Creates and initializes a new BitVector32 which will be set up as sections. - BitVector32 myBVsect(0); - - // Compares myBV and myBVsect. - Console::WriteLine( "myBV : {0}", myBV ); - Console::WriteLine( "myBVsect : {0}", myBVsect ); - if ( myBV.Equals( myBVsect ) ) - Console::WriteLine( " myBV( {0}) equals myBVsect( {1}).", myBV.Data, myBVsect.Data ); - else - Console::WriteLine( " myBV( {0}) does not equal myBVsect( {1}).", myBV.Data, myBVsect.Data ); - - Console::WriteLine(); - - // Assigns values to the sections of myBVsect. - BitVector32::Section mySect1 = BitVector32::CreateSection( 5 ); - BitVector32::Section mySect2 = BitVector32::CreateSection( 1, mySect1 ); - BitVector32::Section mySect3 = BitVector32::CreateSection( 20, mySect2 ); - myBVsect[ mySect1 ] = 3; - myBVsect[ mySect2 ] = 1; - myBVsect[ mySect3 ] = 7; - - // Compares myBV and myBVsect. - Console::WriteLine( "myBV : {0}", myBV ); - Console::WriteLine( "myBVsect with values : {0}", myBVsect ); - if ( myBV.Equals( myBVsect ) ) - Console::WriteLine( " myBV( {0}) equals myBVsect( {1}).", myBV.Data, myBVsect.Data ); - else - Console::WriteLine( " myBV( {0}) does not equal myBVsect( {1}).", myBV.Data, myBVsect.Data ); - - Console::WriteLine(); - - // Compare myBV with an Int32. - Console::WriteLine( "Comparing myBV with an Int32: " ); - Int32 myInt32 = 123; - - // Using Equals will fail because Int32 is not compatible with BitVector32. - if ( myBV.Equals( myInt32 ) ) - Console::WriteLine( " Using BitVector32::Equals, myBV( {0}) equals myInt32( {1}).", myBV.Data, myInt32 ); - else - Console::WriteLine( " Using BitVector32::Equals, myBV( {0}) does not equal myInt32( {1}).", myBV.Data, myInt32 ); - - // To compare a BitVector32 with an Int32, use the "==" operator. - if ( myBV.Data == myInt32 ) - Console::WriteLine( " Using the \"==\" operator, myBV.Data( {0}) equals myInt32( {1}).", myBV.Data, myInt32 ); - else - Console::WriteLine( " Using the \"==\" operator, myBV.Data( {0}) does not equal myInt32( {1}).", myBV.Data, myInt32 ); -} - -/* -This code produces the following output. - -myBV : BitVector32 {00000000000000000000000001111011} -myBVsect : BitVector32 {00000000000000000000000000000000} - myBV(123) does not equal myBVsect(0). - -myBV : BitVector32 {00000000000000000000000001111011} -myBVsect with values : BitVector32 {00000000000000000000000001111011} - myBV(123) equals myBVsect(123). - -Comparing myBV with an Int32: - Using BitVector32::Equals, myBV(123) does not equal myInt32(123). - Using the "==" operator, myBV.Data(123) equals myInt32(123). - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_BitFlags/CPP/bitvector32_bitflags.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_BitFlags/CPP/bitvector32_bitflags.cpp deleted file mode 100644 index 43f50a3e1db..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_BitFlags/CPP/bitvector32_bitflags.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// The following code example uses a BitVector32 as a collection of bit flags. -// -#using - -using namespace System; -using namespace System::Collections::Specialized; -int main() -{ - - // Creates and initializes a BitVector32 with all bit flags set to FALSE. - BitVector32 myBV(0); - - // Creates masks to isolate each of the first five bit flags. - int myBit1 = BitVector32::CreateMask(); - int myBit2 = BitVector32::CreateMask( myBit1 ); - int myBit3 = BitVector32::CreateMask( myBit2 ); - int myBit4 = BitVector32::CreateMask( myBit3 ); - int myBit5 = BitVector32::CreateMask( myBit4 ); - - // Sets the alternating bits to TRUE. - Console::WriteLine( "Setting alternating bits to TRUE:" ); - Console::WriteLine( " Initial: {0}", myBV ); - myBV[ myBit1 ] = true; - Console::WriteLine( " myBit1 = TRUE: {0}", myBV ); - myBV[ myBit3 ] = true; - Console::WriteLine( " myBit3 = TRUE: {0}", myBV ); - myBV[ myBit5 ] = true; - Console::WriteLine( " myBit5 = TRUE: {0}", myBV ); -} - -/* -This code produces the following output. - -Setting alternating bits to TRUE: -Initial: BitVector32 {00000000000000000000000000000000} -myBit1 = TRUE: BitVector32 {00000000000000000000000000000001} -myBit3 = TRUE: BitVector32 {00000000000000000000000000000101} -myBit5 = TRUE: BitVector32 {00000000000000000000000000010101} - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/CPP/bitvector32_sections.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/CPP/bitvector32_sections.cpp deleted file mode 100644 index 91d45f3f84b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/CPP/bitvector32_sections.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// The following code example uses a BitVector32 as a collection of sections. -// -#using - -using namespace System; -using namespace System::Collections::Specialized; - -int main() -{ - // Creates and initializes a BitVector32. - BitVector32 myBV(0); - - // Creates four sections in the BitVector32 with maximum values 6, 3, 1, and 15. - // mySect3, which uses exactly one bit, can also be used as a bit flag. - BitVector32::Section mySect1 = BitVector32::CreateSection( 6 ); - BitVector32::Section mySect2 = BitVector32::CreateSection( 3, mySect1 ); - BitVector32::Section mySect3 = BitVector32::CreateSection( 1, mySect2 ); - BitVector32::Section mySect4 = BitVector32::CreateSection( 15, mySect3 ); - - // Displays the values of the sections. - Console::WriteLine( "Initial values:" ); - Console::WriteLine( "\tmySect1: {0}", myBV[ mySect1 ] ); - Console::WriteLine( "\tmySect2: {0}", myBV[ mySect2 ] ); - Console::WriteLine( "\tmySect3: {0}", myBV[ mySect3 ] ); - Console::WriteLine( "\tmySect4: {0}", myBV[ mySect4 ] ); - - // Sets each section to a new value and displays the value of the BitVector32 at each step. - Console::WriteLine( "Changing the values of each section:" ); - Console::WriteLine( "\tInitial: \t {0}", myBV ); - myBV[ mySect1 ] = 5; - Console::WriteLine( "\tmySect1 = 5:\t {0}", myBV ); - myBV[ mySect2 ] = 3; - Console::WriteLine( "\tmySect2 = 3:\t {0}", myBV ); - myBV[ mySect3 ] = 1; - Console::WriteLine( "\tmySect3 = 1:\t {0}", myBV ); - myBV[ mySect4 ] = 9; - Console::WriteLine( "\tmySect4 = 9:\t {0}", myBV ); - - // Displays the values of the sections. - Console::WriteLine( "New values:" ); - Console::WriteLine( "\tmySect1: {0}", myBV[ mySect1 ] ); - Console::WriteLine( "\tmySect2: {0}", myBV[ mySect2 ] ); - Console::WriteLine( "\tmySect3: {0}", myBV[ mySect3 ] ); - Console::WriteLine( "\tmySect4: {0}", myBV[ mySect4 ] ); -} - -/* -This code produces the following output. - -Initial values: - mySect1: 0 - mySect2: 0 - mySect3: 0 - mySect4: 0 -Changing the values of each section: - Initial: BitVector32 {00000000000000000000000000000000} - mySect1 = 5: BitVector32 {00000000000000000000000000000101} - mySect2 = 3: BitVector32 {00000000000000000000000000011101} - mySect3 = 1: BitVector32 {00000000000000000000000000111101} - mySect4 = 9: BitVector32 {00000000000000000000001001111101} -New values: - mySect1: 5 - mySect2: 3 - mySect3: 1 - mySect4: 9 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/hybriddictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/hybriddictionary.cpp deleted file mode 100644 index f4a12c16ce9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/hybriddictionary.cpp +++ /dev/null @@ -1,222 +0,0 @@ -// The following code example demonstrates several of the properties and methods of HybridDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -void PrintKeysAndValues1( IDictionary^ myCol ); -void PrintKeysAndValues2( IDictionary^ myCol ); -void PrintKeysAndValues3( HybridDictionary^ myCol ); -int main() -{ - - // Creates and initializes a new HybridDictionary. - HybridDictionary^ myCol = gcnew HybridDictionary; - myCol->Add( "Braeburn Apples", "1.49" ); - myCol->Add( "Fuji Apples", "1.29" ); - myCol->Add( "Gala Apples", "1.49" ); - myCol->Add( "Golden Delicious Apples", "1.29" ); - myCol->Add( "Granny Smith Apples", "0.89" ); - myCol->Add( "Red Delicious Apples", "0.99" ); - myCol->Add( "Plantain Bananas", "1.49" ); - myCol->Add( "Yellow Bananas", "0.79" ); - myCol->Add( "Strawberries", "3.33" ); - myCol->Add( "Cranberries", "5.98" ); - myCol->Add( "Navel Oranges", "1.29" ); - myCol->Add( "Grapes", "1.99" ); - myCol->Add( "Honeydew Melon", "0.59" ); - myCol->Add( "Seedless Watermelon", "0.49" ); - myCol->Add( "Pineapple", "1.49" ); - myCol->Add( "Nectarine", "1.99" ); - myCol->Add( "Plums", "1.69" ); - myCol->Add( "Peaches", "1.99" ); - - // Display the contents of the collection using for each. This is the preferred method. - Console::WriteLine( "Displays the elements using for each:" ); - PrintKeysAndValues1( myCol ); - - // Display the contents of the collection using the enumerator. - Console::WriteLine( "Displays the elements using the IDictionaryEnumerator:" ); - PrintKeysAndValues2( myCol ); - - // Display the contents of the collection using the Keys, Values, Count, and Item properties. - Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" ); - PrintKeysAndValues3( myCol ); - - // Copies the HybridDictionary to an array with DictionaryEntry elements. - array^myArr = gcnew array(myCol->Count); - myCol->CopyTo( myArr, 0 ); - - // Displays the values in the array. - Console::WriteLine( "Displays the elements in the array:" ); - Console::WriteLine( " KEY VALUE" ); - for ( int i = 0; i < myArr->Length; i++ ) - Console::WriteLine( " {0,-25} {1}", myArr[ i ].Key, myArr[ i ].Value ); - Console::WriteLine(); - - // Searches for a key. - if ( myCol->Contains( "Kiwis" ) ) - Console::WriteLine( "The collection contains the key \"Kiwis\"." ); - else - Console::WriteLine( "The collection does not contain the key \"Kiwis\"." ); - - Console::WriteLine(); - - // Deletes a key. - myCol->Remove( "Plums" ); - Console::WriteLine( "The collection contains the following elements after removing \"Plums\":" ); - PrintKeysAndValues1( myCol ); - - // Clears the entire collection. - myCol->Clear(); - Console::WriteLine( "The collection contains the following elements after it is cleared:" ); - PrintKeysAndValues1( myCol ); -} - -// Uses the for each statement which hides the complexity of the enumerator. -// NOTE: The for each statement is the preferred way of enumerating the contents of a collection. -void PrintKeysAndValues1( IDictionary^ myCol ) { - Console::WriteLine( " KEY VALUE" ); - for each ( DictionaryEntry^ de in myCol ) - Console::WriteLine( " {0,-25} {1}", de->Key, de->Value ); - Console::WriteLine(); -} - -// Uses the enumerator. -void PrintKeysAndValues2( IDictionary^ myCol ) -{ - IDictionaryEnumerator^ myEnumerator = myCol->GetEnumerator(); - Console::WriteLine( " KEY VALUE" ); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( " {0,-25} {1}", myEnumerator->Key, myEnumerator->Value ); - - Console::WriteLine(); -} - -// Uses the Keys, Values, Count, and Item properties. -void PrintKeysAndValues3( HybridDictionary^ myCol ) -{ - array^myKeys = gcnew array(myCol->Count); - myCol->Keys->CopyTo( myKeys, 0 ); - Console::WriteLine( " INDEX KEY VALUE" ); - for ( int i = 0; i < myCol->Count; i++ ) - Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] ); - Console::WriteLine(); -} - -/* -This code produces output similar to the following: - -Displays the elements using for each: - KEY VALUE - Strawberries 3.33 - Yellow Bananas 0.79 - Cranberries 5.98 - Grapes 1.99 - Granny Smith Apples 0.89 - Seedless Watermelon 0.49 - Honeydew Melon 0.59 - Red Delicious Apples 0.99 - Navel Oranges 1.29 - Fuji Apples 1.29 - Plantain Bananas 1.49 - Gala Apples 1.49 - Pineapple 1.49 - Plums 1.69 - Braeburn Apples 1.49 - Peaches 1.99 - Golden Delicious Apples 1.29 - Nectarine 1.99 - -Displays the elements using the IDictionaryEnumerator: - KEY VALUE - Strawberries 3.33 - Yellow Bananas 0.79 - Cranberries 5.98 - Grapes 1.99 - Granny Smith Apples 0.89 - Seedless Watermelon 0.49 - Honeydew Melon 0.59 - Red Delicious Apples 0.99 - Navel Oranges 1.29 - Fuji Apples 1.29 - Plantain Bananas 1.49 - Gala Apples 1.49 - Pineapple 1.49 - Plums 1.69 - Braeburn Apples 1.49 - Peaches 1.99 - Golden Delicious Apples 1.29 - Nectarine 1.99 - -Displays the elements using the Keys, Values, Count, and Item properties: - INDEX KEY VALUE - 0 Strawberries 3.33 - 1 Yellow Bananas 0.79 - 2 Cranberries 5.98 - 3 Grapes 1.99 - 4 Granny Smith Apples 0.89 - 5 Seedless Watermelon 0.49 - 6 Honeydew Melon 0.59 - 7 Red Delicious Apples 0.99 - 8 Navel Oranges 1.29 - 9 Fuji Apples 1.29 - 10 Plantain Bananas 1.49 - 11 Gala Apples 1.49 - 12 Pineapple 1.49 - 13 Plums 1.69 - 14 Braeburn Apples 1.49 - 15 Peaches 1.99 - 16 Golden Delicious Apples 1.29 - 17 Nectarine 1.99 - -Displays the elements in the array: - KEY VALUE - Strawberries 3.33 - Yellow Bananas 0.79 - Cranberries 5.98 - Grapes 1.99 - Granny Smith Apples 0.89 - Seedless Watermelon 0.49 - Honeydew Melon 0.59 - Red Delicious Apples 0.99 - Navel Oranges 1.29 - Fuji Apples 1.29 - Plantain Bananas 1.49 - Gala Apples 1.49 - Pineapple 1.49 - Plums 1.69 - Braeburn Apples 1.49 - Peaches 1.99 - Golden Delicious Apples 1.29 - Nectarine 1.99 - -The collection does not contain the key "Kiwis". - -The collection contains the following elements after removing "Plums": - KEY VALUE - Strawberries 3.33 - Yellow Bananas 0.79 - Cranberries 5.98 - Grapes 1.99 - Granny Smith Apples 0.89 - Seedless Watermelon 0.49 - Honeydew Melon 0.59 - Red Delicious Apples 0.99 - Navel Oranges 1.29 - Fuji Apples 1.29 - Plantain Bananas 1.49 - Gala Apples 1.49 - Pineapple 1.49 - Braeburn Apples 1.49 - Peaches 1.99 - Golden Delicious Apples 1.29 - Nectarine 1.99 - -The collection contains the following elements after it is cleared: - KEY VALUE - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/source2.cpp deleted file mode 100644 index 5b82c8e92c1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/source2.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::Threading; - -public ref class HybridDictSample -{ -public: - static void Main() - { - // Creates and initializes a new HybridDictionary. - HybridDictionary^ myHybridDictionary = gcnew HybridDictionary(); - - // - for each (DictionaryEntry^ de in myHybridDictionary) - { - //... - } - // - - // - HybridDictionary^ myCollection = gcnew HybridDictionary(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection) - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - HybridDictSample::Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/CPP/hybriddictionary_addremove.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/CPP/hybriddictionary_addremove.cpp deleted file mode 100644 index 1afdca2ae97..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/CPP/hybriddictionary_addremove.cpp +++ /dev/null @@ -1,110 +0,0 @@ - - -// The following code example adds to and removes elements from a HybridDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintKeysAndValues( IDictionary^ myCol ) -{ - Console::WriteLine( " KEY VALUE" ); - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = safe_cast(myEnum->Current); - Console::WriteLine( " {0,-25} {1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new HybridDictionary. - HybridDictionary^ myCol = gcnew HybridDictionary; - myCol->Add( "Braeburn Apples", "1.49" ); - myCol->Add( "Fuji Apples", "1.29" ); - myCol->Add( "Gala Apples", "1.49" ); - myCol->Add( "Golden Delicious Apples", "1.29" ); - myCol->Add( "Granny Smith Apples", "0.89" ); - myCol->Add( "Red Delicious Apples", "0.99" ); - myCol->Add( "Plantain Bananas", "1.49" ); - myCol->Add( "Yellow Bananas", "0.79" ); - myCol->Add( "Strawberries", "3.33" ); - myCol->Add( "Cranberries", "5.98" ); - myCol->Add( "Navel Oranges", "1.29" ); - myCol->Add( "Grapes", "1.99" ); - myCol->Add( "Honeydew Melon", "0.59" ); - myCol->Add( "Seedless Watermelon", "0.49" ); - myCol->Add( "Pineapple", "1.49" ); - myCol->Add( "Nectarine", "1.99" ); - myCol->Add( "Plums", "1.69" ); - myCol->Add( "Peaches", "1.99" ); - - // Displays the values in the HybridDictionary in three different ways. - Console::WriteLine( "Initial contents of the HybridDictionary:" ); - PrintKeysAndValues( myCol ); - - // Deletes a key. - myCol->Remove( "Plums" ); - Console::WriteLine( "The collection contains the following elements after removing \"Plums\":" ); - PrintKeysAndValues( myCol ); - - // Clears the entire collection. - myCol->Clear(); - Console::WriteLine( "The collection contains the following elements after it is cleared:" ); - PrintKeysAndValues( myCol ); -} - -/* -This code produces output similar to the following: - -Initial contents of the HybridDictionary: - KEY VALUE - Seedless Watermelon 0.49 - Nectarine 1.99 - Cranberries 5.98 - Plantain Bananas 1.49 - Honeydew Melon 0.59 - Pineapple 1.49 - Strawberries 3.33 - Grapes 1.99 - Braeburn Apples 1.49 - Peaches 1.99 - Red Delicious Apples 0.99 - Golden Delicious Apples 1.29 - Yellow Bananas 0.79 - Granny Smith Apples 0.89 - Gala Apples 1.49 - Plums 1.69 - Navel Oranges 1.29 - Fuji Apples 1.29 - -The collection contains the following elements after removing "Plums": - KEY VALUE - Seedless Watermelon 0.49 - Nectarine 1.99 - Cranberries 5.98 - Plantain Bananas 1.49 - Honeydew Melon 0.59 - Pineapple 1.49 - Strawberries 3.33 - Grapes 1.99 - Braeburn Apples 1.49 - Peaches 1.99 - Red Delicious Apples 0.99 - Golden Delicious Apples 1.29 - Yellow Bananas 0.79 - Granny Smith Apples 0.89 - Gala Apples 1.49 - Navel Oranges 1.29 - Fuji Apples 1.29 - -The collection contains the following elements after it is cleared: - KEY VALUE - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Contains/CPP/hybriddictionary_contains.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Contains/CPP/hybriddictionary_contains.cpp deleted file mode 100644 index 831a5749541..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Contains/CPP/hybriddictionary_contains.cpp +++ /dev/null @@ -1,87 +0,0 @@ - - -// The following code example searches for an element in a HybridDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintKeysAndValues( IDictionary^ myCol ) -{ - Console::WriteLine( " KEY VALUE" ); - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = safe_cast(myEnum->Current); - Console::WriteLine( " {0,-25} {1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new HybridDictionary. - HybridDictionary^ myCol = gcnew HybridDictionary; - myCol->Add( "Braeburn Apples", "1.49" ); - myCol->Add( "Fuji Apples", "1.29" ); - myCol->Add( "Gala Apples", "1.49" ); - myCol->Add( "Golden Delicious Apples", "1.29" ); - myCol->Add( "Granny Smith Apples", "0.89" ); - myCol->Add( "Red Delicious Apples", "0.99" ); - myCol->Add( "Plantain Bananas", "1.49" ); - myCol->Add( "Yellow Bananas", "0.79" ); - myCol->Add( "Strawberries", "3.33" ); - myCol->Add( "Cranberries", "5.98" ); - myCol->Add( "Navel Oranges", "1.29" ); - myCol->Add( "Grapes", "1.99" ); - myCol->Add( "Honeydew Melon", "0.59" ); - myCol->Add( "Seedless Watermelon", "0.49" ); - myCol->Add( "Pineapple", "1.49" ); - myCol->Add( "Nectarine", "1.99" ); - myCol->Add( "Plums", "1.69" ); - myCol->Add( "Peaches", "1.99" ); - - // Displays the values in the HybridDictionary in three different ways. - Console::WriteLine( "Initial contents of the HybridDictionary:" ); - PrintKeysAndValues( myCol ); - - // Searches for a key. - if ( myCol->Contains( "Kiwis" ) ) - Console::WriteLine( "The collection contains the key \"Kiwis\"." ); - else - Console::WriteLine( "The collection does not contain the key \"Kiwis\"." ); - - Console::WriteLine(); -} - -/* -This code produces output similar to the following: - -Initial contents of the HybridDictionary: - KEY VALUE - Seedless Watermelon 0.49 - Nectarine 1.99 - Cranberries 5.98 - Plantain Bananas 1.49 - Honeydew Melon 0.59 - Pineapple 1.49 - Strawberries 3.33 - Grapes 1.99 - Braeburn Apples 1.49 - Peaches 1.99 - Red Delicious Apples 0.99 - Golden Delicious Apples 1.29 - Yellow Bananas 0.79 - Granny Smith Apples 0.89 - Gala Apples 1.49 - Plums 1.69 - Navel Oranges 1.29 - Fuji Apples 1.29 - -The collection does not contain the key "Kiwis". - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_CopyTo/CPP/hybriddictionary_copyto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_CopyTo/CPP/hybriddictionary_copyto.cpp deleted file mode 100644 index b50664695a8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_CopyTo/CPP/hybriddictionary_copyto.cpp +++ /dev/null @@ -1,109 +0,0 @@ - - -// The following code example copies the elements of a HybridDictionary to an array. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintKeysAndValues( IDictionary^ myCol ) -{ - Console::WriteLine( " KEY VALUE" ); - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = safe_cast(myEnum->Current); - Console::WriteLine( " {0,-25} {1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new HybridDictionary. - HybridDictionary^ myCol = gcnew HybridDictionary; - myCol->Add( "Braeburn Apples", "1.49" ); - myCol->Add( "Fuji Apples", "1.29" ); - myCol->Add( "Gala Apples", "1.49" ); - myCol->Add( "Golden Delicious Apples", "1.29" ); - myCol->Add( "Granny Smith Apples", "0.89" ); - myCol->Add( "Red Delicious Apples", "0.99" ); - myCol->Add( "Plantain Bananas", "1.49" ); - myCol->Add( "Yellow Bananas", "0.79" ); - myCol->Add( "Strawberries", "3.33" ); - myCol->Add( "Cranberries", "5.98" ); - myCol->Add( "Navel Oranges", "1.29" ); - myCol->Add( "Grapes", "1.99" ); - myCol->Add( "Honeydew Melon", "0.59" ); - myCol->Add( "Seedless Watermelon", "0.49" ); - myCol->Add( "Pineapple", "1.49" ); - myCol->Add( "Nectarine", "1.99" ); - myCol->Add( "Plums", "1.69" ); - myCol->Add( "Peaches", "1.99" ); - - // Displays the values in the HybridDictionary in three different ways. - Console::WriteLine( "Initial contents of the HybridDictionary:" ); - PrintKeysAndValues( myCol ); - - // Copies the HybridDictionary to an array with DictionaryEntry elements. - array^myArr = gcnew array(myCol->Count); - myCol->CopyTo( myArr, 0 ); - - // Displays the values in the array. - Console::WriteLine( "Displays the elements in the array:" ); - Console::WriteLine( " KEY VALUE" ); - for ( int i = 0; i < myArr->Length; i++ ) - Console::WriteLine( " {0,-25} {1}", myArr[ i ].Key, myArr[ i ].Value ); - Console::WriteLine(); -} - -/* -This code produces output similar to the following: - -Initial contents of the HybridDictionary: - KEY VALUE - Seedless Watermelon 0.49 - Nectarine 1.99 - Cranberries 5.98 - Plantain Bananas 1.49 - Honeydew Melon 0.59 - Pineapple 1.49 - Strawberries 3.33 - Grapes 1.99 - Braeburn Apples 1.49 - Peaches 1.99 - Red Delicious Apples 0.99 - Golden Delicious Apples 1.29 - Yellow Bananas 0.79 - Granny Smith Apples 0.89 - Gala Apples 1.49 - Plums 1.69 - Navel Oranges 1.29 - Fuji Apples 1.29 - -Displays the elements in the array: - KEY VALUE - Seedless Watermelon 0.49 - Nectarine 1.99 - Cranberries 5.98 - Plantain Bananas 1.49 - Honeydew Melon 0.59 - Pineapple 1.49 - Strawberries 3.33 - Grapes 1.99 - Braeburn Apples 1.49 - Peaches 1.99 - Red Delicious Apples 0.99 - Golden Delicious Apples 1.29 - Yellow Bananas 0.79 - Granny Smith Apples 0.89 - Gala Apples 1.49 - Plums 1.69 - Navel Oranges 1.29 - Fuji Apples 1.29 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp deleted file mode 100644 index 1966022fe36..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// The following code example enumerates the elements of a HybridDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -void PrintKeysAndValues1( IDictionary^ myCol ); -void PrintKeysAndValues2( IDictionary^ myCol ); -void PrintKeysAndValues3( HybridDictionary^ myCol ); - -int main() -{ - // Creates and initializes a new HybridDictionary. - HybridDictionary^ myCol = gcnew HybridDictionary; - myCol->Add( "Braeburn Apples", "1.49" ); - myCol->Add( "Fuji Apples", "1.29" ); - myCol->Add( "Gala Apples", "1.49" ); - myCol->Add( "Golden Delicious Apples", "1.29" ); - myCol->Add( "Granny Smith Apples", "0.89" ); - myCol->Add( "Red Delicious Apples", "0.99" ); - myCol->Add( "Plantain Bananas", "1.49" ); - myCol->Add( "Yellow Bananas", "0.79" ); - myCol->Add( "Strawberries", "3.33" ); - myCol->Add( "Cranberries", "5.98" ); - myCol->Add( "Navel Oranges", "1.29" ); - myCol->Add( "Grapes", "1.99" ); - myCol->Add( "Honeydew Melon", "0.59" ); - myCol->Add( "Seedless Watermelon", "0.49" ); - myCol->Add( "Pineapple", "1.49" ); - myCol->Add( "Nectarine", "1.99" ); - myCol->Add( "Plums", "1.69" ); - myCol->Add( "Peaches", "1.99" ); - - // Display the contents of the collection using for each. This is the preferred method. - Console::WriteLine( "Displays the elements using for each:" ); - PrintKeysAndValues1( myCol ); - - // Display the contents of the collection using the enumerator. - Console::WriteLine( "Displays the elements using the IDictionaryEnumerator:" ); - PrintKeysAndValues2( myCol ); - - // Display the contents of the collection using the Keys, Values, Count, and Item properties. - Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" ); - PrintKeysAndValues3( myCol ); -} - -// Uses the foreach statement which hides the complexity of the enumerator. -// NOTE: The foreach statement is the preferred way of enumerating the contents of a collection. -void PrintKeysAndValues1( IDictionary^ myCol ) { - Console::WriteLine( " KEY VALUE" ); - for each ( DictionaryEntry^ de in myCol ) - Console::WriteLine( " {0,-25} {1}", de->Key, de->Value ); - Console::WriteLine(); -} - -// Uses the enumerator. -void PrintKeysAndValues2( IDictionary^ myCol ) -{ - IDictionaryEnumerator^ myEnumerator = myCol->GetEnumerator(); - Console::WriteLine( " KEY VALUE" ); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( " {0,-25} {1}", myEnumerator->Key, myEnumerator->Value ); - - Console::WriteLine(); -} - -// Uses the Keys, Values, Count, and Item properties. -void PrintKeysAndValues3( HybridDictionary^ myCol ) -{ - array^myKeys = gcnew array(myCol->Count); - myCol->Keys->CopyTo( myKeys, 0 ); - Console::WriteLine( " INDEX KEY VALUE" ); - for ( int i = 0; i < myCol->Count; i++ ) - Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] ); - Console::WriteLine(); -} - -/* -This code produces output similar to the following: - -Displays the elements using for each: - KEY VALUE - Seedless Watermelon 0.49 - Nectarine 1.99 - Cranberries 5.98 - Plantain Bananas 1.49 - Honeydew Melon 0.59 - Pineapple 1.49 - Strawberries 3.33 - Grapes 1.99 - Braeburn Apples 1.49 - Peaches 1.99 - Red Delicious Apples 0.99 - Golden Delicious Apples 1.29 - Yellow Bananas 0.79 - Granny Smith Apples 0.89 - Gala Apples 1.49 - Plums 1.69 - Navel Oranges 1.29 - Fuji Apples 1.29 - -Displays the elements using the IDictionaryEnumerator: - KEY VALUE - Seedless Watermelon 0.49 - Nectarine 1.99 - Cranberries 5.98 - Plantain Bananas 1.49 - Honeydew Melon 0.59 - Pineapple 1.49 - Strawberries 3.33 - Grapes 1.99 - Braeburn Apples 1.49 - Peaches 1.99 - Red Delicious Apples 0.99 - Golden Delicious Apples 1.29 - Yellow Bananas 0.79 - Granny Smith Apples 0.89 - Gala Apples 1.49 - Plums 1.69 - Navel Oranges 1.29 - Fuji Apples 1.29 - -Displays the elements using the Keys, Values, Count, and Item properties: - INDEX KEY VALUE - 0 Seedless Watermelon 0.49 - 1 Nectarine 1.99 - 2 Cranberries 5.98 - 3 Plantain Bananas 1.49 - 4 Honeydew Melon 0.59 - 5 Pineapple 1.49 - 6 Strawberries 3.33 - 7 Grapes 1.99 - 8 Braeburn Apples 1.49 - 9 Peaches 1.99 - 10 Red Delicious Apples 0.99 - 11 Golden Delicious Apples 1.29 - 12 Yellow Bananas 0.79 - 13 Granny Smith Apples 0.89 - 14 Gala Apples 1.49 - 15 Plums 1.69 - 16 Navel Oranges 1.29 - 17 Fuji Apples 1.29 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp deleted file mode 100644 index 641e2daadd9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp +++ /dev/null @@ -1,318 +0,0 @@ -// - -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -// -public ref class PeopleEnum : IDictionaryEnumerator -{ -private: - // Enumerators are positioned before the first element - // until the first MoveNext() call. - int position; - ArrayList^ _people; - -public: - PeopleEnum(ArrayList^ list) - { - this->Reset(); - _people = list; - } - - virtual bool MoveNext() - { - position++; - return (position < _people->Count); - } - - virtual void Reset() - { - position = -1; - } - - virtual property Object^ Current - { - Object^ get() - { - try - { - return _people[position]; - } - catch (IndexOutOfRangeException^) - { - throw gcnew InvalidOperationException(); - } - } - } - - virtual property DictionaryEntry Entry - { - DictionaryEntry get() - { - return (DictionaryEntry)(Current); - } - } - - virtual property Object^ Key - { - Object^ get() - { - try - { - return ((DictionaryEntry^)_people[position])->Key; - } - catch (IndexOutOfRangeException^) - { - throw gcnew InvalidOperationException(); - } - } - } - - virtual property Object^ Value - { - Object^ get() - { - try - { - return ((DictionaryEntry^)_people[position])->Value; - } - catch (IndexOutOfRangeException^) - { - throw gcnew InvalidOperationException(); - } - } - } -}; - -public ref class People : IOrderedDictionary -{ -private: - ArrayList^ _people; - -public: - People(int numItems) - { - _people = gcnew ArrayList(numItems); - } - - int IndexOfKey(Object^ key) - { - for (int i = 0; i < _people->Count; i++) - { - if (((DictionaryEntry^)_people[i])->Key == key) - return i; - } - - // key not found, return -1. - return -1; - } - - virtual property Object^ default[Object^] - { - Object^ get(Object^ key) - { - return ((DictionaryEntry^)_people[IndexOfKey(key)])->Value; - } - void set(Object^ key, Object^ value) - { - _people[IndexOfKey(key)] = gcnew DictionaryEntry(key, value); - } - } - - // IOrderedDictionary Members - virtual IDictionaryEnumerator^ GetEnumerator() - { - return gcnew PeopleEnum(_people); - } - - virtual void Insert(int index, Object^ key, Object^ value) - { - if (IndexOfKey(key) != -1) - { - throw gcnew ArgumentException("An element with the same key already exists in the collection."); - } - _people->Insert(index, gcnew DictionaryEntry(key, value)); - } - - virtual void RemoveAt(int index) - { - _people->RemoveAt(index); - } - - virtual property Object^ default[int] - { - Object^ get(int index) - { - return ((DictionaryEntry^)_people[index])->Value; - } - void set(int index, Object^ value) - { - Object^ key = ((DictionaryEntry^)_people[index])->Key; - _people[index] = gcnew DictionaryEntry(key, value); - } - } - - // IDictionary Members - - virtual void Add(Object^ key, Object^ value) - { - if (IndexOfKey(key) != -1) - { - throw gcnew ArgumentException("An element with the same key already exists in the collection."); - } - _people->Add(gcnew DictionaryEntry(key, value)); - } - - virtual void Clear() - { - _people->Clear(); - } - - virtual bool Contains(Object^ key) - { - if (IndexOfKey(key) == -1) - { - return false; - } - else - { - return true; - } - } - - virtual property bool IsFixedSize - { - bool get() - { - return false; - } - } - - virtual property bool IsReadOnly - { - bool get() - { - return false; - } - } - - virtual property ICollection^ Keys - { - ICollection^ get() - { - ArrayList^ KeyCollection = gcnew ArrayList(_people->Count); - for (int i = 0; i < _people->Count; i++) - { - KeyCollection->Add( ((DictionaryEntry^)_people[i])->Key ); - } - return KeyCollection; - } - } - - virtual void Remove(Object^ key) - { - _people->RemoveAt(IndexOfKey(key)); - } - - virtual property ICollection^ Values - { - ICollection ^get() - { - ArrayList^ ValueCollection = gcnew ArrayList(_people->Count); - for (int i = 0; i < _people->Count; i++) - { - ValueCollection->Add( ((DictionaryEntry^)_people[i])->Value ); - } - return ValueCollection; - } - } - - // ICollection Members - - virtual void CopyTo(Array^ array, int index) - { - _people->CopyTo(array, index); - } - - virtual property int Count - { - int get() - { - return _people->Count; - } - } - - virtual property bool IsSynchronized - { - bool get() - { - return _people->IsSynchronized; - } - } - - virtual property Object^ SyncRoot - { - Object^ get() - { - return _people->SyncRoot; - } - } - - // IEnumerable Members - - virtual IEnumerator^ IfcGetEnumerator() = IEnumerable::GetEnumerator - { - return (IEnumerator^) gcnew PeopleEnum(_people); - } -}; -// - -class App -{ -public: - static void Main() - { - People^ peopleCollection = gcnew People(3); - peopleCollection->Add("John", "Smith"); - peopleCollection->Add("Jim", "Johnson"); - peopleCollection->Add("Sue", "Rabon"); - - Console::WriteLine("Displaying the entries in peopleCollection:"); - for each (DictionaryEntry^ de in peopleCollection) - { - Console::WriteLine("{0} {1}", de->Key, de->Value); - } - Console::WriteLine(); - Console::WriteLine("Displaying the entries in the modified peopleCollection:"); - peopleCollection["Jim"] = "Jackson"; - peopleCollection->Remove("Sue"); - peopleCollection->Insert(0, "Fred", "Anderson"); - - for each (DictionaryEntry^ de in peopleCollection) - { - Console::WriteLine("{0} {1}", de->Key, de->Value); - } - - } -}; - -int main() -{ - App::Main(); -} -/* This code produces output similar to the following: - * - * Displaying the entries in peopleCollection: - * John Smith - * Jim Johnson - * Sue Rabon - * - * Displaying the entries in the modified peopleCollection: - * Fred Anderson - * John Smith - * Jim Jackson - */ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/remarks.cpp deleted file mode 100644 index 05fe0cdd917..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/remarks.cpp +++ /dev/null @@ -1,297 +0,0 @@ - -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class ODEnum : IDictionaryEnumerator -{ -private: - // Enumerators are positioned before the first element - // until the first MoveNext() call. - int position; - ArrayList^ itemlist; - -public: - ODEnum(ArrayList^ list) - { - this->Reset(); - itemlist = list; - } - - virtual bool MoveNext() - { - position++; - return (position < itemlist->Count); - } - - virtual void Reset() - { - position = -1; - } - - virtual property Object^ Current - { - Object^ get() - { - try - { - return itemlist[position]; - } - catch (IndexOutOfRangeException^) - { - throw gcnew InvalidOperationException(); - } - } - } - - virtual property DictionaryEntry Entry - { - DictionaryEntry get() - { - return (DictionaryEntry)(Current); - } - } - - virtual property Object^ Key - { - Object^ get() - { - try - { - return ((DictionaryEntry^)itemlist[position])->Key; - } - catch (IndexOutOfRangeException^) - { - throw gcnew InvalidOperationException(); - } - } - } - - virtual property Object^ Value - { - Object^ get() - { - try - { - return ((DictionaryEntry^)itemlist[position])->Value; - } - catch (IndexOutOfRangeException^) - { - throw gcnew InvalidOperationException(); - } - } - } -}; - -public ref class SimpleOD : IOrderedDictionary -{ -private: - ArrayList^ itemlist; - -public: - SimpleOD(int numItems) - { - itemlist = gcnew ArrayList(numItems); - } - - int IndexOfKey(Object^ key) - { - for (int i = 0; i < itemlist->Count; i++) - { - if (((DictionaryEntry^)itemlist[i])->Key == key) - return i; - } - - // key not found, return -1. - return -1; - } - - virtual property Object^ default[Object^] - { - Object^ get(Object^ key) - { - return ((DictionaryEntry^)itemlist[IndexOfKey(key)])->Value; - } - void set(Object^ key, Object^ value) - { - itemlist[IndexOfKey(key)] = gcnew DictionaryEntry(key, value); - } - } - - // IOrderedDictionary Members - virtual IDictionaryEnumerator^ GetEnumerator() - { - return gcnew ODEnum(itemlist); - } - - virtual void Insert(int index, Object^ key, Object^ value) - { - if (IndexOfKey(key) != -1) - { - throw gcnew ArgumentException("An element with the same key already exists in the collection."); - } - itemlist->Insert(index, gcnew DictionaryEntry(key, value)); - } - - virtual void RemoveAt(int index) - { - itemlist->RemoveAt(index); - } - - virtual property Object^ default[int] - { - Object^ get(int index) - { - return ((DictionaryEntry^)itemlist[index])->Value; - } - void set(int index, Object^ value) - { - Object^ key = ((DictionaryEntry^)itemlist[index])->Key; - itemlist[index] = gcnew DictionaryEntry(Keys, value); - } - } - - // IDictionary Members - - virtual void Add(Object^ key, Object^ value) - { - if (IndexOfKey(key) != -1) - { - throw gcnew ArgumentException("An element with the same key already exists in the collection."); - } - itemlist->Add(gcnew DictionaryEntry(key, value)); - } - - virtual void Clear() - { - itemlist->Clear(); - } - - virtual bool Contains(Object^ key) - { - if (IndexOfKey(key) == -1) - { - return false; - } - else - { - return true; - } - } - - virtual property bool IsFixedSize - { - bool get() - { - return false; - } - } - - virtual property bool IsReadOnly - { - bool get() - { - return false; - } - } - - virtual property ICollection^ Keys - { - ICollection^ get() - { - ArrayList^ KeyCollection = gcnew ArrayList(itemlist->Count); - for (int i = 0; i < itemlist->Count; i++) - { - KeyCollection[i] = ((DictionaryEntry^)itemlist[i])->Key; - } - return KeyCollection; - } - } - - virtual void Remove(Object^ key) - { - itemlist->RemoveAt(IndexOfKey(key)); - } - - virtual property ICollection^ Values - { - ICollection ^get() - { - ArrayList^ ValueCollection = gcnew ArrayList(itemlist->Count); - for (int i = 0; i < itemlist->Count; i++) - { - ValueCollection[i] = ((DictionaryEntry^)itemlist[i])->Value; - } - return ValueCollection; - } - } - - // ICollection Members - - virtual void CopyTo(Array^ array, int index) - { - itemlist->CopyTo(array, index); - } - - virtual property int Count - { - int get() - { - return itemlist->Count; - } - } - - virtual property bool IsSynchronized - { - bool get() - { - return itemlist->IsSynchronized; - } - } - - virtual property Object^ SyncRoot - { - Object^ get() - { - return itemlist->SyncRoot; - } - } - - // IEnumerable Members - - virtual IEnumerator^ IfcGetEnumerator() = IEnumerable::GetEnumerator - { - return (IEnumerator^) gcnew ODEnum(itemlist); - } -}; - -class App -{ -public: - static void Main() - { - int index = 1; - - SimpleOD^ myOrderedDictionary = gcnew SimpleOD(2); - myOrderedDictionary->Add("Way", "ToGo"); - myOrderedDictionary->Add("Far", "Out"); - - Object^ obj; - // - obj = myOrderedDictionary[index]; - // - // - for each (DictionaryEntry de in myOrderedDictionary) - { - //... - } - // - } -}; - -int main() -{ - App::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/listdictionary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/listdictionary.cpp deleted file mode 100644 index d1760135b98..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/listdictionary.cpp +++ /dev/null @@ -1,151 +0,0 @@ -// The following code example demonstrates several of the properties and methods of ListDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -void PrintKeysAndValues1( IDictionary^ myCol ); -void PrintKeysAndValues2( IDictionary^ myCol ); -void PrintKeysAndValues3( ListDictionary^ myCol ); - -int main() -{ - // Creates and initializes a new ListDictionary. - ListDictionary^ myCol = gcnew ListDictionary; - myCol->Add( "Braeburn Apples", "1.49" ); - myCol->Add( "Fuji Apples", "1.29" ); - myCol->Add( "Gala Apples", "1.49" ); - myCol->Add( "Golden Delicious Apples", "1.29" ); - myCol->Add( "Granny Smith Apples", "0.89" ); - myCol->Add( "Red Delicious Apples", "0.99" ); - - // Display the contents of the collection using for each. This is the preferred method. - Console::WriteLine( "Displays the elements using for each:" ); - PrintKeysAndValues1( myCol ); - - // Display the contents of the collection using the enumerator. - Console::WriteLine( "Displays the elements using the IDictionaryEnumerator:" ); - PrintKeysAndValues2( myCol ); - - // Display the contents of the collection using the Keys, Values, Count, and Item properties. - Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" ); - PrintKeysAndValues3( myCol ); - - // Copies the ListDictionary to an array with DictionaryEntry elements. - array^myArr = gcnew array(myCol->Count); - myCol->CopyTo( myArr, 0 ); - - // Displays the values in the array. - Console::WriteLine( "Displays the elements in the array:" ); - Console::WriteLine( " KEY VALUE" ); - for ( int i = 0; i < myArr->Length; i++ ) - Console::WriteLine( " {0,-25} {1}", myArr[ i ].Key, myArr[ i ].Value ); - Console::WriteLine(); - - // Searches for a key. - if ( myCol->Contains( "Kiwis" ) ) - Console::WriteLine( "The collection contains the key \"Kiwis\"." ); - else - Console::WriteLine( "The collection does not contain the key \"Kiwis\"." ); - - Console::WriteLine(); - - // Deletes a key. - myCol->Remove( "Plums" ); - Console::WriteLine( "The collection contains the following elements after removing \"Plums\":" ); - PrintKeysAndValues2( myCol ); - - // Clears the entire collection. - myCol->Clear(); - Console::WriteLine( "The collection contains the following elements after it is cleared:" ); - PrintKeysAndValues2( myCol ); -} - -// Uses the for each statement which hides the complexity of the enumerator. -// NOTE: The for each statement is the preferred way of enumerating the contents of a collection. -void PrintKeysAndValues1( IDictionary^ myCol ) { - Console::WriteLine( " KEY VALUE" ); - for each ( DictionaryEntry^ de in myCol ) - Console::WriteLine( " {0,-25} {1}", de->Key, de->Value ); - Console::WriteLine(); -} - -// Uses the enumerator. -void PrintKeysAndValues2( IDictionary^ myCol ) -{ - IDictionaryEnumerator^ myEnumerator = myCol->GetEnumerator(); - Console::WriteLine( " KEY VALUE" ); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( " {0,-25} {1}", myEnumerator->Key, myEnumerator->Value ); - Console::WriteLine(); -} - -// Uses the Keys, Values, Count, and Item properties. -void PrintKeysAndValues3( ListDictionary^ myCol ) -{ - array^myKeys = gcnew array(myCol->Count); - myCol->Keys->CopyTo( myKeys, 0 ); - Console::WriteLine( " INDEX KEY VALUE" ); - for ( int i = 0; i < myCol->Count; i++ ) - Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] ); - Console::WriteLine(); -} - -/* -This code produces the following output. - -Displays the elements using for each: - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Gala Apples 1.49 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -Displays the elements using the IDictionaryEnumerator: - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Gala Apples 1.49 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -Displays the elements using the Keys, Values, Count, and Item properties: - INDEX KEY VALUE - 0 Braeburn Apples 1.49 - 1 Fuji Apples 1.29 - 2 Gala Apples 1.49 - 3 Golden Delicious Apples 1.29 - 4 Granny Smith Apples 0.89 - 5 Red Delicious Apples 0.99 - -Displays the elements in the array: - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Gala Apples 1.49 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -The collection does not contain the key "Kiwis". - -The collection contains the following elements after removing "Plums": - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Gala Apples 1.49 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -The collection contains the following elements after it is cleared: - KEY VALUE - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/source2.cpp deleted file mode 100644 index 0f3452dcd52..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/source2.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::Threading; - -public ref class SamplesListDictionary -{ -public: - static void Main() - { - // - ListDictionary^ myCollection = gcnew ListDictionary(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection) - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } - - static void Dummy() - { - ListDictionary^ myListDictionary = gcnew ListDictionary(); - // - for each (DictionaryEntry de in myListDictionary) - { - //... - } - // - } -}; - -int main() -{ - SamplesListDictionary::Main(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/CPP/listdictionary_addremove.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/CPP/listdictionary_addremove.cpp deleted file mode 100644 index ef13cdd9540..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/CPP/listdictionary_addremove.cpp +++ /dev/null @@ -1,74 +0,0 @@ - - -// The following code example adds to and removes elements from a ListDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintKeysAndValues( IDictionary^ myCol ) -{ - Console::WriteLine( " KEY VALUE" ); - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = safe_cast(myEnum->Current); - Console::WriteLine( " {0,-25} {1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new ListDictionary. - ListDictionary^ myCol = gcnew ListDictionary; - myCol->Add( "Braeburn Apples", "1.49" ); - myCol->Add( "Fuji Apples", "1.29" ); - myCol->Add( "Gala Apples", "1.49" ); - myCol->Add( "Golden Delicious Apples", "1.29" ); - myCol->Add( "Granny Smith Apples", "0.89" ); - myCol->Add( "Red Delicious Apples", "0.99" ); - - // Displays the values in the ListDictionary in three different ways. - Console::WriteLine( "Initial contents of the ListDictionary:" ); - PrintKeysAndValues( myCol ); - - // Deletes a key. - myCol->Remove( "Gala Apples" ); - Console::WriteLine( "The collection contains the following elements after removing \"Gala Apples\":" ); - PrintKeysAndValues( myCol ); - - // Clears the entire collection. - myCol->Clear(); - Console::WriteLine( "The collection contains the following elements after it is cleared:" ); - PrintKeysAndValues( myCol ); -} - -/* -This code produces the following output. - -Initial contents of the ListDictionary: - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Gala Apples 1.49 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -The collection contains the following elements after removing "Gala Apples": - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -The collection contains the following elements after it is cleared: - KEY VALUE - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Contains/CPP/listdictionary_contains.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Contains/CPP/listdictionary_contains.cpp deleted file mode 100644 index ba69388921b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Contains/CPP/listdictionary_contains.cpp +++ /dev/null @@ -1,63 +0,0 @@ - - -// The following code example searches for an element in a ListDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintKeysAndValues( IDictionary^ myCol ) -{ - Console::WriteLine( " KEY VALUE" ); - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = safe_cast(myEnum->Current); - Console::WriteLine( " {0,-25} {1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new ListDictionary. - ListDictionary^ myCol = gcnew ListDictionary; - myCol->Add( "Braeburn Apples", "1.49" ); - myCol->Add( "Fuji Apples", "1.29" ); - myCol->Add( "Gala Apples", "1.49" ); - myCol->Add( "Golden Delicious Apples", "1.29" ); - myCol->Add( "Granny Smith Apples", "0.89" ); - myCol->Add( "Red Delicious Apples", "0.99" ); - - // Displays the values in the ListDictionary in three different ways. - Console::WriteLine( "Initial contents of the ListDictionary:" ); - PrintKeysAndValues( myCol ); - - // Searches for a key. - if ( myCol->Contains( "Kiwis" ) ) - Console::WriteLine( "The collection contains the key \"Kiwis\"." ); - else - Console::WriteLine( "The collection does not contain the key \"Kiwis\"." ); - - Console::WriteLine(); -} - -/* -This code produces the following output. - -Initial contents of the ListDictionary: - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Gala Apples 1.49 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -The collection does not contain the key "Kiwis". - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_CopyTo/CPP/listdictionary_copyto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_CopyTo/CPP/listdictionary_copyto.cpp deleted file mode 100644 index 772edf629f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_CopyTo/CPP/listdictionary_copyto.cpp +++ /dev/null @@ -1,73 +0,0 @@ - - -// The following code example copies the elements of a ListDictionary to an array. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintKeysAndValues( IDictionary^ myCol ) -{ - Console::WriteLine( " KEY VALUE" ); - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry de = safe_cast(myEnum->Current); - Console::WriteLine( " {0,-25} {1}", de.Key, de.Value ); - } - - Console::WriteLine(); -} - -int main() -{ - - // Creates and initializes a new ListDictionary. - ListDictionary^ myCol = gcnew ListDictionary; - myCol->Add( "Braeburn Apples", "1.49" ); - myCol->Add( "Fuji Apples", "1.29" ); - myCol->Add( "Gala Apples", "1.49" ); - myCol->Add( "Golden Delicious Apples", "1.29" ); - myCol->Add( "Granny Smith Apples", "0.89" ); - myCol->Add( "Red Delicious Apples", "0.99" ); - - // Displays the values in the ListDictionary in three different ways. - Console::WriteLine( "Initial contents of the ListDictionary:" ); - PrintKeysAndValues( myCol ); - - // Copies the ListDictionary to an array with DictionaryEntry elements. - array^myArr = gcnew array(myCol->Count); - myCol->CopyTo( myArr, 0 ); - - // Displays the values in the array. - Console::WriteLine( "Displays the elements in the array:" ); - Console::WriteLine( " KEY VALUE" ); - for ( int i = 0; i < myArr->Length; i++ ) - Console::WriteLine( " {0,-25} {1}", myArr[ i ].Key, myArr[ i ].Value ); - Console::WriteLine(); -} - -/* -This code produces the following output. - -Initial contents of the ListDictionary: - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Gala Apples 1.49 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -Displays the elements in the array: - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Gala Apples 1.49 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp deleted file mode 100644 index 2a525d94ac8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// The following code example enumerates the elements of a ListDictionary. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -void PrintKeysAndValues1( IDictionary^ myCol ); -void PrintKeysAndValues2( IDictionary^ myCol ); -void PrintKeysAndValues3( ListDictionary^ myCol ); - -int main() -{ - // Creates and initializes a new ListDictionary. - ListDictionary^ myCol = gcnew ListDictionary; - myCol->Add( "Braeburn Apples", "1.49" ); - myCol->Add( "Fuji Apples", "1.29" ); - myCol->Add( "Gala Apples", "1.49" ); - myCol->Add( "Golden Delicious Apples", "1.29" ); - myCol->Add( "Granny Smith Apples", "0.89" ); - myCol->Add( "Red Delicious Apples", "0.99" ); - - // Display the contents of the collection using for each. This is the preferred method. - Console::WriteLine( "Displays the elements using for each:" ); - PrintKeysAndValues1( myCol ); - - // Display the contents of the collection using the enumerator. - Console::WriteLine( "Displays the elements using the IDictionaryEnumerator:" ); - PrintKeysAndValues2( myCol ); - - // Display the contents of the collection using the Keys, Values, Count, and Item properties. - Console::WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" ); - PrintKeysAndValues3( myCol ); -} - -// Uses the for each statement which hides the complexity of the enumerator. -// NOTE: The for each statement is the preferred way of enumerating the contents of a collection. -void PrintKeysAndValues1( IDictionary^ myCol ) { - Console::WriteLine( " KEY VALUE" ); - for each ( DictionaryEntry^ de in myCol ) - Console::WriteLine( " {0,-25} {1}", de->Key, de->Value ); - Console::WriteLine(); -} - -// Uses the enumerator. -void PrintKeysAndValues2( IDictionary^ myCol ) -{ - IDictionaryEnumerator^ myEnumerator = myCol->GetEnumerator(); - Console::WriteLine( " KEY VALUE" ); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( " {0,-25} {1}", myEnumerator->Key, myEnumerator->Value ); - - Console::WriteLine(); -} - -// Uses the Keys, Values, Count, and Item properties. -void PrintKeysAndValues3( ListDictionary^ myCol ) -{ - array^myKeys = gcnew array(myCol->Count); - myCol->Keys->CopyTo( myKeys, 0 ); - Console::WriteLine( " INDEX KEY VALUE" ); - for ( int i = 0; i < myCol->Count; i++ ) - Console::WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[ i ], myCol[ myKeys[ i ] ] ); - Console::WriteLine(); -} - -/* -This code produces the following output. - -Displays the elements using for each: - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Gala Apples 1.49 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -Displays the elements using the IDictionaryEnumerator: - KEY VALUE - Braeburn Apples 1.49 - Fuji Apples 1.29 - Gala Apples 1.49 - Golden Delicious Apples 1.29 - Granny Smith Apples 0.89 - Red Delicious Apples 0.99 - -Displays the elements using the Keys, Values, Count, and Item properties: - INDEX KEY VALUE - 0 Braeburn Apples 1.49 - 1 Fuji Apples 1.29 - 2 Gala Apples 1.49 - 3 Golden Delicious Apples 1.29 - 4 Granny Smith Apples 0.89 - 5 Red Delicious Apples 0.99 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseAdd/CPP/nocb_baseadd.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseAdd/CPP/nocb_baseadd.cpp deleted file mode 100644 index e3a242ae17f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseAdd/CPP/nocb_baseadd.cpp +++ /dev/null @@ -1,65 +0,0 @@ - - -// The following example uses BaseAdd to create a new NameObjectCollectionBase with elements from another dictionary. -// For an expanded version of this example, see the NameObjectCollectionBase class topic. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -public ref class MyCollection: public NameObjectCollectionBase -{ -private: - DictionaryEntry _de; - -public: - - property DictionaryEntry Item [ int ] - { - // Gets a key-and-value pair (DictionaryEntry) using an index. - DictionaryEntry get( int index ) - { - _de.Key = this->BaseGetKey( index ); - _de.Value = this->BaseGet( index ); - return (_de); - } - } - - // Adds elements from an IDictionary* into the new collection. - MyCollection( IDictionary^ d ) - { - IEnumerator^ myEnum = d->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry^ de = safe_cast(myEnum->Current); - this->BaseAdd( safe_cast(de->Key), de->Value ); - } - } -}; - -int main() -{ - // Creates and initializes a new MyCollection instance. - IDictionary^ d = gcnew ListDictionary; - d->Add( "red", "apple" ); - d->Add( "yellow", "banana" ); - d->Add( "green", "pear" ); - MyCollection^ myCol = gcnew MyCollection( d ); - - // Displays the keys and values of the MyCollection instance. - for ( int i = 0; i < myCol->Count; i++ ) - { - Console::WriteLine( "[{0}] : {1}, {2}", i, myCol->Item[ i ].Key, myCol->Item[ i ].Value ); - } -} - -/* -This code produces the following output. - -[0] : red, apple -[1] : yellow, banana -[2] : green, pear - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseClear/CPP/nocb_baseclear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseClear/CPP/nocb_baseclear.cpp deleted file mode 100644 index 7dfd2cf7f8b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseClear/CPP/nocb_baseclear.cpp +++ /dev/null @@ -1,83 +0,0 @@ - - -// The following example uses BaseClear to remove all elements from a NameObjectCollectionBase. -// For an expanded version of this example, see the NameObjectCollectionBase class topic. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -public ref class MyCollection: public NameObjectCollectionBase -{ -private: - DictionaryEntry _de; - -public: - - property DictionaryEntry Item [ int ] - { - // Gets a key-and-value pair (DictionaryEntry) using an index. - DictionaryEntry get( int index ) - { - _de.Key = this->BaseGetKey( index ); - _de.Value = this->BaseGet( index ); - return (_de); - } - } - - // Adds elements from an IDictionary* into the new collection. - MyCollection( IDictionary^ d ) - { - IEnumerator^ myEnum = d->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry^ de = safe_cast(myEnum->Current); - this->BaseAdd( safe_cast(de->Key), de->Value ); - } - } - - // Clears all the elements in the collection. - void Clear() - { - this->BaseClear(); - } -}; - -static void PrintKeysAndValues( MyCollection^ myCol ) -{ - for ( int i = 0; i < myCol->Count; i++ ) - { - Console::WriteLine( "[{0}] : {1}, {2}", i, myCol->Item[ i ].Key, myCol->Item[ i ].Value ); - - } -} - -int main() -{ - // Creates and initializes a new MyCollection instance. - IDictionary^ d = gcnew ListDictionary; - d->Add( "red", "apple" ); - d->Add( "yellow", "banana" ); - d->Add( "green", "pear" ); - MyCollection^ myCol = gcnew MyCollection( d ); - Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count ); - PrintKeysAndValues( myCol ); - - // Removes all elements from the collection. - myCol->Clear(); - Console::WriteLine( "After clearing the collection (Count = {0}):", myCol->Count ); - PrintKeysAndValues( myCol ); -} - -/* -This code produces the following output. - -Initial state of the collection (Count = 3): -[0] : red, apple -[1] : yellow, banana -[2] : green, pear -After clearing the collection (Count = 0): - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGet/CPP/nocb_baseget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGet/CPP/nocb_baseget.cpp deleted file mode 100644 index d7954215945..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGet/CPP/nocb_baseget.cpp +++ /dev/null @@ -1,92 +0,0 @@ - -// The following example uses BaseGetKey and BaseGet to get specific keys and values. -// For an expanded version of this example, see the NameObjectCollectionBase class topic. - -// -#using -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class MyCollection : public NameObjectCollectionBase { - -private: - DictionaryEntry^ _de; - - // Gets a key-and-value pair (DictionaryEntry) using an index. -public: - property DictionaryEntry^ default[ int ] { - DictionaryEntry^ get( int index ) { - _de->Key = this->BaseGetKey( index ); - _de->Value = this->BaseGet( index ); - return( _de ); - } - } - - // Gets or sets the value associated with the specified key. - property Object^ default[ String^ ] { - Object^ get(String^ key) { - return( this->BaseGet( key ) ); - } - void set( String^ key, Object^ value ) { - this->BaseSet( key, value ); - } - } - - // Adds elements from an IDictionary into the new collection. - MyCollection( IDictionary^ d ) { - - _de = gcnew DictionaryEntry(); - - for each ( DictionaryEntry^ de in d ) { - this->BaseAdd( (String^) de->Key, de->Value ); - } - } -}; - -public ref class SamplesNameObjectCollectionBase { - -public: - static void Main() { - - // Creates and initializes a new MyCollection instance. - IDictionary^ d = gcnew ListDictionary(); - d->Add( "red", "apple" ); - d->Add( "yellow", "banana" ); - d->Add( "green", "pear" ); - MyCollection^ myCol = gcnew MyCollection( d ); - Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count ); - PrintKeysAndValues( myCol ); - - // Gets specific keys and values. - Console::WriteLine( "The key at index 0 is {0}.", myCol[0]->Key ); - Console::WriteLine( "The value at index 0 is {0}.", myCol[0]->Value ); - Console::WriteLine( "The value associated with the key \"green\" is {0}.", myCol["green"] ); - - } - - static void PrintKeysAndValues( MyCollection^ myCol ) { - for ( int i = 0; i < myCol->Count; i++ ) { - Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value ); - } - } -}; - -int main() -{ - SamplesNameObjectCollectionBase::Main(); -} - -/* -This code produces the following output. - -Initial state of the collection (Count = 3): -[0] : red, apple -[1] : yellow, banana -[2] : green, pear -The key at index 0 is red. -The value at index 0 is apple. -The value associated with the key "green" is pear. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGetAll/CPP/nocb_basegetall.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGetAll/CPP/nocb_basegetall.cpp deleted file mode 100644 index c96322f4cfa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGetAll/CPP/nocb_basegetall.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// The following example uses BaseGetAllKeys and BaseGetAllValues to get an array of the keys or an array of the values. -// For an expanded version of this example, see the NameObjectCollectionBase class topic. - -// -#using -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class MyCollection : public NameObjectCollectionBase { - -private: - DictionaryEntry^ _de; - - // Gets a key-and-value pair (DictionaryEntry) using an index. -public: - property DictionaryEntry^ default[ int ] { - DictionaryEntry^ get(int index) { - _de->Key = this->BaseGetKey( index ); - _de->Value = this->BaseGet( index ); - return( _de ); - } - } - - // Adds elements from an IDictionary into the new collection. - MyCollection( IDictionary^ d ) { - - _de = gcnew DictionaryEntry(); - - for each ( DictionaryEntry^ de in d ) { - this->BaseAdd( (String^) de->Key, de->Value ); - } - } - - // Gets a String array that contains all the keys in the collection. - property array^ AllKeys { - array^ get() { - return( this->BaseGetAllKeys() ); - } - } - - // Gets an Object array that contains all the values in the collection. - property Array^ AllValues { - Array^ get() { - return( this->BaseGetAllValues() ); - } - } - - // Gets a String array that contains all the values in the collection. - property array^ AllStringValues { - array^ get() { - return( (array^) this->BaseGetAllValues( System::String::typeid ) ); - } - } -}; - -public ref class SamplesNameObjectCollectionBase { - -public: - static void Main() { - - // Creates and initializes a new MyCollection instance. - IDictionary^ d = gcnew ListDictionary(); - d->Add( "red", "apple" ); - d->Add( "yellow", "banana" ); - d->Add( "green", "pear" ); - MyCollection^ myCol = gcnew MyCollection( d ); - Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count ); - PrintKeysAndValues( myCol ); - - // Displays the list of keys. - Console::WriteLine( "The list of keys:" ); - for each ( String^ s in myCol->AllKeys ) { - Console::WriteLine( " {0}", s ); - } - - // Displays the list of values of type Object. - Console::WriteLine( "The list of values (Object):" ); - for each ( Object^ o in myCol->AllValues ) { - Console::WriteLine( " {0}", o->ToString() ); - } - - // Displays the list of values of type String. - Console::WriteLine( "The list of values (String):" ); - for each ( String^ s in myCol->AllValues ) { - Console::WriteLine( " {0}", s ); - } - } - -public: - static void PrintKeysAndValues( MyCollection^ myCol ) { - for ( int i = 0; i < myCol->Count; i++ ) { - Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value ); - } - } -}; - -int main() -{ - SamplesNameObjectCollectionBase::Main(); -} - -/* -This code produces the following output. - -Initial state of the collection (Count = 3): -[0] : red, apple -[1] : yellow, banana -[2] : green, pear -The list of keys: - red - yellow - green -The list of values (Object): - apple - banana - pear -The list of values (String): - apple - banana - pear - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseHasKeys/CPP/nocb_basehaskeys.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseHasKeys/CPP/nocb_basehaskeys.cpp deleted file mode 100644 index 663a6cd5536..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseHasKeys/CPP/nocb_basehaskeys.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// The following example uses BaseHasKeys to determine if the collection contains keys that are not a null reference. -// For an expanded version of this example, see the NameObjectCollectionBase class topic. - -// -#using -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class MyCollection : public NameObjectCollectionBase { - -private: - DictionaryEntry^ _de; - - // Gets a key-and-value pair (DictionaryEntry) using an index. -public: - property DictionaryEntry^ default[ int ] { - DictionaryEntry^ get(int index) { - _de->Key = this->BaseGetKey( index ); - _de->Value = this->BaseGet( index ); - return( _de ); - } - } - - // Creates an empty collection. - MyCollection() { - _de = gcnew DictionaryEntry(); - } - - // Adds an entry to the collection. - void Add( String^ key, Object^ value ) { - this->BaseAdd( key, value ); - } - - // Gets a value indicating whether the collection contains keys that are not a null reference. - property Boolean HasKeys { - Boolean get() { - return( this->BaseHasKeys() ); - } - } -}; - -void PrintKeysAndValues( MyCollection^ myCol ) { - for ( int i = 0; i < myCol->Count; i++ ) { - Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value ); - } -} - -int main() { - - // Creates an empty MyCollection instance. - MyCollection^ myCol = gcnew MyCollection(); - Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count ); - PrintKeysAndValues( myCol ); - Console::WriteLine( "HasKeys? {0}", myCol->HasKeys ); - - Console::WriteLine(); - - // Adds an item to the collection. - myCol->Add( "blue", "sky" ); - Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count ); - PrintKeysAndValues( myCol ); - Console::WriteLine( "HasKeys? {0}", myCol->HasKeys ); - -} - -/* -This code produces the following output. - -Initial state of the collection (Count = 0): -HasKeys? False - -Initial state of the collection (Count = 1): -[0] : blue, sky -HasKeys? True - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseRemove/CPP/nocb_baseremove.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseRemove/CPP/nocb_baseremove.cpp deleted file mode 100644 index de50b6634e1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseRemove/CPP/nocb_baseremove.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// The following example uses BaseRemove and BaseRemoveAt to remove elements from a NameObjectCollectionBase. -// For an expanded version of this example, see the NameObjectCollectionBase class topic. - -// -#using -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class MyCollection : public NameObjectCollectionBase { - -private: - DictionaryEntry^ _de; - - // Gets a key-and-value pair (DictionaryEntry) using an index. -public: - property DictionaryEntry^ default[ int ] { - DictionaryEntry^ get(int index) { - _de->Key = this->BaseGetKey( index ); - _de->Value = this->BaseGet( index ); - return( _de ); - } - } - - // Adds elements from an IDictionary into the new collection. - MyCollection( IDictionary^ d ) { - - _de = gcnew DictionaryEntry(); - - for each ( DictionaryEntry^ de in d ) { - this->BaseAdd( (String^) de->Key, de->Value ); - } - } - - // Removes an entry with the specified key from the collection. - void Remove( String^ key ) { - this->BaseRemove( key ); - } - - // Removes an entry in the specified index from the collection. - void Remove( int index ) { - this->BaseRemoveAt( index ); - } -}; - -public ref class SamplesNameObjectCollectionBase { - -public: - static void Main() { - - // Creates and initializes a new MyCollection instance. - IDictionary^ d = gcnew ListDictionary(); - d->Add( "red", "apple" ); - d->Add( "yellow", "banana" ); - d->Add( "green", "pear" ); - MyCollection^ myCol = gcnew MyCollection( d ); - Console::WriteLine( "Initial state of the collection (Count = {0}):", myCol->Count ); - PrintKeysAndValues( myCol ); - - // Removes an element at a specific index. - myCol->Remove( 1 ); - Console::WriteLine( "After removing the element at index 1 (Count = {0}):", myCol->Count ); - PrintKeysAndValues( myCol ); - - // Removes an element with a specific key. - myCol->Remove( "red" ); - Console::WriteLine( "After removing the element with the key \"red\" (Count = {0}):", myCol->Count ); - PrintKeysAndValues( myCol ); - - } - - static void PrintKeysAndValues( MyCollection^ myCol ) { - for ( int i = 0; i < myCol->Count; i++ ) { - Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value ); - } - } -}; - -int main() -{ - SamplesNameObjectCollectionBase::Main(); -} - -/* -This code produces the following output. - -Initial state of the collection (Count = 3): -[0] : red, apple -[1] : yellow, banana -[2] : green, pear -After removing the element at index 1 (Count = 2): -[0] : red, apple -[1] : green, pear -After removing the element with the key "red" (Count = 1): -[0] : green, pear - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseSet/CPP/nocb_baseset.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseSet/CPP/nocb_baseset.cpp deleted file mode 100644 index e9c37f870ef..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseSet/CPP/nocb_baseset.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// The following example uses BaseSet to set the value of a specific element. -// For an expanded version of this example, see the NameObjectCollectionBase class topic. - -// -#using -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class MyCollection : public NameObjectCollectionBase { - - // Gets or sets the value at the specified index. -public: - property Object^ default[ int ] { - Object^ get(int index) { - return( this->BaseGet( index ) ); - } - void set( int index, Object^ value ) { - this->BaseSet( index, value ); - } - } - - // Gets or sets the value associated with the specified key. - property Object^ default[ String^ ] { - Object^ get(String^ key) { - return( this->BaseGet( key ) ); - } - void set( String^ key, Object^ value ) { - this->BaseSet( key, value ); - } - } - - // Gets a String array that contains all the keys in the collection. - property array^ AllKeys { - array^ get() { - return( this->BaseGetAllKeys() ); - } - } - - // Adds elements from an IDictionary into the new collection. - MyCollection( IDictionary^ d ) { - for each ( DictionaryEntry^ de in d ) { - this->BaseAdd( (String^) de->Key, de->Value ); - } - } - -}; - -public ref class SamplesNameObjectCollectionBase { - -public: - static void Main() { - - // Creates and initializes a new MyCollection instance. - IDictionary^ d = gcnew ListDictionary(); - d->Add( "red", "apple" ); - d->Add( "yellow", "banana" ); - d->Add( "green", "pear" ); - MyCollection^ myCol = gcnew MyCollection( d ); - Console::WriteLine( "Initial state of the collection:" ); - PrintKeysAndValues2( myCol ); - Console::WriteLine(); - - // Sets the value at index 1. - myCol[1] = "sunflower"; - Console::WriteLine( "After setting the value at index 1:" ); - PrintKeysAndValues2( myCol ); - Console::WriteLine(); - - // Sets the value associated with the key "red". - myCol["red"] = "tulip"; - Console::WriteLine( "After setting the value associated with the key \"red\":" ); - PrintKeysAndValues2( myCol ); - - } - - static void PrintKeysAndValues2( MyCollection^ myCol ) { - for each ( String^ s in myCol->AllKeys ) { - Console::WriteLine( "{0}, {1}", s, myCol[s] ); - } - } -}; - -int main() -{ - SamplesNameObjectCollectionBase::Main(); -} - -/* -This code produces the following output. - -Initial state of the collection: -red, apple -yellow, banana -green, pear - -After setting the value at index 1: -red, apple -yellow, sunflower -green, pear - -After setting the value associated with the key "red": -red, tulip -yellow, sunflower -green, pear - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.IsReadOnly/CPP/nocb_isreadonly.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.IsReadOnly/CPP/nocb_isreadonly.cpp deleted file mode 100644 index c7f2f6f2036..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.IsReadOnly/CPP/nocb_isreadonly.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// The following example creates a read-only collection. -// For an expanded version of this example, see the NameObjectCollectionBase class topic. - -// -#using -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class MyCollection : public NameObjectCollectionBase { - -private: - DictionaryEntry^ _de; - - // Gets a key-and-value pair (DictionaryEntry) using an index. -public: - property DictionaryEntry^ default[ int ] { - DictionaryEntry^ get( int index ) { - _de->Key = this->BaseGetKey( index ); - _de->Value = this->BaseGet( index ); - return( _de ); - } - } - - // Adds elements from an IDictionary into the new collection. - MyCollection( IDictionary^ d, Boolean bReadOnly ) { - - _de = gcnew DictionaryEntry(); - - for each ( DictionaryEntry^ de in d ) { - this->BaseAdd( (String^) de->Key, de->Value ); - } - this->IsReadOnly = bReadOnly; - } - - // Adds an entry to the collection. - void Add( String^ key, Object^ value ) { - this->BaseAdd( key, value ); - } -}; - -public ref class SamplesNameObjectCollectionBase { - -public: - static void Main() { - - // Creates and initializes a new MyCollection that is read-only. - IDictionary^ d = gcnew ListDictionary(); - d->Add( "red", "apple" ); - d->Add( "yellow", "banana" ); - d->Add( "green", "pear" ); - MyCollection^ myROCol = gcnew MyCollection( d, true ); - - // Tries to add a new item. - try { - myROCol->Add( "blue", "sky" ); - } - catch ( NotSupportedException^ e ) { - Console::WriteLine( e->ToString() ); - } - - // Displays the keys and values of the MyCollection. - Console::WriteLine( "Read-Only Collection:" ); - PrintKeysAndValues( myROCol ); - } - - static void PrintKeysAndValues( MyCollection^ myCol ) { - for ( int i = 0; i < myCol->Count; i++ ) { - Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value ); - } - } -}; - -int main() -{ - SamplesNameObjectCollectionBase::Main(); -} - -/* -This code produces the following output. - -System.NotSupportedException: Collection is read-only. - at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String name, Object value) - at SamplesNameObjectCollectionBase.Main() -Read-Only Collection: -[0] : red, apple -[1] : yellow, banana -[2] : green, pear - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/nameobjectcollectionbase.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/nameobjectcollectionbase.cpp deleted file mode 100644 index 8f68c652453..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/nameobjectcollectionbase.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// The following example shows how to implement and use the NameObjectCollectionBase class. - -// -#using -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class MyCollection : public NameObjectCollectionBase { - -private: - DictionaryEntry^ _de; - - // Creates an empty collection. -public: - MyCollection() { - _de = gcnew DictionaryEntry(); - } - - // Adds elements from an IDictionary into the new collection. - MyCollection( IDictionary^ d, Boolean bReadOnly ) { - - _de = gcnew DictionaryEntry(); - - for each ( DictionaryEntry^ de in d ) { - this->BaseAdd( (String^) de->Key, de->Value ); - } - this->IsReadOnly = bReadOnly; - } - - // Gets a key-and-value pair (DictionaryEntry) using an index. - property DictionaryEntry^ default[ int ] { - DictionaryEntry^ get(int index) { - _de->Key = this->BaseGetKey(index); - _de->Value = this->BaseGet(index); - return( _de ); - } - } - - // Gets or sets the value associated with the specified key. - property Object^ default[ String^ ] { - Object^ get(String^ key) { - return( this->BaseGet( key ) ); - } - void set( String^ key, Object^ value ) { - this->BaseSet( key, value ); - } - } - - // Gets a String array that contains all the keys in the collection. - property array^ AllKeys { - array^ get() { - return( (array^)this->BaseGetAllKeys() ); - } - } - - // Gets an Object array that contains all the values in the collection. - property Array^ AllValues { - Array^ get() { - return( this->BaseGetAllValues() ); - } - } - - // Gets a String array that contains all the values in the collection. - property array^ AllStringValues { - array^ get() { - return( (array^) this->BaseGetAllValues( String ::typeid )); - } - } - - // Gets a value indicating if the collection contains keys that are not null. - property Boolean HasKeys { - Boolean get() { - return( this->BaseHasKeys() ); - } - } - - // Adds an entry to the collection. - void Add( String^ key, Object^ value ) { - this->BaseAdd( key, value ); - } - - // Removes an entry with the specified key from the collection. - void Remove( String^ key ) { - this->BaseRemove( key ); - } - - // Removes an entry in the specified index from the collection. - void Remove( int index ) { - this->BaseRemoveAt( index ); - } - - // Clears all the elements in the collection. - void Clear() { - this->BaseClear(); - } -}; - -public ref class SamplesNameObjectCollectionBase { - -public: - static void Main() { - // Creates and initializes a new MyCollection that is read-only. - IDictionary^ d = gcnew ListDictionary(); - d->Add( "red", "apple" ); - d->Add( "yellow", "banana" ); - d->Add( "green", "pear" ); - MyCollection^ myROCol = gcnew MyCollection( d, true ); - - // Tries to add a new item. - try { - myROCol->Add( "blue", "sky" ); - } - catch ( NotSupportedException^ e ) { - Console::WriteLine( e->ToString() ); - } - - // Displays the keys and values of the MyCollection. - Console::WriteLine( "Read-Only Collection:" ); - PrintKeysAndValues( myROCol ); - - // Creates and initializes an empty MyCollection that is writable. - MyCollection^ myRWCol = gcnew MyCollection(); - - // Adds new items to the collection. - myRWCol->Add( "purple", "grape" ); - myRWCol->Add( "orange", "tangerine" ); - myRWCol->Add( "black", "berries" ); - Console::WriteLine( "Writable Collection (after adding values):" ); - PrintKeysAndValues( myRWCol ); - - // Changes the value of one element. - myRWCol["orange"] = "grapefruit"; - Console::WriteLine( "Writable Collection (after changing one value):" ); - PrintKeysAndValues( myRWCol ); - - // Removes one item from the collection. - myRWCol->Remove( "black" ); - Console::WriteLine( "Writable Collection (after removing one value):" ); - PrintKeysAndValues( myRWCol ); - - // Removes all elements from the collection. - myRWCol->Clear(); - Console::WriteLine( "Writable Collection (after clearing the collection):" ); - PrintKeysAndValues( myRWCol ); - } - - // Prints the indexes, keys, and values. - static void PrintKeysAndValues( MyCollection^ myCol ) { - for ( int i = 0; i < myCol->Count; i++ ) { - Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value ); - } - } - - // Prints the keys and values using AllKeys. - static void PrintKeysAndValues2( MyCollection^ myCol ) { - for each ( String^ s in myCol->AllKeys ) { - Console::WriteLine( "{0}, {1}", s, myCol[s] ); - } - } -}; - -int main() -{ - SamplesNameObjectCollectionBase::Main(); -} - -/* -This code produces the following output. - -System.NotSupportedException: Collection is read-only. - at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String name, Object value) - at SamplesNameObjectCollectionBase.Main() -Read-Only Collection: -[0] : red, apple -[1] : yellow, banana -[2] : green, pear -Writable Collection (after adding values): -[0] : purple, grape -[1] : orange, tangerine -[2] : black, berries -Writable Collection (after changing one value): -[0] : purple, grape -[1] : orange, grapefruit -[2] : black, berries -Writable Collection (after removing one value): -[0] : purple, grape -[1] : orange, grapefruit -Writable Collection (after clearing the collection): - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/remarks.cpp deleted file mode 100644 index 7865c4fe20e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/remarks.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::Threading; - -public ref class DerivedCollection : public NameObjectCollectionBase { - -private: - DictionaryEntry^ _de; - - // Creates an empty collection. -public: - DerivedCollection() { - _de = gcnew DictionaryEntry(); - } - - // Adds elements from an IDictionary into the new collection. - DerivedCollection( IDictionary^ d, Boolean bReadOnly ) { - - _de = gcnew DictionaryEntry(); - - for each ( DictionaryEntry^ de in d ) { - this->BaseAdd( (String^) de->Key, de->Value ); - } - this->IsReadOnly = bReadOnly; - } - - // Gets a key-and-value pair (DictionaryEntry) using an index. - property DictionaryEntry^ default[ int ] { - DictionaryEntry^ get(int index) { - _de->Key = this->BaseGetKey(index); - _de->Value = this->BaseGet(index); - return( _de ); - } - } - - // Gets or sets the value associated with the specified key. - property Object^ default[ String^ ] { - Object^ get(String^ key) { - return( this->BaseGet( key ) ); - } - void set( String^ key, Object^ value ) { - this->BaseSet( key, value ); - } - } - - // Gets a String array that contains all the keys in the collection. - property array^ AllKeys { - array^ get() { - return( (array^)this->BaseGetAllKeys() ); - } - } - - // Gets an Object array that contains all the values in the collection. - property Array^ AllValues { - Array^ get() { - return( this->BaseGetAllValues() ); - } - } - - // Gets a String array that contains all the values in the collection. - property array^ AllStringValues { - array^ get() { - return( (array^) this->BaseGetAllValues( String ::typeid )); - } - } - - // Gets a value indicating if the collection contains keys that are not null. - property Boolean HasKeys { - Boolean get() { - return( this->BaseHasKeys() ); - } - } - - // Adds an entry to the collection. - void Add( String^ key, Object^ value ) { - this->BaseAdd( key, value ); - } - - // Removes an entry with the specified key from the collection. - void Remove( String^ key ) { - this->BaseRemove( key ); - } - - // Removes an entry in the specified index from the collection. - void Remove( int index ) { - this->BaseRemoveAt( index ); - } - - // Clears all the elements in the collection. - void Clear() { - this->BaseClear(); - } -}; - -public ref class SamplesNameObjectCollectionBase -{ -public: - static void Main() - { - // - // Create a collection derived from NameObjectCollectionBase - ICollection^ myCollection = gcnew DerivedCollection(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection) - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesNameObjectCollectionBase::Main(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp deleted file mode 100644 index 6d13a5bf9be..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// The following code example demonstrates several of the properties and methods of NameValueCollection. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -void PrintKeysAndValues( NameValueCollection^ myCol ); -void PrintKeysAndValues2( NameValueCollection^ myCol ); - -int main() -{ - // Creates and initializes a new NameValueCollection. - NameValueCollection^ myCol = gcnew NameValueCollection; - myCol->Add( "red", "rojo" ); - myCol->Add( "green", "verde" ); - myCol->Add( "blue", "azul" ); - myCol->Add( "red", "rouge" ); - - // Displays the values in the NameValueCollection in two different ways. - Console::WriteLine( "Displays the elements using the AllKeys property and the Item (indexer) property:" ); - PrintKeysAndValues( myCol ); - Console::WriteLine( "Displays the elements using GetKey and Get:" ); - PrintKeysAndValues2( myCol ); - - // Gets a value either by index or by key. - Console::WriteLine( "Index 1 contains the value {0}.", myCol[ 1 ] ); - Console::WriteLine( "Key \"red\" has the value {0}.", myCol[ "red" ] ); - Console::WriteLine(); - - // Copies the values to a string array and displays the string array. - array^myStrArr = gcnew array(myCol->Count); - myCol->CopyTo( myStrArr, 0 ); - Console::WriteLine( "The string array contains:" ); - for each ( String^ s in myStrArr ) - Console::WriteLine( " {0}", s ); - Console::WriteLine(); - - // Searches for a key and deletes it. - myCol->Remove( "green" ); - Console::WriteLine( "The collection contains the following elements after removing \"green\":" ); - PrintKeysAndValues( myCol ); - - // Clears the entire collection. - myCol->Clear(); - Console::WriteLine( "The collection contains the following elements after it is cleared:" ); - PrintKeysAndValues( myCol ); -} - -void PrintKeysAndValues( NameValueCollection^ myCol ) -{ - Console::WriteLine( " KEY VALUE" ); - for each ( String^ s in myCol->AllKeys ) - Console::WriteLine( " {0,-10} {1}", s, myCol[s] ); - Console::WriteLine(); -} - -void PrintKeysAndValues2( NameValueCollection^ myCol ) -{ - Console::WriteLine( " [INDEX] KEY VALUE" ); - for ( int i = 0; i < myCol->Count; i++ ) - Console::WriteLine( " [{0}] {1,-10} {2}", i, myCol->GetKey( i ), myCol->Get( i ) ); - Console::WriteLine(); -} - -/* - -This code produces the following output. - -Displays the elements using the AllKeys property and the Item (indexer) property: - KEY VALUE - red rojo,rouge - green verde - blue azul - -Displays the elements using GetKey and Get: - [INDEX] KEY VALUE - [0] red rojo,rouge - [1] green verde - [2] blue azul - -Index 1 contains the value verde. -Key "red" has the value rojo,rouge. - -The string array contains: - rojo,rouge - verde - azul - -The collection contains the following elements after removing "green": - KEY VALUE - red rojo,rouge - blue azul - -The collection contains the following elements after it is cleared: - KEY VALUE - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp deleted file mode 100644 index c59ed515e67..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// -// The following code example enumerates the elements of a OrderedDictionary. -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class OrderedDictionarySample -{ -public: - static void Main() - { - // - // Creates and initializes a OrderedDictionary. - OrderedDictionary^ myOrderedDictionary = gcnew OrderedDictionary(); - myOrderedDictionary->Add("testKey1", "testValue1"); - myOrderedDictionary->Add("testKey2", "testValue2"); - myOrderedDictionary->Add("keyToDelete", "valueToDelete"); - myOrderedDictionary->Add("testKey3", "testValue3"); - - ICollection^ keyCollection = myOrderedDictionary->Keys; - ICollection^ valueCollection = myOrderedDictionary->Values; - - // Display the contents using the key and value collections - DisplayContents(keyCollection, valueCollection, myOrderedDictionary->Count); - // - - // - // Modifying the OrderedDictionary - if (!myOrderedDictionary->IsReadOnly) - { - // Insert a new key to the beginning of the OrderedDictionary - myOrderedDictionary->Insert(0, "insertedKey1", "insertedValue1"); - - // Modify the value of the entry with the key "testKey2" - myOrderedDictionary["testKey2"] = "modifiedValue"; - - // Remove the last entry from the OrderedDictionary: "testKey3" - myOrderedDictionary->RemoveAt(myOrderedDictionary->Count - 1); - - // Remove the "keyToDelete" entry, if it exists - if (myOrderedDictionary->Contains("keyToDelete")) - { - myOrderedDictionary->Remove("keyToDelete"); - } - } - // - - Console::WriteLine( - "{0}Displaying the entries of a modified OrderedDictionary.", - Environment::NewLine); - DisplayContents(keyCollection, valueCollection, myOrderedDictionary->Count); - - // - // Clear the OrderedDictionary and add new values - myOrderedDictionary->Clear(); - myOrderedDictionary->Add("newKey1", "newValue1"); - myOrderedDictionary->Add("newKey2", "newValue2"); - myOrderedDictionary->Add("newKey3", "newValue3"); - - // Display the contents of the "new" Dictionary using an enumerator - IDictionaryEnumerator^ myEnumerator = - myOrderedDictionary->GetEnumerator(); - - Console::WriteLine( - "{0}Displaying the entries of a \"new\" OrderedDictionary.", - Environment::NewLine); - - DisplayEnumerator(myEnumerator); - // - } - - // - // Displays the contents of the OrderedDictionary from its keys and values - static void DisplayContents( - ICollection^ keyCollection, ICollection^ valueCollection, int dictionarySize) - { - array^ myKeys = gcnew array(dictionarySize); - array^ myValues = gcnew array(dictionarySize); - keyCollection->CopyTo(myKeys, 0); - valueCollection->CopyTo(myValues, 0); - - // Displays the contents of the OrderedDictionary - Console::WriteLine(" INDEX KEY VALUE"); - for (int i = 0; i < dictionarySize; i++) - { - Console::WriteLine(" {0,-5} {1,-25} {2}", - i, myKeys[i], myValues[i]); - } - Console::WriteLine(); - } - // - - // - // Displays the contents of the OrderedDictionary using its enumerator - static void DisplayEnumerator(IDictionaryEnumerator^ myEnumerator) - { - Console::WriteLine(" KEY VALUE"); - while (myEnumerator->MoveNext()) - { - Console::WriteLine(" {0,-25} {1}", - myEnumerator->Key, myEnumerator->Value); - } - } - // -}; - -int main() -{ - OrderedDictionarySample::Main(); -} - -/* -This code produces the following output. - - INDEX KEY VALUE - 0 testKey1 testValue1 - 1 testKey2 testValue2 - 2 keyToDelete valueToDelete - 3 testKey3 testValue3 - - -Displaying the entries of a modified OrderedDictionary. - INDEX KEY VALUE - 0 insertedKey1 insertedValue1 - 1 testKey1 testValue1 - 2 testKey2 modifiedValue - - -Displaying the entries of a "new" OrderedDictionary. - KEY VALUE - newKey1 newValue1 - newKey2 newValue2 - newKey3 newValue3 - -*/ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/source2.cpp deleted file mode 100644 index 42c6ceb624c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/source2.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -public ref class OrderedDictionarySample -{ -public: - static void Main() - { - OrderedDictionary^ myOrderedDictionary = gcnew OrderedDictionary(); - // - for each (DictionaryEntry de in myOrderedDictionary) - { - //... - } - // - } -}; - -int main() -{ - OrderedDictionarySample::Main(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/remarks.cpp deleted file mode 100644 index 427029d212e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/remarks.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::Threading; - -public ref class SamplesStringCollection -{ -public: - static void Main() - { - // - StringCollection^ myCollection = gcnew StringCollection(); - bool lockTaken = false; - try - { - Monitor::Enter(myCollection->SyncRoot, lockTaken); - for each (Object^ item in myCollection) - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesStringCollection::Main(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/stringcollection.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/stringcollection.cpp deleted file mode 100644 index c05a22e2367..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/stringcollection.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// The following code example demonstrates several of the properties and methods of StringCollection. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -void PrintValues1( StringCollection^ myCol ); -void PrintValues2( StringCollection^ myCol ); -void PrintValues3( StringCollection^ myCol ); - -int main() -{ - - // Create and initializes a new StringCollection. - StringCollection^ myCol = gcnew StringCollection; - - // Add a range of elements from an array to the end of the StringCollection. - array^myArr = {"RED","orange","yellow","RED","green","blue","RED","indigo","violet","RED"}; - myCol->AddRange( myArr ); - - // Display the contents of the collection using for each. This is the preferred method. - Console::WriteLine( "Displays the elements using for each:" ); - PrintValues1( myCol ); - - // Display the contents of the collection using the enumerator. - Console::WriteLine( "Displays the elements using the IEnumerator:" ); - PrintValues2( myCol ); - - // Display the contents of the collection using the Count and Item properties. - Console::WriteLine( "Displays the elements using the Count and Item properties:" ); - PrintValues3( myCol ); - - // Add one element to the end of the StringCollection and insert another at index 3. - myCol->Add( "* white" ); - myCol->Insert( 3, "* gray" ); - Console::WriteLine( "After adding \"* white\" to the end and inserting \"* gray\" at index 3:" ); - PrintValues1( myCol ); - - // Remove one element from the StringCollection. - myCol->Remove( "yellow" ); - Console::WriteLine( "After removing \"yellow\":" ); - PrintValues1( myCol ); - - // Remove all occurrences of a value from the StringCollection. - int i = myCol->IndexOf( "RED" ); - while ( i > -1 ) - { - myCol->RemoveAt( i ); - i = myCol->IndexOf( "RED" ); - } - - - // Verify that all occurrences of "RED" are gone. - if ( myCol->Contains( "RED" ) ) - Console::WriteLine( "*** The collection still contains \"RED\"." ); - - Console::WriteLine( "After removing all occurrences of \"RED\":" ); - PrintValues1( myCol ); - - // Copy the collection to a new array starting at index 0. - array^myArr2 = gcnew array(myCol->Count); - myCol->CopyTo( myArr2, 0 ); - Console::WriteLine( "The new array contains:" ); - for ( i = 0; i < myArr2->Length; i++ ) - { - Console::WriteLine( " [{0}] {1}", i, myArr2[ i ] ); - - } - Console::WriteLine(); - - // Clears the entire collection. - myCol->Clear(); - Console::WriteLine( "After clearing the collection:" ); - PrintValues1( myCol ); -} - - -// Uses the for each statement which hides the complexity of the enumerator. -// NOTE: The for each statement is the preferred way of enumerating the contents of a collection. -void PrintValues1( StringCollection^ myCol ) { - for each ( Object^ obj in myCol ) - Console::WriteLine( " {0}", obj ); - Console::WriteLine(); -} - -// Uses the enumerator. -void PrintValues2( StringCollection^ myCol ) -{ - StringEnumerator^ myEnumerator = myCol->GetEnumerator(); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( " {0}", myEnumerator->Current ); - - Console::WriteLine(); -} - - -// Uses the Count and Item properties. -void PrintValues3( StringCollection^ myCol ) -{ - for ( int i = 0; i < myCol->Count; i++ ) - Console::WriteLine( " {0}", myCol[ i ] ); - Console::WriteLine(); -} - -/* -This code produces the following output. - -Displays the elements using the IEnumerator: - RED - orange - yellow - RED - green - blue - RED - indigo - violet - RED - -Displays the elements using the Count and Item properties: - RED - orange - yellow - RED - green - blue - RED - indigo - violet - RED - -After adding "* white" to the end and inserting "* gray" at index 3: - RED - orange - yellow - * gray - RED - green - blue - RED - indigo - violet - RED - * white - -After removing "yellow": - RED - orange - * gray - RED - green - blue - RED - indigo - violet - RED - * white - -After removing all occurrences of "RED": - orange - * gray - green - blue - indigo - violet - * white - -The new array contains: - [0] orange - [1] * gray - [2] green - [3] blue - [4] indigo - [5] violet - [6] * white - -After clearing the collection: - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/CPP/stringcollectionadd.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/CPP/stringcollectionadd.cpp deleted file mode 100644 index 841b997b1e1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/CPP/stringcollectionadd.cpp +++ /dev/null @@ -1,76 +0,0 @@ - - -// The following code example adds new elements to the StringCollection. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintValues( IEnumerable^ myCol ); -int main() -{ - - // Creates and initializes a new StringCollection. - StringCollection^ myCol = gcnew StringCollection; - Console::WriteLine( "Initial contents of the StringCollection:" ); - PrintValues( myCol ); - - // Adds a range of elements from an array to the end of the StringCollection. - array^myArr = {"RED","orange","yellow","RED","green","blue","RED","indigo","violet","RED"}; - myCol->AddRange( myArr ); - Console::WriteLine( "After adding a range of elements:" ); - PrintValues( myCol ); - - // Adds one element to the end of the StringCollection and inserts another at index 3. - myCol->Add( "* white" ); - myCol->Insert( 3, "* gray" ); - Console::WriteLine( "After adding \"* white\" to the end and inserting \"* gray\" at index 3:" ); - PrintValues( myCol ); -} - -void PrintValues( IEnumerable^ myCol ) -{ - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* -This code produces the following output. - -Initial contents of the StringCollection: - -After adding a range of elements: - RED - orange - yellow - RED - green - blue - RED - indigo - violet - RED - -After adding "* white" to the end and inserting "* gray" at index 3: - RED - orange - yellow - * gray - RED - green - blue - RED - indigo - violet - RED - * white - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionContains/CPP/stringcollectioncontains.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionContains/CPP/stringcollectioncontains.cpp deleted file mode 100644 index 9d9a32b8e90..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionContains/CPP/stringcollectioncontains.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -// The following code example searches the StringCollection for an element. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintValues( IEnumerable^ myCol ); -int main() -{ - - // Creates and initializes a new StringCollection. - StringCollection^ myCol = gcnew StringCollection; - array^myArr = {"RED","orange","yellow","RED","green","blue","RED","indigo","violet","RED"}; - myCol->AddRange( myArr ); - Console::WriteLine( "Initial contents of the StringCollection:" ); - PrintValues( myCol ); - - // Checks whether the collection contains "orange" and, if so, displays its index. - if ( myCol->Contains( "orange" ) ) - Console::WriteLine( "The collection contains \"orange\" at index {0}.", myCol->IndexOf( "orange" ) ); - else - Console::WriteLine( "The collection does not contain \"orange\"." ); -} - -void PrintValues( IEnumerable^ myCol ) -{ - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* -This code produces the following output. - -Initial contents of the StringCollection: - RED - orange - yellow - RED - green - blue - RED - indigo - violet - RED - -The collection contains "orange" at index 1. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionCopyTo/CPP/stringcollectioncopyto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionCopyTo/CPP/stringcollectioncopyto.cpp deleted file mode 100644 index f90440e4676..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionCopyTo/CPP/stringcollectioncopyto.cpp +++ /dev/null @@ -1,73 +0,0 @@ - - -// The following code example copies a StringCollection to an array. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintValues( IEnumerable^ myCol ); -int main() -{ - - // Creates and initializes a new StringCollection. - StringCollection^ myCol = gcnew StringCollection; - array^myArr = {"RED","orange","yellow","RED","green","blue","RED","indigo","violet","RED"}; - myCol->AddRange( myArr ); - Console::WriteLine( "Initial contents of the StringCollection:" ); - PrintValues( myCol ); - - // Copies the collection to a new array starting at index 0. - array^myArr2 = gcnew array(myCol->Count); - myCol->CopyTo( myArr2, 0 ); - Console::WriteLine( "The new array contains:" ); - for ( int i = 0; i < myArr2->Length; i++ ) - { - Console::WriteLine( " [{0}] {1}", i, myArr2[ i ] ); - - } - Console::WriteLine(); -} - -void PrintValues( IEnumerable^ myCol ) -{ - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* -This code produces the following output. - -Initial contents of the StringCollection: - RED - orange - yellow - RED - green - blue - RED - indigo - violet - RED - -The new array contains: - [0] RED - [1] orange - [2] yellow - [3] RED - [4] green - [5] blue - [6] RED - [7] indigo - [8] violet - [9] RED - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/CPP/stringcollectionremove.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/CPP/stringcollectionremove.cpp deleted file mode 100644 index 98e049d1393..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/CPP/stringcollectionremove.cpp +++ /dev/null @@ -1,91 +0,0 @@ - - -// The following code example removes elements from the StringCollection. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void PrintValues( IEnumerable^ myCol ); -int main() -{ - - // Creates and initializes a new StringCollection. - StringCollection^ myCol = gcnew StringCollection; - array^myArr = {"RED","orange","yellow","RED","green","blue","RED","indigo","violet","RED"}; - myCol->AddRange( myArr ); - Console::WriteLine( "Initial contents of the StringCollection:" ); - PrintValues( myCol ); - - // Removes one element from the StringCollection. - myCol->Remove( "yellow" ); - Console::WriteLine( "After removing \"yellow\":" ); - PrintValues( myCol ); - - // Removes all occurrences of a value from the StringCollection. - int i = myCol->IndexOf( "RED" ); - while ( i > -1 ) - { - myCol->RemoveAt( i ); - i = myCol->IndexOf( "RED" ); - } - - Console::WriteLine( "After removing all occurrences of \"RED\":" ); - PrintValues( myCol ); - - // Clears the entire collection. - myCol->Clear(); - Console::WriteLine( "After clearing the collection:" ); - PrintValues( myCol ); -} - -void PrintValues( IEnumerable^ myCol ) -{ - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ obj = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", obj ); - } - - Console::WriteLine(); -} - -/* -This code produces the following output. - -Initial contents of the StringCollection: - RED - orange - yellow - RED - green - blue - RED - indigo - violet - RED - -After removing "yellow": - RED - orange - RED - green - blue - RED - indigo - violet - RED - -After removing all occurrences of "RED": - orange - green - blue - indigo - violet - -After clearing the collection: - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringDictionary.CopyTo/CPP/stringdictionary_copyto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringDictionary.CopyTo/CPP/stringdictionary_copyto.cpp deleted file mode 100644 index 5bf34579a7f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringDictionary.CopyTo/CPP/stringdictionary_copyto.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -// The following code example shows how a StringDictionary can be copied to an array. -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -void main() -{ - - // Creates and initializes a new StringDictionary. - StringDictionary^ myCol = gcnew StringDictionary; - myCol->Add( "red", "rojo" ); - myCol->Add( "green", "verde" ); - myCol->Add( "blue", "azul" ); - - // Displays the values in the StringDictionary. - Console::WriteLine( "KEYS\tVALUES in the StringDictionary" ); - IEnumerator^ myEnum = myCol->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry^ myDE = safe_cast(myEnum->Current); - Console::WriteLine( "{0}\t{1}", myDE->Key, myDE->Value ); - Console::WriteLine(); - - // Creates an array with DictionaryEntry elements. - array^myArr = gcnew array(3); - - // Copies the StringDictionary to the array. - myCol->CopyTo( myArr, 0 ); - - // Displays the values in the array. - Console::WriteLine( "KEYS\tVALUES in the array" ); - for ( int i = 0; i < myArr->Length; i++ ) - Console::WriteLine( "{0}\t{1}", myArr[ i ].Key, myArr[ i ].Value ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -KEYS VALUES in the StringDictionary -green verde -red rojo -blue azul - -KEYS VALUES in the array -green verde -red rojo -blue azul - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/CPP/stringenumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/CPP/stringenumerator.cpp deleted file mode 100644 index c6cea926c77..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/CPP/stringenumerator.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// The following code example demonstrates several of the properties and methods of StringEnumerator. -// -#using - -using namespace System; -using namespace System::Collections::Specialized; -int main() -{ - - // Creates and initializes a StringCollection. - StringCollection^ myCol = gcnew StringCollection; - array^myArr = {"red","orange","yellow","green","blue","indigo","violet"}; - myCol->AddRange( myArr ); - - // Enumerates the elements in the StringCollection. - StringEnumerator^ myEnumerator = myCol->GetEnumerator(); - while ( myEnumerator->MoveNext() ) - Console::WriteLine( "{0}", myEnumerator->Current ); - - Console::WriteLine(); - - // Resets the enumerator and displays the first element again. - myEnumerator->Reset(); - if ( myEnumerator->MoveNext() ) - Console::WriteLine( "The first element is {0}.", myEnumerator->Current ); -} - -/* -This code produces the following output. - -red -orange -yellow -green -blue -indigo -violet - -The first element is red. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/cpp/correlationmanager.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/cpp/correlationmanager.cpp deleted file mode 100644 index 5c947137978..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/cpp/correlationmanager.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// CorrelationManager.cpp : main project file. - - -// -#using - -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Text; -using namespace System::Diagnostics; -using namespace System::Threading; - -void ThreadProc() -{ - TraceSource^ ts = gcnew TraceSource("MyApp"); - int i = ts->Listeners->Add(gcnew ConsoleTraceListener()); - ts->Listeners[i]->TraceOutputOptions = TraceOptions::LogicalOperationStack; - ts->Switch = gcnew SourceSwitch("MyAPP", "Verbose"); - // Add another logical operation. - Trace::CorrelationManager->StartLogicalOperation("WorkerThread"); - - ts->TraceEvent(TraceEventType::Error, 1, "Trace an error event."); - Trace::CorrelationManager->StopLogicalOperation(); -} - -void main() -{ - TraceSource^ ts = gcnew TraceSource("MyApp"); - int i = ts->Listeners->Add(gcnew ConsoleTraceListener()); - ts->Listeners[i]->TraceOutputOptions = TraceOptions::LogicalOperationStack; - ts->Switch = gcnew SourceSwitch("MyAPP", "Verbose"); - // Start the logical operation on the Main thread. - Trace::CorrelationManager->StartLogicalOperation("MainThread"); - - ts->TraceEvent(TraceEventType::Error, 1, "Trace an error event."); - Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc)); -// Start the worker thread. - t->Start(); -// Give the worker thread a chance to execute. - Thread::Sleep(1000); - Trace::CorrelationManager->StopLogicalOperation();} - - - -// This sample generates the following output: -//MyApp Error: 1 : Trace an error event. -// LogicalOperationStack=MainThread -//MyApp Error: 1 : Trace an error event. -// LogicalOperationStack=WorkerThread, MainThread -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp deleted file mode 100644 index 519ff58fbcd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// - -using namespace System; -using namespace System::Collections; -using namespace System::Diagnostics; -using namespace System::Reflection; - -ref class HashtableDebugView; - -// -[DebuggerDisplay("{value}", Name = "{key}")] -ref class KeyValuePairs -{ -private: - IDictionary^ dictionary; - Object^ key; - Object^ value; - -public: - KeyValuePairs(IDictionary^ dictionary, Object^ key, Object^ value) - { - this->value = value; - this->key = key; - this->dictionary = dictionary; - } -}; -// - -// -[DebuggerDisplay("Count = {Count}")] -// -[DebuggerTypeProxy(HashtableDebugView::typeid)] -ref class MyHashtable : Hashtable -// -{ -private: - static const String^ TestString = "This should not appear in the debug window."; - -internal: - ref class HashtableDebugView - { - private: - Hashtable^ hashtable; - public: - static const String^ TestString = "This should appear in the debug window."; - HashtableDebugView(Hashtable^ hashtable) - { - this->hashtable = hashtable; - } - - // - [DebuggerBrowsable(DebuggerBrowsableState::RootHidden)] - property array^ Keys - { - array^ get() - { - array^ keys = gcnew array(hashtable->Count); - - IEnumerator^ ie = hashtable->Keys->GetEnumerator(); - int i = 0; - Object^ key; - while (ie->MoveNext()) - { - key = ie->Current; - keys[i] = gcnew KeyValuePairs(hashtable, key, hashtable[key]); - i++; - } - return keys; - } - } - // - }; -}; -// - -public ref class DebugViewTest -{ -private: - // The following constant will appear in the debug window for DebugViewTest. - static const String^ TabString = " "; -public: - // - // The following DebuggerBrowsableAttribute prevents the property following it - // from appearing in the debug window for the class. - [DebuggerBrowsable(DebuggerBrowsableState::Never)] - static String^ y = "Test String"; - // - - static void Main() - { - MyHashtable^ myHashTable = gcnew MyHashtable(); - myHashTable->Add("one", 1); - myHashTable->Add("two", 2); - Console::WriteLine(myHashTable->ToString()); - Console::WriteLine("In Main."); - } -}; - -int main() -{ - DebugViewTest::Main(); -} -// - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.EventSchemaTraceListener/CPP/eventschematracelistener.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.EventSchemaTraceListener/CPP/eventschematracelistener.cpp deleted file mode 100644 index 6ac933cf809..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.EventSchemaTraceListener/CPP/eventschematracelistener.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// - -/////////////////////////////////////////////////////////////////////// -// -// EventSchemaTraceListener.cpp : main project file. -// Expected Output: -// 1) -// EventSchemaTraceListener CPP Sample -// -// IsThreadSafe? True -// BufferSize = 65536 -// MaximumFileSize = 20480000 -// MaximumNumberOfFiles = 2 -// Name = eventListener -// TraceLogRetentionOption = LimitedCircularFiles -// TraceOutputOptions = DateTime, Timestamp, ProcessId -// -// Press the enter key to exit -// -// 2) An output file is created named TraceOutput.xml. It will be -// opened and displayed in Microsoft Notepad. -// -// NOTE 1: -// Under certain circumstances, the VS C++ compiler will treat -// Console::WriteLine("MyText = " + MyVar); -// differently then the VS CSharp compiler. -// The C++ compiler will produce error C3063, whereas the -// CSharp compiler accepts the statement. -// This occurs when the VS C++ compiler cannot determine the -// datatype of "MyVar" because it is an enumeration type. -// The solution is: -// Use either of the following two methods: -// Console::WriteLine("MyText = {0} " , MyVar); -// Console::WriteLine("MyText = " + MyVar.ToString()); -// -// Although not specific to this particular pieces of code, -// this is demonstrated below in the Display function: The -// last two members, TraceLogRetentionOption, and -// TraceOutputOptions, are enumerations, and cannot simply be -// concatenated into Console::WriteLine. -// -/////////////////////////////////////////////////////////////////////// -#using -#using - -#define NOCONFIGFILE 1 -using namespace System; -using namespace System::IO; -using namespace System::Diagnostics; - - -[STAThreadAttribute] -void main() -{ - Console::WriteLine("EventSchemaTraceListener CPP Sample\n"); - - File::Delete("TraceOutput.xml"); - TraceSource ^ ts = gcnew TraceSource("TestSource"); - - -#if NOCONFIGFILE - ts->Listeners->Add(gcnew EventSchemaTraceListener("TraceOutput.xml", - "eventListener", 65536, - TraceLogRetentionOption::LimitedCircularFiles, - 20480000, 2)); - ts->Listeners["eventListener"]->TraceOutputOptions = - TraceOptions::DateTime | - TraceOptions::ProcessId | - TraceOptions::Timestamp; -#endif - - EventSchemaTraceListener ^ ESTL = - (EventSchemaTraceListener^)(ts->Listeners["eventListener"]); - - - Console::WriteLine("IsThreadSafe? = " + ESTL->IsThreadSafe); - Console::WriteLine("BufferSize = " + ESTL->BufferSize); - Console::WriteLine("MaximumFileSize = " + ESTL->MaximumFileSize); - Console::WriteLine("MaximumNumberOfFiles = " + ESTL->MaximumNumberOfFiles); - Console::WriteLine("Name = " + ESTL->Name); - Console::WriteLine("TraceLogRetentionOption = " + ESTL->TraceLogRetentionOption.ToString()); - Console::WriteLine("TraceOutputOptions = {0}\n", ESTL->TraceOutputOptions); - - ts->Switch->Level = SourceLevels::All; - String ^ testString = "" - + "" - + "11"; - - UnescapedXmlDiagnosticData ^ unXData = gcnew UnescapedXmlDiagnosticData(testString); - ts->TraceData(TraceEventType::Error, 38, unXData); - ts->TraceEvent(TraceEventType::Error, 38, testString); - ts->Flush(); - ts->Close(); - - Process::Start("notepad.exe", "TraceOutput.xml"); - Console::WriteLine("\nPress the enter key to exit"); - Console::ReadLine(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/CPP/instdatacopyto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/CPP/instdatacopyto.cpp deleted file mode 100644 index 07d517d64ac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/CPP/instdatacopyto.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// -// InstanceData_CopyTo.cpp : main project file. -#using - -using namespace System; -using namespace System::Diagnostics; - - -/////////////////////////////////////////////////////////////////////// -// -// FORWARD DECLARATIONS -// -/////////////////////////////////////////////////////////////////////// - -// Console Utility Functions: -void InitConsole(); // Init console size -void TitleBlock(); // Write the title block -void CW(String^strText , // Write a colored string - String^ C = "", int LF = 1); - - -// InstanceData subroutines -// Display the contents of an InstanceData object. -void ProcessInstanceDataObject(String^ name, CounterSample CSRef); - -// Display the contents of an InstanceDataCollection. -void ProcessInstanceDataCollection(InstanceDataCollection^ idCol); - - - - -/////////////////////////////////////////////////////////////////////// -// -// MAIN PROGRAM -// -/////////////////////////////////////////////////////////////////////// - -void main() -{ - InitConsole(); - TitleBlock(); - - String^ categoryName; - String^ catNumStr; - int categoryNum; - - - array^ categories = - PerformanceCounterCategory::GetCategories(); - - // Create and sort an array of category names. - array^ categoryNames = gcnew array(categories->Length); - int catX; - for(catX=0; catX < categories->Length; catX++) - categoryNames[catX] = categories[catX]->CategoryName; - Array::Sort(categoryNames); - - while(1) - { - CW("These PerformanceCounterCategory categories are registered \n" - +"on this computer:","Red"); - - for(catX=0; catX < categories->Length; catX++) - Console::WriteLine("{0,4} - {1}", catX+1, categoryNames[catX]); - - // Ask the user to choose a category. - Console::Write("\nEnter a category number from the above list: "); - catNumStr = Console::ReadLine(); - - // Validate the entered category number. - try { - categoryNum = int::Parse(catNumStr); - if (categoryNum < 1 || categoryNum > categories->Length) - throw gcnew Exception(String::Format("The category number "+ - " must be in the range 1..{0}.", categories->Length)); - categoryName = categoryNames[(categoryNum-1)]; - - // Process the InstanceDataCollectionCollection for this category. - PerformanceCounterCategory^ pcc = - gcnew PerformanceCounterCategory(categoryName); - InstanceDataCollectionCollection^ idColCol = pcc->ReadCategory(); - array^ idColArray = - gcnew array(idColCol->Count); - - CW("\nInstanceDataCollectionCollection for \"" +categoryName+"\" " - +"has "+idColCol->Count+" elements.","Blue"); - - idColCol->CopyTo(idColArray, 0); - - for each ( InstanceDataCollection ^ idCol in idColArray ) - ProcessInstanceDataCollection(idCol); - } - catch(Exception^ ex) - { - Console::WriteLine("\"{0}\" is not a valid category number." + - "\n{1}", catNumStr, ex->Message); - } - - CW("\n\nRun again (Y,N)?","Yellow"); - catNumStr = Console::ReadLine(); - if ("Y" != catNumStr && "y" != catNumStr) break; - } -} - - -/////////////////////////////////////////////////////////////////////// -// -// SUBROUTINES -// -/////////////////////////////////////////////////////////////////////// - -void InitConsole() -{ - Console::BufferHeight = 4000; - Console::WindowHeight = 40; -} - -void TitleBlock() -{ -Console::Title = "InstDataCopyTo.cpp Sample"; - -CW( - "///////////////////////////////////////////////////////////////////\n" -+"//\n" -+"// PROGRAM instdatacopyto.cpp\n" -+"// PURPOSE Show how to use InstanceData objects\n" -+"// OUTPUT 1) Displays a numbered list of PerformanceCounter\n" -+"// categories that exist on the local computer.\n" -+"// 2) Prompts the user to select a category.\n" -+"// 3) Displays the instance data associated with each\n" -+"// instance of the PerformanceCounter in the\n" -+"// selected PerformanceCounterCategory\n" -+"//\n" -+ "///////////////////////////////////////////////////////////////////\n" -,"Yellow"); -} - - -// Utility function: ConsoleWrite: Write a colored string -void CW(String^ strText , String^ C, int LF) -{ - if (C != "") Console::ForegroundColor = *dynamic_cast - (Enum::Parse(ConsoleColor::typeid, C)); - Console::Write(strText); - Console::ResetColor(); - Console::Write("\n{0}",LF?"\n":""); -} - -// Display the contents of an InstanceDataCollection. -void ProcessInstanceDataCollection(InstanceDataCollection ^ idCol) -{ - array^ instDataArray = gcnew array(idCol->Count); - - CW("\n InstanceDataCollection for \"" - + idCol->CounterName + "\" has " + idCol->Count + " elements.", "Red"); - - // Copy and process the InstanceData array. - idCol->CopyTo(instDataArray, 0); - - int idX; - for(idX=0; idX < instDataArray->Length; idX++) - ProcessInstanceDataObject(instDataArray[idX]->InstanceName, - instDataArray[idX]->Sample); -} - - -// Display the contents of an InstanceData object. -void ProcessInstanceDataObject(String ^ name, CounterSample CSRef) -{ - InstanceData ^ instData = gcnew InstanceData(name, CSRef); - CW(" Data from InstanceData object:","Red",0); - - CW(" InstanceName: "+instData->InstanceName,"Green",0); - CW(" RawValue: " + instData->RawValue); - - CounterSample sample = instData->Sample; - Console::Write(" Data from CounterSample object:\n" + - " CounterType: {0,-27} SystemFrequency: {1}\n" + - " BaseValue: {2,-27} RawValue: {3}\n" + - " CounterFrequency: {4,-27} CounterTimeStamp: {5}\n" + - " TimeStamp: {6,-27} TimeStamp100nSec: {7}\n\n", - sample.CounterType, sample.SystemFrequency, sample.BaseValue, - sample.RawValue, sample.CounterFrequency, sample.CounterTimeStamp, - sample.TimeStamp, sample.TimeStamp100nSec); -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetcount.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetcount.cpp deleted file mode 100644 index 63ae0eabe00..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetcount.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; - -ref class PerfCounterCatGetCountMod -{ - // -public: - static void Main(array^ args) - { - String^ categoryName = ""; - String^ machineName = ""; - String^ instanceName = ""; - PerformanceCounterCategory^ pcc; - array^ counters; - - // Copy the supplied arguments into the local variables. - try - { - categoryName = args[1]; - machineName = args[2]=="."? "": args[2]; - instanceName = args[3]; - } - catch (...) - { - // Ignore the exception from non-supplied arguments. - } - - try - { - // Create the appropriate PerformanceCounterCategory object. - if (machineName->Length>0) - { - pcc = gcnew PerformanceCounterCategory(categoryName, machineName); - } - else - { - pcc = gcnew PerformanceCounterCategory(categoryName); - } - - // Get the counters for this instance or a single instance - // of the selected category. - if (instanceName->Length > 0) - { - counters = pcc->GetCounters(instanceName); - } - else - { - counters = pcc->GetCounters(); - } - - } - catch (Exception^ ex) - { - Console::WriteLine("Unable to get counter information for " + - (instanceName->Length>0? "instance \"{2}\" in ": "single-instance ") + - "category \"{0}\" on " + (machineName->Length>0? "computer \"{1}\":": "this computer:"), - categoryName, machineName, instanceName); - Console::WriteLine(ex->Message); - return; - } - - // Display the counter names if GetCounters was successful. - if (counters != nullptr) - { - Console::WriteLine("These counters exist in " + - (instanceName->Length > 0 ? "instance \"{1}\" of" : "single instance") + - " category {0} on " + (machineName->Length > 0 ? "computer \"{2}\":": "this computer:"), - categoryName, instanceName, machineName); - - // Display a numbered list of the counter names. - int objX; - for(objX = 0; objX < counters->Length; objX++) - { - Console::WriteLine("{0,4} - {1}", objX + 1, counters[objX]->CounterName); - } - } - } - // -}; - -int main() -{ - PerfCounterCatGetCountMod::Main(Environment::GetCommandLineArgs()); -} -// - - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetinst.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetinst.cpp deleted file mode 100644 index 3a2934fc5ec..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetinst.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; - -ref class PerfCounterCatGetInstMod -{ - // -public: - static void Main(array^ args) - { - String^ categoryName = ""; - String^ machineName = ""; - PerformanceCounterCategory^ pcc; - array^ instances; - - // Copy the supplied arguments into the local variables. - try - { - categoryName = args[1]; - machineName = args[2]=="."? "": args[2]; - } - catch (...) - { - // Ignore the exception from non-supplied arguments. - } - - try - { - // Create the appropriate PerformanceCounterCategory object. - if (machineName->Length > 0) - { - pcc = gcnew PerformanceCounterCategory(categoryName, machineName); - } - else - { - pcc = gcnew PerformanceCounterCategory(categoryName); - } - - // Get the instances associated with this category. - instances = pcc->GetInstanceNames(); - - } - catch (Exception^ ex) - { - Console::WriteLine("Unable to get instance information for " + - "category \"{0}\" on " + - (machineName->Length>0? "computer \"{1}\":": "this computer:"), - categoryName, machineName); - Console::WriteLine(ex->Message); - return; - } - - //If an empty array is returned, the category has a single instance. - if (instances->Length==0) - { - Console::WriteLine("Category \"{0}\" on " + - (machineName->Length>0? "computer \"{1}\"": "this computer") + - " is single-instance.", pcc->CategoryName, pcc->MachineName); - } - else - { - // Otherwise, display the instances. - Console::WriteLine("These instances exist in category \"{0}\" on " + - (machineName->Length>0? "computer \"{1}\".": "this computer:"), - pcc->CategoryName, pcc->MachineName); - - Array::Sort(instances); - int objX; - for (objX = 0; objX < instances->Length; objX++) - { - Console::WriteLine("{0,4} - {1}", objX+1, instances[objX]); - } - } - } - // -}; - -int main() -{ - PerfCounterCatGetInstMod::Main(Environment::GetCommandLineArgs()); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountergetcat.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountergetcat.cpp deleted file mode 100644 index 598438b1a46..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountergetcat.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Diagnostics; - -ref class PerfCounterCatGetCatMod -{ - // -public: - static void Main(array^ args) - { - String^ machineName = ""; - array^ categories; - - // Copy the machine name argument into the local variable. - try - { - machineName = args[1]=="."? "": args[1]; - } - catch (...) - { - } - - // Generate a list of categories registered on the specified computer. - try - { - if (machineName->Length > 0) - { - categories = PerformanceCounterCategory::GetCategories(machineName); - } - else - { - categories = PerformanceCounterCategory::GetCategories(); - } - } - catch(Exception^ ex) - { - Console::WriteLine("Unable to get categories on " + - (machineName->Length > 0 ? "computer \"{0}\":": "this computer:"), machineName); - Console::WriteLine(ex->Message); - return; - } - - Console::WriteLine("These categories are registered on " + - (machineName->Length > 0 ? "computer \"{0}\":": "this computer:"), machineName); - - // Create and sort an array of category names. - array^ categoryNames = gcnew array(categories->Length); - int objX; - for (objX = 0; objX < categories->Length; objX++) - { - categoryNames[objX] = categories[objX]->CategoryName; - } - Array::Sort(categoryNames); - - for (objX = 0; objX < categories->Length; objX++) - { - Console::WriteLine("{0,4} - {1}", objX + 1, categoryNames[objX]); - } - } - // -}; - -int main() -{ - PerfCounterCatGetCatMod::Main(Environment::GetCommandLineArgs()); -} -// - - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/CPP/tracesource2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/CPP/tracesource2.cpp deleted file mode 100644 index 43756bed5b8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/CPP/tracesource2.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// -///////////////////////////////////////////////////////////////////////////////// -// -// NAME TraceSource2.cpp : main project file -// -///////////////////////////////////////////////////////////////////////////////// - - - -// The following configuration file can be used with this sample. -// When using a configuration file #define ConfigFile. -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// - -#define TRACE -//#define ConfigFile - -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Diagnostics; -using namespace System::Reflection; -using namespace System::IO; -using namespace System::Security::Permissions; - -void DisplayProperties(TraceSource^ ts); // Forward Declaration - - -int main() -{ - TraceSource^ ts = gcnew TraceSource("TraceTest"); - - try - { - // Initialize trace switches. -#if(!ConfigFile) - SourceSwitch^ sourceSwitch = gcnew SourceSwitch("SourceSwitch", "Verbose"); - ts->Switch = sourceSwitch; - int idxConsole = ts->Listeners->Add(gcnew System::Diagnostics::ConsoleTraceListener()); - ts->Listeners[idxConsole]->Name = "console"; -#endif - DisplayProperties(ts); - ts->Listeners["console"]->TraceOutputOptions |= TraceOptions::Callstack; - ts->TraceEvent(TraceEventType::Warning, 1); - ts->Listeners["console"]->TraceOutputOptions = TraceOptions::DateTime; - // Issue file not found message as a warning. - ts->TraceEvent(TraceEventType::Warning, 2, "File Test not found"); - // Issue file not found message as a verbose event using a formatted string. - ts->TraceEvent(TraceEventType::Verbose, 3, "File {0} not found.", "test"); - // Issue file not found message as information. - ts->TraceInformation("File {0} not found.", "test"); - ts->Listeners["console"]->TraceOutputOptions |= TraceOptions::LogicalOperationStack; - // Issue file not found message as an error event. - ts->TraceEvent(TraceEventType::Error, 4, "File {0} not found.", "test"); - - // Test the filter on the ConsoleTraceListener. - ts->Listeners["console"]->Filter = gcnew SourceFilter("No match"); - ts->TraceData(TraceEventType::Error, 5, - "SourceFilter should reject this message for the console trace listener."); - ts->Listeners["console"]->Filter = gcnew SourceFilter("TraceTest"); - ts->TraceData(TraceEventType::Error, 6, - "SourceFilter should let this message through on the console trace listener."); - ts->Listeners["console"]->Filter = nullptr; - - // Use the TraceData method. - ts->TraceData(TraceEventType::Warning, 7, gcnew array{ "Message 1", "Message 2" }); - - // Activity tests. - ts->TraceEvent(TraceEventType::Start, 9, "Will not appear until the switch is changed."); - ts->Switch->Level = SourceLevels::ActivityTracing | SourceLevels::Critical; - ts->TraceEvent(TraceEventType::Suspend, 10, "Switch includes ActivityTracing, this should appear"); - ts->TraceEvent(TraceEventType::Critical, 11, "Switch includes Critical, this should appear"); - ts->Flush(); - ts->Close(); - Console::WriteLine("Press enter key to exit."); - Console::Read(); - } - catch (Exception ^e) - { - // Catch any unexpected exception. - Console::WriteLine("Unexpected exception: " + e->ToString()); - Console::Read(); - } -} - - -void DisplayProperties(TraceSource^ ts) -{ - Console::WriteLine("TraceSource name = " + ts->Name); -// Console::WriteLine("TraceSource switch level = " + ts->Switch->Level); // error C3063: operator '+': all operands must have the same enumeration type - Console::WriteLine("TraceSource switch level = {0}", ts->Switch->Level); // SUCCESS: does compile. Weird - Console::WriteLine("TraceSource Attributes Count " + ts->Attributes->Count); // SUCCESS: also compiles. Really weird - Console::WriteLine("TraceSource Attributes Count = {0}", ts->Attributes->Count); // SUCCESS: okay, I give up. Somebody call me a cab. - - Console::WriteLine("TraceSource switch = " + ts->Switch->DisplayName); - array^ switches = SwitchAttribute::GetAll(TraceSource::typeid->Assembly); - - for (int i = 0; i < switches->Length; i++) - { - Console::WriteLine("Switch name = " + switches[i]->SwitchName); - Console::WriteLine("Switch type = " + switches[i]->SwitchType); - } - -#if(ConfigFile) - // Get the custom attributes for the TraceSource. - Console::WriteLine("Number of custom trace source attributes = " - + ts.Attributes.Count); - foreach (DictionaryEntry de in ts.Attributes) - Console::WriteLine("Custom trace source attribute = " - + de.Key + " " + de.Value); - // Get the custom attributes for the trace source switch. - foreach (DictionaryEntry de in ts.Switch.Attributes) - Console::WriteLine("Custom switch attribute = " - + de.Key + " " + de.Value); -#endif - Console::WriteLine("Number of listeners = " + ts->Listeners->Count); - for each (TraceListener ^ traceListener in ts->Listeners) - { - Console::Write("TraceListener: " + traceListener->Name + "\t"); - // The following output can be used to update the configuration file. - Console::WriteLine("AssemblyQualifiedName = " + - (traceListener->GetType()->AssemblyQualifiedName)); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp deleted file mode 100644 index 4e3179203c5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// The following code example shows how the result of GetWeekOfYear varies depending on the -// FirstDayOfWeek and the CalendarWeekRule used. -// If the specified date is the last day of the year, GetWeekOfYear returns the total number of weeks in that year. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Gets the Calendar instance associated with a CultureInfo. - CultureInfo^ myCI = gcnew CultureInfo( "en-US" ); - Calendar^ myCal = myCI->Calendar; - - // Gets the DTFI properties required by GetWeekOfYear. - CalendarWeekRule myCWR = myCI->DateTimeFormat->CalendarWeekRule; - DayOfWeek myFirstDOW = myCI->DateTimeFormat->FirstDayOfWeek; - - // Displays the number of the current week relative to the beginning of the year. - Console::WriteLine( "The CalendarWeekRule used for the en-US culture is {0}.", myCWR ); - Console::WriteLine( "The FirstDayOfWeek used for the en-US culture is {0}.", myFirstDOW ); - Console::WriteLine( "Therefore, the current week is Week {0} of the current year.", myCal->GetWeekOfYear( DateTime::Now, myCWR, myFirstDOW ) ); - - // Displays the total number of weeks in the current year. - DateTime LastDay = System::DateTime( DateTime::Now.Year, 12, 31 ); - Console::WriteLine( "There are {0} weeks in the current year ( {1}).", myCal->GetWeekOfYear( LastDay, myCWR, myFirstDOW ), LastDay.Year ); -} - -/* -This code produces the following output. Results vary depending on the system date. - -The CalendarWeekRule used for the en-US culture is FirstDay. -The FirstDayOfWeek used for the en-US culture is Sunday. -Therefore, the current week is Week 1 of the current year. -There are 53 weeks in the current year (2001). -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp deleted file mode 100644 index 0df7a5a06b3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp +++ /dev/null @@ -1,77 +0,0 @@ - -// The following code example demonstrates the members of the Calendar class. -// -using namespace System; -using namespace System::Globalization; -void DisplayValues( Calendar^ myCal, DateTime myDT ) -{ - Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) ); - Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) ); - Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) ); - Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) ); - Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) ); - Console::WriteLine( " Hour: {0}", myCal->GetHour( myDT ) ); - Console::WriteLine( " Minute: {0}", myCal->GetMinute( myDT ) ); - Console::WriteLine( " Second: {0}", myCal->GetSecond( myDT ) ); - Console::WriteLine( " Milliseconds: {0}", myCal->GetMilliseconds( myDT ) ); - Console::WriteLine(); -} - -int main() -{ - - // Sets a DateTime to April 3, 2002 of the Gregorian calendar. - DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar); - - // Uses the default calendar of the InvariantCulture. - Calendar^ myCal = CultureInfo::InvariantCulture->Calendar; - - // Displays the values of the DateTime. - Console::WriteLine( "April 3, 2002 of the Gregorian calendar:" ); - DisplayValues( myCal, myDT ); - - // Adds 5 to every component of the DateTime. - myDT = myCal->AddYears( myDT, 5 ); - myDT = myCal->AddMonths( myDT, 5 ); - myDT = myCal->AddWeeks( myDT, 5 ); - myDT = myCal->AddDays( myDT, 5 ); - myDT = myCal->AddHours( myDT, 5 ); - myDT = myCal->AddMinutes( myDT, 5 ); - myDT = myCal->AddSeconds( myDT, 5 ); - myDT = myCal->AddMilliseconds( myDT, 5 ); - - // Displays the values of the DateTime. - Console::WriteLine( "After adding 5 to each component of the DateTime:" ); - DisplayValues( myCal, myDT ); -} - -/* -This code produces the following output. - -April 3, 2002 of the Gregorian calendar: -Era: 1 -Year: 2002 -Month: 4 -DayOfYear: 93 -DayOfMonth: 3 -DayOfWeek: Wednesday -Hour: 0 -Minute: 0 -Second: 0 -Milliseconds: 0 - -After adding 5 to each component of the DateTime: -Era: 1 -Year: 2007 -Month: 10 -DayOfYear: 286 -DayOfMonth: 13 -DayOfWeek: Saturday -Hour: 5 -Minute: 5 -Second: 5 -Milliseconds: 5 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp deleted file mode 100644 index 865e7a9526e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp +++ /dev/null @@ -1,125 +0,0 @@ - -// The following code example compares different implementations of the Calendar class. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates an instance of every Calendar type. - array^myCals = gcnew array(8); - myCals[ 0 ] = gcnew GregorianCalendar; - myCals[ 1 ] = gcnew HebrewCalendar; - myCals[ 2 ] = gcnew HijriCalendar; - myCals[ 3 ] = gcnew JapaneseCalendar; - myCals[ 4 ] = gcnew JulianCalendar; - myCals[ 5 ] = gcnew KoreanCalendar; - myCals[ 6 ] = gcnew TaiwanCalendar; - myCals[ 7 ] = gcnew ThaiBuddhistCalendar; - - // For each calendar, displays the current year, the number of months in that year, - // and the number of days in each month of that year. - int i; - int j; - int iYear; - int iMonth; - int iDay; - DateTime myDT = DateTime::Today; - for ( i = 0; i < myCals->Length; i++ ) - { - iYear = myCals[ i ]->GetYear( myDT ); - Console::WriteLine(); - Console::WriteLine( " {0}, Year: {1}", myCals[ i ]->GetType(), myCals[ i ]->GetYear( myDT ) ); - Console::WriteLine( " MonthsInYear: {0}", myCals[ i ]->GetMonthsInYear( iYear ) ); - Console::WriteLine( " DaysInYear: {0}", myCals[ i ]->GetDaysInYear( iYear ) ); - Console::WriteLine( " Days in each month:" ); - Console::Write( " " ); - for ( j = 1; j <= myCals[ i ]->GetMonthsInYear( iYear ); j++ ) - Console::Write( " {0, -5}", myCals[ i ]->GetDaysInMonth( iYear, j ) ); - Console::WriteLine(); - iMonth = myCals[ i ]->GetMonth( myDT ); - iDay = myCals[ i ]->GetDayOfMonth( myDT ); - Console::WriteLine( " IsLeapDay: {0}", myCals[ i ]->IsLeapDay( iYear, iMonth, iDay ) ); - Console::WriteLine( " IsLeapMonth: {0}", myCals[ i ]->IsLeapMonth( iYear, iMonth ) ); - Console::WriteLine( " IsLeapYear: {0}", myCals[ i ]->IsLeapYear( iYear ) ); - - } -} - -/* -This code produces the following output. The results vary depending on the date. - -System::Globalization::GregorianCalendar, Year: 2002 -MonthsInYear: 12 -DaysInYear: 365 -Days in each month: -31 28 31 30 31 30 31 31 30 31 30 31 -IsLeapDay: False -IsLeapMonth: False -IsLeapYear: False - -System::Globalization::HebrewCalendar, Year: 5763 -MonthsInYear: 13 -DaysInYear: 385 -Days in each month: -30 30 30 29 30 30 29 30 29 30 29 30 29 -IsLeapDay: False -IsLeapMonth: False -IsLeapYear: True - -System::Globalization::HijriCalendar, Year: 1423 -MonthsInYear: 12 -DaysInYear: 355 -Days in each month: -30 29 30 29 30 29 30 29 30 29 30 30 -IsLeapDay: False -IsLeapMonth: False -IsLeapYear: True - -System::Globalization::JapaneseCalendar, Year: 14 -MonthsInYear: 12 -DaysInYear: 365 -Days in each month: -31 28 31 30 31 30 31 31 30 31 30 31 -IsLeapDay: False -IsLeapMonth: False -IsLeapYear: False - -System::Globalization::JulianCalendar, Year: 2002 -MonthsInYear: 12 -DaysInYear: 365 -Days in each month: -31 28 31 30 31 30 31 31 30 31 30 31 -IsLeapDay: False -IsLeapMonth: False -IsLeapYear: False - -System::Globalization::KoreanCalendar, Year: 4335 -MonthsInYear: 12 -DaysInYear: 365 -Days in each month: -31 28 31 30 31 30 31 31 30 31 30 31 -IsLeapDay: False -IsLeapMonth: False -IsLeapYear: False - -System::Globalization::TaiwanCalendar, Year: 91 -MonthsInYear: 12 -DaysInYear: 365 -Days in each month: -31 28 31 30 31 30 31 31 30 31 30 31 -IsLeapDay: False -IsLeapMonth: False -IsLeapYear: False - -System::Globalization::ThaiBuddhistCalendar, Year: 2545 -MonthsInYear: 12 -DaysInYear: 365 -Days in each month: -31 28 31 30 31 30 31 31 30 31 30 31 -IsLeapDay: False -IsLeapMonth: False -IsLeapYear: False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp deleted file mode 100644 index 868fb637de7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -// The following code example shows the values returned by each method for different types of characters. -// -using namespace System; -using namespace System::Globalization; -void PrintProperties( Char c ); -int main() -{ - Console::WriteLine( " c Num Dig Dec UnicodeCategory" ); - Console::Write( "U+0061 LATIN SMALL LETTER A " ); - PrintProperties( L'a' ); - Console::Write( "U+0393 GREEK CAPITAL LETTER GAMMA " ); - PrintProperties( L'\u0393' ); - Console::Write( "U+0039 DIGIT NINE " ); - PrintProperties( L'9' ); - Console::Write( "U+00B2 SUPERSCRIPT TWO " ); - PrintProperties( L'\u00B2' ); - Console::Write( "U+00BC VULGAR FRACTION ONE QUARTER " ); - PrintProperties( L'\u00BC' ); - Console::Write( "U+0BEF TAMIL DIGIT NINE " ); - PrintProperties( L'\u0BEF' ); - Console::Write( "U+0BF0 TAMIL NUMBER TEN " ); - PrintProperties( L'\u0BF0' ); - Console::Write( "U+0F33 TIBETAN DIGIT HALF ZERO " ); - PrintProperties( L'\u0F33' ); - Console::Write( "U+2788 CIRCLED SANS-SERIF DIGIT NINE " ); - PrintProperties( L'\u2788' ); -} - -void PrintProperties( Char c ) -{ - Console::Write( " {0,-3}", c ); - Console::Write( " {0,-5}", CharUnicodeInfo::GetNumericValue( c ) ); - Console::Write( " {0,-5}", CharUnicodeInfo::GetDigitValue( c ) ); - Console::Write( " {0,-5}", CharUnicodeInfo::GetDecimalDigitValue( c ) ); - Console::WriteLine( "{0}", CharUnicodeInfo::GetUnicodeCategory( c ) ); -} - -/* -This code produces the following output. Some characters might not display at the console. - - c Num Dig Dec UnicodeCategory -U+0061 LATIN SMALL LETTER A a -1 -1 -1 LowercaseLetter -U+0393 GREEK CAPITAL LETTER GAMMA Γ -1 -1 -1 UppercaseLetter -U+0039 DIGIT NINE 9 9 9 9 DecimalDigitNumber -U+00B2 SUPERSCRIPT TWO ² 2 2 -1 OtherNumber -U+00BC VULGAR FRACTION ONE QUARTER ¼ 0.25 -1 -1 OtherNumber -U+0BEF TAMIL DIGIT NINE ௯ 9 9 9 DecimalDigitNumber -U+0BF0 TAMIL NUMBER TEN ௰ 10 -1 -1 OtherNumber -U+0F33 TIBETAN DIGIT HALF ZERO ༳ -0.5 -1 -1 OtherNumber -U+2788 CIRCLED SANS-SERIF DIGIT NINE ➈ 9 9 -1 OtherNumber - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/CPP/charunicodeinfo_string.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/CPP/charunicodeinfo_string.cpp deleted file mode 100644 index 1ff91fb5a7e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/CPP/charunicodeinfo_string.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// The following code example shows the values returned by each method for different types of characters. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // The String to get information for. - String^ s = "a9\u0393\u00B2\u00BC\u0BEF\u0BF0\u2788"; - Console::WriteLine( "String: {0}", s ); - - // Print the values for each of the characters in the string. - Console::WriteLine( "index c Num Dig Dec UnicodeCategory" ); - for ( int i = 0; i < s->Length; i++ ) - { - Console::Write( "{0,-5} {1,-3}", i, s[ i ] ); - Console::Write( " {0,-5}", CharUnicodeInfo::GetNumericValue( s, i ) ); - Console::Write( " {0,-5}", CharUnicodeInfo::GetDigitValue( s, i ) ); - Console::Write( " {0,-5}", CharUnicodeInfo::GetDecimalDigitValue( s, i ) ); - Console::WriteLine( "{0}", CharUnicodeInfo::GetUnicodeCategory( s, i ) ); - - } -} - -/* -This code produces the following output. Some characters might not display at the console. - -String: a9Γ²¼௯௰➈ -index c Num Dig Dec UnicodeCategory -0 a -1 -1 -1 LowercaseLetter -1 9 9 9 9 DecimalDigitNumber -2 Γ -1 -1 -1 UppercaseLetter -3 ² 2 2 -1 OtherNumber -4 ¼ 0.25 -1 -1 OtherNumber -5 ௯ 9 9 9 DecimalDigitNumber -6 ௰ 10 -1 -1 OtherNumber -7 ➈ 9 9 -1 OtherNumber - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntInt/CPP/comparestrintintstrintint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntInt/CPP/comparestrintintstrintint.cpp deleted file mode 100644 index 96de17a4d52..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntInt/CPP/comparestrintintstrintint.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// The following code example compares portions of two strings using the different CompareInfo instances: -// a CompareInfo instance associated with the S"Spanish - Spain" culture with international sort, -// a CompareInfo instance associated with the S"Spanish - Spain" culture with traditional sort, and -// a CompareInfo instance associated with the InvariantCulture. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Defines the strings to compare. - String^ myStr1 = "calle"; - String^ myStr2 = "calor"; - - // Uses GetCompareInfo to create the CompareInfo that uses the S"es-ES" culture with international sort. - CompareInfo^ myCompIntl = CompareInfo::GetCompareInfo( "es-ES" ); - - // Uses GetCompareInfo to create the CompareInfo that uses the S"es-ES" culture with traditional sort. - CompareInfo^ myCompTrad = CompareInfo::GetCompareInfo( 0x040A ); - - // Uses the CompareInfo property of the InvariantCulture. - CompareInfo^ myCompInva = CultureInfo::InvariantCulture->CompareInfo; - - // Compares two strings using myCompIntl. - Console::WriteLine( "Comparing \" {0}\" and \" {1}\"", myStr1->Substring( 2, 2 ), myStr2->Substring( 2, 2 ) ); - Console::WriteLine( " With myCompIntl->Compare: {0}", myCompIntl->Compare( myStr1, 2, 2, myStr2, 2, 2 ) ); - Console::WriteLine( " With myCompTrad->Compare: {0}", myCompTrad->Compare( myStr1, 2, 2, myStr2, 2, 2 ) ); - Console::WriteLine( " With myCompInva->Compare: {0}", myCompInva->Compare( myStr1, 2, 2, myStr2, 2, 2 ) ); -} - -/* -This code produces the following output. - -Comparing S"ll" and S"lo" -With myCompIntl.Compare: -1 -With myCompTrad.Compare: 1 -With myCompInva.Compare: -1 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntIntOpt/CPP/comparestrintintstrintintopt.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntIntOpt/CPP/comparestrintintstrintintopt.cpp deleted file mode 100644 index 4c7273f97da..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntIntOpt/CPP/comparestrintintstrintintopt.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// The following code example compares portions of two strings using different CompareOptions settings. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Defines the strings to compare. - String^ myStr1 = "My Uncle Bill's clients"; - String^ myStr2 = "My uncle bills clients"; - - // Creates a CompareInfo that uses the InvariantCulture. - CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo; - - // Compares two strings using myComp. - Console::WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1->Substring( 3, 10 ), myStr2->Substring( 3, 10 ) ); - Console::WriteLine( " With no CompareOptions : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10 ) ); - Console::WriteLine( " With None : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, CompareOptions::None ) ); - Console::WriteLine( " With Ordinal : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, CompareOptions::Ordinal ) ); - Console::WriteLine( " With StringSort : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, CompareOptions::StringSort ) ); - Console::WriteLine( " With IgnoreCase : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, CompareOptions::IgnoreCase ) ); - Console::WriteLine( " With IgnoreSymbols : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, CompareOptions::IgnoreSymbols ) ); - Console::WriteLine( " With IgnoreCase and IgnoreSymbols : {0}", myComp->Compare( myStr1, 3, 10, myStr2, 3, 10, static_cast(CompareOptions::IgnoreCase | CompareOptions::IgnoreSymbols) ) ); -} - -/* -This code produces the following output. - -Comparing "Uncle Bill" and "uncle bill" - With no CompareOptions : 1 - With None : 1 - With Ordinal : -32 - With StringSort : 1 - With IgnoreCase : 0 - With IgnoreSymbols : 1 - With IgnoreCase and IgnoreSymbols : 0 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrInt/CPP/comparestrintstrint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrInt/CPP/comparestrintstrint.cpp deleted file mode 100644 index 678b54b5912..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrInt/CPP/comparestrintstrint.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// The following code example compares portions of two strings using the different CompareInfo instances: -// a CompareInfo instance associated with the S"Spanish - Spain" culture with international sort, -// a CompareInfo instance associated with the S"Spanish - Spain" culture with traditional sort, and -// a CompareInfo instance associated with the InvariantCulture. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Defines the strings to compare. - String^ myStr1 = "calle"; - String^ myStr2 = "calor"; - - // Uses GetCompareInfo to create the CompareInfo that - // uses the S"es-ES" culture with international sort. - CompareInfo^ myCompIntl = CompareInfo::GetCompareInfo( "es-ES" ); - - // Uses GetCompareInfo to create the CompareInfo that - // uses the S"es-ES" culture with traditional sort. - CompareInfo^ myCompTrad = CompareInfo::GetCompareInfo( 0x040A ); - - // Uses the CompareInfo property of the InvariantCulture. - CompareInfo^ myCompInva = CultureInfo::InvariantCulture->CompareInfo; - - // Compares two strings using myCompIntl. - Console::WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1->Substring( 2 ), myStr2->Substring( 2 ) ); - Console::WriteLine( " With myCompIntl::Compare: {0}", myCompIntl->Compare( myStr1, 2, myStr2, 2 ) ); - Console::WriteLine( " With myCompTrad::Compare: {0}", myCompTrad->Compare( myStr1, 2, myStr2, 2 ) ); - Console::WriteLine( " With myCompInva::Compare: {0}", myCompInva->Compare( myStr1, 2, myStr2, 2 ) ); -} - -/* -This code produces the following output. - -Comparing "lle" and "lor" - With myCompIntl::Compare: -1 - With myCompTrad::Compare: 1 - With myCompInva::Compare: -1 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrIntOpt/CPP/comparestrintstrintopt.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrIntOpt/CPP/comparestrintstrintopt.cpp deleted file mode 100644 index b180520da7d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrIntOpt/CPP/comparestrintstrintopt.cpp +++ /dev/null @@ -1,39 +0,0 @@ - -// The following code example compares portions of two strings using different CompareOptions settings. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Defines the strings to compare. - String^ myStr1 = "My Uncle Bill's clients"; - String^ myStr2 = "My uncle bills clients"; - - // Creates a CompareInfo that uses the InvariantCulture. - CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo; - - // Compares two strings using myComp. - Console::WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1->Substring( 10 ), myStr2->Substring( 10 ) ); - Console::WriteLine( " With no CompareOptions : {0}", myComp->Compare( myStr1, 10, myStr2, 10 ) ); - Console::WriteLine( " With None : {0}", myComp->Compare( myStr1, 10, myStr2, 10, CompareOptions::None ) ); - Console::WriteLine( " With Ordinal : {0}", myComp->Compare( myStr1, 10, myStr2, 10, CompareOptions::Ordinal ) ); - Console::WriteLine( " With StringSort : {0}", myComp->Compare( myStr1, 10, myStr2, 10, CompareOptions::StringSort ) ); - Console::WriteLine( " With IgnoreCase : {0}", myComp->Compare( myStr1, 10, myStr2, 10, CompareOptions::IgnoreCase ) ); - Console::WriteLine( " With IgnoreSymbols : {0}", myComp->Compare( myStr1, 10, myStr2, 10, CompareOptions::IgnoreSymbols ) ); - Console::WriteLine( " With IgnoreCase and IgnoreSymbols : {0}", myComp->Compare( myStr1, 10, myStr2, 10, static_cast(CompareOptions::IgnoreCase | CompareOptions::IgnoreSymbols) ) ); -} - -/* -This code produces the following output. - -Comparing "ill's clients" and "ills clients" - With no CompareOptions : 1 - With None : 1 - With Ordinal : -76 - With StringSort : -1 - With IgnoreCase : 1 - With IgnoreSymbols : 0 - With IgnoreCase and IgnoreSymbols : 0 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/CPP/comparestrstr.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/CPP/comparestrstr.cpp deleted file mode 100644 index f479b4c5433..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/CPP/comparestrstr.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// The following code example compares two strings using the different CompareInfo instances: -// a CompareInfo instance associated with the S"Spanish - Spain" culture with international sort, -// a CompareInfo instance associated with the S"Spanish - Spain" culture with traditional sort, and -// a CompareInfo instance associated with the InvariantCulture. -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Defines the strings to compare. - String^ myStr1 = "calle"; - String^ myStr2 = "calor"; - - // Uses GetCompareInfo to create the CompareInfo that - // uses the S"es-ES" culture with international sort. - CompareInfo^ myCompIntl = CompareInfo::GetCompareInfo( "es-ES" ); - - // Uses GetCompareInfo to create the CompareInfo that - // uses the S"es-ES" culture with traditional sort. - CompareInfo^ myCompTrad = CompareInfo::GetCompareInfo( 0x040A ); - - // Uses the CompareInfo property of the InvariantCulture. - CompareInfo^ myCompInva = CultureInfo::InvariantCulture->CompareInfo; - - // Compares two strings using myCompIntl. - Console::WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1, myStr2 ); - Console::WriteLine( " With myCompIntl::Compare: {0}", myCompIntl->Compare( myStr1, myStr2 ) ); - Console::WriteLine( " With myCompTrad::Compare: {0}", myCompTrad->Compare( myStr1, myStr2 ) ); - Console::WriteLine( " With myCompInva::Compare: {0}", myCompInva->Compare( myStr1, myStr2 ) ); -} - -/* -This code produces the following output. - -Comparing "calle" and "calor" - With myCompIntl::Compare: -1 - With myCompTrad::Compare: 1 - With myCompInva::Compare: -1 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStrOpt/CPP/comparestrstropt.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStrOpt/CPP/comparestrstropt.cpp deleted file mode 100644 index 2e1193e0288..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStrOpt/CPP/comparestrstropt.cpp +++ /dev/null @@ -1,39 +0,0 @@ - -// The following code example compares two strings using different CompareOptions settings. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Defines the strings to compare. - String^ myStr1 = "My Uncle Bill's clients"; - String^ myStr2 = "My uncle bills clients"; - - // Creates a CompareInfo which uses the InvariantCulture. - CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo; - - // Compares two strings using myComp. - Console::WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1, myStr2 ); - Console::WriteLine( " With no CompareOptions : {0}", myComp->Compare( myStr1, myStr2 ) ); - Console::WriteLine( " With None : {0}", myComp->Compare( myStr1, myStr2, CompareOptions::None ) ); - Console::WriteLine( " With Ordinal : {0}", myComp->Compare( myStr1, myStr2, CompareOptions::Ordinal ) ); - Console::WriteLine( " With StringSort : {0}", myComp->Compare( myStr1, myStr2, CompareOptions::StringSort ) ); - Console::WriteLine( " With IgnoreCase : {0}", myComp->Compare( myStr1, myStr2, CompareOptions::IgnoreCase ) ); - Console::WriteLine( " With IgnoreSymbols : {0}", myComp->Compare( myStr1, myStr2, CompareOptions::IgnoreSymbols ) ); - Console::WriteLine( " With IgnoreCase and IgnoreSymbols : {0}", myComp->Compare( myStr1, myStr2, static_cast(CompareOptions::IgnoreCase | CompareOptions::IgnoreSymbols) ) ); -} - -/* -This code produces the following output. - -Comparing "My Uncle Bill's clients" and "My uncle bills clients" - With no CompareOptions : 1 - With None : 1 - With Ordinal : -32 - With StringSort : -1 - With IgnoreCase : 1 - With IgnoreSymbols : 1 - With IgnoreCase and IgnoreSymbols : 0 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOf/CPP/indexof.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOf/CPP/indexof.cpp deleted file mode 100644 index b82a9f2e5ef..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOf/CPP/indexof.cpp +++ /dev/null @@ -1,118 +0,0 @@ - -// The following code example determines the indexes of the first and last occurrences of a character or a substring within a string. -// -using namespace System; -using namespace System::Globalization; -void PrintMarker( String^ Prefix, int First, int Last ) -{ - - // Determines the size of the array to create. - int mySize; - if ( Last > First ) - mySize = Last; - else - mySize = First; - - if ( mySize > -1 ) - { - - // Creates an array of Char to hold the markers. - array^myCharArr = gcnew array(mySize + 1); - - // Inserts the appropriate markers. - if ( First > -1 ) - myCharArr[ First ] = 'f'; - if ( Last > -1 ) - myCharArr[ Last ] = 'l'; - if ( First == Last ) - myCharArr[ First ] = 'b'; - - // Displays the array of Char as a String. - Console::WriteLine( "{0}{1}", Prefix, gcnew String( myCharArr ) ); - } - else - Console::WriteLine( Prefix ); -} - -int main() -{ - - // Creates CompareInfo for the InvariantCulture. - CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo; - - // Searches for the ligature Æ. - String^ myStr = "Is AE or ae the same as Æ or æ?"; - Console::WriteLine(); - Console::WriteLine( "No options : {0}", myStr ); - PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE" ), myComp->LastIndexOf( myStr, "AE" ) ); - PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae" ), myComp->LastIndexOf( myStr, "ae" ) ); - PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ' ), myComp->LastIndexOf( myStr, L'Æ' ) ); - PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ' ), myComp->LastIndexOf( myStr, L'æ' ) ); - Console::WriteLine( "Ordinal : {0}", myStr ); - PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "AE", CompareOptions::Ordinal ) ); - PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "ae", CompareOptions::Ordinal ) ); - PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'Æ', CompareOptions::Ordinal ) ); - PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'æ', CompareOptions::Ordinal ) ); - Console::WriteLine( "IgnoreCase : {0}", myStr ); - PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "AE", CompareOptions::IgnoreCase ) ); - PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "ae", CompareOptions::IgnoreCase ) ); - PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'Æ', CompareOptions::IgnoreCase ) ); - PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'æ', CompareOptions::IgnoreCase ) ); - - // Searches for the combining character sequence Latin capital letter U with diaeresis or Latin small letter u with diaeresis. - myStr = "Is U\u0308 or u\u0308 the same as \u00DC or \u00FC?"; - Console::WriteLine(); - Console::WriteLine( "No options : {0}", myStr ); - PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308" ), myComp->LastIndexOf( myStr, "U\u0308" ) ); - PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308" ), myComp->LastIndexOf( myStr, "u\u0308" ) ); - PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü' ), myComp->LastIndexOf( myStr, L'Ü' ) ); - PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü' ), myComp->LastIndexOf( myStr, L'ü' ) ); - Console::WriteLine( "Ordinal : {0}", myStr ); - PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "U\u0308", CompareOptions::Ordinal ) ); - PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "u\u0308", CompareOptions::Ordinal ) ); - PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'Ü', CompareOptions::Ordinal ) ); - PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'ü', CompareOptions::Ordinal ) ); - Console::WriteLine( "IgnoreCase : {0}", myStr ); - PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "U\u0308", CompareOptions::IgnoreCase ) ); - PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "u\u0308", CompareOptions::IgnoreCase ) ); - PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'Ü', CompareOptions::IgnoreCase ) ); - PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'ü', CompareOptions::IgnoreCase ) ); -} - -/* -This code produces the following output. - -No options : Is AE or ae the same as Æ or æ? - AE : f l - ae : f l - Æ : f l - æ : f l -Ordinal : Is AE or ae the same as Æ or æ? - AE : b - ae : b - Æ : b - æ : b -IgnoreCase : Is AE or ae the same as Æ or æ? - AE : f l - ae : f l - Æ : f l - æ : f l - -No options : Is U" or u" the same as Ü or ü? - U" : f l - u" : f l - Ü : f l - ü : f l -Ordinal : Is U" or u" the same as Ü or ü? - U" : b - u" : b - Ü : b - ü : b -IgnoreCase : Is U" or u" the same as Ü or ü? - U" : f l - u" : f l - Ü : f l - ü : f l - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp deleted file mode 100644 index f5d3d8ae905..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp +++ /dev/null @@ -1,205 +0,0 @@ - -// The following code example determines the indexes of the first and last occurrences of a character or a substring within a portion of a string. -// Note that IndexOf and LastIndexOf are searching in different portions of the string, even with the same StartIndex parameter. -// -using namespace System; -using namespace System::Globalization; -void PrintMarker( String^ Prefix, int First, int Last ) -{ - - // Determines the size of the array to create. - int mySize; - if ( Last > First ) - mySize = Last; - else - mySize = First; - - if ( mySize > -1 ) - { - - // Creates an array of Char to hold the markers. - array^myCharArr = gcnew array(mySize + 1); - - // Inserts the appropriate markers. - if ( First > -1 ) - myCharArr[ First ] = 'f'; - if ( Last > -1 ) - myCharArr[ Last ] = 'l'; - if ( First == Last ) - myCharArr[ First ] = 'b'; - - // Displays the array of Char as a String. - Console::WriteLine( "{0}{1}", Prefix, gcnew String( myCharArr ) ); - } - else - Console::WriteLine( Prefix ); -} - -int main() -{ - - // Creates CompareInfo for the InvariantCulture. - CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo; - - // iS is the starting index of the substring. - int iS = 20; - - // myT1 is the string used for padding. - String^ myT1; - - // Searches for the ligature Æ. - String^ myStr = "Is AE or ae the same as Æ or æ?"; - Console::WriteLine(); - myT1 = gcnew String( '-',iS ); - Console::WriteLine( "IndexOf( String, *, {0}, * )", iS ); - Console::WriteLine( "Original : {0}", myStr ); - Console::WriteLine( "No options : {0}{1}", myT1, myStr->Substring( iS ) ); - PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS ), -1 ); - PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS ), -1 ); - PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS ), -1 ); - PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS ), -1 ); - Console::WriteLine( "Ordinal : {0}{1}", myT1, myStr->Substring( iS ) ); - PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS, CompareOptions::Ordinal ), -1 ); - PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS, CompareOptions::Ordinal ), -1 ); - PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS, CompareOptions::Ordinal ), -1 ); - PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS, CompareOptions::Ordinal ), -1 ); - Console::WriteLine( "IgnoreCase : {0}{1}", myT1, myStr->Substring( iS ) ); - PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS, CompareOptions::IgnoreCase ), -1 ); - PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS, CompareOptions::IgnoreCase ), -1 ); - PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS, CompareOptions::IgnoreCase ), -1 ); - PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS, CompareOptions::IgnoreCase ), -1 ); - myT1 = gcnew String( '-',myStr->Length - iS - 1 ); - Console::WriteLine( "LastIndexOf( String, *, {0}, * )", iS ); - Console::WriteLine( "Original : {0}", myStr ); - Console::WriteLine( "No options : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 ); - PrintMarker( " AE : ", -1, myComp->LastIndexOf( myStr, "AE", iS ) ); - PrintMarker( " ae : ", -1, myComp->LastIndexOf( myStr, "ae", iS ) ); - PrintMarker( " Æ : ", -1, myComp->LastIndexOf( myStr, L'Æ', iS ) ); - PrintMarker( " æ : ", -1, myComp->LastIndexOf( myStr, L'æ', iS ) ); - Console::WriteLine( "Ordinal : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 ); - PrintMarker( " AE : ", -1, myComp->LastIndexOf( myStr, "AE", iS, CompareOptions::Ordinal ) ); - PrintMarker( " ae : ", -1, myComp->LastIndexOf( myStr, "ae", iS, CompareOptions::Ordinal ) ); - PrintMarker( " Æ : ", -1, myComp->LastIndexOf( myStr, L'Æ', iS, CompareOptions::Ordinal ) ); - PrintMarker( " æ : ", -1, myComp->LastIndexOf( myStr, L'æ', iS, CompareOptions::Ordinal ) ); - Console::WriteLine( "IgnoreCase : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 ); - PrintMarker( " AE : ", -1, myComp->LastIndexOf( myStr, "AE", iS, CompareOptions::IgnoreCase ) ); - PrintMarker( " ae : ", -1, myComp->LastIndexOf( myStr, "ae", iS, CompareOptions::IgnoreCase ) ); - PrintMarker( " Æ : ", -1, myComp->LastIndexOf( myStr, L'Æ', iS, CompareOptions::IgnoreCase ) ); - PrintMarker( " æ : ", -1, myComp->LastIndexOf( myStr, L'æ', iS, CompareOptions::IgnoreCase ) ); - - // Searches for the combining character sequence Latin capital letter U with diaeresis or Latin small letter u with diaeresis. - myStr = "Is U\u0308 or u\u0308 the same as \u00DC or \u00FC?"; - Console::WriteLine(); - myT1 = gcnew String( '-',iS ); - Console::WriteLine( "IndexOf( String, *, {0}, * )", iS ); - Console::WriteLine( "Original : {0}", myStr ); - Console::WriteLine( "No options : {0}{1}", myT1, myStr->Substring( iS ) ); - PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS ), -1 ); - PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS ), -1 ); - PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS ), -1 ); - PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS ), -1 ); - Console::WriteLine( "Ordinal : {0}{1}", myT1, myStr->Substring( iS ) ); - PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS, CompareOptions::Ordinal ), -1 ); - PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS, CompareOptions::Ordinal ), -1 ); - PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS, CompareOptions::Ordinal ), -1 ); - PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS, CompareOptions::Ordinal ), -1 ); - Console::WriteLine( "IgnoreCase : {0}{1}", myT1, myStr->Substring( iS ) ); - PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS, CompareOptions::IgnoreCase ), -1 ); - PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS, CompareOptions::IgnoreCase ), -1 ); - PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS, CompareOptions::IgnoreCase ), -1 ); - PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS, CompareOptions::IgnoreCase ), -1 ); - myT1 = gcnew String( '-',myStr->Length - iS - 1 ); - Console::WriteLine( "LastIndexOf( String, *, {0}, * )", iS ); - Console::WriteLine( "Original : {0}", myStr ); - Console::WriteLine( "No options : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 ); - PrintMarker( " U\u0308 : ", -1, myComp->LastIndexOf( myStr, "U\u0308", iS ) ); - PrintMarker( " u\u0308 : ", -1, myComp->LastIndexOf( myStr, "u\u0308", iS ) ); - PrintMarker( " Ü : ", -1, myComp->LastIndexOf( myStr, L'Ü', iS ) ); - PrintMarker( " ü : ", -1, myComp->LastIndexOf( myStr, L'ü', iS ) ); - Console::WriteLine( "Ordinal : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 ); - PrintMarker( " U\u0308 : ", -1, myComp->LastIndexOf( myStr, "U\u0308", iS, CompareOptions::Ordinal ) ); - PrintMarker( " u\u0308 : ", -1, myComp->LastIndexOf( myStr, "u\u0308", iS, CompareOptions::Ordinal ) ); - PrintMarker( " Ü : ", -1, myComp->LastIndexOf( myStr, L'Ü', iS, CompareOptions::Ordinal ) ); - PrintMarker( " ü : ", -1, myComp->LastIndexOf( myStr, L'ü', iS, CompareOptions::Ordinal ) ); - Console::WriteLine( "IgnoreCase : {0}{1}", myStr->Substring( 0, iS + 1 ), myT1 ); - PrintMarker( " U\u0308 : ", -1, myComp->LastIndexOf( myStr, "U\u0308", iS, CompareOptions::IgnoreCase ) ); - PrintMarker( " u\u0308 : ", -1, myComp->LastIndexOf( myStr, "u\u0308", iS, CompareOptions::IgnoreCase ) ); - PrintMarker( " Ü : ", -1, myComp->LastIndexOf( myStr, L'Ü', iS, CompareOptions::IgnoreCase ) ); - PrintMarker( " ü : ", -1, myComp->LastIndexOf( myStr, L'ü', iS, CompareOptions::IgnoreCase ) ); -} - -/* -This code produces the following output. - -IndexOf( String, *, 20, * ) -Original : Is AE or ae the same as Æ or æ? -No options : -------------------- as Æ or æ? - AE : f - ae : f - Æ : f - æ : f -Ordinal : -------------------- as Æ or æ? - AE : - ae : - Æ : f - æ : f -IgnoreCase : -------------------- as Æ or æ? - AE : f - ae : f - Æ : f - æ : f -LastIndexOf( String, *, 20, * ) -Original : Is AE or ae the same as Æ or æ? -No options : Is AE or ae the same ---------- - AE : l - ae : l - Æ : l - æ : l -Ordinal : Is AE or ae the same ---------- - AE : l - ae : l - Æ : - æ : -IgnoreCase : Is AE or ae the same ---------- - AE : l - ae : l - Æ : l - æ : l - -IndexOf( String, *, 20, * ) -Original : Is U" or u" the same as Ü or ü? -No options : -------------------- as Ü or ü? - U" : f - u" : f - Ü : f - ü : f -Ordinal : -------------------- as Ü or ü? - U" : - u" : - Ü : f - ü : f -IgnoreCase : -------------------- as Ü or ü? - U" : f - u" : f - Ü : f - ü : f -LastIndexOf( String, *, 20, * ) -Original : Is U" or u" the same as Ü or ü? -No options : Is U" or u" the same ---------- - U" : l - u" : l - Ü : l - ü : l -Ordinal : Is U" or u" the same ---------- - U" : l - u" : l - Ü : - ü : -IgnoreCase : Is U" or u" the same ---------- - U" : l - u" : l - Ü : l - ü : l - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfIntInt/CPP/indexofintint.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfIntInt/CPP/indexofintint.cpp deleted file mode 100644 index 381970926e1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfIntInt/CPP/indexofintint.cpp +++ /dev/null @@ -1,134 +0,0 @@ - -// The following code example determines the indexes of the first and last occurrences of a character or a substring within a portion of a string. -// -using namespace System; -using namespace System::Globalization; -void PrintMarker( String^ Prefix, int First, int Last ) -{ - - // Determines the size of the array to create. - int mySize; - if ( Last > First ) - mySize = Last; - else - mySize = First; - - if ( mySize > -1 ) - { - - // Creates an array of Char to hold the markers. - array^myCharArr = gcnew array(mySize + 1); - - // Inserts the appropriate markers. - if ( First > -1 ) - myCharArr[ First ] = 'f'; - if ( Last > -1 ) - myCharArr[ Last ] = 'l'; - if ( First == Last ) - myCharArr[ First ] = 'b'; - - // Displays the array of Char as a String. - Console::WriteLine( "{0}{1}", Prefix, gcnew String( myCharArr ) ); - } - else - Console::WriteLine( Prefix ); -} - -int main() -{ - - // Creates CompareInfo for the InvariantCulture. - CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo; - - // iS is the starting index of the substring. - int iS = 8; - - // iL is the length of the substring. - int iL = 18; - - // myT1 and myT2 are the strings used for padding. - String^ myT1 = gcnew String( '-',iS ); - String^ myT2; - - // Searches for the ligature Æ. - String^ myStr = "Is AE or ae the same as Æ or æ?"; - myT2 = gcnew String( '-',myStr->Length - iS - iL ); - Console::WriteLine(); - Console::WriteLine( "Original : {0}", myStr ); - Console::WriteLine( "No options : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 ); - PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS, iL ), myComp->LastIndexOf( myStr, "AE", iS + iL - 1, iL ) ); - PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS, iL ), myComp->LastIndexOf( myStr, "ae", iS + iL - 1, iL ) ); - PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS, iL ), myComp->LastIndexOf( myStr, L'Æ', iS + iL - 1, iL ) ); - PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS, iL ), myComp->LastIndexOf( myStr, L'æ', iS + iL - 1, iL ) ); - Console::WriteLine( "Ordinal : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 ); - PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "AE", iS + iL - 1, iL, CompareOptions::Ordinal ) ); - PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "ae", iS + iL - 1, iL, CompareOptions::Ordinal ) ); - PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'Æ', iS + iL - 1, iL, CompareOptions::Ordinal ) ); - PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'æ', iS + iL - 1, iL, CompareOptions::Ordinal ) ); - Console::WriteLine( "IgnoreCase : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 ); - PrintMarker( " AE : ", myComp->IndexOf( myStr, "AE", iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "AE", iS + iL - 1, iL, CompareOptions::IgnoreCase ) ); - PrintMarker( " ae : ", myComp->IndexOf( myStr, "ae", iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "ae", iS + iL - 1, iL, CompareOptions::IgnoreCase ) ); - PrintMarker( " Æ : ", myComp->IndexOf( myStr, L'Æ', iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'Æ', iS + iL - 1, iL, CompareOptions::IgnoreCase ) ); - PrintMarker( " æ : ", myComp->IndexOf( myStr, L'æ', iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'æ', iS + iL - 1, iL, CompareOptions::IgnoreCase ) ); - - // Searches for the combining character sequence Latin capital letter U with diaeresis or Latin small letter u with diaeresis. - myStr = "Is U\u0308 or u\u0308 the same as \u00DC or \u00FC?"; - myT2 = gcnew String( '-',myStr->Length - iS - iL ); - Console::WriteLine(); - Console::WriteLine( "Original : {0}", myStr ); - Console::WriteLine( "No options : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 ); - PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS, iL ), myComp->LastIndexOf( myStr, "U\u0308", iS + iL - 1, iL ) ); - PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS, iL ), myComp->LastIndexOf( myStr, "u\u0308", iS + iL - 1, iL ) ); - PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS, iL ), myComp->LastIndexOf( myStr, L'Ü', iS + iL - 1, iL ) ); - PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS, iL ), myComp->LastIndexOf( myStr, L'ü', iS + iL - 1, iL ) ); - Console::WriteLine( "Ordinal : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 ); - PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "U\u0308", iS + iL - 1, iL, CompareOptions::Ordinal ) ); - PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, "u\u0308", iS + iL - 1, iL, CompareOptions::Ordinal ) ); - PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'Ü', iS + iL - 1, iL, CompareOptions::Ordinal ) ); - PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS, iL, CompareOptions::Ordinal ), myComp->LastIndexOf( myStr, L'ü', iS + iL - 1, iL, CompareOptions::Ordinal ) ); - Console::WriteLine( "IgnoreCase : {0}{1}{2}", myT1, myStr->Substring( iS, iL ), myT2 ); - PrintMarker( " U\u0308 : ", myComp->IndexOf( myStr, "U\u0308", iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "U\u0308", iS + iL - 1, iL, CompareOptions::IgnoreCase ) ); - PrintMarker( " u\u0308 : ", myComp->IndexOf( myStr, "u\u0308", iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, "u\u0308", iS + iL - 1, iL, CompareOptions::IgnoreCase ) ); - PrintMarker( " Ü : ", myComp->IndexOf( myStr, L'Ü', iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'Ü', iS + iL - 1, iL, CompareOptions::IgnoreCase ) ); - PrintMarker( " ü : ", myComp->IndexOf( myStr, L'ü', iS, iL, CompareOptions::IgnoreCase ), myComp->LastIndexOf( myStr, L'ü', iS + iL - 1, iL, CompareOptions::IgnoreCase ) ); -} - -/* -This code produces the following output. - -Original : Is AE or ae the same as Æ or æ? -No options : -------- ae the same as Æ ----- - AE : b - ae : b - Æ : b - æ : b -Ordinal : -------- ae the same as Æ ----- - AE : - ae : b - Æ : b - æ : -IgnoreCase : -------- ae the same as Æ ----- - AE : f l - ae : f l - Æ : f l - æ : f l - -Original : Is U" or u" the same as Ü or ü? -No options : -------- u" the same as Ü ----- - U" : b - u" : b - Ü : b - ü : b -Ordinal : -------- u" the same as Ü ----- - U" : - u" : b - Ü : b - ü : -IgnoreCase : -------- u" the same as Ü ----- - U" : f l - u" : f l - Ü : f l - ü : f l - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffix/CPP/isprefixsuffix.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffix/CPP/isprefixsuffix.cpp deleted file mode 100644 index 67bd06172ff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffix/CPP/isprefixsuffix.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// The following code example determines whether a String* is the prefix or suffix of another String*. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Defines the strings to compare. - String^ myStr1 = "calle"; - String^ myStr2 = "llegar"; - String^ myXfix = "lle"; - - // Uses the CompareInfo property of the InvariantCulture. - CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo; - - // Determines whether myXfix is a prefix of S"calle" and S"llegar". - Console::WriteLine( "IsPrefix( {0}, {1}) : {2}", myStr1, myXfix, myComp->IsPrefix( myStr1, myXfix ) ); - Console::WriteLine( "IsPrefix( {0}, {1}) : {2}", myStr2, myXfix, myComp->IsPrefix( myStr2, myXfix ) ); - - // Determines whether myXfix is a suffix of S"calle" and S"llegar". - Console::WriteLine( "IsSuffix( {0}, {1}) : {2}", myStr1, myXfix, myComp->IsSuffix( myStr1, myXfix ) ); - Console::WriteLine( "IsSuffix( {0}, {1}) : {2}", myStr2, myXfix, myComp->IsSuffix( myStr2, myXfix ) ); -} - -/* -This code produces the following output. - -IsPrefix(calle, lle) : False -IsPrefix(llegar, lle) : True -IsSuffix(calle, lle) : True -IsSuffix(llegar, lle) : False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffixOpt/CPP/isprefixsuffixopt.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffixOpt/CPP/isprefixsuffixopt.cpp deleted file mode 100644 index 4873c4342d0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffixOpt/CPP/isprefixsuffixopt.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// The following code example determines whether a String* is the prefix or suffix of another String* using CompareOptions. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Defines the strings to compare. - String^ myStr1 = "calle"; - String^ myStr2 = "llegar"; - String^ myXfix = "LLE"; - - // Uses the CompareInfo property of the InvariantCulture. - CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo; - Console::WriteLine( "IsSuffix \"{0}\", \"{1}\"", myStr1, myXfix ); - Console::WriteLine( " With no CompareOptions : {0}", myComp->IsSuffix( myStr1, myXfix ) ); - Console::WriteLine( " With None : {0}", myComp->IsSuffix( myStr1, myXfix, CompareOptions::None ) ); - Console::WriteLine( " With Ordinal : {0}", myComp->IsSuffix( myStr1, myXfix, CompareOptions::Ordinal ) ); - Console::WriteLine( " With IgnoreCase : {0}", myComp->IsSuffix( myStr1, myXfix, CompareOptions::IgnoreCase ) ); - Console::WriteLine( "IsPrefix \"{0}\", \"{1}\"", myStr2, myXfix ); - Console::WriteLine( " With no CompareOptions : {0}", myComp->IsPrefix( myStr2, myXfix ) ); - Console::WriteLine( " With None : {0}", myComp->IsPrefix( myStr2, myXfix, CompareOptions::None ) ); - Console::WriteLine( " With Ordinal : {0}", myComp->IsPrefix( myStr2, myXfix, CompareOptions::Ordinal ) ); - Console::WriteLine( " With IgnoreCase : {0}", myComp->IsPrefix( myStr2, myXfix, CompareOptions::IgnoreCase ) ); -} - -/* -This code produces the following output. - -IsSuffix "calle", "LLE" - With no CompareOptions : False - With None : False - With Ordinal : False - With IgnoreCase : True -IsPrefix "llegar", "LLE" - With no CompareOptions : False - With None : False - With Ordinal : False - With IgnoreCase : True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp deleted file mode 100644 index 36c0e20d3fc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// The following code example shows that CultureInfo::Clone also clones the DateTimeFormatInfo and -// NumberFormatInfo instances associated with the CultureInfo. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a CultureInfo. - CultureInfo^ myCI = gcnew CultureInfo( "en-US",false ); - - // Clones myCI and modifies the DTFI and NFI instances associated with the clone. - CultureInfo^ myCIclone = dynamic_cast(myCI->Clone()); - myCIclone->DateTimeFormat->AMDesignator = "a.m."; - myCIclone->DateTimeFormat->DateSeparator = "-"; - myCIclone->NumberFormat->CurrencySymbol = "USD"; - myCIclone->NumberFormat->NumberDecimalDigits = 4; - - // Displays the properties of the DTFI and NFI instances associated with the original and with the clone. - Console::WriteLine( "DTFI/NFI PROPERTY\tORIGINAL\tMODIFIED CLONE" ); - Console::WriteLine( "DTFI.AMDesignator\t{0}\t\t{1}", myCI->DateTimeFormat->AMDesignator, myCIclone->DateTimeFormat->AMDesignator ); - Console::WriteLine( "DTFI.DateSeparator\t{0}\t\t{1}", myCI->DateTimeFormat->DateSeparator, myCIclone->DateTimeFormat->DateSeparator ); - Console::WriteLine( "NFI.CurrencySymbol\t{0}\t\t{1}", myCI->NumberFormat->CurrencySymbol, myCIclone->NumberFormat->CurrencySymbol ); - Console::WriteLine( "NFI.NumberDecimalDigits\t{0}\t\t{1}", myCI->NumberFormat->NumberDecimalDigits, myCIclone->NumberFormat->NumberDecimalDigits ); -} - -/* -This code produces the following output. - -DTFI/NFI PROPERTY ORIGINAL MODIFIED CLONE -DTFI.AMDesignator AM a.m. -DTFI.DateSeparator / - -NFI.CurrencySymbol $ USD -NFI.NumberDecimalDigits 2 4 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CPP/currentculture.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CPP/currentculture.cpp deleted file mode 100644 index 39d0500f201..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CPP/currentculture.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; -using namespace System::Threading; - -int main() -{ - // Display the name of the current thread culture. - Console::WriteLine("CurrentCulture is {0}.", CultureInfo::CurrentCulture->Name); - - // Change the current culture to th-TH. - CultureInfo::CurrentCulture = gcnew CultureInfo("th-TH",false); - Console::WriteLine("CurrentCulture is now {0}.", CultureInfo::CurrentCulture->Name); - - // Displays the name of the CurrentUICulture of the current thread. - Console::WriteLine("CurrentUICulture is {0}.", CultureInfo::CurrentCulture->Name); - - // Changes the CurrentUICulture of the current thread to ja-JP. - CultureInfo::CurrentUICulture = gcnew CultureInfo("ja-JP",false); - Console::WriteLine("CurrentUICulture is now {0}.", CultureInfo::CurrentCulture->Name); -} -// The example displays the following output: -// CurrentCulture is en-US. -// CurrentCulture is now th-TH. -// CurrentUICulture is en-US. -// CurrentUICulture is now ja-JP. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp deleted file mode 100644 index 895e3754d36..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// The following code example displays several properties of the neutral cultures. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Displays several properties of the neutral cultures. - Console::WriteLine( "CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME" ); - System::Collections::IEnumerator^ enum0 = CultureInfo::GetCultures( CultureTypes::NeutralCultures )->GetEnumerator(); - while ( enum0->MoveNext() ) - { - CultureInfo^ ci = safe_cast(enum0->Current); - Console::Write( "{0,-7}", ci->Name ); - Console::Write( " {0,-3}", ci->TwoLetterISOLanguageName ); - Console::Write( " {0,-3}", ci->ThreeLetterISOLanguageName ); - Console::Write( " {0,-3}", ci->ThreeLetterWindowsLanguageName ); - Console::Write( " {0,-40}", ci->DisplayName ); - Console::WriteLine( " {0,-40}", ci->EnglishName ); - } -} - -/* -This code produces the following output. This output has been cropped for brevity. - -CULTURE ISO ISO WIN DISPLAYNAME ENGLISHNAME -ar ar ara ARA Arabic Arabic -bg bg bul BGR Bulgarian Bulgarian -ca ca cat CAT Catalan Catalan -zh-Hans zh zho CHS Chinese (Simplified) Chinese (Simplified) -cs cs ces CSY Czech Czech -da da dan DAN Danish Danish -de de deu DEU German German -el el ell ELL Greek Greek -en en eng ENU English English -es es spa ESP Spanish Spanish -fi fi fin FIN Finnish Finnish -zh zh zho CHS Chinese Chinese -zh-Hant zh zho CHT Chinese (Traditional) Chinese (Traditional) -zh-CHS zh zho CHS Chinese (Simplified) Legacy Chinese (Simplified) Legacy -zh-CHT zh zho CHT Chinese (Traditional) Legacy Chinese (Traditional) Legacy - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/CPP/neutralculture.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/CPP/neutralculture.cpp deleted file mode 100644 index c7d200f5865..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/CPP/neutralculture.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example determines which cultures using the Chinese language are neutral cultures. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Lists the cultures that use the Chinese language and determines if each is a neutral culture. - System::Collections::IEnumerator^ enum0 = CultureInfo::GetCultures( CultureTypes::AllCultures )->GetEnumerator(); - while ( enum0->MoveNext() ) - { - CultureInfo^ ci = safe_cast(enum0->Current); - if ( ci->TwoLetterISOLanguageName->Equals( "zh" ) ) - { - Console::Write( "{0,-7} {1,-40}", ci->Name, ci->EnglishName ); - if ( ci->IsNeutralCulture ) - { - Console::WriteLine( ": neutral" ); - } - else - { - Console::WriteLine( ": specific" ); - } - } - } -} - -/* -This code produces the following output. - -zh-Hans Chinese (Simplified) : neutral -zh-TW Chinese (Traditional, Taiwan) : specific -zh-CN Chinese (Simplified, PRC) : specific -zh-HK Chinese (Traditional, Hong Kong S.A.R.) : specific -zh-SG Chinese (Simplified, Singapore) : specific -zh-MO Chinese (Traditional, Macao S.A.R.) : specific -zh Chinese : neutral -zh-Hant Chinese (Traditional) : neutral -zh-CHS Chinese (Simplified) Legacy : neutral -zh-CHT Chinese (Traditional) Legacy : neutral - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Parent/CPP/parentculture.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Parent/CPP/parentculture.cpp deleted file mode 100644 index bc3ff941693..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Parent/CPP/parentculture.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// The following code example displays the parent culture of each specific -// culture using the Chinese language. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Prints the header. - Console::WriteLine( "SPECIFIC CULTURE PARENT CULTURE" ); - - // Determines the specific cultures that use the Chinese language, - // and displays the parent culture. - System::Collections::IEnumerator^ en = CultureInfo::GetCultures( CultureTypes::SpecificCultures )->GetEnumerator(); - while ( en->MoveNext() ) - { - CultureInfo^ ci = safe_cast(en->Current); - if ( ci->TwoLetterISOLanguageName->Equals( "zh" ) ) - { - Console::Write( "0x{0} {1} {2,-40}", ci->LCID.ToString( "X4" ), ci->Name, ci->EnglishName ); - Console::WriteLine( "0x{0} {1} {2}", ci->Parent->LCID.ToString( "X4" ), ci->Parent->Name, ci->Parent->EnglishName ); - } - } -} - -/* -This code produces the following output. - -SPECIFIC CULTURE PARENT CULTURE -0x0404 zh-TW Chinese (Traditional, Taiwan) 0x7C04 zh-CHT Chinese (Traditional) Legacy -0x0804 zh-CN Chinese (Simplified, PRC) 0x0004 zh-CHS Chinese (Simplified) Legacy -0x0C04 zh-HK Chinese (Traditional, Hong Kong S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) Legacy -0x1004 zh-SG Chinese (Simplified, Singapore) 0x0004 zh-CHS Chinese (Simplified) Legacy -0x1404 zh-MO Chinese (Traditional, Macao S.A.R.) 0x7C04 zh-CHT Chinese (Traditional) Legacy - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/CPP/yslin_cultureinfo_readonly.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/CPP/yslin_cultureinfo_readonly.cpp deleted file mode 100644 index c2e98b06394..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/CPP/yslin_cultureinfo_readonly.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// The following code example shows that CultureInfo::ReadOnly also protects the -// DateTimeFormatInfo and NumberFormatInfo instances associated with the CultureInfo. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates a CultureInfo. - CultureInfo^ myCI = gcnew CultureInfo( "en-US" ); - - // Creates a read-only CultureInfo based on myCI -> - CultureInfo^ myReadOnlyCI = CultureInfo::ReadOnly( myCI ); - - // Display the read-only status of each CultureInfo and their DateTimeFormat and NumberFormat properties. - Console::WriteLine( "myCI is {0}.", myCI->IsReadOnly ? (String^)"read only" : "writable" ); - Console::WriteLine( "myCI -> DateTimeFormat is {0}.", myCI->DateTimeFormat->IsReadOnly ? (String^)"read only" : "writable" ); - Console::WriteLine( "myCI -> NumberFormat is {0}.", myCI->NumberFormat->IsReadOnly ? (String^)"read only" : "writable" ); - Console::WriteLine( "myReadOnlyCI is {0}.", myReadOnlyCI->IsReadOnly ? (String^)"read only" : "writable" ); - Console::WriteLine( "myReadOnlyCI -> DateTimeFormat is {0}.", myReadOnlyCI->DateTimeFormat->IsReadOnly ? (String^)"read only" : "writable" ); - Console::WriteLine( "myReadOnlyCI -> NumberFormat is {0}.", myReadOnlyCI->NumberFormat->IsReadOnly ? (String^)"read only" : "writable" ); -} - -/* -This code produces the following output. - -myCI is writable. -myCI -> DateTimeFormat is writable. -myCI -> NumberFormat is writable. -myReadOnlyCI is read only. -myReadOnlyCI -> DateTimeFormat is read only. -myReadOnlyCI -> NumberFormat is read only. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp deleted file mode 100644 index 5a683e17740..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -// The following code example shows how to create a CultureInfo for S"Spanish - Spain" -// with the international sort and another with the traditional sort. -// -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes the CultureInfo which uses the international sort. - CultureInfo^ myCIintl = gcnew CultureInfo( "es-ES",false ); - - // Creates and initializes the CultureInfo which uses the traditional sort. - CultureInfo^ myCItrad = gcnew CultureInfo( 0x040A,false ); - - // Displays the properties of each culture. - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "PROPERTY", "INTERNATIONAL", "TRADITIONAL" ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "CompareInfo", myCIintl->CompareInfo, myCItrad->CompareInfo ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "DisplayName", myCIintl->DisplayName, myCItrad->DisplayName ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "EnglishName", myCIintl->EnglishName, myCItrad->EnglishName ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "IsNeutralCulture", myCIintl->IsNeutralCulture, myCItrad->IsNeutralCulture ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "IsReadOnly", myCIintl->IsReadOnly, myCItrad->IsReadOnly ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "LCID", myCIintl->LCID, myCItrad->LCID ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "Name", myCIintl->Name, myCItrad->Name ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "NativeName", myCIintl->NativeName, myCItrad->NativeName ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "Parent", myCIintl->Parent, myCItrad->Parent ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "TextInfo", myCIintl->TextInfo, myCItrad->TextInfo ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "ThreeLetterISOLanguageName", myCIintl->ThreeLetterISOLanguageName, myCItrad->ThreeLetterISOLanguageName ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "ThreeLetterWindowsLanguageName", myCIintl->ThreeLetterWindowsLanguageName, myCItrad->ThreeLetterWindowsLanguageName ); - Console::WriteLine( "{0,-31}{1,-47}{2,-25}", "TwoLetterISOLanguageName", myCIintl->TwoLetterISOLanguageName, myCItrad->TwoLetterISOLanguageName ); - Console::WriteLine(); - - // Compare two strings using myCIintl -> - Console::WriteLine( "Comparing \"llegar\" and \"lugar\"" ); - Console::WriteLine( " With myCIintl -> CompareInfo -> Compare: {0}", myCIintl->CompareInfo->Compare( "llegar", "lugar" ) ); - Console::WriteLine( " With myCItrad -> CompareInfo -> Compare: {0}", myCItrad->CompareInfo->Compare( "llegar", "lugar" ) ); -} - -/* -This code produces the following output. - -PROPERTY INTERNATIONAL TRADITIONAL -CompareInfo CompareInfo - es-ES CompareInfo - es-ES_tradnl -DisplayName Spanish (Spain) Spanish (Spain) -EnglishName Spanish (Spain, International Sort) Spanish (Spain, Traditional Sort) -IsNeutralCulture False False -IsReadOnly False False -LCID 3082 1034 -Name es-ES es-ES -NativeName Español (España, alfabetización internacional) Español (España, alfabetización tradicional) -Parent es es -TextInfo TextInfo - es-ES TextInfo - es-ES_tradnl -ThreeLetterISOLanguageName spa spa -ThreeLetterWindowsLanguageName ESN ESP -TwoLetterISOLanguageName es es - -Comparing "llegar" and "lugar" - With myCIintl -> CompareInfo -> Compare: -1 - With myCItrad -> CompareInfo -> Compare: 1 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.FullDateTimePattern/CPP/dtfi_fulldatetimepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.FullDateTimePattern/CPP/dtfi_fulldatetimepattern.cpp deleted file mode 100644 index c9f0bdb0a61..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.FullDateTimePattern/CPP/dtfi_fulldatetimepattern.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// The following code example displays the value of FullDateTimePattern for selected cultures. -// -using namespace System; -using namespace System::Globalization; -void PrintPattern( String^ myCulture ) -{ - CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false ); - DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat; - Console::WriteLine( " {0} {1}", myCulture, myDTFI->FullDateTimePattern ); -} - -int main() -{ - - // Displays the values of the pattern properties. - Console::WriteLine( " CULTURE PROPERTY VALUE" ); - PrintPattern( "en-US" ); - PrintPattern( "ja-JP" ); - PrintPattern( "fr-FR" ); -} - -/* -This code produces the following output. The question marks take the place of native script characters. - -CULTURE PROPERTY VALUE -en-US dddd, MMMM dd, yyyy h:mm:ss tt -ja-JP yyyy'年'M'月'd'日' H:mm:ss -fr-FR dddd d MMMM yyyy HH:mm:ss - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongDatePattern/CPP/dtfi_longdatepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongDatePattern/CPP/dtfi_longdatepattern.cpp deleted file mode 100644 index 64fb0d7708a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongDatePattern/CPP/dtfi_longdatepattern.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// The following code example displays the value of LongDatePattern for selected cultures. -// -using namespace System; -using namespace System::Globalization; -void PrintPattern( String^ myCulture ) -{ - CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false ); - DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat; - Console::WriteLine( " {0} {1}", myCulture, myDTFI->LongDatePattern ); -} - -int main() -{ - - // Displays the values of the pattern properties. - Console::WriteLine( " CULTURE PROPERTY VALUE" ); - PrintPattern( "en-US" ); - PrintPattern( "ja-JP" ); - PrintPattern( "fr-FR" ); -} - -/* -This code produces the following output: - -CULTURE PROPERTY VALUE -en-US dddd, MMMM dd, yyyy -ja-JP yyyy'年'M'月'd'日' -fr-FR dddd d MMMM yyyy - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongTimePattern/CPP/dtfi_longtimepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongTimePattern/CPP/dtfi_longtimepattern.cpp deleted file mode 100644 index 035bc98e2a0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongTimePattern/CPP/dtfi_longtimepattern.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// The following code example displays the value of LongTimePattern for selected cultures. -// -using namespace System; -using namespace System::Globalization; -void PrintPattern( String^ myCulture ) -{ - CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false ); - DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat; - Console::WriteLine( " {0} {1}", myCulture, myDTFI->LongTimePattern ); -} - -int main() -{ - - // Displays the values of the pattern properties. - Console::WriteLine( " CULTURE PROPERTY VALUE" ); - PrintPattern( "en-US" ); - PrintPattern( "ja-JP" ); - PrintPattern( "fr-FR" ); -} - -/* -This code produces the following output. - -CULTURE PROPERTY VALUE -en-US h:mm:ss tt -ja-JP H:mm:ss -fr-FR HH:mm:ss - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.MonthDayPattern/CPP/dtfi_monthdaypattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.MonthDayPattern/CPP/dtfi_monthdaypattern.cpp deleted file mode 100644 index 29e0b173c0f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.MonthDayPattern/CPP/dtfi_monthdaypattern.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// The following code example displays the value of MonthDayPattern for selected cultures. -// -using namespace System; -using namespace System::Globalization; -void PrintPattern( String^ myCulture ) -{ - CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false ); - DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat; - Console::WriteLine( " {0} {1}", myCulture, myDTFI->MonthDayPattern ); -} - -int main() -{ - - // Displays the values of the pattern properties. - Console::WriteLine( " CULTURE PROPERTY VALUE" ); - PrintPattern( "en-US" ); - PrintPattern( "ja-JP" ); - PrintPattern( "fr-FR" ); -} - -/* -This code produces the following output. The question marks take the place of native script characters. - -CULTURE PROPERTY VALUE -en-US MMMM dd -ja-JP M'?'d'?' -fr-FR d MMMM - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.RFC1123Pattern/CPP/dtfi_rfc1123pattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.RFC1123Pattern/CPP/dtfi_rfc1123pattern.cpp deleted file mode 100644 index 6f5088a4914..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.RFC1123Pattern/CPP/dtfi_rfc1123pattern.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// The following code example displays the value of RFC1123Pattern for selected cultures. -// -using namespace System; -using namespace System::Globalization; -void PrintPattern( String^ myCulture ) -{ - CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false ); - DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat; - Console::WriteLine( " {0} {1}", myCulture, myDTFI->RFC1123Pattern ); -} - -int main() -{ - - // Displays the values of the pattern properties. - Console::WriteLine( " CULTURE PROPERTY VALUE" ); - PrintPattern( "en-US" ); - PrintPattern( "ja-JP" ); - PrintPattern( "fr-FR" ); -} - -/* -This code produces the following output. - -CULTURE PROPERTY VALUE -en-US ddd, dd MMM yyyy HH':'mm':'ss 'GMT' -ja-JP ddd, dd MMM yyyy HH':'mm':'ss 'GMT' -fr-FR ddd, dd MMM yyyy HH':'mm':'ss 'GMT' - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.ShortTimePattern/CPP/dtfi_shorttimepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.ShortTimePattern/CPP/dtfi_shorttimepattern.cpp deleted file mode 100644 index 7bc1dc8a065..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.ShortTimePattern/CPP/dtfi_shorttimepattern.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// The following code example displays the value of ShortTimePattern for selected cultures. -// -using namespace System; -using namespace System::Globalization; -void PrintPattern( String^ myCulture ) -{ - CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false ); - DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat; - Console::WriteLine( " {0} {1}", myCulture, myDTFI->ShortTimePattern ); -} - -int main() -{ - - // Displays the values of the pattern properties. - Console::WriteLine( " CULTURE PROPERTY VALUE" ); - PrintPattern( "en-US" ); - PrintPattern( "ja-JP" ); - PrintPattern( "fr-FR" ); -} - -/* -This code produces the following output. - -CULTURE PROPERTY VALUE -en-US h:mm tt -ja-JP H:mm -fr-FR HH:mm - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.SortableDateTimePattern/CPP/dtfi_sortabledatetimepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.SortableDateTimePattern/CPP/dtfi_sortabledatetimepattern.cpp deleted file mode 100644 index e49b6b214a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.SortableDateTimePattern/CPP/dtfi_sortabledatetimepattern.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// The following code example displays the value of SortableDateTimePattern for selected cultures. -// -using namespace System; -using namespace System::Globalization; -void PrintPattern( String^ myCulture ) -{ - CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false ); - DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat; - Console::WriteLine( " {0} {1}", myCulture, myDTFI->SortableDateTimePattern ); -} - -int main() -{ - - // Displays the values of the pattern properties. - Console::WriteLine( " CULTURE PROPERTY VALUE" ); - PrintPattern( "en-US" ); - PrintPattern( "ja-JP" ); - PrintPattern( "fr-FR" ); -} - -/* -This code produces the following output. - -CULTURE PROPERTY VALUE -en-US yyyy'-'MM'-'dd'T'HH':'mm':'ss -ja-JP yyyy'-'MM'-'dd'T'HH':'mm':'ss -fr-FR yyyy'-'MM'-'dd'T'HH':'mm':'ss - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.UniversalSortableDateTimePattern/CPP/dtfi_universalsortabledatetimepattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.UniversalSortableDateTimePattern/CPP/dtfi_universalsortabledatetimepattern.cpp deleted file mode 100644 index f3e77ca4e46..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.UniversalSortableDateTimePattern/CPP/dtfi_universalsortabledatetimepattern.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// The following code example displays the value of UniversalSortableDateTimePattern -// for selected cultures. -// -using namespace System; -using namespace System::Globalization; -void PrintPattern( String^ myCulture ) -{ - CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false ); - DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat; - Console::WriteLine( " {0} {1}", myCulture, myDTFI->UniversalSortableDateTimePattern ); -} - -int main() -{ - - // Displays the values of the pattern properties. - Console::WriteLine( " CULTURE PROPERTY VALUE" ); - PrintPattern( "en-US" ); - PrintPattern( "ja-JP" ); - PrintPattern( "fr-FR" ); -} - -/* -This code produces the following output. - -CULTURE PROPERTY VALUE -en-US yyyy'-'MM'-'dd HH':'mm':'ss'Z' -ja-JP yyyy'-'MM'-'dd HH':'mm':'ss'Z' -fr-FR yyyy'-'MM'-'dd HH':'mm':'ss'Z' - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.YearMonthPattern/CPP/dtfi_yearmonthpattern.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.YearMonthPattern/CPP/dtfi_yearmonthpattern.cpp deleted file mode 100644 index 549fe6aecfd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.YearMonthPattern/CPP/dtfi_yearmonthpattern.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// The following code example displays the value of YearMonthPattern for selected cultures. -// -using namespace System; -using namespace System::Globalization; -void PrintPattern( String^ myCulture ) -{ - CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false ); - DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat; - Console::WriteLine( " {0} {1}", myCulture, myDTFI->YearMonthPattern ); -} - -int main() -{ - - // Displays the values of the pattern properties. - Console::WriteLine( " CULTURE PROPERTY VALUE" ); - PrintPattern( "en-US" ); - PrintPattern( "ja-JP" ); - PrintPattern( "fr-FR" ); -} - -/* -This code produces the following output. The question marks take the place of native script characters. - - CULTURE PROPERTY VALUE - en-US MMMM yyyy - ja-JP yyyy年M月 - fr-FR MMMM yyyy - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInMonth/CPP/gregoriancalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInMonth/CPP/gregoriancalendar_getdaysinmonth.cpp deleted file mode 100644 index cde0e811c88..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInMonth/CPP/gregoriancalendar_getdaysinmonth.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example calls GetDaysInMonth for the second month in each of -// 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a GregorianCalendar. - GregorianCalendar^ myCal = gcnew GregorianCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, GregorianCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2001 2002 2003 2004 2005 -CurrentEra: 28 28 28 29 28 -Era 1: 28 28 28 29 28 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInYear/CPP/gregoriancalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInYear/CPP/gregoriancalendar_getdaysinyear.cpp deleted file mode 100644 index a15e780eff2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetDaysInYear/CPP/gregoriancalendar_getdaysinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetDaysInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a GregorianCalendar. - GregorianCalendar^ myCal = gcnew GregorianCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, GregorianCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2001 2002 2003 2004 2005 -CurrentEra: 365 365 365 366 365 -Era 1: 365 365 365 366 365 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/CPP/gregorian_getera.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/CPP/gregorian_getera.cpp deleted file mode 100644 index 990c729f21e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/CPP/gregorian_getera.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -// The following code example shows that DTFI ignores the punctuation in the -// era name only if the calendar is Gregorian and the culture uses the era name "A.D.". -// -using namespace System; -using namespace System::Globalization; -using namespace System::Collections; -int main() -{ - - // Creates strings with punctuation and without. - String^ strADPunc = "A.D."; - String^ strADNoPunc = "AD"; - String^ strCEPunc = "C.E."; - String^ strCENoPunc = "CE"; - - // Calls DTFI::GetEra for each culture that uses GregorianCalendar as the default calendar. - Console::WriteLine( " ----- AD ----- ----- CE -----" ); - Console::WriteLine( "CULTURE PUNC NO PUNC PUNC NO PUNC CALENDAR" ); - IEnumerator^ en = CultureInfo::GetCultures( CultureTypes::SpecificCultures )->GetEnumerator(); - while ( en->MoveNext() ) - { - CultureInfo^ myCI = safe_cast(en->Current); - Console::Write( "{0, -12}", myCI ); - Console::Write( "{0,-7}{1,-9}", myCI->DateTimeFormat->GetEra( strADPunc ), myCI->DateTimeFormat->GetEra( strADNoPunc ) ); - Console::Write( "{0, -7}{1, -9}", myCI->DateTimeFormat->GetEra( strCEPunc ), myCI->DateTimeFormat->GetEra( strCENoPunc ) ); - Console::Write( "{0}", myCI->Calendar ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. This output has been cropped for brevity. - - ----- AD ----- ----- CE ----- -CULTURE PUNC NO PUNC PUNC NO PUNC CALENDAR -ar-SA -1 -1 -1 -1 System.Globalization.HijriCalendar -ar-IQ 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-EG 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-LY 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-DZ 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-MA 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-TN 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-OM 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-YE 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-SY 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-JO 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-LB 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-KW 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-AE 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-BH 1 1 -1 -1 System.Globalization.GregorianCalendar -ar-QA 1 1 -1 -1 System.Globalization.GregorianCalendar -bg-BG 1 1 -1 -1 System.Globalization.GregorianCalendar -ca-ES -1 -1 -1 -1 System.Globalization.GregorianCalendar -zh-TW -1 -1 -1 -1 System.Globalization.GregorianCalendar -zh-CN -1 -1 -1 -1 System.Globalization.GregorianCalendar -zh-HK 1 1 -1 -1 System.Globalization.GregorianCalendar -zh-SG 1 1 -1 -1 System.Globalization.GregorianCalendar -zh-MO 1 1 -1 -1 System.Globalization.GregorianCalendar -cs-CZ -1 -1 -1 -1 System.Globalization.GregorianCalendar -da-DK 1 1 -1 -1 System.Globalization.GregorianCalendar - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetMonthsInYear/CPP/gregoriancalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetMonthsInYear/CPP/gregoriancalendar_getmonthsinyear.cpp deleted file mode 100644 index dfe3801afab..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetMonthsInYear/CPP/gregoriancalendar_getmonthsinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetMonthsInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a GregorianCalendar. - GregorianCalendar^ myCal = gcnew GregorianCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, GregorianCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2001 2002 2003 2004 2005 -CurrentEra: 12 12 12 12 12 -Era 1: 12 12 12 12 12 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapDay/CPP/gregoriancalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapDay/CPP/gregoriancalendar_isleapday.cpp deleted file mode 100644 index e69e21eeaba..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapDay/CPP/gregoriancalendar_isleapday.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// The following code example calls IsLeapDay for the last day of the second -// month (February) for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a GregorianCalendar. - GregorianCalendar^ myCal = gcnew GregorianCalendar; - - // Creates a holder for the last day of the second month (February). - int iLastDay; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 2001; y <= 2005; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, GregorianCalendar::CurrentEra ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, GregorianCalendar::CurrentEra ) ); - - } - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2001; y <= 2005; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) ); - - } - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2001 2002 2003 2004 2005 -CurrentEra: False False False True False -Era 1: False False False True False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapMonth/CPP/gregoriancalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapMonth/CPP/gregoriancalendar_isleapmonth.cpp deleted file mode 100644 index 140956b9f7f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapMonth/CPP/gregoriancalendar_isleapmonth.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// The following code example calls IsLeapMonth for all the months in five years -// in the current era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a GregorianCalendar. - GregorianCalendar^ myCal = gcnew GregorianCalendar; - - // Checks all the months in five years in the current era. - int iMonthsInYear; - for ( int y = 2001; y <= 2005; y++ ) - { - Console::Write( " {0}:\t", y ); - iMonthsInYear = myCal->GetMonthsInYear( y, GregorianCalendar::CurrentEra ); - for ( int m = 1; m <= iMonthsInYear; m++ ) - Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, GregorianCalendar::CurrentEra ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -2001: False False False False False False False False False False False False -2002: False False False False False False False False False False False False -2003: False False False False False False False False False False False False -2004: False False False False False False False False False False False False -2005: False False False False False False False False False False False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapYear/CPP/gregoriancalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapYear/CPP/gregoriancalendar_isleapyear.cpp deleted file mode 100644 index 6331dd01784..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.IsLeapYear/CPP/gregoriancalendar_isleapyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls IsLeapYear for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a GregorianCalendar. - GregorianCalendar^ myCal = gcnew GregorianCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, GregorianCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2001 2002 2003 2004 2005 -CurrentEra: False False False True False -Era 1: False False False True False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/CPP/gregorianlocalized.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/CPP/gregorianlocalized.cpp deleted file mode 100644 index 1a0b6a1e910..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/CPP/gregorianlocalized.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// The following code example prints a DateTime using a GregorianCalendar that is localized. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes three different CultureInfo. - CultureInfo^ myCIdeDE = gcnew CultureInfo( "de-DE",false ); - CultureInfo^ myCIenUS = gcnew CultureInfo( "en-US",false ); - CultureInfo^ myCIfrFR = gcnew CultureInfo( "fr-FR",false ); - CultureInfo^ myCIruRU = gcnew CultureInfo( "ru-RU",false ); - - // Creates a Localized GregorianCalendar. - // GregorianCalendarTypes::Localized is the default when using the GregorianCalendar constructor with->Item[Out] parameters. - Calendar^ myCal = gcnew GregorianCalendar; - - // Sets the DateTimeFormatInfo::Calendar property to a Localized GregorianCalendar. - // Localized GregorianCalendar is the default calendar for de-DE, en-US, and fr-FR, - myCIruRU->DateTimeFormat->Calendar = myCal; - - // Creates a DateTime. - DateTime myDT = DateTime(2002,1,3,13,30,45); - - // Displays the DateTime. - Console::WriteLine( "de-DE: {0}", myDT.ToString( "F", myCIdeDE ) ); - Console::WriteLine( "en-US: {0}", myDT.ToString( "F", myCIenUS ) ); - Console::WriteLine( "fr-FR: {0}", myDT.ToString( "F", myCIfrFR ) ); - Console::WriteLine( "ru-RU: {0}", myDT.ToString( "F", myCIruRU ) ); -} - -/* -The example displays the following output: - de-DE: Donnerstag, 3. Januar 2002 13:30:45 - en-US: Thursday, January 03, 2002 1:30:45 PM - fr-FR: jeudi 3 janvier 2002 13:30:45 - ru-RU: 3 января 2002 г. 13:30:45 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/CPP/gregoriancalendartypes.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/CPP/gregoriancalendartypes.cpp deleted file mode 100644 index 698b5b3e06f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/CPP/gregoriancalendartypes.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example demonstrates how to determine the GregorianCalendar -// version supported by the culture. -// -using namespace System; -using namespace System::Globalization; -using namespace System::Collections; -int main() -{ - - // Calendar* myOptCals[] = new CultureInfo(S"ar-SA") -> OptionalCalendars; - CultureInfo^ MyCI = gcnew CultureInfo( "ar-SA" ); - array^myOptCals = MyCI->OptionalCalendars; - - // Checks which ones are GregorianCalendar then determines the GregorianCalendar version. - Console::WriteLine( "The ar-SA culture supports the following calendars:" ); - IEnumerator^ myEnum = myOptCals->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Calendar^ cal = safe_cast(myEnum->Current); - if ( cal->GetType() == GregorianCalendar::typeid ) - { - GregorianCalendar^ myGreCal = dynamic_cast(cal); - GregorianCalendarTypes calType = myGreCal->CalendarType; - Console::WriteLine( " {0} ( {1})", cal, calType ); - } - else - Console::WriteLine( " {0}", cal ); - } -} - -/* -This code produces the following output. - -The ar-SA culture supports the following calendars: - System.Globalization.HijriCalendar - System.Globalization.GregorianCalendar ( USEnglish) - System.Globalization.GregorianCalendar ( MiddleEastFrench) - System.Globalization.GregorianCalendar ( Arabic) - System.Globalization.GregorianCalendar ( Localized) - System.Globalization.GregorianCalendar ( TransliteratedFrench) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp deleted file mode 100644 index 372b38993c5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// The following code example displays the values of several components of a DateTime in terms of the Gregorian calendar. -// -using namespace System; -using namespace System::Globalization; -void DisplayValues( Calendar^ myCal, DateTime myDT ) -{ - Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) ); - Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) ); - Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) ); - Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) ); - Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) ); - Console::WriteLine(); -} - -int main() -{ - - // Sets a DateTime to April 3, 2002 of the Gregorian calendar. - DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar); - - // Creates an instance of the GregorianCalendar. - GregorianCalendar^ myCal = gcnew GregorianCalendar; - - // Displays the values of the DateTime. - Console::WriteLine( "April 3, 2002 of the Gregorian calendar:" ); - DisplayValues( myCal, myDT ); - - // Adds two years and ten months. - myDT = myCal->AddYears( myDT, 2 ); - myDT = myCal->AddMonths( myDT, 10 ); - - // Displays the values of the DateTime. - Console::WriteLine( "After adding two years and ten months:" ); - DisplayValues( myCal, myDT ); -} - -/* -This code produces the following output. - -April 3, 2002 of the Gregorian calendar: - Era: 1 - Year: 2002 - Month: 4 - DayOfYear: 93 - DayOfMonth: 3 - DayOfWeek: Wednesday - -After adding two years and ten months: - Era: 1 - Year: 2005 - Month: 2 - DayOfYear: 34 - DayOfMonth: 3 - DayOfWeek: Thursday - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_MinMax/CPP/gregoriancalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_MinMax/CPP/gregoriancalendar_minmax.cpp deleted file mode 100644 index f3640634df9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_MinMax/CPP/gregoriancalendar_minmax.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// The following code example gets the minimum date and the maximum date of the calendar. -// -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Create an instance of the calendar. - GregorianCalendar^ myCal = gcnew GregorianCalendar; - Console::WriteLine( myCal ); - - // Display the MinSupportedDateTime. - DateTime myMin = myCal->MinSupportedDateTime; - Console::WriteLine( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) ); - - // Display the MaxSupportedDateTime. - DateTime myMax = myCal->MaxSupportedDateTime; - Console::WriteLine( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) ); -} - -/* -This code produces the following output. - -System.Globalization.GregorianCalendar -MinSupportedDateTime: 01/01/0001 -MaxSupportedDateTime: 12/31/9999 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetDaysInMonth/CPP/hebrewcalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetDaysInMonth/CPP/hebrewcalendar_getdaysinmonth.cpp deleted file mode 100644 index bc4213e8f2e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetDaysInMonth/CPP/hebrewcalendar_getdaysinmonth.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example calls GetDaysInMonth for the second month in each of -// 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HebrewCalendar. - HebrewCalendar^ myCal = gcnew HebrewCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, HebrewCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 5761 5762 5763 5764 5765 -CurrentEra: 29 29 30 30 29 -Era 1: 29 29 30 30 29 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetMonthsInYear/CPP/hebrewcalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetMonthsInYear/CPP/hebrewcalendar_getmonthsinyear.cpp deleted file mode 100644 index 57e2ea00d8c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetMonthsInYear/CPP/hebrewcalendar_getmonthsinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetMonthsInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HebrewCalendar. - HebrewCalendar^ myCal = gcnew HebrewCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, HebrewCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 5761 5762 5763 5764 5765 -CurrentEra: 12 12 13 12 13 -Era 1: 12 12 13 12 13 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapDay/CPP/hebrewcalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapDay/CPP/hebrewcalendar_isleapday.cpp deleted file mode 100644 index 9c1c73168c4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapDay/CPP/hebrewcalendar_isleapday.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// The following code example calls IsLeapDay for the last day of the second month -// (February) for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HebrewCalendar. - HebrewCalendar^ myCal = gcnew HebrewCalendar; - - // Creates a holder for the last day of the second month (February). - int iLastDay; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 5761; y <= 5765; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, HebrewCalendar::CurrentEra ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, HebrewCalendar::CurrentEra ) ); - - } - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 5761; y <= 5765; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) ); - - } - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 5761 5762 5763 5764 5765 -CurrentEra: False False False False False -Era 1: False False False False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapMonth/CPP/hebrewcalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapMonth/CPP/hebrewcalendar_isleapmonth.cpp deleted file mode 100644 index 1da1268009b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapMonth/CPP/hebrewcalendar_isleapmonth.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// The following code example calls IsLeapMonth for all the months in five years -// in the current era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HebrewCalendar. - HebrewCalendar^ myCal = gcnew HebrewCalendar; - - // Checks all the months in five years in the current era. - int iMonthsInYear; - for ( int y = 5761; y <= 5765; y++ ) - { - Console::Write( " {0}:\t", y ); - iMonthsInYear = myCal->GetMonthsInYear( y, HebrewCalendar::CurrentEra ); - for ( int m = 1; m <= iMonthsInYear; m++ ) - Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, HebrewCalendar::CurrentEra ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -5761: False False False False False False False False False False False False -5762: False False False False False False False False False False False False -5763: False False False False False False True False False False False False False -5764: False False False False False False False False False False False False -5765: False False False False False False True False False False False False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapYear/CPP/hebrewcalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapYear/CPP/hebrewcalendar_isleapyear.cpp deleted file mode 100644 index f7458927a3b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapYear/CPP/hebrewcalendar_isleapyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls IsLeapYear for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HebrewCalendar. - HebrewCalendar^ myCal = gcnew HebrewCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, HebrewCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 5761 5762 5763 5764 5765 -CurrentEra: False False True False True -Era 1: False False True False True - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp deleted file mode 100644 index cadc36701b1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// The following code example displays the values of several components of a DateTime in terms of the Hebrew calendar. -// -using namespace System; -using namespace System::Globalization; -void DisplayValues( Calendar^ myCal, DateTime myDT ) -{ - Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) ); - Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) ); - Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) ); - Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) ); - Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) ); - Console::WriteLine(); -} - -int main() -{ - - // Sets a DateTime to April 3, 2002 of the Gregorian calendar. - DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar); - - // Creates an instance of the HebrewCalendar. - HebrewCalendar^ myCal = gcnew HebrewCalendar; - - // Displays the values of the DateTime. - Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Hebrew calendar:" ); - DisplayValues( myCal, myDT ); - - // Adds two years and ten months. - myDT = myCal->AddYears( myDT, 2 ); - myDT = myCal->AddMonths( myDT, 10 ); - - // Displays the values of the DateTime. - Console::WriteLine( "After adding two years and ten months:" ); - DisplayValues( myCal, myDT ); -} - -/* -This code produces the following output. - -April 3, 2002 of the Gregorian calendar equals the following in the Hebrew calendar: - Era: 1 - Year: 5762 - Month: 7 - DayOfYear: 198 - DayOfMonth: 21 - DayOfWeek: Wednesday - -After adding two years and ten months: - Era: 1 - Year: 5765 - Month: 5 - DayOfYear: 138 - DayOfMonth: 21 - DayOfWeek: Monday - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_GetDaysInYear/CPP/hebrewcalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_GetDaysInYear/CPP/hebrewcalendar_getdaysinyear.cpp deleted file mode 100644 index d739184677c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_GetDaysInYear/CPP/hebrewcalendar_getdaysinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetDaysInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HebrewCalendar. - HebrewCalendar^ myCal = gcnew HebrewCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, HebrewCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 5761; y <= 5765; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 5761 5762 5763 5764 5765 -CurrentEra: 353 354 385 355 383 -Era 1: 353 354 385 355 383 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_MinMax/CPP/hebrewcalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_MinMax/CPP/hebrewcalendar_minmax.cpp deleted file mode 100644 index 6355880b6f4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_MinMax/CPP/hebrewcalendar_minmax.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// The following code example gets the minimum date and the maximum date of the calendar. -// -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Create an instance of the calendar. - HebrewCalendar^ myCal = gcnew HebrewCalendar; - Console::WriteLine( myCal ); - - // Create an instance of the GregorianCalendar. - GregorianCalendar^ myGre = gcnew GregorianCalendar; - - // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMin = myCal->MinSupportedDateTime; - Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) ); - - // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMax = myCal->MaxSupportedDateTime; - Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) ); -} - -/* -This code produces the following output. - -System.Globalization.HebrewCalendar -MinSupportedDateTime: 04/07/5343 (in Gregorian, 01/01/1583) -MaxSupportedDateTime: 13/29/5999 (in Gregorian, 09/29/2239) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInMonth/CPP/hijricalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInMonth/CPP/hijricalendar_getdaysinmonth.cpp deleted file mode 100644 index b31c1af503b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInMonth/CPP/hijricalendar_getdaysinmonth.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// The following code example calls GetDaysInMonth for the twelfth month in -// each of 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HijriCalendar. - HijriCalendar^ myCal = gcnew HijriCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 12, HijriCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 12, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. The results might vary depending on -the settings in Regional and Language Options (or Regional Options or Regional Settings). - -YEAR 1421 1422 1423 1424 1425 -CurrentEra: 29 29 30 29 29 -Era 1: 29 29 30 29 29 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInYear/CPP/hijricalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInYear/CPP/hijricalendar_getdaysinyear.cpp deleted file mode 100644 index 036e38f6962..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetDaysInYear/CPP/hijricalendar_getdaysinyear.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example calls GetDaysInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HijriCalendar. - HijriCalendar^ myCal = gcnew HijriCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, HijriCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. The results might vary depending on -the settings in Regional and Language Options (or Regional Options or Regional Settings). - -YEAR 1421 1422 1423 1424 1425 -CurrentEra: 354 354 355 354 354 -Era 1: 354 354 355 354 354 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetMonthsInYear/CPP/hijricalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetMonthsInYear/CPP/hijricalendar_getmonthsinyear.cpp deleted file mode 100644 index f922542fad0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.GetMonthsInYear/CPP/hijricalendar_getmonthsinyear.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example calls GetMonthsInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HijriCalendar. - HijriCalendar^ myCal = gcnew HijriCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, HijriCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. The results might vary depending on -the settings in Regional and Language Options (or Regional Options or Regional Settings). - -YEAR 1421 1422 1423 1424 1425 -CurrentEra: 12 12 12 12 12 -Era 1: 12 12 12 12 12 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.HijriAdjustment/CPP/hijriadjustment.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.HijriAdjustment/CPP/hijriadjustment.cpp deleted file mode 100644 index 8ad91079056..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.HijriAdjustment/CPP/hijriadjustment.cpp +++ /dev/null @@ -1,53 +0,0 @@ - -// The following code example shows how HijriAdjustment affects the date. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HijriCalendar. - HijriCalendar^ myCal = gcnew HijriCalendar; - - // Creates a DateTime and initializes it to the second day of the first month of the year 1422. - DateTime myDT = DateTime(1422,1,2,myCal); - - // Displays the current values of the DateTime. - Console::WriteLine( "HijriAdjustment is {0}.", myCal->HijriAdjustment ); - Console::WriteLine( " Year is {0}.", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month is {0}.", myCal->GetMonth( myDT ) ); - Console::WriteLine( " Day is {0}.", myCal->GetDayOfMonth( myDT ) ); - - // Sets the HijriAdjustment property to 2. - myCal->HijriAdjustment = 2; - Console::WriteLine( "HijriAdjustment is {0}.", myCal->HijriAdjustment ); - Console::WriteLine( " Year is {0}.", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month is {0}.", myCal->GetMonth( myDT ) ); - Console::WriteLine( " Day is {0}.", myCal->GetDayOfMonth( myDT ) ); - - // Sets the HijriAdjustment property to -2. - myCal->HijriAdjustment = -2; - Console::WriteLine( "HijriAdjustment is {0}.", myCal->HijriAdjustment ); - Console::WriteLine( " Year is {0}.", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month is {0}.", myCal->GetMonth( myDT ) ); - Console::WriteLine( " Day is {0}.", myCal->GetDayOfMonth( myDT ) ); -} - -/* -This code produces the following output. Results vary depending on the registry settings. - -HijriAdjustment is 0. -Year is 1422. -Month is 1. -Day is 2. -HijriAdjustment is 2. -Year is 1422. -Month is 1. -Day is 4. -HijriAdjustment is -2. -Year is 1421. -Month is 12. -Day is 29. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapDay/CPP/hijricalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapDay/CPP/hijricalendar_isleapday.cpp deleted file mode 100644 index 374dfbf3d96..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapDay/CPP/hijricalendar_isleapday.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// The following code example calls IsLeapDay for the last day of the second -// month (February) for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HijriCalendar. - HijriCalendar^ myCal = gcnew HijriCalendar; - - // Creates a holder for the last day of the second month (February). - int iLastDay; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 1421; y <= 1425; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, HijriCalendar::CurrentEra ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, HijriCalendar::CurrentEra ) ); - - } - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 1421; y <= 1425; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) ); - - } - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 1421 1422 1423 1424 1425 -CurrentEra: False False False False False -Era 1: False False False False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapMonth/CPP/hijricalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapMonth/CPP/hijricalendar_isleapmonth.cpp deleted file mode 100644 index aa01d2f822d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapMonth/CPP/hijricalendar_isleapmonth.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// The following code example calls IsLeapMonth for all the months in -// five years in the current era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HijriCalendar. - HijriCalendar^ myCal = gcnew HijriCalendar; - - // Checks all the months in five years in the current era. - int iMonthsInYear; - for ( int y = 1421; y <= 1425; y++ ) - { - Console::Write( " {0}:\t", y ); - iMonthsInYear = myCal->GetMonthsInYear( y, HijriCalendar::CurrentEra ); - for ( int m = 1; m <= iMonthsInYear; m++ ) - Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, HijriCalendar::CurrentEra ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -1421: False False False False False False False False False False False False -1422: False False False False False False False False False False False False -1423: False False False False False False False False False False False False -1424: False False False False False False False False False False False False -1425: False False False False False False False False False False False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapYear/CPP/hijricalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapYear/CPP/hijricalendar_isleapyear.cpp deleted file mode 100644 index e3896e85af1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapYear/CPP/hijricalendar_isleapyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls IsLeapYear for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a HijriCalendar. - HijriCalendar^ myCal = gcnew HijriCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, HijriCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 1421; y <= 1425; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 1421 1422 1423 1424 1425 -CurrentEra: False False True False False -Era 1: False False True False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp deleted file mode 100644 index 8585d7966f6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// The following code example displays the values of several components of a DateTime in terms of the Hijri calendar. -// -using namespace System; -using namespace System::Globalization; -void DisplayValues( Calendar^ myCal, DateTime myDT ) -{ - Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) ); - Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) ); - Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) ); - Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) ); - Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) ); - Console::WriteLine(); -} - -int main() -{ - - // Sets a DateTime to April 3, 2002 of the Gregorian calendar. - DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar); - - // Creates an instance of the HijriCalendar. - HijriCalendar^ myCal = gcnew HijriCalendar; - - // Displays the values of the DateTime. - Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Hijri calendar:" ); - DisplayValues( myCal, myDT ); - - // Adds two years and ten months. - myDT = myCal->AddYears( myDT, 2 ); - myDT = myCal->AddMonths( myDT, 10 ); - - // Displays the values of the DateTime. - Console::WriteLine( "After adding two years and ten months:" ); - DisplayValues( myCal, myDT ); -} - -/* -This code produces the following output. - -April 3, 2002 of the Gregorian calendar equals the following in the Hijri calendar: - Era: 1 - Year: 1423 - Month: 1 - DayOfYear: 21 - DayOfMonth: 21 - DayOfWeek: Wednesday - -After adding two years and ten months: - Era: 1 - Year: 1425 - Month: 11 - DayOfYear: 316 - DayOfMonth: 21 - DayOfWeek: Saturday - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_MinMax/CPP/hijricalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_MinMax/CPP/hijricalendar_minmax.cpp deleted file mode 100644 index 4c8f361ea5f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_MinMax/CPP/hijricalendar_minmax.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// The following code example gets the minimum date and the maximum date of the calendar. -// -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Create an instance of the calendar. - HijriCalendar^ myCal = gcnew HijriCalendar; - Console::WriteLine( myCal ); - - // Create an instance of the GregorianCalendar. - GregorianCalendar^ myGre = gcnew GregorianCalendar; - - // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMin = myCal->MinSupportedDateTime; - Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) ); - - // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMax = myCal->MaxSupportedDateTime; - Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) ); -} - -/* -This code produces the following output. - -System.Globalization.HijriCalendar -MinSupportedDateTime: 01/01/0001 (in Gregorian, 07/18/0622) -MaxSupportedDateTime: 04/03/9666 (in Gregorian, 12/31/9999) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/CPP/yslin_japanesecalendar_eras.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/CPP/yslin_japanesecalendar_eras.cpp deleted file mode 100644 index 41a3f5fffa3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/CPP/yslin_japanesecalendar_eras.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// The following code example displays the values contained in the Eras property. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a JapaneseCalendar. - JapaneseCalendar^ myCal = gcnew JapaneseCalendar; - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::WriteLine( "Eras[ {0}] = {1}", i, myCal->Eras[ i ] ); - - } -} - -/* -This code produces the following output. - -Eras->Item[0] = 4 -Eras->Item[1] = 3 -Eras->Item[2] = 2 -Eras->Item[3] = 1 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInMonth/CPP/japanesecalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInMonth/CPP/japanesecalendar_getdaysinmonth.cpp deleted file mode 100644 index 18dc3f18f24..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInMonth/CPP/japanesecalendar_getdaysinmonth.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// The following code example calls GetDaysInMonth for the second month in each -// of 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a JapaneseCalendar. - JapaneseCalendar^ myCal = gcnew JapaneseCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, JapaneseCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 1 2 3 4 5 -CurrentEra: 28 28 28 29 28 -Era 4: 28 28 28 29 28 -Era 3: 28 28 29 28 28 -Era 2: 29 28 28 28 29 -Era 1: 29 28 28 28 29 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInYear/CPP/japanesecalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInYear/CPP/japanesecalendar_getdaysinyear.cpp deleted file mode 100644 index b7c757179f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInYear/CPP/japanesecalendar_getdaysinyear.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// The following code example calls GetDaysInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a JapaneseCalendar. - JapaneseCalendar^ myCal = gcnew JapaneseCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, JapaneseCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 1 2 3 4 5 -CurrentEra: 365 365 365 366 365 -Era 4: 365 365 365 366 365 -Era 3: 365 365 366 365 365 -Era 2: 366 365 365 365 366 -Era 1: 366 365 365 365 366 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetMonthsInYear/CPP/japanesecalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetMonthsInYear/CPP/japanesecalendar_getmonthsinyear.cpp deleted file mode 100644 index 8fff71ba264..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetMonthsInYear/CPP/japanesecalendar_getmonthsinyear.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Creates and initializes a JapaneseCalendar. - JapaneseCalendar^ myCal = gcnew JapaneseCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, JapaneseCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapDay/CPP/japanesecalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapDay/CPP/japanesecalendar_isleapday.cpp deleted file mode 100644 index 085173db873..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapDay/CPP/japanesecalendar_isleapday.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Creates and initializes a JapaneseCalendar. - JapaneseCalendar^ myCal = gcnew JapaneseCalendar; - - // Creates a holder for the last day of the second month (February)-> - int iLastDay; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 1; y <= 5; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, JapaneseCalendar::CurrentEra ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, JapaneseCalendar::CurrentEra ) ); - - } - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 1; y <= 5; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) ); - } - Console::WriteLine(); - } -} -/* -This code produces the following output. - -YEAR 1 2 3 4 5 -CurrentEra: False True False False False -Era 5: False True False False False -Era 4: False False False True False -Era 3: False False True False False -Era 2: True False False False True -Era 1: True False False False True - -*/ diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapMonth/CPP/japanesecalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapMonth/CPP/japanesecalendar_isleapmonth.cpp deleted file mode 100644 index de254b59da9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapMonth/CPP/japanesecalendar_isleapmonth.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// The following code example calls IsLeapMonth for all the months -// in five years in the current era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a JapaneseCalendar. - JapaneseCalendar^ myCal = gcnew JapaneseCalendar; - - // Checks all the months in five years in the current era. - int iMonthsInYear; - for ( int y = 1; y <= 5; y++ ) - { - Console::Write( " {0}:\t", y ); - iMonthsInYear = myCal->GetMonthsInYear( y, JapaneseCalendar::CurrentEra ); - for ( int m = 1; m <= iMonthsInYear; m++ ) - Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, JapaneseCalendar::CurrentEra ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -1: False False False False False False False False False False False False -2: False False False False False False False False False False False False -3: False False False False False False False False False False False False -4: False False False False False False False False False False False False -5: False False False False False False False False False False False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapYear/CPP/japanesecalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapYear/CPP/japanesecalendar_isleapyear.cpp deleted file mode 100644 index 5a922425510..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapYear/CPP/japanesecalendar_isleapyear.cpp +++ /dev/null @@ -1,41 +0,0 @@ -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Creates and initializes a JapaneseCalendar. - JapaneseCalendar^ myCal = gcnew JapaneseCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, JapaneseCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 1; y <= 5; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - } -} -/* -This code produces the following output. - -YEAR 1 2 3 4 5 -CurrentEra: False True False False False -Era 5: False True False False False -Era 4: False False False True False -Era 3: False False True False False -Era 2: True False False False True -Era 1: True False False False True - -*/ diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp deleted file mode 100644 index b5ce5f316e5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// The following code example displays the values of several components of a DateTime in terms of the Japanese calendar. -// -using namespace System; -using namespace System::Globalization; -void DisplayValues( Calendar^ myCal, DateTime myDT ) -{ - Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) ); - Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) ); - Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) ); - Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) ); - Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) ); - Console::WriteLine(); -} - -int main() -{ - - // Sets a DateTime to April 3, 2002 of the Gregorian calendar. - DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar); - - // Creates an instance of the JapaneseCalendar. - JapaneseCalendar^ myCal = gcnew JapaneseCalendar; - - // Displays the values of the DateTime. - Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Japanese calendar:" ); - DisplayValues( myCal, myDT ); - - // Adds two years and ten months. - myDT = myCal->AddYears( myDT, 2 ); - myDT = myCal->AddMonths( myDT, 10 ); - - // Displays the values of the DateTime. - Console::WriteLine( "After adding two years and ten months:" ); - DisplayValues( myCal, myDT ); -} - -/* -This code produces the following output. - -April 3, 2002 of the Gregorian calendar equals the following in the Japanese calendar: - Era: 4 - Year: 14 - Month: 4 - DayOfYear: 93 - DayOfMonth: 3 - DayOfWeek: Wednesday - -After adding two years and ten months: - Era: 4 - Year: 17 - Month: 2 - DayOfYear: 34 - DayOfMonth: 3 - DayOfWeek: Thursday - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_MinMax/CPP/japanesecalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_MinMax/CPP/japanesecalendar_minmax.cpp deleted file mode 100644 index d982671caed..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_MinMax/CPP/japanesecalendar_minmax.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// The following code example gets the minimum date and the maximum date of the calendar. -// -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Create an instance of the calendar. - JapaneseCalendar^ myCal = gcnew JapaneseCalendar; - Console::WriteLine( myCal ); - - // Create an instance of the GregorianCalendar. - GregorianCalendar^ myGre = gcnew GregorianCalendar; - - // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMin = myCal->MinSupportedDateTime; - Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) ); - - // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMax = myCal->MaxSupportedDateTime; - Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) ); -} - -/* -This code produces the following output. - -System.Globalization.JapaneseCalendar -MinSupportedDateTime: 09/08/0001 (in Gregorian, 09/08/1868) -MaxSupportedDateTime: 12/31/8011 (in Gregorian, 12/31/9999) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInMonth/CPP/juliancalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInMonth/CPP/juliancalendar_getdaysinmonth.cpp deleted file mode 100644 index 34d49e99fe2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInMonth/CPP/juliancalendar_getdaysinmonth.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example calls GetDaysInMonth for the second month in -// each of 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a JulianCalendar. - JulianCalendar^ myCal = gcnew JulianCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, JulianCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2001 2002 2003 2004 2005 -CurrentEra: 28 28 28 29 28 -Era 1: 28 28 28 29 28 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInYear/CPP/juliancalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInYear/CPP/juliancalendar_getdaysinyear.cpp deleted file mode 100644 index 3e36971f4c5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInYear/CPP/juliancalendar_getdaysinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetDaysInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a JulianCalendar. - JulianCalendar^ myCal = gcnew JulianCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, JulianCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2001 2002 2003 2004 2005 -CurrentEra: 365 365 365 366 365 -Era 1: 365 365 365 366 365 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetMonthsInYear/CPP/juliancalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetMonthsInYear/CPP/juliancalendar_getmonthsinyear.cpp deleted file mode 100644 index 113ce8b1c77..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetMonthsInYear/CPP/juliancalendar_getmonthsinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetMonthsInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a JulianCalendar. - JulianCalendar^ myCal = gcnew JulianCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, JulianCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2001 2002 2003 2004 2005 -CurrentEra: 12 12 12 12 12 -Era 1: 12 12 12 12 12 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapDay/CPP/juliancalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapDay/CPP/juliancalendar_isleapday.cpp deleted file mode 100644 index b8036ac7e05..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapDay/CPP/juliancalendar_isleapday.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// The following code example calls IsLeapDay for the last day of the -// second month (February) for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a JulianCalendar. - JulianCalendar^ myCal = gcnew JulianCalendar; - - // Creates a holder for the last day of the second month (February). - int iLastDay; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 2001; y <= 2005; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, JulianCalendar::CurrentEra ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, JulianCalendar::CurrentEra ) ); - - } - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2001; y <= 2005; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) ); - - } - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2001 2002 2003 2004 2005 -CurrentEra: False False False True False -Era 1: False False False True False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapMonth/CPP/juliancalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapMonth/CPP/juliancalendar_isleapmonth.cpp deleted file mode 100644 index b2d0997f2f8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapMonth/CPP/juliancalendar_isleapmonth.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// The following code example calls IsLeapMonth for all the months in -// five years in the current era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a JulianCalendar. - JulianCalendar^ myCal = gcnew JulianCalendar; - - // Checks all the months in five years in the current era. - int iMonthsInYear; - for ( int y = 2001; y <= 2005; y++ ) - { - Console::Write( " {0}:\t", y ); - iMonthsInYear = myCal->GetMonthsInYear( y, JulianCalendar::CurrentEra ); - for ( int m = 1; m <= iMonthsInYear; m++ ) - Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, JulianCalendar::CurrentEra ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -2001: False False False False False False False False False False False False -2002: False False False False False False False False False False False False -2003: False False False False False False False False False False False False -2004: False False False False False False False False False False False False -2005: False False False False False False False False False False False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapYear/CPP/juliancalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapYear/CPP/juliancalendar_isleapyear.cpp deleted file mode 100644 index 5436dfbd8b5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapYear/CPP/juliancalendar_isleapyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls IsLeapYear for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a JulianCalendar. - JulianCalendar^ myCal = gcnew JulianCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, JulianCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2001; y <= 2005; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2001 2002 2003 2004 2005 -CurrentEra: False False False True False -Era 1: False False False True False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp deleted file mode 100644 index e14dd6e99a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// The following code example displays the values of several components of a DateTime in terms of the Julian calendar. -// -using namespace System; -using namespace System::Globalization; -void DisplayValues( Calendar^ myCal, DateTime myDT ) -{ - Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) ); - Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) ); - Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) ); - Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) ); - Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) ); - Console::WriteLine(); -} - -int main() -{ - - // Sets a DateTime to April 3, 2002 of the Gregorian calendar. - DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar); - - // Creates an instance of the JulianCalendar. - JulianCalendar^ myCal = gcnew JulianCalendar; - - // Displays the values of the DateTime. - Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Julian calendar:" ); - DisplayValues( myCal, myDT ); - - // Adds two years and ten months. - myDT = myCal->AddYears( myDT, 2 ); - myDT = myCal->AddMonths( myDT, 10 ); - - // Displays the values of the DateTime. - Console::WriteLine( "After adding two years and ten months:" ); - DisplayValues( myCal, myDT ); -} - -/* -This code produces the following output. - -April 3, 2002 of the Gregorian calendar equals the following in the Julian calendar: - Era: 1 - Year: 2002 - Month: 3 - DayOfYear: 80 - DayOfMonth: 21 - DayOfWeek: Wednesday - -After adding two years and ten months: - Era: 1 - Year: 2005 - Month: 1 - DayOfYear: 21 - DayOfMonth: 21 - DayOfWeek: Thursday - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_MinMax/CPP/juliancalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_MinMax/CPP/juliancalendar_minmax.cpp deleted file mode 100644 index 5aa56fb4924..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_MinMax/CPP/juliancalendar_minmax.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// The following code example gets the minimum date and the maximum date of the calendar. -// -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Create an instance of the calendar. - JulianCalendar^ myCal = gcnew JulianCalendar; - Console::WriteLine( myCal ); - - // Create an instance of the GregorianCalendar. - GregorianCalendar^ myGre = gcnew GregorianCalendar; - - // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMin = myCal->MinSupportedDateTime; - Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) ); - - // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMax = myCal->MaxSupportedDateTime; - Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) ); -} - -/* -This code produces the following output. - -System.Globalization.JulianCalendar -MinSupportedDateTime: 01/03/0001 (in Gregorian, 01/01/0001) -MaxSupportedDateTime: 10/19/9999 (in Gregorian, 12/31/9999) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInMonth/CPP/koreancalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInMonth/CPP/koreancalendar_getdaysinmonth.cpp deleted file mode 100644 index 6b3c77a66da..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInMonth/CPP/koreancalendar_getdaysinmonth.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example calls GetDaysInMonth for the second month -// in each of 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a KoreanCalendar. - KoreanCalendar^ myCal = gcnew KoreanCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, KoreanCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 4334 4335 4336 4337 4338 -CurrentEra: 28 28 28 29 28 -Era 1: 28 28 28 29 28 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInYear/CPP/koreancalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInYear/CPP/koreancalendar_getdaysinyear.cpp deleted file mode 100644 index 5211726ccf0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInYear/CPP/koreancalendar_getdaysinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetDaysInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a KoreanCalendar. - KoreanCalendar^ myCal = gcnew KoreanCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, KoreanCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 4334 4335 4336 4337 4338 -CurrentEra: 365 365 365 366 365 -Era 1: 365 365 365 366 365 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetMonthsInYear/CPP/koreancalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetMonthsInYear/CPP/koreancalendar_getmonthsinyear.cpp deleted file mode 100644 index 33b5c948bd3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetMonthsInYear/CPP/koreancalendar_getmonthsinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetMonthsInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a KoreanCalendar. - KoreanCalendar^ myCal = gcnew KoreanCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, KoreanCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 4334 4335 4336 4337 4338 -CurrentEra: 12 12 12 12 12 -Era 1: 12 12 12 12 12 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapDay/CPP/koreancalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapDay/CPP/koreancalendar_isleapday.cpp deleted file mode 100644 index d973b468e66..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapDay/CPP/koreancalendar_isleapday.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// The following code example calls IsLeapDay for the last day of the second -// month (February) for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a KoreanCalendar. - KoreanCalendar^ myCal = gcnew KoreanCalendar; - - // Creates a holder for the last day of the second month (February). - int iLastDay; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 4334; y <= 4338; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, KoreanCalendar::CurrentEra ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, KoreanCalendar::CurrentEra ) ); - - } - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 4334; y <= 4338; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) ); - - } - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 4334 4335 4336 4337 4338 -CurrentEra: False False False True False -Era 1: False False False True False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapMonth/CPP/koreancalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapMonth/CPP/koreancalendar_isleapmonth.cpp deleted file mode 100644 index 3446270064d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapMonth/CPP/koreancalendar_isleapmonth.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// The following code example calls IsLeapMonth for all the months in five years in the current era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a KoreanCalendar. - KoreanCalendar^ myCal = gcnew KoreanCalendar; - - // Checks all the months in five years in the current era. - int iMonthsInYear; - for ( int y = 4334; y <= 4338; y++ ) - { - Console::Write( " {0}:\t", y ); - iMonthsInYear = myCal->GetMonthsInYear( y, KoreanCalendar::CurrentEra ); - for ( int m = 1; m <= iMonthsInYear; m++ ) - Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, KoreanCalendar::CurrentEra ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -4334: False False False False False False False False False False False False -4335: False False False False False False False False False False False False -4336: False False False False False False False False False False False False -4337: False False False False False False False False False False False False -4338: False False False False False False False False False False False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapYear/CPP/koreancalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapYear/CPP/koreancalendar_isleapyear.cpp deleted file mode 100644 index 5e2e16c671d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapYear/CPP/koreancalendar_isleapyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls IsLeapYear for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a KoreanCalendar. - KoreanCalendar^ myCal = gcnew KoreanCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, KoreanCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 4334; y <= 4338; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 4334 4335 4336 4337 4338 -CurrentEra: False False False True False -Era 1: False False False True False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp deleted file mode 100644 index 0af45b0db54..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// The following code example displays the values of several components of a DateTime in terms of the Korean calendar. -// -using namespace System; -using namespace System::Globalization; -void DisplayValues( Calendar^ myCal, DateTime myDT ) -{ - Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) ); - Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) ); - Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) ); - Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) ); - Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) ); - Console::WriteLine(); -} - -int main() -{ - - // Sets a DateTime to April 3, 2002 of the Gregorian calendar. - DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar); - - // Creates an instance of the KoreanCalendar. - KoreanCalendar^ myCal = gcnew KoreanCalendar; - - // Displays the values of the DateTime. - Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Korean calendar:" ); - DisplayValues( myCal, myDT ); - - // Adds two years and ten months. - myDT = myCal->AddYears( myDT, 2 ); - myDT = myCal->AddMonths( myDT, 10 ); - - // Displays the values of the DateTime. - Console::WriteLine( "After adding two years and ten months:" ); - DisplayValues( myCal, myDT ); -} - -/* -This code produces the following output. - -April 3, 2002 of the Gregorian calendar equals the following in the Korean calendar: - Era: 1 - Year: 4335 - Month: 4 - DayOfYear: 93 - DayOfMonth: 3 - DayOfWeek: Wednesday - -After adding two years and ten months: - Era: 1 - Year: 4338 - Month: 2 - DayOfYear: 34 - DayOfMonth: 3 - DayOfWeek: Thursday - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_MinMax/CPP/koreancalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_MinMax/CPP/koreancalendar_minmax.cpp deleted file mode 100644 index 00de6b90a65..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_MinMax/CPP/koreancalendar_minmax.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// The following code example gets the minimum date and the maximum date of the calendar. -// -using namespace System; -using namespace System::Globalization; - -int main() -{ - - // Create an instance of the calendar. - KoreanCalendar^ myCal = gcnew KoreanCalendar; - Console::WriteLine( myCal ); - - // Create an instance of the GregorianCalendar. - GregorianCalendar^ myGre = gcnew GregorianCalendar; - - // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMin = myCal->MinSupportedDateTime; - Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) ); - - // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMax = myCal->MaxSupportedDateTime; - Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) ); -} - -/* -This code produces the following output. - -System.Globalization.KoreanCalendar -MinSupportedDateTime: 01/01/2334 (in Gregorian, 01/01/0001) -MaxSupportedDateTime: 12/31/12332 (in Gregorian, 12/31/9999) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.NumberFormatInfo.InvariantInfo/CPP/invariantinfo.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.NumberFormatInfo.InvariantInfo/CPP/invariantinfo.cpp deleted file mode 100644 index 0725c178ee9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.NumberFormatInfo.InvariantInfo/CPP/invariantinfo.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; -using namespace System::Text; -int main() -{ - - // Gets the InvariantInfo. - NumberFormatInfo^ myInv = NumberFormatInfo::InvariantInfo; - - // Gets a UnicodeEncoding to display the Unicode value of symbols. - UnicodeEncoding^ myUE = gcnew UnicodeEncoding( true,false ); - array^myCodes; - - // Displays the default values for each of the properties. - Console::WriteLine( "InvariantInfo:\nNote: Symbols might not display correctly on the console, \ntherefore, Unicode values are included." ); - Console::WriteLine( "\tCurrencyDecimalDigits\t\t {0}", myInv->CurrencyDecimalDigits ); - Console::WriteLine( "\tCurrencyDecimalSeparator\t {0}", myInv->CurrencyDecimalSeparator ); - Console::WriteLine( "\tCurrencyGroupSeparator\t\t {0}", myInv->CurrencyGroupSeparator ); - Console::WriteLine( "\tCurrencyGroupSizes\t\t {0}", myInv->CurrencyGroupSizes[ 0 ] ); - Console::WriteLine( "\tCurrencyNegativePattern\t\t {0}", myInv->CurrencyNegativePattern ); - Console::WriteLine( "\tCurrencyPositivePattern\t\t {0}", myInv->CurrencyPositivePattern ); - myCodes = myUE->GetBytes( myInv->CurrencySymbol ); - Console::WriteLine( "\tCurrencySymbol\t\t\t {0}\t(U+ {1:x2} {2:x2})", myInv->CurrencySymbol, myCodes[ 0 ], myCodes[ 1 ] ); - Console::WriteLine( "\tNaNSymbol\t\t\t {0}", myInv->NaNSymbol ); - Console::WriteLine( "\tNegativeInfinitySymbol\t\t {0}", myInv->NegativeInfinitySymbol ); - Console::WriteLine( "\tNegativeSign\t\t\t {0}", myInv->NegativeSign ); - Console::WriteLine( "\tNumberDecimalDigits\t\t {0}", myInv->NumberDecimalDigits ); - Console::WriteLine( "\tNumberDecimalSeparator\t\t {0}", myInv->NumberDecimalSeparator ); - Console::WriteLine( "\tNumberGroupSeparator\t\t {0}", myInv->NumberGroupSeparator ); - Console::WriteLine( "\tNumberGroupSizes\t\t {0}", myInv->NumberGroupSizes[ 0 ] ); - Console::WriteLine( "\tNumberNegativePattern\t\t {0}", myInv->NumberNegativePattern ); - Console::WriteLine( "\tPercentDecimalDigits\t\t {0}", myInv->PercentDecimalDigits ); - Console::WriteLine( "\tPercentDecimalSeparator\t\t {0}", myInv->PercentDecimalSeparator ); - Console::WriteLine( "\tPercentGroupSeparator\t\t {0}", myInv->PercentGroupSeparator ); - Console::WriteLine( "\tPercentGroupSizes\t\t {0}", myInv->PercentGroupSizes[ 0 ] ); - Console::WriteLine( "\tPercentNegativePattern\t\t {0}", myInv->PercentNegativePattern ); - Console::WriteLine( "\tPercentPositivePattern\t\t {0}", myInv->PercentPositivePattern ); - myCodes = myUE->GetBytes( myInv->PercentSymbol ); - Console::WriteLine( "\tPercentSymbol\t\t\t {0}\t(U+ {1:x2} {2:x2})", myInv->PercentSymbol, myCodes[ 0 ], myCodes[ 1 ] ); - myCodes = myUE->GetBytes( myInv->PerMilleSymbol ); - Console::WriteLine( "\tPerMilleSymbol\t\t\t {0}\t(U+ {1:x2} {2:x2})", myInv->PerMilleSymbol, myCodes[ 0 ], myCodes[ 1 ] ); - Console::WriteLine( "\tPositiveInfinitySymbol\t\t {0}", myInv->PositiveInfinitySymbol ); - Console::WriteLine( "\tPositiveSign\t\t\t {0}", myInv->PositiveSign ); -} - -/* - -This code produces the following output. - -InvariantInfo: -Note: Symbols might not display correctly on the console, -therefore, Unicode values are included. -CurrencyDecimalDigits 2 -CurrencyDecimalSeparator . -CurrencyGroupSeparator , -CurrencyGroupSizes 3 -CurrencyNegativePattern 0 -CurrencyPositivePattern 0 -CurrencySymbol (U+00a4) -NaNSymbol NaN -NegativeInfinitySymbol -Infinity -NegativeSign - -NumberDecimalDigits 2 -NumberDecimalSeparator . -NumberGroupSeparator , -NumberGroupSizes 3 -NumberNegativePattern 1 -PercentDecimalDigits 2 -PercentDecimalSeparator . -PercentGroupSeparator , -PercentGroupSizes 3 -PercentNegativePattern 0 -PercentPositivePattern 0 -PercentSymbol % (U+0025) -PerMilleSymbol % (U+2030) -PositiveInfinitySymbol Infinity -PositiveSign + - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo.ctorCultureName/CPP/regioninfo_ctorculturename.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo.ctorCultureName/CPP/regioninfo_ctorculturename.cpp deleted file mode 100644 index 1a0bf689d64..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo.ctorCultureName/CPP/regioninfo_ctorculturename.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// The following code example creates instances of -// T:System.Globalization.RegionInfo using culture names. - -// -using namespace System; -using namespace System::Collections; -using namespace System::Globalization; - -namespace Sample -{ - public ref class SamplesRegionInfo - { - public: - static void Work() - { - - // Creates an array containing culture names. - array ^ commonCultures = - {"", "ar", "ar-DZ", "en", "en-US"}; - - // Creates a RegionInfo for each of the culture names. - // Note that "ar" is the culture name for the neutral - // culture "Arabic", but it is also the region name for - // the country/region "Argentina"; therefore, it does not - // fail as expected. - Console::WriteLine("Without checks..."); - for each (String^ cultureID in commonCultures) - { - try - { - RegionInfo^ region = - gcnew RegionInfo(cultureID); - } - - catch (ArgumentException^ ex) - { - Console::WriteLine(ex); - } - } - - Console::WriteLine(); - - Console::WriteLine("Checking the culture" - " names first..."); - - for each (String^ cultureID in commonCultures) - { - if (cultureID->Length == 0) - { - Console::WriteLine( - "The culture is the invariant culture."); - } - else - { - CultureInfo^ culture = - gcnew CultureInfo(cultureID, false); - if (culture->IsNeutralCulture) - { - Console::WriteLine("The culture {0} is " - "a neutral culture.", cultureID); - } - else - { - Console::WriteLine("The culture {0} is " - "a specific culture.", cultureID); - try - { - RegionInfo^ region = - gcnew RegionInfo(cultureID); - } - catch (ArgumentException^ ex) - { - Console::WriteLine(ex); - } - } - } - } - Console::ReadLine(); - } - }; -} - -int main() -{ - Sample::SamplesRegionInfo::Work(); - return 0; -} - -/* -This code produces the following output. - -Without checks... -System.ArgumentException: Region name '' is not supported. -Parameter name: name -at System.Globalization.RegionInfo..ctor(String name) -at SamplesRegionInfo.Main() -System.ArgumentException: Region name 'en' is not supported. -Parameter name: name -at System.Globalization.CultureTableRecord..ctor(String regionName, - Boolean useUserOverride) -at System.Globalization.RegionInfo..ctor(String name) -at SamplesRegionInfo.Main() - -Checking the culture names first... -The culture is the invariant culture. -The culture ar is a neutral culture. -The culture ar-DZ is a specific culture. -The culture en is a neutral culture. -The culture en-US is a specific culture. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CPP/regioninfo.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CPP/regioninfo.cpp deleted file mode 100644 index afae697de7f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CPP/regioninfo.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// The following code example demonstrates several members of the RegionInfo class. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Displays the property values of the RegionInfo for "US". - RegionInfo^ myRI1 = gcnew RegionInfo( "US" ); - Console::WriteLine( " Name: {0}", myRI1->Name ); - Console::WriteLine( " DisplayName: {0}", myRI1->DisplayName ); - Console::WriteLine( " EnglishName: {0}", myRI1->EnglishName ); - Console::WriteLine( " IsMetric: {0}", myRI1->IsMetric ); - Console::WriteLine( " ThreeLetterISORegionName: {0}", myRI1->ThreeLetterISORegionName ); - Console::WriteLine( " ThreeLetterWindowsRegionName: {0}", myRI1->ThreeLetterWindowsRegionName ); - Console::WriteLine( " TwoLetterISORegionName: {0}", myRI1->TwoLetterISORegionName ); - Console::WriteLine( " CurrencySymbol: {0}", myRI1->CurrencySymbol ); - Console::WriteLine( " ISOCurrencySymbol: {0}", myRI1->ISOCurrencySymbol ); - Console::WriteLine(); - - // Compares the RegionInfo above with another RegionInfo created using CultureInfo. - RegionInfo^ myRI2 = gcnew RegionInfo( (gcnew CultureInfo( "en-US",false ))->LCID ); - if ( myRI1->Equals( myRI2 ) ) - Console::WriteLine( "The two RegionInfo instances are equal." ); - else - Console::WriteLine( "The two RegionInfo instances are NOT equal." ); -} - -/* -This code produces the following output. - - Name: US - DisplayName: United States - EnglishName: United States - IsMetric: False - ThreeLetterISORegionName: USA - ThreeLetterWindowsRegionName: USA - TwoLetterISORegionName: US - CurrencySymbol: $ - ISOCurrencySymbol: USD - -The two RegionInfo instances are equal. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/CPP/regioninfo_equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/CPP/regioninfo_equals.cpp deleted file mode 100644 index 59f19db370c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/CPP/regioninfo_equals.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// The following code example compares two instances of RegionInfo that were created differently. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates a RegionInfo using the ISO 3166 two-letter code. - RegionInfo^ myRI1 = gcnew RegionInfo( "US" ); - - // Creates a RegionInfo using a CultureInfo.LCID. - RegionInfo^ myRI2 = gcnew RegionInfo( (gcnew CultureInfo( "en-US",false ))->LCID ); - - // Compares the two instances. - if ( myRI1->Equals( myRI2 ) ) - Console::WriteLine( "The two RegionInfo instances are equal." ); - else - Console::WriteLine( "The two RegionInfo instances are NOT equal." ); -} - -/* -This code produces the following output. - -The two RegionInfo instances are equal. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp deleted file mode 100644 index b61096e79cc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// The following code example displays the properties of the RegionInfo class. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Displays the property values of the RegionInfo for "US". - RegionInfo^ myRI1 = gcnew RegionInfo( "US" ); - Console::WriteLine( " Name: {0}", myRI1->Name ); - Console::WriteLine( " DisplayName: {0}", myRI1->DisplayName ); - Console::WriteLine( " EnglishName: {0}", myRI1->EnglishName ); - Console::WriteLine( " IsMetric: {0}", myRI1->IsMetric ); - Console::WriteLine( " ThreeLetterISORegionName: {0}", myRI1->ThreeLetterISORegionName ); - Console::WriteLine( " ThreeLetterWindowsRegionName: {0}", myRI1->ThreeLetterWindowsRegionName ); - Console::WriteLine( " TwoLetterISORegionName: {0}", myRI1->TwoLetterISORegionName ); - Console::WriteLine( " CurrencySymbol: {0}", myRI1->CurrencySymbol ); - Console::WriteLine( " ISOCurrencySymbol: {0}", myRI1->ISOCurrencySymbol ); -} - -/* -This code produces the following output. - - Name: US - DisplayName: United States - EnglishName: United States - IsMetric: False - ThreeLetterISORegionName: USA - ThreeLetterWindowsRegionName: USA - TwoLetterISORegionName: US - CurrencySymbol: $ - ISOCurrencySymbol: USD - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Compare/CPP/sortkey_compare.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Compare/CPP/sortkey_compare.cpp deleted file mode 100644 index 1b59bd014bf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Compare/CPP/sortkey_compare.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// The following code example compares SortKey objects created with -// cultures that have different sort orders. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates a SortKey using the en-US culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - CompareInfo^ myComp_enUS = MyCI->CompareInfo; - SortKey^ mySK1 = myComp_enUS->GetSortKey( "llama" ); - - // Creates a SortKey using the es-ES culture with international sort. - MyCI = gcnew CultureInfo( "es-ES",false ); - CompareInfo^ myComp_esES = MyCI->CompareInfo; - SortKey^ mySK2 = myComp_esES->GetSortKey( "llama" ); - - // Creates a SortKey using the es-ES culture with traditional sort. - MyCI = gcnew CultureInfo( 0x040A,false ); - CompareInfo^ myComp_es = MyCI->CompareInfo; - SortKey^ mySK3 = myComp_es->GetSortKey( "llama" ); - - // Compares the en-US SortKey with each of the es-ES SortKey objects. - Console::WriteLine( "Comparing \"llama\" in en-US and in es-ES with international sort : {0}", SortKey::Compare( mySK1, mySK2 ) ); - Console::WriteLine( "Comparing \"llama\" in en-US and in es-ES with traditional sort : {0}", SortKey::Compare( mySK1, mySK3 ) ); -} - -/* -This code produces the following output. - -Comparing S"llama" in en-US and in es-ES with international sort : 0 -Comparing S"llama" in en-US and in es-ES with traditional sort : -1 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Equals/CPP/sortkey_equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Equals/CPP/sortkey_equals.cpp deleted file mode 100644 index 3f300f6813f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Equals/CPP/sortkey_equals.cpp +++ /dev/null @@ -1,80 +0,0 @@ - -// The following code example shows the results of SortKey->Equals -// when compared with different SortKey objects. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates two identical en-US cultures and one de-DE culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - CompareInfo^ myComp_enUS1 = MyCI->CompareInfo; - MyCI = gcnew CultureInfo( "en-US",false ); - CompareInfo^ myComp_enUS2 = MyCI->CompareInfo; - MyCI = gcnew CultureInfo( "de-DE",false ); - CompareInfo^ myComp_deDE = MyCI->CompareInfo; - - // Creates the base SortKey to compare with all the others. - SortKey^ mySK1 = myComp_enUS1->GetSortKey( "cant", CompareOptions::StringSort ); - - // Creates a SortKey that is derived exactly the same way as the base SortKey. - SortKey^ mySK2 = myComp_enUS1->GetSortKey( "cant", CompareOptions::StringSort ); - - // Creates a SortKey that uses word sort, which is the default sort. - SortKey^ mySK3 = myComp_enUS1->GetSortKey( "cant" ); - - // Creates a SortKey for a different String*. - SortKey^ mySK4 = myComp_enUS1->GetSortKey( "can't", CompareOptions::StringSort ); - - // Creates a SortKey from a different CompareInfo with the same culture. - SortKey^ mySK5 = myComp_enUS2->GetSortKey( "cant", CompareOptions::StringSort ); - - // Creates a SortKey from a different CompareInfo with a different culture. - SortKey^ mySK6 = myComp_deDE->GetSortKey( "cant", CompareOptions::StringSort ); - - // Compares the base SortKey with itself. - Console::WriteLine( "Comparing the base SortKey with itself: {0}", mySK1->Equals( mySK1 ) ); - Console::WriteLine(); - - // Prints the header for the table. - Console::WriteLine( "CompareInfo Culture OriginalString CompareOptions Equals()" ); - - // Compares the base SortKey with a SortKey that is - // created from the same CompareInfo with the same String* and the same CompareOptions. - Console::WriteLine( "same same same same {0}", mySK1->Equals( mySK2 ) ); - - // Compares the base SortKey with a SortKey that is - // created from the same CompareInfo with the same String* but with different CompareOptions. - Console::WriteLine( "same same same different {0}", mySK1->Equals( mySK3 ) ); - - // Compares the base SortKey with a SortKey that is - // created from the same CompareInfo with the different String* - // but with the same CompareOptions. - Console::WriteLine( "same same different same {0}", mySK1->Equals( mySK4 ) ); - - // Compares the base SortKey with a SortKey that is - // created from a different CompareInfo (same culture) - // with the same String* and the same CompareOptions. - Console::WriteLine( "different same same same {0}", mySK1->Equals( mySK5 ) ); - - // Compares the base SortKey with a SortKey that is - // created from a different CompareInfo (different culture) - // with the same String* and the same CompareOptions. - Console::WriteLine( "different different same same {0}", mySK1->Equals( mySK6 ) ); -} - -/* -This code produces the following output. - -Comparing the base SortKey with itself: True - -CompareInfo Culture OriginalString CompareOptions Equals() -same same same same True -same same same different False -same same different same False -different same same same True -different different same same False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInMonth/CPP/taiwancalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInMonth/CPP/taiwancalendar_getdaysinmonth.cpp deleted file mode 100644 index 59e7fbd6cec..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInMonth/CPP/taiwancalendar_getdaysinmonth.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example calls GetDaysInMonth for the second month in each -// of 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a TaiwanCalendar. - TaiwanCalendar^ myCal = gcnew TaiwanCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, TaiwanCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 90 91 92 93 94 -CurrentEra: 28 28 28 29 28 -Era 1: 28 28 28 29 28 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInYear/CPP/taiwancalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInYear/CPP/taiwancalendar_getdaysinyear.cpp deleted file mode 100644 index be31d941d3e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInYear/CPP/taiwancalendar_getdaysinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetDaysInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a TaiwanCalendar. - TaiwanCalendar^ myCal = gcnew TaiwanCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, TaiwanCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 90 91 92 93 94 -CurrentEra: 365 365 365 366 365 -Era 1: 365 365 365 366 365 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetMonthsInYear/CPP/taiwancalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetMonthsInYear/CPP/taiwancalendar_getmonthsinyear.cpp deleted file mode 100644 index 5dd8e46be7e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetMonthsInYear/CPP/taiwancalendar_getmonthsinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetMonthsInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a TaiwanCalendar. - TaiwanCalendar^ myCal = gcnew TaiwanCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, TaiwanCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 90 91 92 93 94 -CurrentEra: 12 12 12 12 12 -Era 1: 12 12 12 12 12 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapDay/CPP/taiwancalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapDay/CPP/taiwancalendar_isleapday.cpp deleted file mode 100644 index 89fc7fb7e6f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapDay/CPP/taiwancalendar_isleapday.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -// The following code example calls IsLeapDay for the last day of the second month (February) for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a TaiwanCalendar. - TaiwanCalendar^ myCal = gcnew TaiwanCalendar; - - // Creates a holder for the last day of the second month (February). - int iLastDay; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t{0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 90; y <= 94; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, TaiwanCalendar::CurrentEra ); - Console::Write( "\t{0}", myCal->IsLeapDay( y, 2, iLastDay, TaiwanCalendar::CurrentEra ) ); - - } - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 90; y <= 94; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ); - Console::Write( "\t{0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) ); - - } - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 90 91 92 93 94 -CurrentEra: False False False True False -Era 1: False False False True False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapMonth/CPP/taiwancalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapMonth/CPP/taiwancalendar_isleapmonth.cpp deleted file mode 100644 index 914453cabe8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapMonth/CPP/taiwancalendar_isleapmonth.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// The following code example calls IsLeapMonth for all the months in five years in the current era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a TaiwanCalendar. - TaiwanCalendar^ myCal = gcnew TaiwanCalendar; - - // Checks all the months in five years in the current era. - int iMonthsInYear; - for ( int y = 90; y <= 94; y++ ) - { - Console::Write( " {0}:\t", y ); - iMonthsInYear = myCal->GetMonthsInYear( y, TaiwanCalendar::CurrentEra ); - for ( int m = 1; m <= iMonthsInYear; m++ ) - Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, TaiwanCalendar::CurrentEra ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -90: False False False False False False False False False False False False -91: False False False False False False False False False False False False -92: False False False False False False False False False False False False -93: False False False False False False False False False False False False -94: False False False False False False False False False False False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapYear/CPP/taiwancalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapYear/CPP/taiwancalendar_isleapyear.cpp deleted file mode 100644 index dc8bffdcf80..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapYear/CPP/taiwancalendar_isleapyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls IsLeapYear for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a TaiwanCalendar. - TaiwanCalendar^ myCal = gcnew TaiwanCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, TaiwanCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 90; y <= 94; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 90 91 92 93 94 -CurrentEra: False False False True False -Era 1: False False False True False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp deleted file mode 100644 index 99c84b107ab..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// The following code example displays the values of several components of a DateTime in terms of the Taiwan calendar. -// -using namespace System; -using namespace System::Globalization; -void DisplayValues( Calendar^ myCal, DateTime myDT ) -{ - Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) ); - Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) ); - Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) ); - Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) ); - Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) ); - Console::WriteLine(); -} - -int main() -{ - - // Sets a DateTime to April 3, 2002 of the Gregorian calendar. - DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar); - - // Creates an instance of the TaiwanCalendar. - TaiwanCalendar^ myCal = gcnew TaiwanCalendar; - - // Displays the values of the DateTime. - Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Taiwan calendar:" ); - DisplayValues( myCal, myDT ); - - // Adds two years and ten months. - myDT = myCal->AddYears( myDT, 2 ); - myDT = myCal->AddMonths( myDT, 10 ); - - // Displays the values of the DateTime. - Console::WriteLine( "After adding two years and ten months:" ); - DisplayValues( myCal, myDT ); -} - -/* -This code produces the following output. - -April 3, 2002 of the Gregorian calendar equals the following in the Taiwan calendar: - Era: 1 - Year: 91 - Month: 4 - DayOfYear: 93 - DayOfMonth: 3 - DayOfWeek: Wednesday - -After adding two years and ten months: - Era: 1 - Year: 94 - Month: 2 - DayOfYear: 34 - DayOfMonth: 3 - DayOfWeek: Thursday - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_MinMax/CPP/taiwancalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_MinMax/CPP/taiwancalendar_minmax.cpp deleted file mode 100644 index 3deda76056f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_MinMax/CPP/taiwancalendar_minmax.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// The following code example gets the minimum value and the maximum value of the calendar. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Create an instance of the calendar. - TaiwanCalendar^ myCal = gcnew TaiwanCalendar; - Console::WriteLine( myCal ); - - // Create an instance of the GregorianCalendar. - GregorianCalendar^ myGre = gcnew GregorianCalendar; - - // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMin = myCal->MinSupportedDateTime; - Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) ); - - // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMax = myCal->MaxSupportedDateTime; - Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) ); -} - -/* -This code produces the following output. - -System.Globalization.TaiwanCalendar -MinSupportedDateTime: 01/01/0001 (in Gregorian, 01/01/1912) -MaxSupportedDateTime: 12/31/8088 (in Gregorian, 12/31/9999) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextElementEnumerator.Summary/CPP/tee_summary.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextElementEnumerator.Summary/CPP/tee_summary.cpp deleted file mode 100644 index 9e73e264824..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextElementEnumerator.Summary/CPP/tee_summary.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// The following code example shows the values returned by TextElementEnumerator. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a String containing the following: - // - a surrogate pair (high surrogate U+D800 and low surrogate U+DC00) - // - a combining character sequence (the Latin small letter S"a" followed by the combining grave accent) - // - a base character (the ligature S"") - String^ myString = L"\xD800\xDC00" - L"a\u0300\u00C6"; - - // Creates and initializes a TextElementEnumerator for myString. - TextElementEnumerator^ myTEE = StringInfo::GetTextElementEnumerator( myString ); - - // Displays the values returned by ElementIndex, Current and GetTextElement. - // Current and GetTextElement return a String* containing the entire text element. - Console::WriteLine( "Index\tCurrent\tGetTextElement" ); - myTEE->Reset(); - while ( myTEE->MoveNext() ) - Console::WriteLine( "[{0}]:\t {1}\t {2}", myTEE->ElementIndex, myTEE->Current, myTEE->GetTextElement() ); -} - -/* -This code produces the following output. The question marks take the place of high and low surrogates. - -Index Current GetTextElement -[0]: 𐀀 𐀀 -[2]: à à -[4]: Æ Æ - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/CPP/textinfo_casing.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/CPP/textinfo_casing.cpp deleted file mode 100644 index c77a0736012..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/CPP/textinfo_casing.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// The following code example changes the casing of a String*. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Defines the String* with mixed casing. - String^ myString = "wAr aNd pEaCe"; - - // Creates a TextInfo based on the S"en-US" culture. - CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); - TextInfo^ myTI = MyCI->TextInfo; - - // Changes a String* to lowercase. - Console::WriteLine( "\"{0}\" to lowercase: {1}", myString, myTI->ToLower( myString ) ); - - // Changes a String* to uppercase. - Console::WriteLine( "\"{0}\" to uppercase: {1}", myString, myTI->ToUpper( myString ) ); - - // Changes a String* to titlecase. - Console::WriteLine( "\"{0}\" to titlecase: {1}", myString, myTI->ToTitleCase( myString ) ); -} - -/* -This code produces the following output. - -S"wAr aNd pEaCe" to lowercase: war and peace -S"wAr aNd pEaCe" to uppercase: WAR AND PEACE -S"wAr aNd pEaCe" to titlecase: War And Peace - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInMonth/CPP/thaibuddhistcalendar_getdaysinmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInMonth/CPP/thaibuddhistcalendar_getdaysinmonth.cpp deleted file mode 100644 index 88271b26c94..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInMonth/CPP/thaibuddhistcalendar_getdaysinmonth.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example calls GetDaysInMonth for the second month in each of 5 -// years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a ThaiBuddhistCalendar. - ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, ThaiBuddhistCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2544 2545 2546 2547 2548 -CurrentEra: 28 28 28 29 28 -Era 1: 28 28 28 29 28 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInYear/CPP/thaibuddhistcalendar_getdaysinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInYear/CPP/thaibuddhistcalendar_getdaysinyear.cpp deleted file mode 100644 index 9aa2d9d8dee..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInYear/CPP/thaibuddhistcalendar_getdaysinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetDaysInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a ThaiBuddhistCalendar. - ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, ThaiBuddhistCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", myCal->GetDaysInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2544 2545 2546 2547 2548 -CurrentEra: 365 365 365 366 365 -Era 1: 365 365 365 366 365 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetMonthsInYear/CPP/thaibuddhistcalendar_getmonthsinyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetMonthsInYear/CPP/thaibuddhistcalendar_getmonthsinyear.cpp deleted file mode 100644 index 3a8a6d35a73..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetMonthsInYear/CPP/thaibuddhistcalendar_getmonthsinyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls GetMonthsInYear for 5 years in each era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a ThaiBuddhistCalendar. - ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Displays the value of the CurrentEra property. - Console::Write( "CurrentEra:" ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, ThaiBuddhistCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Displays the values in the Eras property. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", myCal->GetMonthsInYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2544 2545 2546 2547 2548 -CurrentEra: 12 12 12 12 12 -Era 1: 12 12 12 12 12 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapDay/CPP/thaibuddhistcalendar_isleapday.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapDay/CPP/thaibuddhistcalendar_isleapday.cpp deleted file mode 100644 index 356591167c0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapDay/CPP/thaibuddhistcalendar_isleapday.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// The following code example calls IsLeapDay for the last day of the -// second month (February) for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a ThaiBuddhistCalendar. - ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar; - - // Creates a holder for the last day of the second month (February). - int iLastDay; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 2544; y <= 2548; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, ThaiBuddhistCalendar::CurrentEra ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, ThaiBuddhistCalendar::CurrentEra ) ); - - } - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2544; y <= 2548; y++ ) - { - iLastDay = myCal->GetDaysInMonth( y, 2, myCal->Eras[ i ] ); - Console::Write( "\t {0}", myCal->IsLeapDay( y, 2, iLastDay, myCal->Eras[ i ] ) ); - - } - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2544 2545 2546 2547 2548 -CurrentEra: False False False True False -Era 1: False False False True False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapMonth/CPP/thaibuddhistcalendar_isleapmonth.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapMonth/CPP/thaibuddhistcalendar_isleapmonth.cpp deleted file mode 100644 index 23dd963fa16..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapMonth/CPP/thaibuddhistcalendar_isleapmonth.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// The following code example calls IsLeapMonth for all the months in five years in the current era. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a ThaiBuddhistCalendar. - ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar; - - // Checks all the months in five years in the current era. - int iMonthsInYear; - for ( int y = 2544; y <= 2548; y++ ) - { - Console::Write( " {0}:\t", y ); - iMonthsInYear = myCal->GetMonthsInYear( y, ThaiBuddhistCalendar::CurrentEra ); - for ( int m = 1; m <= iMonthsInYear; m++ ) - Console::Write( "\t {0}", myCal->IsLeapMonth( y, m, ThaiBuddhistCalendar::CurrentEra ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -2544: False False False False False False False False False False False False -2545: False False False False False False False False False False False False -2546: False False False False False False False False False False False False -2547: False False False False False False False False False False False False -2548: False False False False False False False False False False False False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapYear/CPP/thaibuddhistcalendar_isleapyear.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapYear/CPP/thaibuddhistcalendar_isleapyear.cpp deleted file mode 100644 index f8db76f0cbb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapYear/CPP/thaibuddhistcalendar_isleapyear.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// The following code example calls IsLeapYear for five years in each of the eras. -// -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Creates and initializes a ThaiBuddhistCalendar. - ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar; - - // Displays the header. - Console::Write( "YEAR\t" ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", y ); - Console::WriteLine(); - - // Checks five years in the current era. - Console::Write( "CurrentEra:" ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, ThaiBuddhistCalendar::CurrentEra ) ); - Console::WriteLine(); - - // Checks five years in each of the eras. - for ( int i = 0; i < myCal->Eras->Length; i++ ) - { - Console::Write( "Era {0}:\t", myCal->Eras[ i ] ); - for ( int y = 2544; y <= 2548; y++ ) - Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) ); - Console::WriteLine(); - - } -} - -/* -This code produces the following output. - -YEAR 2544 2545 2546 2547 2548 -CurrentEra: False False False True False -Era 1: False False False True False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp deleted file mode 100644 index 814657e163c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// The following code example displays the values of several components of a DateTime in terms of the ThaiBuddhist calendar. -// -using namespace System; -using namespace System::Globalization; -void DisplayValues( Calendar^ myCal, DateTime myDT ) -{ - Console::WriteLine( " Era: {0}", myCal->GetEra( myDT ) ); - Console::WriteLine( " Year: {0}", myCal->GetYear( myDT ) ); - Console::WriteLine( " Month: {0}", myCal->GetMonth( myDT ) ); - Console::WriteLine( " DayOfYear: {0}", myCal->GetDayOfYear( myDT ) ); - Console::WriteLine( " DayOfMonth: {0}", myCal->GetDayOfMonth( myDT ) ); - Console::WriteLine( " DayOfWeek: {0}", myCal->GetDayOfWeek( myDT ) ); - Console::WriteLine(); -} - -int main() -{ - - // Sets a DateTime to April 3, 2002 of the Gregorian calendar. - DateTime myDT = DateTime(2002,4,3,gcnew GregorianCalendar); - - // Creates an instance of the ThaiBuddhistCalendar. - ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar; - - // Displays the values of the DateTime. - Console::WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the ThaiBuddhist calendar:" ); - DisplayValues( myCal, myDT ); - - // Adds two years and ten months. - myDT = myCal->AddYears( myDT, 2 ); - myDT = myCal->AddMonths( myDT, 10 ); - - // Displays the values of the DateTime. - Console::WriteLine( "After adding two years and ten months:" ); - DisplayValues( myCal, myDT ); -} - -/* -This code produces the following output. - -April 3, 2002 of the Gregorian calendar equals the following in the ThaiBuddhist calendar: - Era: 1 - Year: 2545 - Month: 4 - DayOfYear: 93 - DayOfMonth: 3 - DayOfWeek: Wednesday - -After adding two years and ten months: - Era: 1 - Year: 2548 - Month: 2 - DayOfYear: 34 - DayOfMonth: 3 - DayOfWeek: Thursday - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_MinMax/CPP/thaibuddhistcalendar_minmax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_MinMax/CPP/thaibuddhistcalendar_minmax.cpp deleted file mode 100644 index a3628cd7019..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_MinMax/CPP/thaibuddhistcalendar_minmax.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// The following code example gets the minimum date and the maximum date of the calendar. -// -using namespace System; -using namespace System::Globalization; - -int main() -{ - // Create an instance of the calendar. - ThaiBuddhistCalendar^ myCal = gcnew ThaiBuddhistCalendar; - Console::WriteLine( myCal ); - - // Create an instance of the GregorianCalendar. - GregorianCalendar^ myGre = gcnew GregorianCalendar; - - // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMin = myCal->MinSupportedDateTime; - Console::Write( "MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMin ), myCal->GetDayOfMonth( myMin ), myCal->GetYear( myMin ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMin ), myGre->GetDayOfMonth( myMin ), myGre->GetYear( myMin ) ); - - // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar. - DateTime myMax = myCal->MaxSupportedDateTime; - Console::Write( "MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal->GetMonth( myMax ), myCal->GetDayOfMonth( myMax ), myCal->GetYear( myMax ) ); - Console::WriteLine( " (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre->GetMonth( myMax ), myGre->GetDayOfMonth( myMax ), myGre->GetYear( myMax ) ); -} - -/* -This code produces the following output. - -System.Globalization.ThaiBuddhistCalendar -MinSupportedDateTime: 01/01/0544 (in Gregorian, 01/01/0001) -MaxSupportedDateTime: 12/31/10542 (in Gregorian, 12/31/9999) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWByte/CPP/rwbyte.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWByte/CPP/rwbyte.cpp deleted file mode 100644 index f1c0b919c12..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWByte/CPP/rwbyte.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - int i = 0; - - // Create random data to write to the stream. - array^writeArray = gcnew array(1000); - (gcnew Random)->NextBytes( writeArray ); - BinaryWriter^ binWriter = gcnew BinaryWriter( gcnew MemoryStream ); - BinaryReader^ binReader = gcnew BinaryReader( binWriter->BaseStream ); - try - { - - // Write the data to the stream. - Console::WriteLine( "Writing the data." ); - for ( i = 0; i < writeArray->Length; i++ ) - { - binWriter->Write( writeArray[ i ] ); - - } - - // Set the stream position to the beginning of the stream. - binReader->BaseStream->Position = 0; - - // Read and verify the data from the stream. - for ( i = 0; i < writeArray->Length; i++ ) - { - if ( binReader->ReadByte() != writeArray[ i ] ) - { - Console::WriteLine( "Error writing the data." ); - return -1; - } - - } - Console::WriteLine( "The data was written and verified." ); - } - // Catch the EndOfStreamException and write an error message. - catch ( EndOfStreamException^ e ) - { - Console::WriteLine( "Error writing the data.\n{0}", e->GetType()->Name ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes1/CPP/rwbytes.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes1/CPP/rwbytes.cpp deleted file mode 100644 index a47e5998074..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes1/CPP/rwbytes.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - const int arrayLength = 1000; - - // Create random data to write to the stream. - array^dataArray = gcnew array(arrayLength); - (gcnew Random)->NextBytes( dataArray ); - BinaryWriter^ binWriter = gcnew BinaryWriter( gcnew MemoryStream ); - - // Write the data to the stream. - Console::WriteLine( "Writing the data." ); - binWriter->Write( dataArray ); - - // Create the reader using the stream from the writer. - BinaryReader^ binReader = gcnew BinaryReader( binWriter->BaseStream ); - - // Set the stream position to the beginning of the stream. - binReader->BaseStream->Position = 0; - - // Read and verify the data. - array^verifyArray = binReader->ReadBytes( arrayLength ); - if ( verifyArray->Length != arrayLength ) - { - Console::WriteLine( "Error writing the data." ); - return -1; - } - - for ( int i = 0; i < arrayLength; i++ ) - { - if ( verifyArray[ i ] != dataArray[ i ] ) - { - Console::WriteLine( "Error writing the data." ); - return -1; - } - - } - Console::WriteLine( "The data was written and verified." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/CPP/rwchar.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/CPP/rwchar.cpp deleted file mode 100644 index f77f117e2d3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/CPP/rwchar.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - int i; - array^invalidPathChars = Path::InvalidPathChars; - MemoryStream^ memStream = gcnew MemoryStream; - BinaryWriter^ binWriter = gcnew BinaryWriter( memStream ); - - // Write to memory. - binWriter->Write( "Invalid file path characters are: " ); - for ( i = 0; i < invalidPathChars->Length; i++ ) - { - binWriter->Write( invalidPathChars[ i ] ); - - } - - // Create the reader using the same MemoryStream - // as used with the writer. - BinaryReader^ binReader = gcnew BinaryReader( memStream ); - - // Set Position to the beginning of the stream. - binReader->BaseStream->Position = 0; - - // Read the data from memory and write it to the console. - Console::Write( binReader->ReadString() ); - array^memoryData = gcnew array(memStream->Length - memStream->Position); - for ( i = 0; i < memoryData->Length; i++ ) - { - memoryData[ i ] = binReader->ReadChar(); - - } - Console::WriteLine( memoryData ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar2/CPP/rwreadchar.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar2/CPP/rwreadchar.cpp deleted file mode 100644 index 1e60a82c46f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar2/CPP/rwreadchar.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - int i; - array^invalidPathChars = Path::InvalidPathChars; - MemoryStream^ memStream = gcnew MemoryStream; - BinaryWriter^ binWriter = gcnew BinaryWriter( memStream ); - - // Write to memory. - binWriter->Write( "Invalid file path characters are: " ); - for ( i = 0; i < invalidPathChars->Length; i++ ) - { - binWriter->Write( invalidPathChars[ i ] ); - - } - - // Create the reader using the same MemoryStream - // as used with the writer. - BinaryReader^ binReader = gcnew BinaryReader( memStream ); - - // Set Position to the beginning of the stream. - binReader->BaseStream->Position = 0; - - // Read the data from memory and write it to the console. - Console::Write( binReader->ReadString() ); - array^memoryData = gcnew array(memStream->Length - memStream->Position); - for ( i = 0; i < memoryData->Length; i++ ) - { - memoryData[ i ] = Convert::ToChar( binReader->Read() ); - - } - Console::WriteLine( memoryData ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/CPP/rwchars.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/CPP/rwchars.cpp deleted file mode 100644 index 18e3d52cf62..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/CPP/rwchars.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - array^invalidPathChars = Path::InvalidPathChars; - MemoryStream^ memStream = gcnew MemoryStream; - BinaryWriter^ binWriter = gcnew BinaryWriter( memStream ); - - // Write to memory. - binWriter->Write( "Invalid file path characters are: " ); - binWriter->Write( Path::InvalidPathChars ); - - // Create the reader using the same MemoryStream - // as used with the writer. - BinaryReader^ binReader = gcnew BinaryReader( memStream ); - - // Set Position to the beginning of the stream. - binReader->BaseStream->Position = 0; - - // Read the data from memory and write it to the console. - Console::Write( binReader->ReadString() ); - Console::WriteLine( binReader->ReadChars( (int)(memStream->Length - memStream->Position) ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars2/CPP/rwreadchars.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars2/CPP/rwreadchars.cpp deleted file mode 100644 index 591906554cb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars2/CPP/rwreadchars.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - array^invalidPathChars = Path::InvalidPathChars; - MemoryStream^ memStream = gcnew MemoryStream; - BinaryWriter^ binWriter = gcnew BinaryWriter( memStream ); - - // Write to memory. - binWriter->Write( "Invalid file path characters are: " ); - binWriter->Write( Path::InvalidPathChars, 0, Path::InvalidPathChars->Length ); - - // Create the reader using the same MemoryStream - // as used with the writer. - BinaryReader^ binReader = gcnew BinaryReader( memStream ); - - // Set Position to the beginning of the stream. - binReader->BaseStream->Position = 0; - - // Read the data from memory and write it to the console. - Console::Write( binReader->ReadString() ); - int arraySize = (int)(memStream->Length - memStream->Position); - array^memoryData = gcnew array(arraySize); - binReader->Read( memoryData, 0, arraySize ); - Console::WriteLine( memoryData ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp deleted file mode 100644 index 68e90396c8a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - int i; - const int arrayLength = 1000; - - // Create random data to write to the stream. - array^dataArray = gcnew array(arrayLength); - Random^ randomGenerator = gcnew Random; - for ( i = 0; i < arrayLength; i++ ) - { - dataArray[ i ] = 100.1 * randomGenerator->NextDouble(); - - } - BinaryWriter^ binWriter = gcnew BinaryWriter( gcnew MemoryStream ); - try - { - - // Write data to the stream. - Console::WriteLine( "Writing data to the stream." ); - i = 0; - for ( i = 0; i < arrayLength; i++ ) - { - binWriter->Write( dataArray[ i ] ); - - } - - // Create a reader using the stream from the writer. - BinaryReader^ binReader = gcnew BinaryReader( binWriter->BaseStream ); - - // Return to the beginning of the stream. - binReader->BaseStream->Position = 0; - try - { - - // Read and verify the data. - i = 0; - Console::WriteLine( "Verifying the written data." ); - for ( i = 0; i < arrayLength; i++ ) - { - if ( binReader->ReadDouble() != dataArray[ i ] ) - { - Console::WriteLine( "Error writing data." ); - break; - } - - } - Console::WriteLine( "The data was written and verified." ); - } - catch ( EndOfStreamException^ e ) - { - Console::WriteLine( "Error writing data: {0}.", e->GetType()->Name ); - } - - } - finally - { - binWriter->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/CPP/source3.cpp deleted file mode 100644 index 432c26e3d9c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/CPP/source3.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -public ref class BinReadWrite -{ -public: - static void Main() - { - String^ testfile = "C:\\temp\\testfile.bin"; - - // create a test file using BinaryWriter - FileStream^ fs = File::Create(testfile); - UTF8Encoding^ utf8 = gcnew UTF8Encoding(); - - BinaryWriter^ bw = gcnew BinaryWriter(fs, utf8); - // write a series of bytes to the file, each time incrementing - // the value from 0 - 127 - int pos; - - for (pos = 0; pos < 128; pos++) - { - bw->Write((Byte)pos); - } - - // reset the stream position for the next write pass - bw->Seek(0, SeekOrigin::Begin); - // write marks in file with the value of 255 going forward - for (pos = 0; pos < 120; pos += 8) - { - bw->Seek(7, SeekOrigin::Current); - bw->Write((Byte)255); - } - - // reset the stream position for the next write pass - bw->Seek(0, SeekOrigin::End); - // write marks in file with the value of 254 going backward - for (pos = 128; pos > 6; pos -= 6) - { - bw->Seek(-6, SeekOrigin::Current); - bw->Write((Byte)254); - bw->Seek(-1, SeekOrigin::Current); - } - - // now dump the contents of the file using the original file stream - fs->Seek(0, SeekOrigin::Begin); - array^ rawbytes = gcnew array(fs->Length); - fs->Read(rawbytes, 0, (int)fs->Length); - - int i = 0; - for each (Byte b in rawbytes) - { - switch (b) - { - case 254: - { - Console::Write("-%- "); - } - break; - - case 255: - { - Console::Write("-*- "); - } - break; - - default: - { - Console::Write("{0:d3} ", b); - } - break; - } - i++; - if (i == 16) - { - Console::WriteLine(); - i = 0; - } - } - fs->Close(); - } -}; - -int main() -{ - BinReadWrite::Main(); -} - -//The output from the program is this: -// -// 000 001 -%- 003 004 005 006 -*- -%- 009 010 011 012 013 -%- -*- -// 016 017 018 019 -%- 021 022 -*- 024 025 -%- 027 028 029 030 -*- -// -%- 033 034 035 036 037 -%- -*- 040 041 042 043 -%- 045 046 -*- -// 048 049 -%- 051 052 053 054 -*- -%- 057 058 059 060 061 -%- -*- -// 064 065 066 067 -%- 069 070 -*- 072 073 -%- 075 076 077 078 -*- -// -%- 081 082 083 084 085 -%- -*- 088 089 090 091 -%- 093 094 -*- -// 096 097 -%- 099 100 101 102 -*- -%- 105 106 107 108 109 -%- -*- -// 112 113 114 115 -%- 117 118 -*- 120 121 -%- 123 124 125 126 127 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp deleted file mode 100644 index c0d99cbb370..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp +++ /dev/null @@ -1,168 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Globalization; -using namespace System::Net; -using namespace System::Net::Sockets; -static const int streamBufferSize = 1000; -public ref class Client -{ -private: - literal int dataArraySize = 100; - literal int numberOfLoops = 10000; - Client(){} - - -public: - static void ReceiveData( Stream^ netStream, Stream^ bufStream ) - { - DateTime startTime; - Double networkTime; - Double bufferedTime = 0; - int bytesReceived = 0; - array^receivedData = gcnew array(dataArraySize); - - // Receive data using the NetworkStream. - Console::WriteLine( "Receiving data using NetworkStream." ); - startTime = DateTime::Now; - while ( bytesReceived < numberOfLoops * receivedData->Length ) - { - bytesReceived += netStream->Read( receivedData, 0, receivedData->Length ); - } - - networkTime = (DateTime::Now - startTime).TotalSeconds; - Console::WriteLine( "{0} bytes received in {1} seconds.\n", bytesReceived.ToString(), networkTime.ToString( "F1" ) ); - - // - // Receive data using the BufferedStream. - Console::WriteLine( "Receiving data using BufferedStream." ); - bytesReceived = 0; - startTime = DateTime::Now; - while ( bytesReceived < numberOfLoops * receivedData->Length ) - { - bytesReceived += bufStream->Read( receivedData, 0, receivedData->Length ); - } - - bufferedTime = (DateTime::Now - startTime).TotalSeconds; - Console::WriteLine( "{0} bytes received in {1} seconds.\n", bytesReceived.ToString(), bufferedTime.ToString( "F1" ) ); - - // - // Print the ratio of read times. - Console::WriteLine( "Receiving data using the buffered " - "network stream was {0} {1} than using the network " - "stream alone.", (networkTime / bufferedTime).ToString( "P0" ), bufferedTime < networkTime ? (String^)"faster" : "slower" ); - } - - static void SendData( Stream^ netStream, Stream^ bufStream ) - { - DateTime startTime; - Double networkTime; - Double bufferedTime; - - // Create random data to send to the server. - array^dataToSend = gcnew array(dataArraySize); - (gcnew Random)->NextBytes( dataToSend ); - - // Send the data using the NetworkStream. - Console::WriteLine( "Sending data using NetworkStream." ); - startTime = DateTime::Now; - for ( int i = 0; i < numberOfLoops; i++ ) - { - netStream->Write( dataToSend, 0, dataToSend->Length ); - - } - networkTime = (DateTime::Now - startTime).TotalSeconds; - Console::WriteLine( "{0} bytes sent in {1} seconds.\n", (numberOfLoops * dataToSend->Length).ToString(), networkTime.ToString( "F1" ) ); - - // - // Send the data using the BufferedStream. - Console::WriteLine( "Sending data using BufferedStream." ); - startTime = DateTime::Now; - for ( int i = 0; i < numberOfLoops; i++ ) - { - bufStream->Write( dataToSend, 0, dataToSend->Length ); - - } - bufStream->Flush(); - bufferedTime = (DateTime::Now - startTime).TotalSeconds; - Console::WriteLine( "{0} bytes sent in {1} seconds.\n", (numberOfLoops * dataToSend->Length).ToString(), bufferedTime.ToString( "F1" ) ); - - // - // Print the ratio of write times. - Console::WriteLine( "Sending data using the buffered " - "network stream was {0} {1} than using the network " - "stream alone.\n", (networkTime / bufferedTime).ToString( "P0" ), bufferedTime < networkTime ? (String^)"faster" : "slower" ); - } - -}; - -int main( int argc, char *argv[] ) -{ - - // Check that an argument was specified when the - // program was invoked. - if ( argc == 1 ) - { - Console::WriteLine( "Error: The name of the host computer" - " must be specified when the program is invoked." ); - return -1; - } - - String^ remoteName = gcnew String( argv[ 1 ] ); - - // Create the underlying socket and connect to the server. - Socket^ clientSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - clientSocket->Connect( gcnew IPEndPoint( Dns::Resolve( remoteName )->AddressList[ 0 ],1800 ) ); - Console::WriteLine( "Client is connected.\n" ); - - // - // Create a NetworkStream that owns clientSocket and - // then create a BufferedStream on top of the NetworkStream. - NetworkStream^ netStream = gcnew NetworkStream( clientSocket,true ); - BufferedStream^ bufStream = gcnew BufferedStream( netStream,streamBufferSize ); - - // - try - { - - // - // Check whether the underlying stream supports seeking. - Console::WriteLine( "NetworkStream {0} seeking.\n", bufStream->CanSeek ? (String^)"supports" : "does not support" ); - - // - // Send and receive data. - // - if ( bufStream->CanWrite ) - { - Client::SendData( netStream, bufStream ); - } - - // - // - if ( bufStream->CanRead ) - { - Client::ReceiveData( netStream, bufStream ); - } - - // - } - finally - { - - // - // When bufStream is closed, netStream is in turn closed, - // which in turn shuts down the connection and closes - // clientSocket. - Console::WriteLine( "\nShutting down connection." ); - bufStream->Close(); - - // - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream2/CPP/server.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream2/CPP/server.cpp deleted file mode 100644 index fef12f4fa47..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream2/CPP/server.cpp +++ /dev/null @@ -1,91 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Net; -using namespace System::Net::Sockets; -int main() -{ - - // This is a Windows Sockets 2 error code. - const int WSAETIMEDOUT = 10060; - Socket^ serverSocket; - int bytesReceived; - int totalReceived = 0; - array^receivedData = gcnew array(2000000); - - // Create random data to send to the client. - array^dataToSend = gcnew array(2000000); - (gcnew Random)->NextBytes( dataToSend ); - IPAddress^ ipAddress = Dns::Resolve( Dns::GetHostName() )->AddressList[ 0 ]; - IPEndPoint^ ipEndpoint = gcnew IPEndPoint( ipAddress,1800 ); - - // Create a socket and listen for incoming connections. - Socket^ listenSocket = gcnew Socket( AddressFamily::InterNetwork,SocketType::Stream,ProtocolType::Tcp ); - try - { - listenSocket->Bind( ipEndpoint ); - listenSocket->Listen( 1 ); - - // Accept a connection and create a socket to handle it. - serverSocket = listenSocket->Accept(); - Console::WriteLine( "Server is connected.\n" ); - } - finally - { - listenSocket->Close(); - } - - try - { - - // Send data to the client. - Console::Write( "Sending data ... " ); - int bytesSent = serverSocket->Send( dataToSend, 0, dataToSend->Length, SocketFlags::None ); - Console::WriteLine( "{0} bytes sent.\n", bytesSent.ToString() ); - - // Set the timeout for receiving data to 2 seconds. - serverSocket->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::ReceiveTimeout, 2000 ); - - // Receive data from the client. - Console::Write( "Receiving data ... " ); - try - { - do - { - bytesReceived = serverSocket->Receive( receivedData, 0, receivedData->Length, SocketFlags::None ); - totalReceived += bytesReceived; - } - while ( bytesReceived != 0 ); - } - catch ( SocketException^ e ) - { - if ( e->ErrorCode == WSAETIMEDOUT ) - { - - // Data was not received within the given time. - // Assume that the transmission has ended. - } - else - { - Console::WriteLine( "{0}: {1}\n", e->GetType()->Name, e->Message ); - } - } - finally - { - Console::WriteLine( "{0} bytes received.\n", totalReceived.ToString() ); - } - - } - finally - { - serverSocket->Shutdown( SocketShutdown::Both ); - Console::WriteLine( "Connection shut down." ); - serverSocket->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Directory/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Directory/CPP/class1.cpp deleted file mode 100644 index c11186b5225..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Directory/CPP/class1.cpp +++ /dev/null @@ -1,163 +0,0 @@ - -// -// -// -// -// -using namespace System; -class Class1 -{ -public: - void PrintFileSystemEntries( String^ path ) - { - try - { - - // Obtain the file system entries in the directory path. - array^directoryEntries = System::IO::Directory::GetFileSystemEntries( path ); - for ( int i = 0; i < directoryEntries->Length; i++ ) - { - System::Console::WriteLine( directoryEntries[ i ] ); - - } - } - catch ( ArgumentNullException^ ) - { - System::Console::WriteLine( "Path is a null reference." ); - } - catch ( System::Security::SecurityException^ ) - { - System::Console::WriteLine( "The caller does not have the \HelloServer' required permission." ); - } - catch ( ArgumentException^ ) - { - System::Console::WriteLine( "Path is an empty String, \HelloServer' contains only white spaces, \HelloServer' or contains invalid characters." ); - } - catch ( System::IO::DirectoryNotFoundException^ ) - { - System::Console::WriteLine( "The path encapsulated in the \HelloServer' Directory object does not exist." ); - } - - } - - void PrintFileSystemEntries( String^ path, String^ pattern ) - { - try - { - - // Obtain the file system entries in the directory - // path that match the pattern. - array^directoryEntries = System::IO::Directory::GetFileSystemEntries( path, pattern ); - for ( int i = 0; i < directoryEntries->Length; i++ ) - { - System::Console::WriteLine( directoryEntries[ i ] ); - - } - } - catch ( ArgumentNullException^ ) - { - System::Console::WriteLine( "Path is a null reference." ); - } - catch ( System::Security::SecurityException^ ) - { - System::Console::WriteLine( "The caller does not have the \HelloServer' required permission." ); - } - catch ( ArgumentException^ ) - { - System::Console::WriteLine( "Path is an empty String, \HelloServer' contains only white spaces, \HelloServer' or contains invalid characters." ); - } - catch ( System::IO::DirectoryNotFoundException^ ) - { - System::Console::WriteLine( "The path encapsulated in the \HelloServer' Directory object does not exist." ); - } - - } - - - // Print out all logical drives on the system. - void GetLogicalDrives() - { - try - { - array^drives = System::IO::Directory::GetLogicalDrives(); - for ( int i = 0; i < drives->Length; i++ ) - { - System::Console::WriteLine( drives[ i ] ); - - } - } - catch ( System::IO::IOException^ ) - { - System::Console::WriteLine( "An I/O error occurs." ); - } - catch ( System::Security::SecurityException^ ) - { - System::Console::WriteLine( "The caller does not have the \HelloServer' required permission." ); - } - - } - - void GetParent( String^ path ) - { - try - { - System::IO::DirectoryInfo^ directoryInfo = System::IO::Directory::GetParent( path ); - System::Console::WriteLine( directoryInfo->FullName ); - } - catch ( ArgumentNullException^ ) - { - System::Console::WriteLine( "Path is a null reference." ); - } - catch ( ArgumentException^ ) - { - System::Console::WriteLine( "Path is an empty String, \HelloServer' contains only white spaces, or \HelloServer' contains invalid characters." ); - } - - } - - void Move( String^ sourcePath, String^ destinationPath ) - { - try - { - System::IO::Directory::Move( sourcePath, destinationPath ); - System::Console::WriteLine( "The directory move is complete." ); - } - catch ( ArgumentNullException^ ) - { - System::Console::WriteLine( "Path is a null reference." ); - } - catch ( System::Security::SecurityException^ ) - { - System::Console::WriteLine( "The caller does not have the \HelloServer' required permission." ); - } - catch ( ArgumentException^ ) - { - System::Console::WriteLine( "Path is an empty String, \HelloServer' contains only white spaces, \HelloServer' or contains invalid characters." ); - } - catch ( System::IO::IOException^ ) - { - System::Console::WriteLine( "An attempt was made to move a \HelloServer' directory to a different \HelloServer' volume, or destDirName \HelloServer' already exists." ); - } - - } - -}; - -int main() -{ - Class1 * snippets = new Class1; - String^ path = System::IO::Directory::GetCurrentDirectory(); - String^ filter = "*.exe"; - snippets->PrintFileSystemEntries( path ); - snippets->PrintFileSystemEntries( path, filter ); - snippets->GetLogicalDrives(); - snippets->GetParent( path ); - snippets->Move( "C:\\proof", "C:\\Temp" ); - return 0; -} - -// -// -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/cpp/searchoption.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/cpp/searchoption.cpp deleted file mode 100644 index 4223289ec56..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/cpp/searchoption.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -ref class App -{ -public: - static void Main() - { - // Specify the directory you want to manipulate. - String^ path = "c:\\"; - String^ searchPattern = "c*"; - - DirectoryInfo^ di = gcnew DirectoryInfo(path); - array^ directories = - di->GetDirectories(searchPattern, SearchOption::TopDirectoryOnly); - - array^ files = - di->GetFiles(searchPattern, SearchOption::TopDirectoryOnly); - - Console::WriteLine( - "Directories that begin with the letter \"c\" in {0}", path); - for each (DirectoryInfo^ dir in directories) - { - Console::WriteLine( - "{0,-25} {1,25}", dir->FullName, dir->LastWriteTime); - } - - Console::WriteLine(); - Console::WriteLine( - "Files that begin with the letter \"c\" in {0}", path); - for each (FileInfo^ file in files) - { - Console::WriteLine( - "{0,-25} {1,25}", file->Name, file->LastWriteTime); - } - } // Main() -}; // App() - -int main() -{ - App::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryRoot/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryRoot/CPP/example.cpp deleted file mode 100644 index 5bae2a921c4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryRoot/CPP/example.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -// This sample shows how to set the current directory and how to determine -// the root directory. -using namespace System; -using namespace System::IO; -int main() -{ - - // Create string for a directory. This value should be an existing directory - // or the sample will throw a DirectoryNotFoundException. - String^ dir = "C:\\test"; - try - { - - //Set the current directory. - Directory::SetCurrentDirectory( dir ); - } - catch ( DirectoryNotFoundException^ e ) - { - Console::WriteLine( "The specified directory does not exist. {0}", e ); - } - - - // Print to console the results. - Console::WriteLine( "Root directory: {0}", Directory::GetDirectoryRoot( dir ) ); - Console::WriteLine( "Current directory: {0}", Directory::GetCurrentDirectory() ); -} - -// The output of this sample depends on what value you assign to the variable dir. -// If the directory c:\test exists, the output for this sample is: -// Root directory: C:\ -// Current directory: C:\test -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream1/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream1/CPP/source.cpp deleted file mode 100644 index fc1124722e1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream1/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - String^ fileName = "Test@##@.dat"; - - // Create random data to write to the file. - array^dataArray = gcnew array(100000); - (gcnew Random)->NextBytes( dataArray ); - FileStream^ fileStream = gcnew FileStream( fileName,FileMode::Create ); - try - { - - // Write the data to the file, byte by byte. - for ( int i = 0; i < dataArray->Length; i++ ) - { - fileStream->WriteByte( dataArray[ i ] ); - - } - - // Set the stream position to the beginning of the file. - fileStream->Seek( 0, SeekOrigin::Begin ); - - // Read and verify the data. - for ( int i = 0; i < fileStream->Length; i++ ) - { - if ( dataArray[ i ] != fileStream->ReadByte() ) - { - Console::WriteLine( "Error writing data." ); - return -1; - } - - } - Console::WriteLine( "The data was written to {0} " - "and verified.", fileStream->Name ); - } - finally - { - fileStream->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream2/CPP/source.cpp deleted file mode 100644 index e6d0b8b59b5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream2/CPP/source.cpp +++ /dev/null @@ -1,156 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Threading; - -// Maintain state information to be passed to -// EndWriteCallback and EndReadCallback. -ref class State -{ -private: - - // fStream is used to read and write to the file. - FileStream^ fStream; - - // writeArray stores data that is written to the file. - array^writeArray; - - // readArray stores data that is read from the file. - array^readArray; - - // manualEvent signals the main thread - // when verification is complete. - ManualResetEvent^ manualEvent; - -public: - State( FileStream^ fStream, array^writeArray, ManualResetEvent^ manualEvent ) - { - this->fStream = fStream; - this->writeArray = writeArray; - this->manualEvent = manualEvent; - readArray = gcnew array(writeArray->Length); - } - - - property FileStream^ FStream - { - FileStream^ get() - { - return fStream; - } - - } - - property array^ WriteArray - { - array^ get() - { - return writeArray; - } - - } - - property array^ ReadArray - { - array^ get() - { - return readArray; - } - - } - - property ManualResetEvent^ ManualEvent - { - ManualResetEvent^ get() - { - return manualEvent; - } - - } - -}; - -ref class FStream -{ -private: - - // When BeginRead is finished reading data from the file, the - // EndReadCallback method is called to end the asynchronous - // read operation and then verify the data. - // - static void EndReadCallback( IAsyncResult^ asyncResult ) - { - State^ tempState = dynamic_cast(asyncResult->AsyncState); - int readCount = tempState->FStream->EndRead( asyncResult ); - int i = 0; - while ( i < readCount ) - { - if ( tempState->ReadArray[ i ] != tempState->WriteArray[ i++ ] ) - { - Console::WriteLine( "Error writing data." ); - tempState->FStream->Close(); - return; - } - } - - Console::WriteLine( "The data was written to {0} " - "and verified.", tempState->FStream->Name ); - tempState->FStream->Close(); - - // Signal the main thread that the verification is finished. - tempState->ManualEvent->Set(); - } - - -public: - - // - // When BeginWrite is finished writing data to the file, the - // EndWriteCallback method is called to end the asynchronous - // write operation and then read back and verify the data. - // - static void EndWriteCallback( IAsyncResult^ asyncResult ) - { - State^ tempState = dynamic_cast(asyncResult->AsyncState); - FileStream^ fStream = tempState->FStream; - fStream->EndWrite( asyncResult ); - - // Asynchronously read back the written data. - fStream->Position = 0; - asyncResult = fStream->BeginRead( tempState->ReadArray, 0, tempState->ReadArray->Length, gcnew AsyncCallback( &FStream::EndReadCallback ), tempState ); - - // Concurrently do other work, such as - // logging the write operation. - } - -}; - - -// -// -int main() -{ - - // Create a synchronization object that gets - // signaled when verification is complete. - ManualResetEvent^ manualEvent = gcnew ManualResetEvent( false ); - - // Create the data to write to the file. - array^writeArray = gcnew array(100000); - (gcnew Random)->NextBytes( writeArray ); - FileStream^ fStream = gcnew FileStream( "Test#@@#.dat",FileMode::Create,FileAccess::ReadWrite,FileShare::None,4096,true ); - - // Check that the FileStream was opened asynchronously. - Console::WriteLine( "fStream was {0}opened asynchronously.", fStream->IsAsync ? (String^)"" : "not " ); - - // Asynchronously write to the file. - IAsyncResult^ asyncResult = fStream->BeginWrite( writeArray, 0, writeArray->Length, gcnew AsyncCallback( &FStream::EndWriteCallback ), gcnew State( fStream,writeArray,manualEvent ) ); - - // Concurrently do other work and then wait - // for the data to be written and verified. - manualEvent->WaitOne( 5000, false ); -} - -// -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream3/CPP/fstreamlock.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream3/CPP/fstreamlock.cpp deleted file mode 100644 index c9d04e24506..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream3/CPP/fstreamlock.cpp +++ /dev/null @@ -1,144 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Text; -int main() -{ - UnicodeEncoding^ uniEncoding = gcnew UnicodeEncoding; - String^ lastRecordText = "The last processed record number was: "; - int textLength = uniEncoding->GetByteCount( lastRecordText ); - int recordNumber = 13; - int byteCount = uniEncoding->GetByteCount( recordNumber.ToString() ); - String^ tempString; - - // - FileStream^ fileStream = gcnew FileStream( "Test#@@#.dat",FileMode::OpenOrCreate,FileAccess::ReadWrite,FileShare::ReadWrite ); - - // - try - { - - // - // Write the original file data. - if ( fileStream->Length == 0 ) - { - tempString = String::Concat( lastRecordText, recordNumber.ToString() ); - fileStream->Write( uniEncoding->GetBytes( tempString ), 0, uniEncoding->GetByteCount( tempString ) ); - } - - // - // Allow the user to choose the operation. - Char consoleInput = 'R'; - array^readText = gcnew array(fileStream->Length); - while ( consoleInput != 'X' ) - { - Console::Write( "\nEnter 'R' to read, 'W' to write, 'L' to " - "lock, 'U' to unlock, anything else to exit: " ); - if ( (tempString = Console::ReadLine())->Length == 0 ) - { - break; - } - consoleInput = Char::ToUpper( tempString[0] ); - switch ( consoleInput ) - { - case 'R': - try - { - fileStream->Seek( 0, SeekOrigin::Begin ); - fileStream->Read( readText, 0, (int)fileStream->Length ); - tempString = gcnew String( uniEncoding->GetChars( readText, 0, readText->Length ) ); - Console::WriteLine( tempString ); - recordNumber = Int32::Parse( tempString->Substring( tempString->IndexOf( ':' ) + 2 ) ); - } - // Catch the IOException generated if the - // specified part of the file is locked. - catch ( IOException^ e ) - { - Console::WriteLine( "{0}: The read " - "operation could not be performed " - "because the specified part of the " - "file is locked.", e->GetType()->Name ); - } - - break; - - // - // Update the file. - case 'W': - try - { - fileStream->Seek( textLength, SeekOrigin::Begin ); - fileStream->Read( readText, textLength - 1, byteCount ); - tempString = gcnew String( uniEncoding->GetChars( readText, textLength - 1, byteCount ) ); - recordNumber = Int32::Parse( tempString ) + 1; - fileStream->Seek( textLength, SeekOrigin::Begin ); - fileStream->Write( uniEncoding->GetBytes( recordNumber.ToString() ), 0, byteCount ); - fileStream->Flush(); - Console::WriteLine( "Record has been updated." ); - } - // - // - // Catch the IOException generated if the - // specified part of the file is locked. - catch ( IOException^ e ) - { - Console::WriteLine( "{0}: The write operation could not " - "be performed because the specified " - "part of the file is locked.", e->GetType()->Name ); - } - - - // - break; - - // Lock the specified part of the file. - case 'L': - try - { - fileStream->Lock( textLength - 1, byteCount ); - Console::WriteLine( "The specified part " - "of file has been locked." ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "{0}: The specified part of file is" - " already locked.", e->GetType()->Name ); - } - - break; - - // - // Unlock the specified part of the file. - case 'U': - try - { - fileStream->Unlock( textLength - 1, byteCount ); - Console::WriteLine( "The specified part " - "of file has been unlocked." ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "{0}: The specified part of file is " - "not locked by the current process.", e->GetType()->Name ); - } - - break; - - default: - - // - // Exit the program. - consoleInput = 'X'; - break; - } - } - } - finally - { - fileStream->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp deleted file mode 100644 index af3bee22a32..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp +++ /dev/null @@ -1,61 +0,0 @@ -using namespace System; -using namespace System::IO; -using namespace System::IO::IsolatedStorage; - -public ref class IsoFileGetStoreSample -{ -public: - static void Main() - { - IsolatedStorageFile^ isoFile; - - // remarks for GetMachineStoreForApplication() - // - isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Application | - IsolatedStorageScope::Machine, (Type^)nullptr); - // - isoFile->Close(); - - // remarks for GetMachineStoreForAssembly() - // - isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Assembly | - IsolatedStorageScope::Machine, (Type^)nullptr, (Type^)nullptr); - // - isoFile->Close(); - - // remarks for GetMachineStoreForDomain() - // - isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Assembly | - IsolatedStorageScope::Domain | IsolatedStorageScope::Machine, - (Type^)nullptr, (Type^)nullptr); - // - isoFile->Close(); - - // remarks for GetUserStoreForApplication() - // - isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Application | - IsolatedStorageScope::User, (Type^)nullptr); - // - isoFile->Close(); - - // remarks for GetUserStoreForAssembly() - // - isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Assembly | - IsolatedStorageScope::User, (Type^)nullptr, (Type^)nullptr); - // - isoFile->Close(); - - // remarks for GetUserStoreForDomain() - // - isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Assembly | - IsolatedStorageScope::Domain | IsolatedStorageScope::User, - (Type^)nullptr, (Type^)nullptr); - // - isoFile->Close(); - } -}; - -int main() -{ - IsoFileGetStoreSample::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp deleted file mode 100644 index daaf6e6e7ea..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp +++ /dev/null @@ -1,422 +0,0 @@ - -// -// This sample demonstrates methods of classes found in the System.IO IsolatedStorage namespace. -using namespace System; -using namespace System::IO; -using namespace System::IO::IsolatedStorage; -using namespace System::Security::Policy; -using namespace System::Security::Permissions; - -public ref class LoginPrefs -{ -private: - String^ userName; - String^ newsUrl; - String^ sportsUrl; - bool newPrefs; - -public: - - // - [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)] - bool GetPrefsForUser() - { - try - { - - // - // Retrieve an IsolatedStorageFile for the current Domain and Assembly. - IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), (Type^)nullptr, nullptr ); - IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::Open,FileAccess::ReadWrite,isoFile ); - - // - // farThe code executes to this point only if a file corresponding to the username exists. - // Though you can perform operations on the stream, you cannot get a handle to the file. - try - { - IntPtr aFileHandle = isoStream->Handle; - Console::WriteLine( "A pointer to a file handle has been obtained. {0} {1}", aFileHandle, aFileHandle.GetHashCode() ); - } - catch ( Exception^ e ) - { - - // Handle the exception. - Console::WriteLine( "Expected exception" ); - Console::WriteLine( e->ToString() ); - } - - StreamReader^ reader = gcnew StreamReader( isoStream ); - - // Read the data. - this->NewsUrl = reader->ReadLine(); - this->SportsUrl = reader->ReadLine(); - reader->Close(); - isoFile->Close(); - isoStream->Close(); - return false; - } - catch ( Exception^ e ) - { - - // Expected exception if a file cannot be found. This indicates that we have a new user. - String^ errorMessage = e->ToString(); - return true; - } - - } - - - // - // - bool GetIsoStoreInfo() - { - - // Get a User store with type evidence for the current Domain and the Assembly. - IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid ); - - // - array^dirNames = isoFile->GetDirectoryNames( "*" ); - array^fileNames = isoFile->GetFileNames( "*" ); - - // List directories currently in this Isolated Storage. - if ( dirNames->Length > 0 ) - { - for ( int i = 0; i < dirNames->Length; ++i ) - { - Console::WriteLine( "Directory Name: {0}", dirNames[ i ] ); - - } - } - - - // List the files currently in this Isolated Storage. - // The list represents all users who have personal preferences stored for this application. - if ( fileNames->Length > 0 ) - { - for ( int i = 0; i < fileNames->Length; ++i ) - { - Console::WriteLine( "File Name: {0}", fileNames[ i ] ); - - } - } - - - // - isoFile->Close(); - return true; - } - - - // - // - double SetPrefsForUser() - { - try - { - - // - IsolatedStorageFile^ isoFile; - isoFile = IsolatedStorageFile::GetUserStoreForDomain(); - - // Open or create a writable file. - IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,FileAccess::Write,isoFile ); - StreamWriter^ writer = gcnew StreamWriter( isoStream ); - writer->WriteLine( this->NewsUrl ); - writer->WriteLine( this->SportsUrl ); - - // Calculate the amount of space used to record the user's preferences. - double d = isoFile->CurrentSize / isoFile->MaximumSize; - Console::WriteLine( "CurrentSize = {0}", isoFile->CurrentSize.ToString() ); - Console::WriteLine( "MaximumSize = {0}", isoFile->MaximumSize.ToString() ); - writer->Close(); - isoFile->Close(); - isoStream->Close(); - return d; - - // - } - catch ( Exception^ e ) - { - // Add code here to handle the exception. - Console::WriteLine( e->ToString() ); - return 0.0; - } - - } - - - // - // - void DeleteFiles() - { - - // - try - { - IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid ); - array^dirNames = isoFile->GetDirectoryNames( "*" ); - array^fileNames = isoFile->GetFileNames( "*" ); - - // - // List the files currently in this Isolated Storage. - // The list represents all users who have personal - // preferences stored for this application. - if ( fileNames->Length > 0 ) - { - for ( int i = 0; i < fileNames->Length; ++i ) - { - - //Delete the files. - isoFile->DeleteFile( fileNames[ i ] ); - - } - fileNames = isoFile->GetFileNames( "*" ); - } - isoFile->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - - } - - - // - // - // This method deletes directories in the specified Isolated Storage, after first - // deleting the files they contain. In this example, the Archive directory is deleted. - // There should be no other directories in this Isolated Storage. - void DeleteDirectories() - { - try - { - IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid ); - array^dirNames = isoFile->GetDirectoryNames( "*" ); - array^fileNames = isoFile->GetFileNames( "Archive\\*" ); - - // Delete the current files within the Archive directory. - if ( fileNames->Length > 0 ) - { - for ( int i = 0; i < fileNames->Length; ++i ) - { - - //delete files - isoFile->DeleteFile( String::Concat("Archive\\", fileNames[ i ]) ); - - } - fileNames = isoFile->GetFileNames( "Archive\\*" ); - } - if ( dirNames->Length > 0 ) - { - for ( int i = 0; i < dirNames->Length; ++i ) - { - - // Delete the Archive directory. - isoFile->DeleteDirectory( dirNames[ i ] ); - - } - } - dirNames = isoFile->GetDirectoryNames( "*" ); - isoFile->Remove(); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - } - - } - - - // - // - double SetNewPrefsForUser() - { - try - { - Byte inputChar; - IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid ); - - // If this is not a new user, archive the old preferences and - // overwrite them using the new preferences. - if ( !this->NewPrefs ) - { - if ( isoFile->GetDirectoryNames( "Archive" )->Length == 0 ) - isoFile->CreateDirectory( "Archive" ); - else - { - - // - // This is the stream to which data will be written. - IsolatedStorageFileStream^ source = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,isoFile ); - - // This is the stream from which data will be read. - Console::WriteLine( "Is the source file readable? {0}", (source->CanRead ? (String^)"true" : "false") ); - Console::WriteLine( "Creating new IsolatedStorageFileStream for Archive." ); - - // Open or create a writable file. - IsolatedStorageFileStream^ target = gcnew IsolatedStorageFileStream( String::Concat("Archive\\",this->userName),FileMode::OpenOrCreate,FileAccess::Write,FileShare::Write,isoFile ); - - // - // - Console::WriteLine( "Is the target file writable? {0}", (target->CanWrite ? (String^)"true" : "false") ); - - // - // Stream the old file to a new file in the Archive directory. - if ( source->IsAsync && target->IsAsync ) - { - - // IsolatedStorageFileStreams cannot be asynchronous. However, you - // can use the asynchronous BeginRead and BeginWrite functions - // with some possible performance penalty. - Console::WriteLine( "IsolatedStorageFileStreams cannot be asynchronous." ); - } - else - { - - // - Console::WriteLine( "Writing data to the new file." ); - while ( source->Position < source->Length ) - { - inputChar = (Byte)source->ReadByte(); - target->WriteByte( (Byte)source->ReadByte() ); - } - - // Determine the size of the IsolatedStorageFileStream - // by checking its Length property. - Console::WriteLine( "Total Bytes Read: {0}", source->Length.ToString() ); - - // - } - - // After you have read and written to the streams, close them. - target->Close(); - source->Close(); - } - } - - // - // Open or create a writable file, no larger than 10k - IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,FileAccess::Write,FileShare::Write,10240,isoFile ); - - // - isoStream->Position = 0; // Position to overwrite the old data. - - // - // - StreamWriter^ writer = gcnew StreamWriter( isoStream ); - - // Update the data based on the new inputs. - writer->WriteLine( this->NewsUrl ); - writer->WriteLine( this->SportsUrl ); - - // Calculate the amount of space used to record this user's preferences. - double d = isoFile->CurrentSize / isoFile->MaximumSize; - Console::WriteLine( "CurrentSize = {0}", isoFile->CurrentSize.ToString() ); - Console::WriteLine( "MaximumSize = {0}", isoFile->MaximumSize.ToString() ); - - // - // StreamWriter.Close implicitly closes isoStream. - writer->Close(); - isoFile->Close(); - return d; - } - catch ( Exception^ e ) - { - Console::WriteLine( e->ToString() ); - return 0.0; - } - - } - - LoginPrefs( String^ aUserName ) - { - userName = aUserName; - newPrefs = GetPrefsForUser(); - } - - - property String^ NewsUrl - { - String^ get() - { - return newsUrl; - } - - void set( String^ value ) - { - newsUrl = value; - } - - } - - property String^ SportsUrl - { - String^ get() - { - return sportsUrl; - } - - void set( String^ value ) - { - sportsUrl = value; - } - - } - - property bool NewPrefs - { - bool get() - { - return newPrefs; - } - - } - -}; - -void GatherInfoFromUser( LoginPrefs^ lp ) -{ - Console::WriteLine( "Please enter the URL of your news site." ); - lp->NewsUrl = Console::ReadLine(); - Console::WriteLine( "Please enter the URL of your sports site." ); - lp->SportsUrl = Console::ReadLine(); -} - -int main() -{ - - // Prompt the user for their username. - Console::WriteLine( "Enter your login ID:" ); - - // Does no error checking. - LoginPrefs^ lp = gcnew LoginPrefs( Console::ReadLine() ); - if ( lp->NewPrefs ) - { - Console::WriteLine( "Please set preferences for a new user." ); - GatherInfoFromUser( lp ); - - // Write the new preferences to storage. - double percentUsed = lp->SetPrefsForUser(); - Console::WriteLine( "Your preferences have been written. Current space used is {0}%", percentUsed ); - } - else - { - Console::WriteLine( "Welcome back." ); - Console::WriteLine( "Your preferences have expired, please reset them." ); - GatherInfoFromUser( lp ); - lp->SetNewPrefsForUser(); - Console::WriteLine( "Your news site has been set to {0}\n and your sports site has been set to {1}.", lp->NewsUrl, lp->SportsUrl ); - } - - lp->GetIsoStoreInfo(); - Console::WriteLine( "Enter 'd' to delete the IsolatedStorage files and exit, or press any other key to exit without deleting files." ); - String^ consoleInput = Console::ReadLine(); - if ( consoleInput->Equals( "d" ) ) - { - lp->DeleteFiles(); - lp->DeleteDirectories(); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp deleted file mode 100644 index 6d60f8f19f3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp +++ /dev/null @@ -1,74 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Text; - -int main() -{ - int count; - array^byteArray; - array^charArray; - UnicodeEncoding^ uniEncoding = gcnew UnicodeEncoding; - - // Create the data to write to the stream. - array^firstString = uniEncoding->GetBytes( "Invalid file path characters are: " ); - array^secondString = uniEncoding->GetBytes( Path::InvalidPathChars ); - - // - MemoryStream^ memStream = gcnew MemoryStream( 100 ); - // - try - { - // - // Write the first string to the stream. - memStream->Write( firstString, 0, firstString->Length ); - // - - // - // Write the second string to the stream, byte by byte. - count = 0; - while ( count < secondString->Length ) - { - memStream->WriteByte( secondString[ count++ ] ); - } - // - - - // - // Write the stream properties to the console. - Console::WriteLine( "Capacity = {0}, Length = {1}, " - "Position = {2}\n", memStream->Capacity.ToString(), memStream->Length.ToString(), memStream->Position.ToString() ); - // - - // - // Set the stream position to the beginning of the stream. - memStream->Seek( 0, SeekOrigin::Begin ); - // - - // - // Read the first 20 bytes from the stream. - byteArray = gcnew array(memStream->Length); - count = memStream->Read( byteArray, 0, 20 ); - // - - // - // Read the remaining bytes, byte by byte. - while ( count < memStream->Length ) - { - byteArray[ count++ ] = Convert::ToByte( memStream->ReadByte() ); - } - // - - // Decode the Byte array into a Char array - // and write it to the console. - charArray = gcnew array(uniEncoding->GetCharCount( byteArray, 0, count )); - uniEncoding->GetDecoder()->GetChars( byteArray, 0, count, charArray, 0 ); - Console::WriteLine( charArray ); - } - finally - { - memStream->Close(); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp deleted file mode 100644 index ea4a47ab8ca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp +++ /dev/null @@ -1,307 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -void ChangeExtension() -{ - String^ goodFileName = "C:\\mydir\\myfile.com.extension"; - String^ badFileName = "C:\\mydir\\"; - String^ result; - result = Path::ChangeExtension( goodFileName, ".old" ); - Console::WriteLine( "ChangeExtension({0}, '.old') returns '{1}'", goodFileName, result ); - result = Path::ChangeExtension( goodFileName, "" ); - Console::WriteLine( "ChangeExtension({0}, '') returns '{1}'", goodFileName, result ); - result = Path::ChangeExtension( badFileName, ".old" ); - Console::WriteLine( "ChangeExtension({0}, '.old') returns '{1}'", badFileName, result ); - - // This code produces output similar to the following: - // - // ChangeExtension(C:\mydir\myfile.com.extension, '.old') returns 'C:\mydir\myfile.com.old' - // ChangeExtension(C:\mydir\myfile.com.extension, '') returns 'C:\mydir\myfile.com.' - // ChangeExtension(C:\mydir\, '.old') returns 'C:\mydir\.old' - // - Console::WriteLine(); -} - -void Combine() -{ - // - String^ path1 = " C:\\mydir1"; - String^ path2 = "mydir2"; - String^ path3 = " mydir3"; - String^ combinedPaths; - combinedPaths = Path::Combine( path1, path2 ); - Console::WriteLine( "Combine('{0}', '{1}') returns '{2}'", path1, path2, combinedPaths ); - combinedPaths = Path::Combine( path1, path3 ); - Console::WriteLine( "Combine('{0}', '{1}') returns '{2}'", path1, path3, combinedPaths ); - - // This code produces output similar to the following: - // - // Combine(' C:\mydir1', 'mydir2') returns ' C:\mydir1\mydir2' - // Combine(' C:\mydir1', ' mydir3') returns ' C:\mydir1\ mydir3' - // - Console::WriteLine(); -} - -void GetDirectoryName() -{ - // - String^ filePath = "C:\\MyDir\\MySubDir\\myfile.ext"; - String^ directoryName; - int i = 0; - - while (filePath != nullptr) - { - directoryName = Path::GetDirectoryName(filePath); - Console::WriteLine("GetDirectoryName('{0}') returns '{1}'", - filePath, directoryName); - filePath = directoryName; - if (i == 1) - { - filePath = directoryName + "\\"; // this will preserve the previous path - } - i++; - } - /* - This code produces the following output: - - GetDirectoryName('C:\MyDir\MySubDir\myfile.ext') returns 'C:\MyDir\MySubDir' - GetDirectoryName('C:\MyDir\MySubDir') returns 'C:\MyDir' - GetDirectoryName('C:\MyDir\') returns 'C:\MyDir' - GetDirectoryName('C:\MyDir') returns 'C:\' - GetDirectoryName('C:\') returns '' - */ - // - Console::WriteLine(); -} - -void GetExtension() -{ - // - String^ fileName = "C:\\mydir.old\\myfile.ext"; - String^ path = "C:\\mydir.old\\"; - String^ extension; - extension = Path::GetExtension( fileName ); - Console::WriteLine( "GetExtension('{0}') returns '{1}'", fileName, extension ); - extension = Path::GetExtension( path ); - Console::WriteLine( "GetExtension('{0}') returns '{1}'", path, extension ); - - // This code produces output similar to the following: - // - // GetExtension('C:\mydir.old\myfile.ext') returns '.ext' - // GetExtension('C:\mydir.old\') returns '' - // - Console::WriteLine(); -} - -void GetFileName() -{ - // - String^ fileName = "C:\\mydir\\myfile.ext"; - String^ path = "C:\\mydir\\"; - String^ result; - result = Path::GetFileName( fileName ); - Console::WriteLine( "GetFileName('{0}') returns '{1}'", fileName, result ); - result = Path::GetFileName( path ); - Console::WriteLine( "GetFileName('{0}') returns '{1}'", path, result ); - - // This code produces output similar to the following: - // - // GetFileName('C:\mydir\myfile.ext') returns 'myfile.ext' - // GetFileName('C:\mydir\') returns '' - // - Console::WriteLine(); -} - -void GetFileNameWithoutExtension() -{ - // - String^ fileName = "C:\\mydir\\myfile.ext"; - String^ path = "C:\\mydir\\"; - String^ result; - result = Path::GetFileNameWithoutExtension( fileName ); - Console::WriteLine( "GetFileNameWithoutExtension('{0}') returns '{1}'", fileName, result ); - result = Path::GetFileName( path ); - Console::WriteLine( "GetFileName('{0}') returns '{1}'", path, result ); - - // This code produces output similar to the following: - // - // GetFileNameWithoutExtension('C:\mydir\myfile.ext') returns 'myfile' - // GetFileName('C:\mydir\') returns '' - // - Console::WriteLine(); -} - -void GetFullPath() -{ - // - String^ fileName = "myfile.ext"; - String^ path = "\\mydir\\"; - String^ fullPath; - fullPath = Path::GetFullPath( path ); - Console::WriteLine( "GetFullPath('{0}') returns '{1}'", path, fullPath ); - fullPath = Path::GetFullPath( fileName ); - Console::WriteLine( "GetFullPath('{0}') returns '{1}'", fileName, fullPath ); - - // Output is based on your current directory, except - // in the last case, where it is based on the root drive - // GetFullPath('mydir') returns 'C:\temp\Demo\mydir' - // GetFullPath('myfile.ext') returns 'C:\temp\Demo\myfile.ext' - // GetFullPath('\mydir') returns 'C:\mydir' - // - Console::WriteLine(); -} - -void GetPathRoot() -{ - // - String^ path = "\\mydir\\"; - String^ fileName = "myfile.ext"; - String^ fullPath = "C:\\mydir\\myfile.ext"; - String^ pathRoot; - pathRoot = Path::GetPathRoot( path ); - Console::WriteLine( "GetPathRoot('{0}') returns '{1}'", path, pathRoot ); - pathRoot = Path::GetPathRoot( fileName ); - Console::WriteLine( "GetPathRoot('{0}') returns '{1}'", fileName, pathRoot ); - pathRoot = Path::GetPathRoot( fullPath ); - Console::WriteLine( "GetPathRoot('{0}') returns '{1}'", fullPath, pathRoot ); - - // This code produces output similar to the following: - // - // GetPathRoot('\mydir\') returns '\' - // GetPathRoot('myfile.ext') returns '' - // GetPathRoot('C:\mydir\myfile.ext') returns 'C:\' - // - Console::WriteLine(); -} - -void GetTempFileName() -{ - // - String^ fileName = Path::GetTempFileName(); - FileInfo^ fileInfo = gcnew FileInfo( fileName ); - Console::WriteLine( "File '{0}' created of size {1} bytes", fileName, (fileInfo->Length).ToString() ); - - // Write some text to the file. - FileStream^ f = gcnew FileStream( fileName,FileMode::Open ); - StreamWriter^ s = gcnew StreamWriter( f ); - s->WriteLine( "Output to the file" ); - s->Close(); - f->Close(); - fileInfo->Refresh(); - Console::WriteLine( "File '{0}' now has size {1} bytes", fileName, (fileInfo->Length).ToString() ); - - // This code produces output similar to the following: - // - // File 'D:\Documents and Settings\cliffc\Local Settings\Temp\8\tmp38.tmp' created of size 0 bytes - // File 'D:\Documents and Settings\cliffc\Local Settings\Temp\8\tmp38.tmp' now has size 20 bytes - // - Console::WriteLine(); -} - -void GetTempPath() -{ - // - String^ tempPath = Path::GetTempPath(); - Console::WriteLine( "Temporary path is '{0}'", tempPath ); - DirectoryInfo^ tempDir = gcnew DirectoryInfo( tempPath ); - Console::WriteLine( "{0} contains {1} files", tempPath, (tempDir->GetFiles()->Length).ToString() ); - - // This code produces output similar to the following: - // - // Temporary path is 'D:\Documents and Settings\cliffc\Local Settings\Temp\8\' - // D:\Documents and Settings\cliffc\Local Settings\Temp\8\ contains 6 files - // - Console::WriteLine(); -} - -void HasExtension() -{ - // - String^ fileName1 = "myfile.ext"; - String^ fileName2 = "mydir\\myfile"; - String^ path = "C:\\mydir.ext\\"; - bool result; - result = Path::HasExtension( fileName1 ); - Console::WriteLine( "HasExtension('{0}') returns {1}", fileName1, result.ToString() ); - result = Path::HasExtension( fileName2 ); - Console::WriteLine( "HasExtension('{0}') returns {1}", fileName2, result.ToString() ); - result = Path::HasExtension( path ); - Console::WriteLine( "HasExtension('{0}') returns {1}", path, result.ToString() ); - - // This code produces output similar to the following: - // - // HasExtension('myfile.ext') returns True - // HasExtension('mydir\myfile') returns False - // HasExtension('C:\mydir.ext\') returns False - // - Console::WriteLine(); -} - -void IsPathRooted() -{ - // - String^ fileName = "C:\\mydir\\myfile.ext"; - String^ UncPath = "\\\\myPc\\mydir\\myfile"; - String^ relativePath = "mydir\\sudir\\"; - bool result; - result = Path::IsPathRooted( fileName ); - Console::WriteLine( "IsPathRooted('{0}') returns {1}", fileName, result.ToString() ); - result = Path::IsPathRooted( UncPath ); - Console::WriteLine( "IsPathRooted('{0}') returns {1}", UncPath, result.ToString() ); - result = Path::IsPathRooted( relativePath ); - Console::WriteLine( "IsPathRooted('{0}') returns {1}", relativePath, result.ToString() ); - - // This code produces output similar to the following: - // - // IsPathRooted('C:\mydir\myfile.ext') returns True - // IsPathRooted('\\myPc\mydir\myfile') returns True - // IsPathRooted('mydir\sudir\') returns False - // - Console::WriteLine(); -} - -void StaticProperties() -{ - // - Console::WriteLine( "Path::AltDirectorySeparatorChar={0}", (Path::AltDirectorySeparatorChar).ToString() ); - Console::WriteLine( "Path::DirectorySeparatorChar={0}", (Path::DirectorySeparatorChar).ToString() ); - Console::WriteLine( "Path::PathSeparator={0}", (Path::PathSeparator).ToString() ); - Console::WriteLine( "Path::VolumeSeparatorChar={0}", (Path::VolumeSeparatorChar).ToString() ); - Console::Write( "Path::InvalidPathChars=" ); - for ( int i = 0; i < Path::InvalidPathChars->Length; i++ ) - Console::Write( Path::InvalidPathChars[ i ] ); - Console::WriteLine(); - - // This code produces output similar to the following: - // Note that the InvalidPathCharacters contain characters - // outside of the printable character set. - // - // Path.AltDirectorySeparatorChar=/ - // Path.DirectorySeparatorChar=\ - // Path.PathSeparator=; - // Path.VolumeSeparatorChar=: - // - Console::WriteLine(); -} - -int main( void ) -{ - Console::WriteLine(); - StaticProperties(); - ChangeExtension(); - Combine(); - GetDirectoryName(); - GetExtension(); - GetFileName(); - GetFileNameWithoutExtension(); - GetFullPath(); - GetPathRoot(); - GetTempFileName(); - GetTempPath(); - HasExtension(); - IsPathRooted(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/cpp/program.cpp deleted file mode 100644 index 2aed9679b07..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/cpp/program.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::IO::Pipes; - -ref class PipeClient -{ -public: - static void Main(array^ args) - { - if (args->Length > 1) - { - PipeStream^ pipeClient = gcnew AnonymousPipeClientStream(PipeDirection::In, args[1]); - - Console::WriteLine("[CLIENT] Current TransmissionMode: {0}.", - pipeClient->TransmissionMode); - - StreamReader^ sr = gcnew StreamReader(pipeClient); - - // Display the read text to the console - String^ temp; - - // Wait for 'sync message' from the server. - do - { - Console::WriteLine("[CLIENT] Wait for sync..."); - temp = sr->ReadLine(); - } - while (!temp->StartsWith("SYNC")); - - // Read the server data and echo to the console. - while ((temp = sr->ReadLine()) != nullptr) - { - Console::WriteLine("[CLIENT] Echo: " + temp); - } - sr->Close(); - pipeClient->Close(); - } - Console::Write("[CLIENT] Press Enter to continue..."); - Console::ReadLine(); - } -}; - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - PipeClient::Main(args); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp deleted file mode 100644 index 26174ff6fe9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::IO::Pipes; -using namespace System::Diagnostics; - -ref class PipeServer -{ -public: - static void Main() - { - Process^ pipeClient = gcnew Process(); - - pipeClient->StartInfo->FileName = "pipeClient.exe"; - - AnonymousPipeServerStream^ pipeServer = - gcnew AnonymousPipeServerStream(PipeDirection::Out, - HandleInheritability::Inheritable); - - Console::WriteLine("[SERVER] Current TransmissionMode: {0}.", - pipeServer->TransmissionMode); - - // Pass the client process a handle to the server. - pipeClient->StartInfo->Arguments = - pipeServer->GetClientHandleAsString(); - pipeClient->StartInfo->UseShellExecute = false; - pipeClient->Start(); - - pipeServer->DisposeLocalCopyOfClientHandle(); - - try - { - // Read user input and send that to the client process. - StreamWriter^ sw = gcnew StreamWriter(pipeServer); - - sw->AutoFlush = true; - // Send a 'sync message' and wait for client to receive it. - sw->WriteLine("SYNC"); - pipeServer->WaitForPipeDrain(); - // Send the console input to the client process. - Console::Write("[SERVER] Enter text: "); - sw->WriteLine(Console::ReadLine()); - sw->Close(); - } - // Catch the IOException that is raised if the pipe is broken - // or disconnected. - catch (IOException^ e) - { - Console::WriteLine("[SERVER] Error: {0}", e->Message); - } - pipeServer->Close(); - pipeClient->WaitForExit(); - pipeClient->Close(); - Console::WriteLine("[SERVER] Client quit. Server terminating."); - } -}; - -int main() -{ - PipeServer::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.NamedPipeServerStream_ImpersonationSample1/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.NamedPipeServerStream_ImpersonationSample1/cpp/program.cpp deleted file mode 100644 index 8908a781218..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.NamedPipeServerStream_ImpersonationSample1/cpp/program.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::IO::Pipes; -using namespace System::Text; -using namespace System::Threading; - -// Defines the data protocol for reading and writing strings on our stream -public ref class StreamString -{ -private: - Stream^ ioStream; - UnicodeEncoding^ streamEncoding; - -public: - StreamString(Stream^ ioStream) - { - this->ioStream = ioStream; - streamEncoding = gcnew UnicodeEncoding(); - } - - String^ ReadString() - { - int len; - - len = ioStream->ReadByte() * 256; - len += ioStream->ReadByte(); - array^ inBuffer = gcnew array(len); - ioStream->Read(inBuffer, 0, len); - - return streamEncoding->GetString(inBuffer); - } - - int WriteString(String^ outString) - { - array^ outBuffer = streamEncoding->GetBytes(outString); - int len = outBuffer->Length; - if (len > UInt16::MaxValue) - { - len = (int)UInt16::MaxValue; - } - ioStream->WriteByte((Byte)(len / 256)); - ioStream->WriteByte((Byte)(len & 255)); - ioStream->Write(outBuffer, 0, len); - ioStream->Flush(); - - return outBuffer->Length + 2; - } -}; - -// Contains the method executed in the context of the impersonated user -public ref class ReadFileToStream -{ -private: - String^ fn; - StreamString ^ss; - -public: - ReadFileToStream(StreamString^ str, String^ filename) - { - fn = filename; - ss = str; - } - - void Start() - { - String^ contents = File::ReadAllText(fn); - ss->WriteString(contents); - } -}; - -public ref class PipeServer -{ -private: - static int numThreads = 4; - -public: - static void Main() - { - int i; - array^ servers = gcnew array(numThreads); - - Console::WriteLine("\n*** Named pipe server stream with impersonation example ***\n"); - Console::WriteLine("Waiting for client connect...\n"); - for (i = 0; i < numThreads; i++) - { - servers[i] = gcnew Thread(gcnew ThreadStart(&ServerThread)); - servers[i]->Start(); - } - Thread::Sleep(250); - while (i > 0) - { - for (int j = 0; j < numThreads; j++) - { - if (servers[j] != nullptr) - { - if (servers[j]->Join(250)) - { - Console::WriteLine("Server thread[{0}] finished.", servers[j]->ManagedThreadId); - servers[j] = nullptr; - i--; // decrement the thread watch count - } - } - } - } - Console::WriteLine("\nServer threads exhausted, exiting."); - } - -private: - static void ServerThread() - { - NamedPipeServerStream^ pipeServer = - gcnew NamedPipeServerStream("testpipe", PipeDirection::InOut, numThreads); - - int threadId = Thread::CurrentThread->ManagedThreadId; - - // Wait for a client to connect - pipeServer->WaitForConnection(); - - Console::WriteLine("Client connected on thread[{0}].", threadId); - try - { - // - // Read the request from the client. Once the client has - // written to the pipe its security token will be available. - - StreamString^ ss = gcnew StreamString(pipeServer); - - // Verify our identity to the connected client using a - // string that the client anticipates. - - ss->WriteString("I am the one true server!"); - String^ filename = ss->ReadString(); - - // Read in the contents of the file while impersonating the client. - ReadFileToStream^ fileReader = gcnew ReadFileToStream(ss, filename); - - // Display the name of the user we are impersonating. - Console::WriteLine("Reading file: {0} on thread[{1}] as user: {2}.", - filename, threadId, pipeServer->GetImpersonationUserName()); - pipeServer->RunAsClient(gcnew PipeStreamImpersonationWorker(fileReader, &ReadFileToStream::Start)); - // - } - // Catch the IOException that is raised if the pipe is broken - // or disconnected. - catch (IOException^ e) - { - Console::WriteLine("ERROR: {0}", e->Message); - } - pipeServer->Close(); - } -}; - -int main() -{ - PipeServer::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/datareceived.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/datareceived.cpp deleted file mode 100644 index 17fffe2f8bb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/datareceived.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO::Ports; - -ref class PortDataReceived -{ -public: - static void Main() - { - // - SerialPort^ mySerialPort = gcnew SerialPort("COM1"); - - mySerialPort->BaudRate = 9600; - mySerialPort->Parity = Parity::None; - mySerialPort->StopBits = StopBits::One; - mySerialPort->DataBits = 8; - mySerialPort->Handshake = Handshake::None; - mySerialPort->RtsEnable = true; - // - - mySerialPort->DataReceived += gcnew SerialDataReceivedEventHandler(DataReceivedHandler); - - mySerialPort->Open(); - - Console::WriteLine("Press any key to continue..."); - Console::WriteLine(); - Console::ReadKey(); - mySerialPort->Close(); - } - -private: - static void DataReceivedHandler( - Object^ sender, - SerialDataReceivedEventArgs^ e) - { - SerialPort^ sp = (SerialPort^)sender; - String^ indata = sp->ReadExisting(); - Console::WriteLine("Data Received:"); - Console::Write(indata); - } -}; - -int main() -{ - PortDataReceived::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp deleted file mode 100644 index 86631d9ff20..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp +++ /dev/null @@ -1,207 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO::Ports; -using namespace System::Threading; - -public ref class PortChat -{ -private: - static bool _continue; - static SerialPort^ _serialPort; - - // -public: - static void Main() - { - String^ name; - String^ message; - StringComparer^ stringComparer = StringComparer::OrdinalIgnoreCase; - Thread^ readThread = gcnew Thread(gcnew ThreadStart(PortChat::Read)); - - // Create a new SerialPort object with default settings. - _serialPort = gcnew SerialPort(); - - // Allow the user to set the appropriate properties. - _serialPort->PortName = SetPortName(_serialPort->PortName); - _serialPort->BaudRate = SetPortBaudRate(_serialPort->BaudRate); - _serialPort->Parity = SetPortParity(_serialPort->Parity); - _serialPort->DataBits = SetPortDataBits(_serialPort->DataBits); - _serialPort->StopBits = SetPortStopBits(_serialPort->StopBits); - _serialPort->Handshake = SetPortHandshake(_serialPort->Handshake); - - // Set the read/write timeouts - _serialPort->ReadTimeout = 500; - _serialPort->WriteTimeout = 500; - - _serialPort->Open(); - _continue = true; - readThread->Start(); - - Console::Write("Name: "); - name = Console::ReadLine(); - - Console::WriteLine("Type QUIT to exit"); - - while (_continue) - { - message = Console::ReadLine(); - - if (stringComparer->Equals("quit", message)) - { - _continue = false; - } - else - { - _serialPort->WriteLine( - String::Format("<{0}>: {1}", name, message) ); - } - } - - readThread->Join(); - _serialPort->Close(); - } - - static void Read() - { - while (_continue) - { - try - { - String^ message = _serialPort->ReadLine(); - Console::WriteLine(message); - } - catch (TimeoutException ^) { } - } - } - // - - // - static String^ SetPortName(String^ defaultPortName) - { - String^ portName; - - Console::WriteLine("Available Ports:"); - for each (String^ s in SerialPort::GetPortNames()) - { - Console::WriteLine(" {0}", s); - } - - Console::Write("Enter COM port value (Default: {0}): ", defaultPortName); - portName = Console::ReadLine(); - - if (portName == "") - { - portName = defaultPortName; - } - return portName; - } - // - - static Int32 SetPortBaudRate(Int32 defaultPortBaudRate) - { - String^ baudRate; - - Console::Write("Baud Rate(default:{0}): ", defaultPortBaudRate); - baudRate = Console::ReadLine(); - - if (baudRate == "") - { - baudRate = defaultPortBaudRate.ToString(); - } - - return Int32::Parse(baudRate); - } - - // - static Parity SetPortParity(Parity defaultPortParity) - { - String^ parity; - - Console::WriteLine("Available Parity options:"); - for each (String^ s in Enum::GetNames(Parity::typeid)) - { - Console::WriteLine(" {0}", s); - } - - Console::Write("Enter Parity value (Default: {0}):", defaultPortParity.ToString()); - parity = Console::ReadLine(); - - if (parity == "") - { - parity = defaultPortParity.ToString(); - } - - return (Parity)Enum::Parse(Parity::typeid, parity); - } - // - - static Int32 SetPortDataBits(Int32 defaultPortDataBits) - { - String^ dataBits; - - Console::Write("Enter DataBits value (Default: {0}): ", defaultPortDataBits); - dataBits = Console::ReadLine(); - - if (dataBits == "") - { - dataBits = defaultPortDataBits.ToString(); - } - - return Int32::Parse(dataBits); - } - - // - static StopBits SetPortStopBits(StopBits defaultPortStopBits) - { - String^ stopBits; - - Console::WriteLine("Available Stop Bits options:"); - for each (String^ s in Enum::GetNames(StopBits::typeid)) - { - Console::WriteLine(" {0}", s); - } - - Console::Write("Enter StopBits value (None is not supported and \n" + - "raises an ArgumentOutOfRangeException. \n (Default: {0}):", defaultPortStopBits.ToString()); - stopBits = Console::ReadLine(); - - if (stopBits == "") - { - stopBits = defaultPortStopBits.ToString(); - } - - return (StopBits)Enum::Parse(StopBits::typeid, stopBits); - } - // - - // - static Handshake SetPortHandshake(Handshake defaultPortHandshake) - { - String^ handshake; - - Console::WriteLine("Available Handshake options:"); - for each (String^ s in Enum::GetNames(Handshake::typeid)) - { - Console::WriteLine(" {0}", s); - } - - Console::Write("Enter Handshake value (Default: {0}):", defaultPortHandshake.ToString()); - handshake = Console::ReadLine(); - - if (handshake == "") - { - handshake = defaultPortHandshake.ToString(); - } - - return (Handshake)Enum::Parse(Handshake::typeid, handshake); - } - // -}; - -int main() -{ - PortChat::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp deleted file mode 100644 index a1f9f662b60..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp +++ /dev/null @@ -1,177 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -ref class StreamReaderSample: public TextReader -{ -public: - - // - StreamReaderSample() - { - printInfo(); - usePeek(); - usePosition(); - useNull(); - useReadLine(); - useReadToEnd(); - } - - -private: - - //All Overloaded Constructors for StreamReader - // - void getNewStreamReader() - { - - //Get a new StreamReader in ASCII format from a - //file using a buffer and byte order mark detection - StreamReader^ srAsciiFromFileFalse512 = gcnew StreamReader( "C:\\Temp\\Test.txt",System::Text::Encoding::ASCII,false,512 ); - - //Get a new StreamReader in ASCII format from a - //file with byte order mark detection = false - StreamReader^ srAsciiFromFileFalse = gcnew StreamReader( "C:\\Temp\\Test.txt",System::Text::Encoding::ASCII,false ); - - //Get a new StreamReader in ASCII format from a file - StreamReader^ srAsciiFromFile = gcnew StreamReader( "C:\\Temp\\Test.txt",System::Text::Encoding::ASCII ); - - //Get a new StreamReader from a - //file with byte order mark detection = false - StreamReader^ srFromFileFalse = gcnew StreamReader( "C:\\Temp\\Test.txt",false ); - - //Get a new StreamReader from a file - StreamReader^ srFromFile = gcnew StreamReader( "C:\\Temp\\Test.txt" ); - - //Get a new StreamReader in ASCII format from a - //FileStream with byte order mark detection = false and a buffer - StreamReader^ srAsciiFromStreamFalse512 = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII,false,512 ); - - //Get a new StreamReader in ASCII format from a - //FileStream with byte order mark detection = false - StreamReader^ srAsciiFromStreamFalse = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII,false ); - - //Get a new StreamReader in ASCII format from a FileStream - StreamReader^ srAsciiFromStream = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII ); - - //Get a new StreamReader from a - //FileStream with byte order mark detection = false - StreamReader^ srFromStreamFalse = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),false ); - - //Get a new StreamReader from a FileStream - StreamReader^ srFromStream = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ) ); - } - - - // - // - void printInfo() - { - - // - // - StreamReader^ srEncoding = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII ); - Console::WriteLine( "Encoding: {0}", srEncoding->CurrentEncoding->EncodingName ); - srEncoding->Close(); - - // - } - - void usePeek() - { - - // - StreamReader^ srPeek = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII ); - - // set the file pointer to the beginning - srPeek->BaseStream->Seek( 0, SeekOrigin::Begin ); - - // cycle while there is a next char - while ( srPeek->Peek() > -1 ) - { - Console::Write( srPeek->ReadLine() ); - } - - srPeek->Close(); - - // - } - - void usePosition() - { - - // - StreamReader^ srRead = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII ); - - // set the file pointer to the beginning - srRead->BaseStream->Seek( 0, SeekOrigin::Begin ); - srRead->BaseStream->Position = 0; - while ( srRead->BaseStream->Position < srRead->BaseStream->Length ) - { - array<__wchar_t>^buffer = gcnew array<__wchar_t>(1); - srRead->Read( buffer, 0, 1 ); - Console::Write( buffer[ 0 ].ToString() ); - srRead->BaseStream->Position = srRead->BaseStream->Position + 1; - } - - srRead->DiscardBufferedData(); - srRead->Close(); - - // - } - - void useNull() - { - - // - StreamReader^ srNull = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII ); - if ( !srNull->Equals( StreamReader::Null ) ) - { - srNull->BaseStream->Seek( 0, SeekOrigin::Begin ); - Console::WriteLine( srNull->ReadToEnd() ); - } - - srNull->Close(); - - // - } - - void useReadLine() - { - - // - StreamReader^ srReadLine = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII ); - srReadLine->BaseStream->Seek( 0, SeekOrigin::Begin ); - while ( srReadLine->Peek() > -1 ) - { - Console::WriteLine( srReadLine->ReadLine() ); - } - - srReadLine->Close(); - - // - } - - void useReadToEnd() - { - - // - StreamReader^ srReadToEnd = gcnew StreamReader( File::OpenRead( "C:\\Temp\\Test.txt" ),System::Text::Encoding::ASCII ); - srReadToEnd->BaseStream->Seek( 0, SeekOrigin::Begin ); - Console::WriteLine( srReadToEnd->ReadToEnd() ); - srReadToEnd->Close(); - - // - // - } - - // - // -}; - - -// -void main( int argc ) -{ - StreamReaderSample^ srs = gcnew StreamReaderSample; -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamWriter/CPP/logger.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamWriter/CPP/logger.cpp deleted file mode 100644 index a901e502b87..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamWriter/CPP/logger.cpp +++ /dev/null @@ -1,201 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Runtime; -using namespace System::Reflection; -using namespace System::Runtime::Remoting::Lifetime; -using namespace System::Security::Permissions; - -namespace StreamWriterSample -{ - public ref class Logger - { -// - public: - //Constructors - Logger() - { - BeginWrite(); - } - - Logger( String^ logFile ) - { - BeginWrite( logFile ); - } - - //Destructor - ~Logger() - { - EndWrite(); - } - - // - void CreateTextFile( String^ fileName, String^ textToAdd ) - { - String^ logFile = String::Concat( DateTime::Now.ToShortDateString() - ->Replace( "/", "-" )->Replace( "\\", "-" ), ".log" ); - - FileStream^ fs = gcnew FileStream( fileName, - FileMode::CreateNew, FileAccess::Write, FileShare::None ); - - StreamWriter^ swFromFile = gcnew StreamWriter( logFile ); - swFromFile->Write( textToAdd ); - swFromFile->Flush(); - swFromFile->Close(); - - StreamWriter^ swFromFileStream = gcnew StreamWriter( fs ); - swFromFileStream->Write( textToAdd ); - swFromFileStream->Flush(); - swFromFileStream->Close(); - - StreamWriter^ swFromFileStreamDefaultEnc = - gcnew System::IO::StreamWriter( fs, - System::Text::Encoding::Default ); - swFromFileStreamDefaultEnc->Write( textToAdd ); - swFromFileStreamDefaultEnc->Flush(); - swFromFileStreamDefaultEnc->Close(); - - StreamWriter^ swFromFileTrue = - gcnew StreamWriter( fileName,true ); - swFromFileTrue->Write( textToAdd ); - swFromFileTrue->Flush(); - swFromFileTrue->Close(); - - StreamWriter^ swFromFileTrueUTF8Buffer = - gcnew StreamWriter( fileName, - true, System::Text::Encoding::UTF8, 512 ); - swFromFileTrueUTF8Buffer->Write( textToAdd ); - swFromFileTrueUTF8Buffer->Flush(); - swFromFileTrueUTF8Buffer->Close(); - - StreamWriter^ swFromFileTrueUTF8 = - gcnew StreamWriter( fileName, true, - System::Text::Encoding::UTF8 ); - swFromFileTrueUTF8->Write( textToAdd ); - swFromFileTrueUTF8->Flush(); - swFromFileTrueUTF8->Close(); - - StreamWriter^ swFromFileStreamUTF8Buffer = - gcnew StreamWriter( fs, System::Text::Encoding::UTF8, 512 ); - swFromFileStreamUTF8Buffer->Write( textToAdd ); - swFromFileStreamUTF8Buffer->Flush(); - swFromFileStreamUTF8Buffer->Close(); - } - // - - // - private: - [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)] - void BeginWrite( String^ logFile ) - { - // - // - StreamWriter^ sw = gcnew StreamWriter( logFile,true ); - - // - // - // Gets or sets a value indicating whether the StreamWriter - // will flush its buffer to the underlying stream after every - // call to StreamWriter.Write. - sw->AutoFlush = true; - // - // - if ( sw->Equals( StreamWriter::Null ) ) - { - sw->WriteLine( "The store can be written to, but not read from." ); - } - // - // - sw->Write( Char::Parse( " " ) ); - // - // - String^ hello = "Hellow World!"; - array^ buffer = hello->ToCharArray(); - sw->Write( buffer ); - // - // - String^ helloWorld = "Hellow World!"; - // writes out "low World" - sw->Write( helloWorld ); - // - // - sw->WriteLine( "---Begin Log Entry---" ); - // - // - // Write out the current text encoding - sw->WriteLine( "Encoding: {0}", - sw->Encoding->ToString() ); - // - // - // Display the Format Provider - sw->WriteLine( "Format Provider: {0} ", - sw->FormatProvider->ToString() ); - // - // - // Set the characters you would like to designate a new line - sw->NewLine = "\r\n"; - // - // - ILease^ obj = dynamic_cast(sw->InitializeLifetimeService()); - if ( obj != nullptr ) - { - sw->WriteLine( "Object initialized lease " + - "time remaining: {0}.", - obj->CurrentLeaseTime.ToString() ); - } - // - // - ILease^ lease = dynamic_cast(sw->GetLifetimeService()); - if ( lease != nullptr ) - { - sw->WriteLine( "Object lease time remaining: {0}.", - lease->CurrentLeaseTime.ToString() ); - } - // - - // - // update underlying file - sw->Flush(); - // - // - // close the file by closing the writer - sw->Close(); - // - // - } - // - - void BeginWrite() - { - BeginWrite( String::Concat( DateTime::Now.ToShortDateString() - ->Replace( "/", "-" )->Replace( "\\", "-" ), ".log" ) ); - } - - void EndWrite( String^ logFile ) - { - StreamWriter^ sw = gcnew StreamWriter( logFile,true ); - - // Set the file pointer to the end of file. - sw->BaseStream->Seek( 0, SeekOrigin::End ); - // Write text to the file. - sw->WriteLine( "---End Log Entry---\r\n" ); - // Update the underlying file. - sw->Flush(); - // Close the file by closing the writer. - sw->Close(); - } - - void EndWrite() - { - EndWrite( String::Concat( DateTime::Now.ToShortDateString() - ->Replace( "/", "-" )->Replace( "\\", "-" ), ".log" ) ); - } - // - }; -} -// - -int main() -{ - StreamWriterSample::Logger^ l = gcnew StreamWriterSample::Logger; -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp deleted file mode 100644 index 0e1c9ac1f5b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp +++ /dev/null @@ -1,76 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - String^ textReaderText = "TextReader is the abstract base " - "class of StreamReader and StringReader, which read " - "characters from streams and strings, respectively.\n\n" - "Create an instance of TextReader to open a text file " - "for reading a specified range of characters, or to " - "create a reader based on an existing stream.\n\n" - "You can also use an instance of TextReader to read " - "text from a custom backing store using the same " - "APIs you would use for a string or a stream.\n\n"; - Console::WriteLine( "Original text:\n\n{0}", textReaderText ); - - // - // From textReaderText, create a continuous paragraph - // with two spaces between each sentence. - String^ aLine; - String^ aParagraph; - StringReader^ strReader = gcnew StringReader( textReaderText ); - while ( true ) - { - aLine = strReader->ReadLine(); - if ( aLine != nullptr ) - { - aParagraph = String::Concat( aParagraph, aLine, " " ); - } - else - { - aParagraph = String::Concat( aParagraph, "\n" ); - break; - } - } - - Console::WriteLine( "Modified text:\n\n{0}", aParagraph ); - - // - // Re-create textReaderText from aParagraph. - int intCharacter; - Char convertedCharacter; - StringWriter^ strWriter = gcnew StringWriter; - strReader = gcnew StringReader( aParagraph ); - while ( true ) - { - intCharacter = strReader->Read(); - - // Check for the end of the string - // before converting to a character. - if ( intCharacter == -1 ) - break; - - - // - convertedCharacter = Convert::ToChar( intCharacter ); - if ( convertedCharacter == '.' ) - { - strWriter->Write( ".\n\n" ); - - // Bypass the spaces between sentences. - strReader->Read(); - strReader->Read(); - } - // - else - { - strWriter->Write( convertedCharacter ); - } - } - - Console::WriteLine( "\nOriginal text:\n\n{0}", strWriter->ToString() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp deleted file mode 100644 index 8c1ec78fa24..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Text; -int main() -{ - StringWriter^ strWriter = gcnew StringWriter; - - // - // Use the three overloads of the Write method that are - // overridden by the StringWriter class. - strWriter->Write( "file path characters are: " ); - strWriter->Write( Path::InvalidPathChars, 0, Path::InvalidPathChars->Length ); - strWriter->Write( Char::Parse( "." ) ); - - // - // - // Use the underlying StringBuilder for more complex - // manipulations of the string. - strWriter->GetStringBuilder()->Insert( 0, "Invalid " ); - - // - // - Console::WriteLine( "The following string is {0} encoded.\n{1}", strWriter->Encoding->EncodingName, strWriter->ToString() ); - - // -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter2/CPP/strwriter2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter2/CPP/strwriter2.cpp deleted file mode 100644 index 3314eaac96a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter2/CPP/strwriter2.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; -using namespace System::IO; -int main() -{ - StringWriter^ strWriter = gcnew StringWriter( gcnew CultureInfo( "ar-DZ" ) ); - strWriter->Write( DateTime::Now ); - - // - Console::WriteLine( "Current date and time using the invariant culture: {0}\n" - "Current date and time using the Algerian culture: {1}", DateTime::Now.ToString(), strWriter->ToString() ); - - // -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter3/CPP/strwriter3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter3/CPP/strwriter3.cpp deleted file mode 100644 index 10ced5c03d7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter3/CPP/strwriter3.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Text; -int main() -{ - StringBuilder^ strBuilder = gcnew StringBuilder( "file path characters are: " ); - StringWriter^ strWriter = gcnew StringWriter( strBuilder ); - strWriter->Write( Path::InvalidPathChars, 0, Path::InvalidPathChars->Length ); - - // - strWriter->Close(); - - // Since the StringWriter is closed, an exception will - // be thrown if the Write method is called. However, - // the StringBuilder can still manipulate the string. - strBuilder->Insert( 0, "Invalid " ); - Console::WriteLine( strWriter->ToString() ); - - // -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.TextReaderWriter/CPP/textrw.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.TextReaderWriter/CPP/textrw.cpp deleted file mode 100644 index e9352f717a0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.TextReaderWriter/CPP/textrw.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::IO; - -// -void WriteText( TextWriter^ textWriter ) -{ - textWriter->Write( "Invalid file path characters are: " ); - textWriter->Write( Path::InvalidPathChars ); - textWriter->Write( Char::Parse( "." ) ); -} - - -// -// -void ReadText( TextReader^ textReader ) -{ - Console::WriteLine( "From {0} - {1}", textReader->GetType()->Name, textReader->ReadToEnd() ); -} - - -// -int main() -{ - - // - TextWriter^ stringWriter = gcnew StringWriter; - TextWriter^ streamWriter = gcnew StreamWriter( "InvalidPathChars.txt" ); - - // - WriteText( stringWriter ); - WriteText( streamWriter ); - streamWriter->Close(); - - // - TextReader^ stringReader = gcnew StringReader( stringWriter->ToString() ); - TextReader^ streamReader = gcnew StreamReader( "InvalidPathChars.txt" ); - - // - ReadText( stringReader ); - ReadText( streamReader ); - streamReader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IO.UTCExample/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IO.UTCExample/CPP/example.cpp deleted file mode 100644 index bcc6eb8fc3a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IO.UTCExample/CPP/example.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -// -// This sample shows the differences between dates from methods that use -//coordinated universal time (UTC) format and those that do not. -using namespace System; -using namespace System::IO; -int main() -{ - - // Set the directory. - String^ n = "C:\\test\\newdir"; - - //Create two variables to use to set the time. - DateTime dtime1 = DateTime(2002,1,3); - DateTime dtime2 = DateTime(1999,1,1); - - //Create the directory. - try - { - Directory::CreateDirectory( n ); - } - catch ( IOException^ e ) - { - Console::WriteLine( e ); - } - - - //Set the creation and last access times to a variable DateTime value. - Directory::SetCreationTime( n, dtime1 ); - Directory::SetLastAccessTimeUtc( n, dtime1 ); - - // Print to console the results. - Console::WriteLine( "Creation Date: {0}", Directory::GetCreationTime( n ) ); - Console::WriteLine( "UTC creation Date: {0}", Directory::GetCreationTimeUtc( n ) ); - Console::WriteLine( "Last write time: {0}", Directory::GetLastWriteTime( n ) ); - Console::WriteLine( "UTC last write time: {0}", Directory::GetLastWriteTimeUtc( n ) ); - Console::WriteLine( "Last access time: {0}", Directory::GetLastAccessTime( n ) ); - Console::WriteLine( "UTC last access time: {0}", Directory::GetLastAccessTimeUtc( n ) ); - - //Set the last write time to a different value. - Directory::SetLastWriteTimeUtc( n, dtime2 ); - Console::WriteLine( "Changed last write time: {0}", Directory::GetLastWriteTimeUtc( n ) ); -} - -// Obviously, since this sample deals with dates and times, the output will vary -// depending on when you run the executable. Here is one example of the output: -//Creation Date: 1/3/2002 12:00:00 AM -//UTC creation Date: 1/3/2002 8:00:00 AM -//Last write time: 12/31/1998 4:00:00 PM -//UTC last write time: 1/1/1999 12:00:00 AM -//Last access time: 1/2/2002 4:00:00 PM -//UTC last access time: 1/3/2002 12:00:00 AM -//Changed last write time: 1/1/1999 12:00:00 AM -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp deleted file mode 100644 index c07a0a5476f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Resources; -using namespace System::Collections; -void main() -{ - - // Create a ResXResourceReader for the file items.resx. - ResXResourceReader^ rsxr = gcnew ResXResourceReader( "items.resx" ); - - - // Iterate through the resources and display the contents to the console. - IEnumerator^ myEnum = rsxr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry^ d = safe_cast(myEnum->Current); - Console::WriteLine( "{0}:\t {1}", d->Key, d->Value ); - } - - - //Close the reader. - rsxr->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp deleted file mode 100644 index d1d5faf2d6d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Resources; -using namespace System::ComponentModel::Design; - -namespace UseDataNodesExample -{ - public ref class Program - { - public: - static void Main() - { - Console::WriteLine("\nEnumerating as data items..."); - EnumResourceItems("Resource1.resx", false); - - Console::WriteLine("\nEnumerating as data nodes..."); - EnumResourceItems("Resource1.resx", true); - } - - static void EnumResourceItems(String^ resxFile, bool useDataNodes) - { - ResXResourceReader^ reader = gcnew ResXResourceReader(resxFile); - - reader->UseResXDataNodes = useDataNodes; - - // - // Enumerate using IEnumerable.GetEnumerator(). - Console::WriteLine("\n Default enumerator:"); - for each (DictionaryEntry entry in reader) - { - ShowResourceItem(entry, useDataNodes); - } - // - - // - // Enumerate using GetMetadataEnumerator() - IDictionaryEnumerator^ metadataEnumerator = reader->GetMetadataEnumerator(); - - Console::WriteLine("\n MetadataEnumerator:"); - while (metadataEnumerator->MoveNext()) - { - ShowResourceItem(metadataEnumerator->Entry, useDataNodes); - } - // - - // - // Enumerate using GetEnumerator() - IDictionaryEnumerator^ enumerator = reader->GetEnumerator(); - - Console::WriteLine("\n Enumerator:"); - while (enumerator->MoveNext()) - { - ShowResourceItem(enumerator->Entry, useDataNodes); - } - // - delete reader; - } - - static void ShowResourceItem(DictionaryEntry entry, bool isDataNode) - { - // Use a nullptr type resolver. - ITypeResolutionService^ typeres = nullptr; - ResXDataNode^ dnode; - - if (isDataNode) - { - // Display from node info. - dnode = (ResXDataNode^)entry.Value; - Console::WriteLine(" {0}={1}", dnode->Name, dnode->GetValue(typeres)); - } - else - { - // Display as DictionaryEntry info. - Console::WriteLine(" {0}={1}", entry.Key, entry.Value); - } - } - }; -} - -int main() -{ - UseDataNodesExample::Program::Main(); -} -// The example program will have the following output: -// -// Enumerating as data items... -// -// Default enumerator: -// DataSample=Sample DATA value -// -// MetadataEnumerator: -// MetadataSample=Sample METADATA value -// -// Enumerator: -// DataSample=Sample DATA value -// -// Enumerating as data nodes... -// -// Default enumerator: -// DataSample=Sample DATA value -// MetadataSample=Sample METADATA value -// -// MetadataEnumerator: -// -// Enumerator: -// DataSample=Sample DATA value -// MetadataSample=Sample METADATA value -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp deleted file mode 100644 index 07b62bf13b4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -using namespace System::Collections; -int main() -{ - - // Create a ResourceReader for the file items.resources. - ResourceReader^ rr = gcnew ResourceReader( "items.resources" ); - - // Create an IDictionaryEnumerator* to iterate through the resources. - IDictionaryEnumerator^ id = rr->GetEnumerator(); - - // Iterate through the resources and display the contents to the console. - while ( id->MoveNext() ) - Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value ); - - rr->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp deleted file mode 100644 index 8f81922ead1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -using namespace System::Collections; -int main() -{ - - // Create a ResourceSet for the file items.resources. - ResourceSet^ rs = gcnew ResourceSet( "items.resources" ); - - // Create an IDictionaryEnumerator* to read the data in the ResourceSet. - IDictionaryEnumerator^ id = rs->GetEnumerator(); - - // Iterate through the ResourceSet and display the contents to the console. - while ( id->MoveNext() ) - Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value ); - - rs->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp deleted file mode 100644 index b782b33e9ef..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -using namespace System::IO; -int main() -{ - - // Create a file stream to encapsulate items.resources. - FileStream^ fs = gcnew FileStream( "items.resources",FileMode::OpenOrCreate,FileAccess::Write ); - - // Open a resource writer to write from the stream. - IResourceWriter^ writer = gcnew ResourceWriter( fs ); - - // Add resources to the resource writer. - writer->AddResource( "String 1", "First String" ); - writer->AddResource( "String 2", "Second String" ); - writer->AddResource( "String 3", "Third String" ); - - // Write the resources to the stream, and close it. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp deleted file mode 100644 index f96fb6c9ed2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -using namespace System::IO; -int main() -{ - // Create a file stream to encapsulate items.resources. - FileStream^ fs = gcnew FileStream( "items.resources",FileMode::OpenOrCreate,FileAccess::Write ); - - // Open a resource writer to write from the stream. - IResourceWriter^ writer = gcnew ResourceWriter( fs ); - - // Add resources to the resource writer. - writer->AddResource( "String 1", "First String" ); - writer->AddResource( "String 2", "Second String" ); - writer->AddResource( "String 3", "Third String" ); - - // Write the resources to the stream, - // and clean up all resources associated with the writer. - // Calling Dispose is equivalent to calling Close. - writer->~IResourceWriter(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp deleted file mode 100644 index ae4c0f1b512..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -using namespace System::IO; -int main() -{ - - // Create a file stream to encapsulate items.resources. - FileStream^ fs = gcnew FileStream( "items.resources",FileMode::OpenOrCreate,FileAccess::Write ); - - // Open a resource writer to write from the stream. - IResourceWriter^ writer = gcnew ResourceWriter( fs ); - - // Add resources to the resource writer. - writer->AddResource( "String 1", "First String" ); - writer->AddResource( "String 2", "Second String" ); - writer->AddResource( "String 3", "Third String" ); - - // Generate the resources, and close the writer. - writer->Generate(); - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp deleted file mode 100644 index 08370f3519c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp +++ /dev/null @@ -1,150 +0,0 @@ - -//#pragma comment(linker, "/CLRUNMANAGEDCODECHECK:NO") -// -// The following HTML code can be used to call the user control in this sample. -// -// -// -// -// -//

-// -// -// To run this test control you must create a strong name key, snkey.snk, and -// a code group that gives full trust to assemblies signed with snkey.snk. -// The user control displays an OpenFileDialog box, then displays a text box containing the name of -// the file selected and a list box that displays the contents of the file. The selected file must -// contain text in order for the control to display the data properly. -// Caution This sample demonstrates the use of the Assert method. Calling Assert removes the -// requirement that all code in the call chain must be granted permission to access the specified -// resource, it can open up security vulnerabilities if used incorrectly or inappropriately. Therefore, -// it should be used with great caution. Assert should always be followed with a RevertAssert -// command to restore the security settings. -#using -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::ComponentModel; -using namespace System::Drawing; -using namespace System::Data; -using namespace System::Windows::Forms; -using namespace System::IO; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Reflection; -using namespace System::Runtime::CompilerServices; - -// This strong name key is used to create a code group that gives permissions to this assembly. -// The AllowPartiallyTrustedCallersAttribute requires the assembly to be signed with a strong name key. -// This attribute is necessary since the control is called by either an intranet or Internet -// Web page that should be running under restricted permissions. -// The userControl1 displays an OpenFileDialog box, then displays a text box containing the name of -// the file selected and a list box that displays the contents of the file. The selected file must -// contain text in order for the control to display the data properly. - -[assembly:AssemblyKeyFile("snKey.snk")]; -[assembly:AssemblyVersion("1.0.0.0")]; -[assembly:AllowPartiallyTrustedCallers]; -public ref class UserControl1: public System::Windows::Forms::UserControl -{ -private: - System::Windows::Forms::TextBox^ textBox1; - System::Windows::Forms::ListBox^ listBox1; - - // Required designer variable. - System::ComponentModel::Container^ components; - -public: -// Demand the zone requirement for the calling application. -[ZoneIdentityPermission(SecurityAction::Demand, Zone = SecurityZone::Intranet)] - UserControl1() - { - - // This call is required by the Windows.Forms Form Designer. - InitializeComponent(); - - // The OpenFileDialog box should not require any special permissions. - OpenFileDialog^ fileDialog = gcnew OpenFileDialog; - if ( fileDialog->ShowDialog() == DialogResult::OK ) - { - - // Reading the name of the selected file from the OpenFileDialog box - // and reading the file requires FileIOPermission. The user control should - // have this permission granted through its code group; the Web page that calls the - // control should not have this permission. The Assert command prevents a stack walk - // that would fail because the caller does not have the required FileIOPermission. - // The use of Assert can open up security vulnerabilities if used incorrectly or - // inappropriately. Therefore, it should be used with great caution. - // The Assert command should be followed by a RevertAssert as soon as the file operation - // is completed. - (gcnew FileIOPermission( PermissionState::Unrestricted ))->Assert(); - textBox1->Text = fileDialog->FileName; - - // Display the contents of the file in the text box. - FileStream^ fsIn = gcnew FileStream( textBox1->Text,FileMode::Open,FileAccess::Read,FileShare::Read ); - StreamReader^ sr = gcnew StreamReader( fsIn ); - - // Process every line in the file - for ( String ^ Line = sr->ReadLine(); Line != nullptr; Line = sr->ReadLine() ) - { - listBox1->Items->Add( Line ); - - } - - // file operations. - FileIOPermission::RevertAssert(); - } - } - -private: - - ///

- /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - void InitializeComponent() - { - this->textBox1 = gcnew System::Windows::Forms::TextBox; - this->listBox1 = gcnew System::Windows::Forms::ListBox; - this->SuspendLayout(); - - // - // textBox1 - // - this->textBox1->Location = System::Drawing::Point( 208, 112 ); - this->textBox1->Name = "textBox1"; - this->textBox1->Size = System::Drawing::Size( 320, 20 ); - this->textBox1->TabIndex = 0; - this->textBox1->Text = "textBox1"; - this->textBox1->TextChanged += gcnew System::EventHandler( this,&UserControl1::textBox1_TextChanged ); - - // - // listBox1 - // - this->listBox1->Location = System::Drawing::Point( 200, 184 ); - this->listBox1->Name = "listBox1"; - this->listBox1->Size = System::Drawing::Size( 336, 108 ); - this->listBox1->TabIndex = 1; - - // - // UserControl1 - // - this->Controls->Add( this->listBox1 ); - this->Controls->Add( this->textBox1 ); - this->Name = "UserControl1"; - this->Size = System::Drawing::Size( 592, 400 ); - this->Load += gcnew System::EventHandler( this,&UserControl1::UserControl1_Load ); - this->ResumeLayout( false ); - } - - void UserControl1_Load( Object^ /*sender*/, System::EventArgs^ /*e*/ ){} - - void textBox1_TextChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ){} - -}; - -//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp deleted file mode 100644 index 5a67133635d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// This class creates a custom crytographic object based on the asymmetric -// algorithm by extending the abstract base class AsymmetricAlgorithm. -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Text; -using namespace System::Security::Cryptography; -using namespace System::Reflection; - -[assembly: AssemblyKeyFile("CustomCrypto.snk")]; -[assembly: AssemblyVersion("1.0.0.0")]; -[assembly: CLSCompliant(true)]; -namespace Contoso -{ - // Define a CustomCrypto class that inherits from the AsymmetricAlgorithm - // class. - public ref class CustomCrypto : - public System::Security::Cryptography::AsymmetricAlgorithm - { - // Declare local member variables. - private: - CspParameters^ cryptoServiceParameters; - array^ customValidKeySizes; - - // Initialize a CustomCrypto with the default key size of 8. - public: - CustomCrypto() - { - customValidKeySizes = - gcnew array{gcnew KeySizes(8, 64, 8)}; - this->KeySize = 8; - } - - // Initialize a CustomCrypto with the specified key size. - public: - CustomCrypto(int keySize) - { - customValidKeySizes = - gcnew array{gcnew KeySizes(8, 64, 8)}; - this->KeySize = keySize; - } - - // Accessor function for keySizes member variable. - public: - property array^ LegalKeySizes - { - virtual array^ get() override - { - return (array^)customValidKeySizes->Clone(); - } - } - - // Modify the KeySizeValue property inherited from the Asymmetric - // class. Prior to setting the value, ensure it falls within the - // range identified in the local keySizes member variable. - // - public: - property int KeySize - { - virtual int get() override - { - return KeySizeValue; - } - - virtual void set(int value) override - { - for (int i = 0; i < customValidKeySizes->Length; i++) - { - if (customValidKeySizes[i]->SkipSize == 0) - { - if (customValidKeySizes[i]->MinSize == value) - { - KeySizeValue = value; - return; - } - } - else - { - for (int j = customValidKeySizes[i]->MinSize; - j <= customValidKeySizes[i]->MaxSize; - j += customValidKeySizes[i]->SkipSize) - { - if (j == value) - { - KeySizeValue = value; - return; - } - } - } - } - - // If the key does not fall within the range identified - // in the keySizes member variable, throw an exception. - throw gcnew CryptographicException("Invalid key size."); - } - } - // - - // Initialize the parameters with default values. - public: - void InitializeParameters() - { - cryptoServiceParameters = gcnew CspParameters(); - cryptoServiceParameters->ProviderName = "Contoso"; - cryptoServiceParameters->KeyContainerName = "SecurityBin1"; - cryptoServiceParameters->KeyNumber = 1; - cryptoServiceParameters->ProviderType = 2; - } - - // Parse specified xmlString for values to populate the CspParams - // - // Expected XML schema: - // - // - // - // - // - // - public: - virtual void FromXmlString(String^ xmlString) override - { - if (xmlString != nullptr) - { - XmlDocument^ document = gcnew XmlDocument(); - document->LoadXml(xmlString); - XmlNode^ firstNode = document->FirstChild; - XmlNodeList^ nodeList; - - // Assemble parameters from values in each XML element. - cryptoServiceParameters = gcnew CspParameters(); - - // KeyContainerName is optional. - nodeList = - document->GetElementsByTagName("KeyContainerName"); - if (nodeList->Count > 0) - { - cryptoServiceParameters->KeyContainerName = - nodeList->Item(0)->InnerText; - } - - // KeyNumber is optional. - nodeList = document->GetElementsByTagName("KeyNumber"); - if (nodeList->Count > 0) - { - cryptoServiceParameters->KeyNumber = - Int32::Parse(nodeList->Item(0)->InnerText); - } - - // ProviderName is optional. - nodeList = document->GetElementsByTagName("ProviderName"); - if (nodeList->Count > 0) - { - cryptoServiceParameters->ProviderName = - nodeList->Item(0)->InnerText; - } - - // ProviderType is optional. - nodeList = document->GetElementsByTagName("ProviderType"); - if (nodeList->Count > 0) - { - cryptoServiceParameters->ProviderType = - Int32::Parse(nodeList->Item(0)->InnerText); - } - } - else - { - throw gcnew ArgumentNullException("xmlString"); - } - } - // - - // Create an XML string representation of the parameters in the - // current customCrypto object. - // - public: - virtual String^ ToXmlString(bool includePrivateParameters) override - { - String^ keyContainerName = ""; - String^ keyNumber = ""; - String^ providerName = ""; - String^ providerType = ""; - - if (cryptoServiceParameters != nullptr) - { - keyContainerName = - cryptoServiceParameters->KeyContainerName; - keyNumber = cryptoServiceParameters->KeyNumber.ToString(); - providerName = cryptoServiceParameters->ProviderName; - providerType = - cryptoServiceParameters->ProviderType.ToString(); - } - - StringBuilder^ sb = gcnew StringBuilder(); - sb->Append(""); - - sb->Append(""); - sb->Append(keyContainerName); - sb->Append(""); - - sb->Append(""); - sb->Append(keyNumber); - sb->Append(""); - - sb->Append(""); - sb->Append(providerName); - sb->Append(""); - - sb->Append(""); - sb->Append(providerType); - sb->Append(""); - - sb->Append(""); - return(sb->ToString()); - } - // - - // Return the name for the key exchange algorithm. - // - public: - property String^ KeyExchangeAlgorithm - { - virtual String^ get() override - { - return "RSA-PKCS1-KeyEx"; - } - } - // - - // Retrieves the name of the signature alogrithm. - // - // This example uses the SHA1 algorithm. - // Due to collision problems with SHA1, Microsoft recommends SHA256 or better. - - public: - property String^ SignatureAlgorithm - { - virtual String^ get() override - { - return "http://www.w3.org/2000/09/xmldsig#rsa-sha1"; - } - } - // - - // Required member for implementing the AsymmetricAlgorithm class. - protected: - virtual ~CustomCrypto() - { - } - - // Call the Create method using the CustomCrypto assembly name. - // - // The create function attempts to create a CustomCrypto - // object using the assembly name. This functionality requires - // modification of the machine.config file. Add the following - // section to the configuration element and modify the values - // of the cryptoClass to reflect what isinstalled - // in your machines GAC. - // - // - // - // - // - // - // - // - // - // - // - - public: - static CustomCrypto^ Create() - { - return Create("CustomCrypto"); - } - // - - // Create a CustomCrypto object by calling CrytoConfig's - // CreateFromName method and casting the type to CustomCrypto. - // - // The create function attempts to create a CustomCrypto object - // using the assembly name. This functionality requires - // modification of the machine.config file. Add the following - // section to the configuration element and modify the values - // of the cryptoClass to reflect what is installed - // in your machines GAC. - // - // - // - // - // - // - // - // - // - // - // - - public: - static CustomCrypto^ Create(String^ algorithmName) - { - return (CustomCrypto^) - CryptoConfig::CreateFromName(algorithmName); - } - // - }; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp deleted file mode 100644 index 0de4308d5f7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp +++ /dev/null @@ -1,129 +0,0 @@ - -// This sample demonstrates how to implement a custom asymmetric algorithm -// inherited from the AsymmetricAlgorithm base class. -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Text; -using namespace System::Security::Cryptography; - -// Display the properties of the specified CustomCrypto object to the -// console. -static void DisplayProperties(Contoso::CustomCrypto^ customCryptoAlgorithm) -{ - // Retrieve the class description for the customCrypto object. - // - String^ classDescription = customCryptoAlgorithm->ToString(); - // - - Console::WriteLine(classDescription); - Console::WriteLine("KeyExchangeAlgorithm: {0}", - customCryptoAlgorithm->KeyExchangeAlgorithm); - Console::WriteLine("SignatureAlgorithm: {0}", - customCryptoAlgorithm->SignatureAlgorithm); - Console::WriteLine("KeySize: {0}", - customCryptoAlgorithm->KeySize); - Console::WriteLine("Parameters described in Xml format:"); - Console::WriteLine(customCryptoAlgorithm->ToXmlString(true)); - - // Display the MinSize, MaxSize, and SkipSize properties of - // each KeySize item in the local keySizes member variable. - // - array^ legalKeySizes = customCryptoAlgorithm->LegalKeySizes; - for (int i = 0; i < legalKeySizes->Length; i++) - { - Console::WriteLine( - "Keysize{0} min, max, step: {1}, {2}, {3}, ", i, - legalKeySizes[i]->MinSize, - legalKeySizes[i]->MaxSize, - legalKeySizes[i]->SkipSize); - } - // -} - -[STAThread] -int main() -{ - // Construct a CustomCrypto object and initialize its - // CspParameters. - Contoso::CustomCrypto^ customCryptoAlgorithm = gcnew Contoso::CustomCrypto(); - customCryptoAlgorithm->InitializeParameters(); - - // Display properties of the current customCrypto object. - Console::WriteLine( - "*** CustomCrypto created with default parameters:"); - DisplayProperties(customCryptoAlgorithm); - - // Release all the resources used by this instance of - // CustomCrypto. - // - customCryptoAlgorithm->Clear(); - // - - customCryptoAlgorithm = gcnew Contoso::CustomCrypto(64); - // Create new parameters and set them by using the FromXmlString - // method. - String^ parameterXml = "" + - "Contoso" + - "SecurityBin2" + - "1" + - "2" + - ""; - customCryptoAlgorithm->FromXmlString(parameterXml); - - // Display the properties of a customCrypto object created with - // custom parameters. - Console::WriteLine( - "{0}*** CustomCrypto created with custom parameters:", Environment::NewLine); - DisplayProperties(customCryptoAlgorithm); - - // Create an object by using the assembly name. - Contoso::CustomCrypto^ cryptoFromAssembly = - Contoso::CustomCrypto::Create("CustomCrypto"); - if (cryptoFromAssembly != nullptr) - { - Console::WriteLine("{0}*** Successfully created " + - "CustomCrypto from the Create method.", Environment::NewLine); - DisplayProperties(cryptoFromAssembly); - } - else - { - Console::WriteLine("Unable to create CustomCrypto from " + - "the Create method."); - } - - Console::WriteLine( - "This sample completed successfully; press Enter to exit."); - Console::ReadLine(); -} - -// -// This sample produces the following output: -// -// *** CustomCrypto created with default parameters: -// Contoso.vbCustomCrypto -// KeyExchangeAlgorithm: RSA-PKCS1-KeyEx -// SignatureAlgorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1 -// KeySize: 8 -// Parameters described in Xml format: -// SecurityBin1 -// 1Contoso -// 2 -// Keysize0 min, max, step: 8, 64, 8, -// -// *** CustomCrypto created with custom parameters: -// Contoso.vbCustomCrypto -// KeyExchangeAlgorithm: RSA-PKCS1-KeyEx -// SignatureAlgorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1 -// KeySize: 64 -// Parameters described in Xml format: -// SecurityBin2 -// 1Contoso -// 2 -// Keysize0 min, max, step: 8, 64, 8, -// Unable to create CustomCrypto from the Create method -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp deleted file mode 100644 index 49ba079bd65..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// This sample demonstrates how to use each member of the CryptoConfig class. -// -using namespace System; -using namespace System::Security::Cryptography; - -int main() -{ - // Create a CryptoConfig object to store configuration information. - // - CryptoConfig^ cryptoConfig = gcnew CryptoConfig; - // - - // Retrieve the class path for CryptoConfig. - // - String^ classDescription = cryptoConfig->ToString(); - // - - // Create a new SHA1 provider. - // - SHA1CryptoServiceProvider^ SHA1alg = - dynamic_cast( - CryptoConfig::CreateFromName( L"SHA1" )); - // - - // Create an RSAParameters with the TestContainer key container. - // - CspParameters^ parameters = gcnew CspParameters; - parameters->KeyContainerName = L"TestContainer"; - array^argsArray = gcnew array(1){ - parameters - }; - - // Instantiate the RSA provider instance accessing the TestContainer - // key container. - RSACryptoServiceProvider^ rsaProvider = - static_cast( - CryptoConfig::CreateFromName( L"RSA", argsArray )); - // - - // Use the MapNameToOID method to get an object identifier - // (OID) from the string name of the SHA1 algorithm. - // - String^ sha1Oid = CryptoConfig::MapNameToOID( L"SHA1" ); - // - - // Encode the specified object identifier. - // - array^encodedMessage = CryptoConfig::EncodeOID( sha1Oid ); - - // - // Display the results to the console. - Console::WriteLine( L"** {0} **", classDescription ); - Console::WriteLine( L"Created an RSA provider with a KeyContainerName called {0}.", - parameters->KeyContainerName ); - Console::WriteLine( L"Object identifier from the SHA1 name:{0}", - sha1Oid ); - Console::WriteLine( L"The object identifier encoded: {0}", - System::Text::Encoding::ASCII->GetString( encodedMessage ) ); - Console::WriteLine( L"This sample completed successfully; press Enter to exit." ); - Console::ReadLine(); -} - -// -// This sample produces the following output: -// -// ** System.Security.Cryptography.CryptoConfig ** -// Created an RSA provider with a KeyContainerName called TestContainer. -// Object identifier from the SHA1 name:1.3.14.3.2.26 -// The object identifier encoded: HH*((*H9 -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp deleted file mode 100644 index fc83f952401..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp +++ /dev/null @@ -1,243 +0,0 @@ -// This sample demonstrates how to use each member of the -// CryptographicException class. -// -using namespace System; -using namespace System::Text; -using namespace System::Security::Cryptography; -using namespace System::Runtime::Serialization; - -ref class CryptographicExceptionMembers -{ -public: - - static void Run() - { - CryptographicExceptionMembers^ testRun = gcnew CryptographicExceptionMembers; - testRun->TestConstructors(); - testRun->ShowProperties(); - Console::WriteLine( L"This sample ended successfully; " - L" press Enter to exit." ); - Console::ReadLine(); - } - -private: - // Test each public implementation of the CryptographicException - // constructors. - void TestConstructors() - { - EmptyConstructor(); - IntConstructor(); - StringConstructor(); - StringExceptionConstructor(); - StringStringConstructor(); - } - - void EmptyConstructor() - { - // Construct a CryptographicException with no parameters. - // - CryptographicException^ cryptographicException = gcnew CryptographicException; - - // - Console::WriteLine( L"Created an empty CryptographicException." ); - } - - void IntConstructor() - { - // Construct a CryptographicException using the error code for an - // unexpected operation exception. - // - int exceptionNumber = (int)0x80131431; - CryptographicException^ cryptographicException = gcnew CryptographicException( exceptionNumber ); - // - - Console::WriteLine( L"Created a CryptographicException with the " - L"following error code: {0}", exceptionNumber ); - } - - void StringConstructor() - { - // Construct a CryptographicException using a custom error message. - // - String^ errorMessage = (L"Unexpected Operation exception."); - CryptographicException^ cryptographicException = gcnew CryptographicException( errorMessage ); - // - - Console::WriteLine( L"Created a CryptographicException with the " - L"following error message: {0}", errorMessage ); - } - - void StringExceptionConstructor() - { - // Construct a CryptographicException using a custom error message - // and an inner exception. - // - String^ errorMessage = (L"The current operation is not supported."); - NullReferenceException^ nullException = gcnew NullReferenceException; - CryptographicException^ cryptographicException = gcnew CryptographicException( errorMessage,nullException ); - // - - Console::WriteLine( L"Created a CryptographicException with the " - L"following error message: {0} and the inner exception of {1}", errorMessage, nullException ); - } - - void StringStringConstructor() - { - // Create a CryptographicException using a time format and a the - // current date. - // - String^ dateFormat = L"{0:t}"; - String^ timeStamp = (DateTime::Now.ToString()); - CryptographicException^ cryptographicException = gcnew CryptographicException( dateFormat,timeStamp ); - // - - Console::WriteLine( L"Created a CryptographicException with ({0}) as the format and ({1}) as the message.", dateFormat, timeStamp ); - } - - // Construct an invalid DSACryptoServiceProvider to throw a - // CryptographicException for introspection. - void ShowProperties() - { - try - { - // Create a DSACryptoServiceProvider with invalid provider type - // code to throw a CryptographicException exception. - CspParameters^ cspParams = gcnew CspParameters( 44 ); - DSACryptoServiceProvider^ DSAalg = gcnew DSACryptoServiceProvider( cspParams ); - } - catch ( CryptographicException^ ex ) - { - // Retrieve the link to the help file for the exception. - // - String^ helpLink = ex->HelpLink; - // - - // Retrieve the exception that caused the current - // CryptographicException exception. - // - System::Exception^ innerException = ex->InnerException; - // - - String^ innerExceptionMessage = L""; - if ( innerException != nullptr ) - { - innerExceptionMessage = innerException->ToString(); - } - - // Retrieve the message that describes the exception. - // - String^ message = ex->Message; - // - - // Retrieve the name of the application that caused the exception. - // - String^ exceptionSource = ex->Source; - // - - // Retrieve the call stack at the time the exception occurred. - // - String^ stackTrace = ex->StackTrace; - // - - // Retrieve the method that threw the exception. - // - System::Reflection::MethodBase^ targetSite = ex->TargetSite; - // - - String^ siteName = targetSite->Name; - - // Retrieve the entire exception as a single string. - // - String^ entireException = ex->ToString(); - // - - // GetObjectData - setSerializationInfo( &ex ); - - // Get the root exception that caused the current - // CryptographicException exception. - // - System::Exception^ baseException = ex->GetBaseException(); - // - - String^ baseExceptionMessage = L""; - if ( baseException != nullptr ) - { - baseExceptionMessage = baseException->Message; - } - Console::WriteLine( L"Caught an expected exception:" ); - Console::WriteLine( entireException ); - Console::WriteLine( L"\n" ); - Console::WriteLine( L"Properties of the exception are as follows:" ); - Console::WriteLine( L"Message: {0}", message ); - Console::WriteLine( L"Source: {0}", exceptionSource ); - Console::WriteLine( L"Stack trace: {0}", stackTrace ); - Console::WriteLine( L"Help link: {0}", helpLink ); - Console::WriteLine( L"Target site's name: {0}", siteName ); - Console::WriteLine( L"Base exception message: {0}", baseExceptionMessage ); - Console::WriteLine( L"Inner exception message: {0}", innerExceptionMessage ); - } - - } - - void setSerializationInfo( interior_ptr ex ) - { - // Insert information about the exception into a serialized object. - // - FormatterConverter^ formatConverter = gcnew FormatterConverter; - SerializationInfo^ serializationInfo = gcnew SerializationInfo( ( *ex)->GetType(),formatConverter ); - StreamingContext streamingContext = StreamingContext(StreamingContextStates::All); - ( *ex)->GetObjectData( serializationInfo, streamingContext ); - // - } - -}; - -void main() -{ - CryptographicExceptionMembers::Run(); -} - -// -// This sample produces the following output: -// -// Created an empty CryptographicException. -// Created a CryptographicException with the following error code: -2146233295 -// Created a CryptographicException with the following error message: -// Unexpected Operation exception. -// Created a CryptographicException with the following error message: The -// current operation is not supported. and the inner exception of -// System.NullReferenceException: Object reference not set to an instance of -// an object. -// Created a CryptographicException with ({0:t}) as the format and (2/24/2004 -// 2:13:15 PM) as the message. -// Caught an expected exception: -// System.Security.Cryptography.CryptographicException: CryptoAPI -// cryptographic service provider (CSP) for this implementation could not be -// acquired. -// at System.Security.Cryptography.DSACryptoServiceProvider..ctor(Int32 -// dwKeySize, CspParameters parameters) -// at System.Security.Cryptography.DSACryptoServiceProvider..ctor( -// CspParametersparameters) -// at CryptographicExceptionMembers.ShowProperties() in c:\inetpub\ -// vssolutions\test\testbuild\consoleapplication1\class1.cs:line 109 -// -// -// Properties of the exception are as follows: -// Message: CryptoAPI cryptographic service provider (CSP) for this -// implementation could not be acquired. -// Source: mscorlib -// Stack trace: -// at System.Security.Cryptography.DSACryptoServiceProvider..ctor( -// Int32 dwKeySize, CspParameters parameters) -// at System.Security.Cryptography.DSACryptoServiceProvider..ctor( -// CspParameters parameters) -// at CryptographicExceptionMembers.ShowProperties() in c:\inetpub\ -// vssolutions\test\testbuild\consoleapplication1\class1.cs:line 109 -// Help link: -// Target site's name: .ctor -// Base exception message: CryptoAPI cryptographic service provider (CSP) for -// this implementation could not be acquired. -// Inner exception message: -// This sample ended successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp deleted file mode 100644 index 463fd5703f5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp +++ /dev/null @@ -1,50 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Security::Cryptography; -int main() -{ - try - { - - //Create a new instance of DSA. - DSA^ DSA = DSA::Create(); - - //The hash to sign. - array^Hash = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100,197,213,134,130,135}; - - //Create an DSASignatureFormatter object and pass it the - //DSA instance to transfer the key information. - DSASignatureFormatter^ DSAFormatter = gcnew DSASignatureFormatter( DSA ); - - //Set the hash algorithm to SHA1. - DSAFormatter->SetHashAlgorithm( "SHA1" ); - - //Create a signature for HashValue and return it. - array^SignedHash = DSAFormatter->CreateSignature( Hash ); - - //Create an DSASignatureDeformatter object and pass it the - //DSA instance to transfer the key information. - DSASignatureDeformatter^ DSADeformatter = gcnew DSASignatureDeformatter( DSA ); - - //Verify the hash and display the results to the console. - if ( DSADeformatter->VerifySignature( Hash, SignedHash ) ) - { - Console::WriteLine( "The signature was verified." ); - } - else - { - Console::WriteLine( "The signature was not verified." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp deleted file mode 100644 index bc448969175..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Security::Cryptography; -int main() -{ - try - { - - //Create a new instance of DSA. - DSA^ DSA = DSA::Create(); - - //The hash to sign. - array^Hash = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100,197,213,134,130,135}; - - //Create an DSASignatureFormatter Object* and pass it the - //DSA instance to transfer the key information. - DSASignatureFormatter^ DSAFormatter = gcnew DSASignatureFormatter( DSA ); - - //Set the hash algorithm to SHA1. - DSAFormatter->SetHashAlgorithm( "SHA1" ); - - //Create a signature for HashValue and return it. - array^SignedHash = DSAFormatter->CreateSignature( Hash ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp deleted file mode 100644 index 2d3ec8ddc55..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -class MyMainClass -{ -public: - static void DecodeFromFile( String^ inFileName, String^ outFileName ) - { - FromBase64Transform^ myTransform = gcnew FromBase64Transform( FromBase64TransformMode::IgnoreWhiteSpaces ); - array^myOutputBytes = gcnew array(myTransform->OutputBlockSize); - - //Open the input and output files. - FileStream^ myInputFile = gcnew FileStream( inFileName,FileMode::Open,FileAccess::Read ); - FileStream^ myOutputFile = gcnew FileStream( outFileName,FileMode::Create,FileAccess::Write ); - - //Retrieve the file contents into a Byte array. - array^myInputBytes = gcnew array(myInputFile->Length); - myInputFile->Read( myInputBytes, 0, myInputBytes->Length ); - - //Transform the data in chunks the size of InputBlockSize. - int i = 0; - while ( myInputBytes->Length - i > 4 ) - { - myTransform->TransformBlock( myInputBytes, i, 4, myOutputBytes, 0 ); - - /*myTransform->InputBlockSize*/ - i += 4; - - /*myTransform->InputBlockSize*/ - myOutputFile->Write( myOutputBytes, 0, myTransform->OutputBlockSize ); - } - - - //Transform the final block of data. - myOutputBytes = myTransform->TransformFinalBlock( myInputBytes, i, myInputBytes->Length - i ); - myOutputFile->Write( myOutputBytes, 0, myOutputBytes->Length ); - - //Free up any used resources. - myTransform->Clear(); - myInputFile->Close(); - myOutputFile->Close(); - } - -}; - -int main() -{ - MyMainClass * m = new MyMainClass; - - //Insert your file names into this method call. - m->DecodeFromFile( "c:\\encoded.txt", "c:\\roundtrip.txt" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp deleted file mode 100644 index 7ac5fae23ff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// This sample demonstrates how to use each member of the KeySizes class. -// - -using namespace System; -using namespace System::Security::Cryptography; - -namespace CryptographySample -{ - ref class KeySizesMembers - { - public: - static void Work() - { - // Initializes a new instance of the KeySizes class - // with the specified key values. - // - int minSize = 64; - int maxSize = 1024; - int skipSize = 64; - KeySizes^ keySizes = - gcnew KeySizes(minSize, maxSize, skipSize); - // - - // Show the values of the keys. - ShowKeys(gcnew array(1) {keySizes}, - "Custom Keys"); - - // Create a new symmetric algorithm and display its - // key values. - Aes^ aes = Aes::Create(); - ShowKeys(aes->LegalKeySizes, aes->ToString()); - Console::WriteLine("aes.blocksize:{0}", - aes->BlockSize); - - // Create a new RSA algorithm and display its key values. - RSA^ rsa = RSA::Create(); - ShowKeys(rsa->LegalKeySizes, rsa->ToString()); - Console::WriteLine("RSA KeySize =" - " {0}", - rsa->KeySize); - - Console::WriteLine("This sample completed successfully; " - "press Enter to exit."); - Console::ReadLine(); - } - - private: - // Display specified KeySize properties to the console. - static void ShowKeys(array ^ keySizes, - String^ objectName) - { - // Retrieve the first KeySizes in the array. - KeySizes^ firstKeySize = keySizes[0]; - - // Retrieve the minimum key size in bits. - // - int minKeySize = firstKeySize->MinSize; - // - - // Retrieve the maximum key size in bits. - // - int maxKeySize = firstKeySize->MaxSize; - // - - // Retrieve the interval between valid key size in bits. - // - int skipKeySize = firstKeySize->SkipSize; - // - - Console::Write("\n KeySizes retrieved from the "); - Console::WriteLine("{0} object.", objectName); - Console::WriteLine("Minimum key size bits: {0}", - minKeySize); - Console::WriteLine("Maximum key size bits: {0}", - maxKeySize); - Console::WriteLine("Interval between key size bits: {0}", - skipKeySize); - } - }; -} - -using namespace CryptographySample; - -int main() -{ - KeySizesMembers::Work(); -} -// -// This sample produces the following output: -// -// KeySizes retrieved from the Custom Keys object. -// Minimum key size bits: 64 -// Maximum key size bits: 1024 -// Interval between key size bits: 64 -// -// KeySizes retrieved from the -// System.Security.Cryptography.Aes object. -// Minimum key size bits: 128 -// Maximum key size bits: 256 -// Interval between key size bits: 64 -// aes.blocksize:128 -// -// KeySizes retrieved from the -// System.Security.Cryptography.RSA object. -// Minimum key size bits: 512 -// Maximum key size bits: 16384 -// Interval between key size bits: 64 -// RSA KeySize = 2048 -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp deleted file mode 100644 index d25c4d73ac5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// This sample demonstrates how to extend the KeyedHashAlgorithm class. -// -using namespace System; -using namespace System::Security::Cryptography; - -namespace Contoso -{ - public ref class ContosoKeyedHash: public KeyedHashAlgorithm - { - private: - KeyedHashAlgorithm^ keyedCrypto; - - public: - ContosoKeyedHash( array^ rgbKey ) - { - Init( L"System.Security.Cryptography.KeyedHashAlgorithm", rgbKey ); - } - - ContosoKeyedHash( String^ keyedHashName, array^ rgbKey ) - { - Init( keyedHashName, rgbKey ); - } - - void Init( String^ keyedHashName, array^ rgbKey ) - { - // Make sure we know which algorithm to use - if ( rgbKey != nullptr ) - { - KeyValue = rgbKey; - HashSizeValue = 160; - - // Create a KeyedHashAlgorithm encryptor - if ( keyedHashName == nullptr ) - { - - // - keyedCrypto = KeyedHashAlgorithm::Create(); - // - } - else - { - // - keyedCrypto = KeyedHashAlgorithm::Create( keyedHashName ); - // - } - } - else - { - throw gcnew ArgumentNullException( L"rgbKey" ); - } - } - - // Override abstract methods from the HashAlgorithm class. - virtual void Initialize() override {} - - property array^ Key - { - // - virtual array^ get() override - { - return dynamic_cast^>(keyedCrypto->Key->Clone()); - } - - virtual void set( array^value ) override - { - keyedCrypto->Key = dynamic_cast^>(value->Clone()); - } - } - // - - protected: - virtual void HashCore( array^ , int /*ibStart*/, int /*cbSize*/ ) override {} - - virtual array^ HashFinal() override - { - return gcnew array(0); - } - }; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp deleted file mode 100644 index 3c77ea0c947..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// This sample demonstrates how to derive from -// the MaskGenerationMethod class. -// -#using - -using namespace System; -using namespace System::Security::Cryptography; - -namespace Contoso -{ - // - ref class MaskGenerator: MaskGenerationMethod - { - private: - String^ hashNameValue; - - public: - // Initialize a mask to encrypt using the SHA256 algorithm. - MaskGenerator() - { - hashNameValue = "SHA256"; - } - - // - // Create a mask with the specified seed. - // - virtual array^ GenerateMask(array^ seed, int maskLength) override - { - HashAlgorithm^ hash; - array^ rgbCounter = gcnew array(4); - array^ targetRgb = gcnew array(maskLength); - UInt32 counter = 0; - for (int inc = 0; inc < targetRgb->Length; ) - { - ConvertIntToByteArray(counter++, rgbCounter); - hash = (HashAlgorithm^)CryptoConfig::CreateFromName( - hashNameValue); - array^ temp = gcnew array( - 4 + seed->Length); - Buffer::BlockCopy(rgbCounter, 0, temp, 0, 4); - Buffer::BlockCopy(seed, 0, temp, 4, seed->Length); - hash->ComputeHash(temp); - if (targetRgb->Length - inc > hash->HashSize / 8) - { - Buffer::BlockCopy(hash->Hash, 0, targetRgb, inc, - hash->Hash->Length); - } - else - { - Buffer::BlockCopy(hash->Hash, 0, targetRgb, inc, - targetRgb->Length - inc); - } - - inc += hash->Hash->Length; - } - return targetRgb; - } - - private: - // - // Convert the specified integer to the byte array. - void ConvertIntToByteArray(UInt32 source, - array^ targetBytes) - { - UInt32 remainder; - int inc = 0; - - // Clear the array prior to filling it. - Array::Clear(targetBytes, 0, targetBytes->Length); - while (source > 0) - { - remainder = source % 256; - targetBytes[ 3 - inc ] = (Byte)remainder; - source = (source - remainder) / 256; - inc++; - } - } - }; - - // This class demonstrates how to create the MaskGenerator class - // and call its GenerateMask member. - ref class MaskGeneratorImpl - { - public: - void static Work() - { - array^ seed = gcnew array(4){ - 0x01,0x02,0x03,0x04}; - int length = 16; - MaskGenerator^ maskGenerator = gcnew MaskGenerator; - array^ mask = maskGenerator->GenerateMask(seed, - length); - Console::WriteLine("Generated the following mask:"); - Console::WriteLine(System::Text::Encoding:: - ASCII::get()->GetString(mask)); - Console::WriteLine("This sample completed successfully;" - " press Enter to exit."); - Console::ReadLine(); - } - }; -} - -void main() -{ - Contoso::MaskGeneratorImpl::Work(); -} - -// -// This sample produces the following output: -// -// Generated the following mask: -// ?"TFd(?~OtO? -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp deleted file mode 100644 index 18a61d351be..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Security::Cryptography; -int main() -{ - try - { - - //initialze the Byte arrays to the public key information. - array^PublicKey = {214,46,220,83,160,73,40,39,201,155,19,202,3,11,191,178,56,74,90,36,248,103,18,144,170,163,145,87,54,61,34,220,222,207,137,149,173,14,92,120,206,222,158,28,40,24,30,16,175,108,128,35,230,118,40,121,113,125,216,130,11,24,90,48,194,240,105,44,76,34,57,249,228,125,80,38,9,136,29,117,207,139,168,181,85,137,126,10,126,242,120,247,121,8,100,12,201,171,38,226,193,180,190,117,177,87,143,242,213,11,44,180,113,93,106,99,179,68,175,211,164,116,64,148,226,254,172,147}; - array^Exponent = {1,0,1}; - - //Values to store encrypted symmetric keys. - array^EncryptedSymmetricKey; - array^EncryptedSymmetricIV; - - //Create a new instance of RSACryptoServiceProvider. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Create a new instance of RSAParameters. - RSAParameters RSAKeyInfo; - - //Set RSAKeyInfo to the public key values. - RSAKeyInfo.Modulus = PublicKey; - RSAKeyInfo.Exponent = Exponent; - - //Import key parameters into RSA. - RSA->ImportParameters( RSAKeyInfo ); - - //Create a new instance of the Aes class. - Aes^ aes = Aes::Create(); - - //Encrypt the symmetric key and IV. - EncryptedSymmetricKey = RSA->Encrypt( aes->Key, false ); - EncryptedSymmetricIV = RSA->Encrypt( aes->IV, false ); - Console::WriteLine( "Aes Key and IV have been encrypted with RSACryptoServiceProvider." ); - } - catch ( CryptographicException^ e ) - { - - //Catch and display a CryptographicException - //to the console. - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp deleted file mode 100644 index 92218fec226..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::Security::Cryptography; -void main() -{ - // - try - { - //Create a new RSACryptoServiceProvider Object*. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Export the key information to an RSAParameters object. - //Pass false to export the public key information or pass - //true to export public and private key information. - RSAParameters RSAParams = RSA->ExportParameters( false ); - } - catch ( CryptographicException^ e ) - { - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( e->Message ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp deleted file mode 100644 index a5bf383b029..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#using - -using namespace System; -using namespace System::Security::Cryptography; - -int main() -{ - // - try - { - //Create a new RSACryptoServiceProvider object. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Export the key information to an RSAParameters object. - //Pass false to export the public key information or pass - //true to export public and private key information. - RSAParameters RSAParams = RSA->ExportParameters( false ); - - //Create another RSACryptoServiceProvider object. - RSACryptoServiceProvider^ RSA2 = gcnew RSACryptoServiceProvider; - - //Import the key information from the other - //RSACryptoServiceProvider object. - RSA2->ImportParameters( RSAParams ); - } - catch ( CryptographicException^ e ) - { - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( e->Message ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp deleted file mode 100644 index 9f6ac45281c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -array^ RSAEncrypt( array^DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding ) -{ - try - { - - //Create a new instance of RSACryptoServiceProvider. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Import the RSA Key information. This only needs - //toinclude the public key information. - RSA->ImportParameters( RSAKeyInfo ); - - //Encrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - - array^encryptedData = RSA->Encrypt( DataToEncrypt, DoOAEPPadding ); - delete RSA; - return encryptedData; - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -array^ RSADecrypt( array^DataToDecrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding ) -{ - try - { - - //Create a new instance of RSACryptoServiceProvider. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Import the RSA Key information. This needs - //to include the private key information. - RSA->ImportParameters( RSAKeyInfo ); - - //Decrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - - array^decryptedData = RSA->Decrypt( DataToDecrypt, DoOAEPPadding ); - delete RSA; - return decryptedData; - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e ); - return nullptr; - } - -} - -int main() -{ - try - { - - //Create a UnicodeEncoder to convert between byte array and string. - UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding; - - //Create byte arrays to hold original, encrypted, and decrypted data. - array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" ); - array^encryptedData; - array^decryptedData; - - //Create a new instance of RSACryptoServiceProvider to generate - //public and private key data. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Pass the data to ENCRYPT, the public key information - //(using RSACryptoServiceProvider.ExportParameters(false), - //and a boolean flag specifying no OAEP padding. - encryptedData = RSAEncrypt( dataToEncrypt, RSA->ExportParameters( false ), false ); - - //Pass the data to DECRYPT, the private key information - //(using RSACryptoServiceProvider.ExportParameters(true), - //and a boolean flag specifying no OAEP padding. - decryptedData = RSADecrypt( encryptedData, RSA->ExportParameters( true ), false ); - - //Display the decrypted plaintext to the console. - Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) ); - delete RSA; - } - catch ( ArgumentNullException^ ) - { - - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( "Encryption failed." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp deleted file mode 100644 index cb8ce0d69c9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// This sample demonstrates how to encode and decode a string using -// the RSAOAEPKeyExchangeFormatter and RSAOAEPKeyExchangeDeformatter classes. -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; - -ref class RSAEncoder -{ -private: - // Use a member variable to hold the RSA key for encoding and decoding. - RSA^ rsaKey; - -public: - [STAThread] - static void Main() - { - String^ message = L"A phrase to be encoded."; - RSAEncoder^ rsaEncoder = gcnew RSAEncoder; - rsaEncoder->InitializeKey( RSA::Create() ); - Console::WriteLine( L"Encoding the following message:" ); - Console::WriteLine( message ); - array^encodedMessage = rsaEncoder->EncodeMessage( message ); - Console::WriteLine( L"Resulting message encoded:" ); - Console::WriteLine( Encoding::ASCII->GetString( encodedMessage ) ); - String^ decodedMessage = rsaEncoder->DecodeMessage( encodedMessage ); - Console::WriteLine( L"Resulting message decoded:" ); - Console::WriteLine( decodedMessage ); - - // Construct a formatter to demonstrate how to set each property. - rsaEncoder->ConstructFormatter(); - - // Construct a deformatter to demonstrate how to set each property. - rsaEncoder->ConstructDeformatter(); - Console::WriteLine( L"This sample completed successfully, " - L" press enter to continue." ); - Console::ReadLine(); - } - - -private: - // Initialize an rsaKey member variable with the specified RSA key. - void InitializeKey( RSA^ key ) - { - rsaKey = key; - } - - // Use the RSAOAEPKeyExchangeDeformatter class to decode the - // specified message. - array^ EncodeMessage( String^ message ) - { - array^encodedMessage = nullptr; - try - { - - // Construct a formatter with the specified RSA key. - // - RSAOAEPKeyExchangeFormatter^ keyEncryptor = - gcnew RSAOAEPKeyExchangeFormatter( rsaKey ); - // - - // Convert the message to bytes to create the encrypted data. - // - array^byteMessage = Encoding::ASCII->GetBytes( message ); - encodedMessage = keyEncryptor->CreateKeyExchange( byteMessage ); - // - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"Unexpected exception caught:{0}", ex ); - } - - return encodedMessage; - } - - // Use the RSAOAEPKeyExchangeDeformatter class to decode the - // specified message. - String^ DecodeMessage( array^encodedMessage ) - { - String^ decodedMessage = nullptr; - try - { - // Construct a deformatter with the specified RSA key. - // - RSAOAEPKeyExchangeDeformatter^ keyDecryptor = - gcnew RSAOAEPKeyExchangeDeformatter( rsaKey ); - // - - // Decrypt the encoded message. - // - array^decodedBytes = keyDecryptor->DecryptKeyExchange( encodedMessage ); - // - - // Retrieve a string representation of the decoded message. - decodedMessage = Encoding::ASCII->GetString( decodedBytes ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"Unexpected exception caught:{0}", ex ); - } - - return decodedMessage; - } - - - // Create an RSAOAEPKeyExchangeFormatter object with a new RSA key. - // Display its properties to the console. - void ConstructFormatter() - { - // Construct an empty Optimal Asymmetric Encryption Padding (OAEP) - // key exchange. - // - RSAOAEPKeyExchangeFormatter^ rsaFormatter = gcnew RSAOAEPKeyExchangeFormatter; - // - - // Create an RSA and set it into the specified - // RSAOAEPKeyExchangeFormatter. - // - RSA^ key = RSA::Create(); - rsaFormatter->SetKey( key ); - // - - // Create a random number using the RNGCryptoServiceProvider provider. - // - RandomNumberGenerator^ ring = RandomNumberGenerator::Create(); - rsaFormatter->Rng = ring; - // - - // Export InverseQ and set it into the RSAOAEPKeyExchangeFormatter. - // - rsaFormatter->Parameter = key->ExportParameters( true ).InverseQ; - // - - Console::WriteLine(); - Console::WriteLine( L"**{0}**", rsaFormatter ); - Console::Write( L"The following random number was generated using the " ); - Console::WriteLine( L"class:" ); - Console::WriteLine( rsaFormatter->Rng ); - Console::WriteLine(); - Console::Write( L"The RSA formatter contains the following InverseQ" ); - Console::WriteLine( L" parameter:" ); - Console::WriteLine( Encoding::ASCII->GetString( rsaFormatter->Parameter ) ); - Console::WriteLine(); - - // - String^ xmlParameters = rsaFormatter->Parameters; - // - - Console::WriteLine( L"The RSA formatter has the following parameters:" ); - Console::WriteLine( xmlParameters ); - } - - // Create an RSAOAEPKeyExchangeDeformatter object with a new RSA key. - // Display its properties to the console. - void ConstructDeformatter() - { - // Construct an empty OAEP key exchange. - // - RSAOAEPKeyExchangeDeformatter^ rsaDeformatter = - gcnew RSAOAEPKeyExchangeDeformatter; - // - - // Create an RSAKey and set it into the specified - // RSAOAEPKeyExchangeFormatter. - // - RSA^ key = RSA::Create(); - rsaDeformatter->SetKey( key ); - // - - Console::WriteLine(); - Console::WriteLine( L"**{0}**", rsaDeformatter ); - - // - String^ xmlParameters = rsaDeformatter->Parameters; - // - - Console::WriteLine(); - Console::WriteLine( L"The RSA deformatter has the following " ); - Console::WriteLine( L"parameters:{0}", xmlParameters ); - } -}; - -int main() -{ - RSAEncoder::Main(); -} - -// -// This sample produces the following output: -// -// Encoding the following message: -// A phrase to be encoded. -// Resulting message encoded: %?}T:v??xu?eD)YucItjwu¦ALH HB,Uj??2xq?.?s45 -// ?f?L2?=X?CPzWx???"q5?6&N"AE,Z+T?(]S?_7~,?G{?VV!:S?df? -// Resulting message decoded: -// A phrase to be encoded. -// -// **System.Security.Cryptography.RSAOAEPKeyExchangeFormatter** -// The following random number was generated using the class: -// System.Security.Cryptography.RNGCryptoServiceProvider -// -// The RSA formatter contains the following InverseQ parameter: -// 3MM??]D#?mBq_;:ws^1?ko??,_ ??A[hyWcP$?`v.>@?^!dU%\?H0N'??Ca?Ns -// -// The RSA formatter has the following parameters: -// -// -// **System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter** -// -// The RSA deformatter has the following -// parameters: -// This sample completed successfully, press enter to continue. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp deleted file mode 100644 index 1cf5a6c9d9b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// This sample demonstrates how to use each member of the ToBase64Transform -// class. The file named members.cs is read in and written out as a -// transformed file named members.enc. -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - -ref class Members -{ -public: - [STAThread] - static void Main() - { - String^ appPath = (String::Concat( - System::IO::Directory::GetCurrentDirectory(), L"\\" )); - - // Insert your file names into this method call. - EncodeFromFile( String::Concat( appPath, L"members.cpp" ), - String::Concat( appPath, L"members.enc" ) ); - Console::WriteLine( L"This sample completed successfully; " - L"press Enter to exit." ); - Console::ReadLine(); - } - -private: - // Read in the specified source file and write out an encoded target file. - static void EncodeFromFile( String^ sourceFile, String^ targetFile ) - { - // Verify members.cpp exists at the specified directory. - if ( !File::Exists( sourceFile ) ) - { - Console::Write( L"Unable to locate source file located at " ); - Console::WriteLine( L"{0}.", sourceFile ); - Console::Write( L"Please correct the path and run the " ); - Console::WriteLine( L"sample again." ); - return; - } - - // Retrieve the input and output file streams. - FileStream^ inputFileStream = gcnew FileStream( - sourceFile,FileMode::Open,FileAccess::Read ); - FileStream^ outputFileStream = gcnew FileStream( - targetFile,FileMode::Create,FileAccess::Write ); - - // Create a new ToBase64Transform object to convert to base 64. - // - ToBase64Transform^ base64Transform = gcnew ToBase64Transform; - // - - // Create a new byte array with the size of the output block size. - // - array^outputBytes = gcnew array( - base64Transform->OutputBlockSize); - // - - // Retrieve the file contents into a byte array. - array^inputBytes = gcnew array(inputFileStream->Length); - inputFileStream->Read( inputBytes, 0, inputBytes->Length ); - - // Verify that multiple blocks can not be transformed. - // - if ( !base64Transform->CanTransformMultipleBlocks ) - // - { - // Initializie the offset size. - int inputOffset = 0; - - // Iterate through inputBytes transforming by blockSize. - // - // - int inputBlockSize = base64Transform->InputBlockSize; - // - while ( inputBytes->Length - inputOffset > inputBlockSize ) - { - base64Transform->TransformBlock( - inputBytes, - inputOffset, - inputBytes->Length - inputOffset, - outputBytes, - 0 ); - - inputOffset += base64Transform->InputBlockSize; - outputFileStream->Write( - outputBytes, - 0, - base64Transform->OutputBlockSize ); - } - // - - // Transform the final block of data. - // - outputBytes = base64Transform->TransformFinalBlock( - inputBytes, - inputOffset, - inputBytes->Length - inputOffset ); - // - outputFileStream->Write( outputBytes, 0, outputBytes->Length ); - Console::WriteLine( L"Created encoded file at {0}", targetFile ); - } - - // Determine if the current transform can be reused. - // - if ( !base64Transform->CanReuseTransform ) - // - { - // Free up any used resources. - // - base64Transform->Clear(); - // - } - - // Close file streams. - inputFileStream->Close(); - outputFileStream->Close(); - } -}; - -int main() -{ - Members::Main(); -} - -// -// This sample produces the following output: -// -// Created encoded file at C:\ConsoleApplication1\\membersvcs.enc -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp deleted file mode 100644 index 080c61111a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp +++ /dev/null @@ -1,132 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ Key ) -{ - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Assign the key to the SignedXml object. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyDetachedSignature( String^ XmlSigFileName ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passed XML file into the document. - xmlDocument->Load( XmlSigFileName ); - - // Create a new SignedXMl object. - SignedXml^ signedXml = gcnew SignedXml; - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// - -[STAThread] -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmldsig.xml"; - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resourceand save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, Key ); - Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - - //Verify the XML signature in the XML file. - bool result = VerifyDetachedSignature( XmlFileName ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp deleted file mode 100644 index 780d8fbafbf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp +++ /dev/null @@ -1,171 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", Key ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp deleted file mode 100644 index d4942102cf3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp +++ /dev/null @@ -1,132 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, DSA^ DSAKey ) -{ - - // Create a SignedXml Object*. - SignedXml^ signedXml = gcnew SignedXml; - - // Assign the DSA key to the SignedXml object. - signedXml->SigningKey = DSAKey; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add a DSAKeyValue to the KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew DSAKeyValue( safe_cast(DSAKey) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyDetachedSignature( String^ XmlSigFileName ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passed XML file into the document. - xmlDocument->Load( XmlSigFileName ); - - // Create a new SignedXMl object. - SignedXml^ signedXml = gcnew SignedXml; - - // Find the S"Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// - -[STAThread] -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmldsig.xml"; - try - { - - // Generate a DSA signing key. - DSA^ DSAKey = DSA::Create(); - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resourceand save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, DSAKey ); - Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - - //Verify the XML signature in the XML file. - bool result = VerifyDetachedSignature( XmlFileName ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp deleted file mode 100644 index 20276a9a84d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp +++ /dev/null @@ -1,174 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, DSA^ DSAKey ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the DSA key to the SignedXml document. - signedXml->SigningKey = DSAKey; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add a transformation to the reference. - Transform^ trns = gcnew XmlDsigC14NTransform; - reference->AddTransform( trns ); - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add a DSAKeyValue to the KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew DSAKeyValue( safe_cast(DSAKey) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a DSA signing key. - DSA^ DSAKey = DSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", DSAKey ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp deleted file mode 100644 index aca4a856e3f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp +++ /dev/null @@ -1,100 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ Key, String^ Certificate ) -{ - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Assign the key to the SignedXml object. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Create a new KeyInfo object. - KeyInfo^ keyInfo = gcnew KeyInfo; - - // Load the X509 certificate. - X509Certificate^ MSCert = X509Certificate::CreateFromCertFile( Certificate ); - - // Load the certificate into a KeyInfoX509Data object - // and add it to the KeyInfo object. - keyInfo->AddClause( gcnew KeyInfoX509Data( MSCert ) ); - - // Add the KeyInfo object to the SignedXml object. - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); -} - - -// - -[STAThread] -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmldsig.xml"; - - // The name of the X509 certificate - String^ Certificate = "microsoft.cer"; - try - { - - // Generate a signing key. This key should match the certificate. - RSA^ Key = RSA::Create(); - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resource and save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, Key, Certificate ); - Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp deleted file mode 100644 index 31aee98e1a6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp +++ /dev/null @@ -1,135 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, String^ Certificate ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Create a new KeyInfo object. - KeyInfo^ keyInfo = gcnew KeyInfo; - - // Load the X509 certificate. - X509Certificate^ MSCert = X509Certificate::CreateFromCertFile( Certificate ); - - // Load the certificate into a KeyInfoX509Data object - // and add it to the KeyInfo object. - keyInfo->AddClause( gcnew KeyInfoX509Data( MSCert ) ); - - // Add the KeyInfo object to the SignedXml object. - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - String^ Certificate = "microsoft.cer"; - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", Key, Certificate ); - Console::WriteLine( "XML file signed." ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp deleted file mode 100644 index 43ae77e2392..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp +++ /dev/null @@ -1,170 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ RSAKey ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the RSA key to the SignedXml document. - signedXml->SigningKey = RSAKey; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add a RSAKeyValue to the KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(RSAKey) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a RSA signing key. - RSA^ RSAKey = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", RSAKey ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml" ); - - // Display the results of the signature verification to \ - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp deleted file mode 100644 index 8d9b7b1fc42..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp +++ /dev/null @@ -1,172 +0,0 @@ - - -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ RSAKey ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the RSA key to the SignedXml document. - signedXml->SigningKey = RSAKey; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add a transformation to the reference. - Transform^ trns = gcnew XmlDsigC14NTransform; - reference->AddTransform( trns ); - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue to the KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(RSAKey) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate an RSA signing key. - RSA^ RSAKey = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", RSAKey ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp deleted file mode 100644 index fa1867d2679..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp +++ /dev/null @@ -1,124 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. This method does not -// save the public key within the XML file. This file cannot be verified unless -// the verifying code has the key with which it was signed. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ Key ) -{ - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Assign the key to the SignedXml object. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file against an asymmetric -// algorithm and return the result. -static Boolean VerifyDetachedSignature( String^ XmlSigFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passedXML file into the document. - xmlDocument->Load( XmlSigFileName ); - - // Create a new SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList[ 0 ]) ); - - // Check the signature against the passed asymmetric key - // and return the result. - return signedXml->CheckSignature( Key ); -} - -int main() -{ - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmldsig.xml"; - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resourceand save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, Key ); - Console::WriteLine( "XML Signature was successfully computed and saved to {0}.", XmlFileName ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - - //Verify the XML signature in the XML file against the key. - bool result = VerifyDetachedSignature( XmlFileName, Key ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp deleted file mode 100644 index 270360c4f71..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp +++ /dev/null @@ -1,159 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. This method does not -// save the public key within the XML file. This file cannot be verified unless -// the verifying code has the key with which it was signed. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file against an asymmetric -// algorithm and return the result. -Boolean VerifyXmlFile( String^ Name, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature( Key ); -} - - -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument Object*. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "signedExample.xml", Key ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml", Key ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp deleted file mode 100644 index 979040a9f1c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp +++ /dev/null @@ -1,117 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, KeyedHashAlgorithm^ Key ) -{ - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Compute the signature. - signedXml->ComputeSignature( Key ); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -Boolean VerifyDetachedSignature( String^ XmlSigFileName, KeyedHashAlgorithm^ Key ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passedXML file into the document. - xmlDocument->Load( XmlSigFileName ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml; - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature( Key ); -} - -int main() -{ - try - { - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmlsig.xml"; - - // Generate a signing key. - HMACSHA256^ Key = gcnew HMACSHA256; - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resourceand save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, Key ); - Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - - //Verify the XML signature in the XML file. - bool result = VerifyDetachedSignature( XmlFileName, Key ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp deleted file mode 100644 index 5ea1b276c55..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp +++ /dev/null @@ -1,160 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, KeyedHashAlgorithm^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXML object. - signedXml->AddReference( reference ); - - // Compute the signature. - signedXml->ComputeSignature( Key ); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name, KeyedHashAlgorithm^ Key ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXMl object and pass it - // the XMl document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature( Key ); -} - - -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the filename specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a signing key. - HMACSHA256^ Key = gcnew HMACSHA256; - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", Key ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying Signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml", Key ); - - // Display the results of the signature verification to \ - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp deleted file mode 100644 index 24b3bee5ff8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp +++ /dev/null @@ -1,134 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ RSAKey ) -{ - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Assign the key to the SignedXml object. - signedXml->SigningKey = RSAKey; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add a transformation if the URI is an XML file. - if ( URIString->EndsWith( "xml" ) ) - { - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(RSAKey) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); - } -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyDetachedSignature( String^ XmlSigFileName ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passed XML file into the document. - xmlDocument->Load( XmlSigFileName ); - - // Create a new SignedXMl object. - SignedXml^ signedXml = gcnew SignedXml; - - // Find the S"Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -int main() -{ - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmldsig.xml"; - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resourceand save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, Key ); - Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - - //Verify the XML signature in the XML file. - bool result = VerifyDetachedSignature( XmlFileName ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp deleted file mode 100644 index 19f81fd3bec..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp +++ /dev/null @@ -1,168 +0,0 @@ - - -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml Object*. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml Object*. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement Object*. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed String*. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml Object* and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the S"Signature" node and create a new - // XmlNodeList Object*. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument Object*. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode Object*. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -void main() -{ - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", Key ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp deleted file mode 100644 index 35c00691bbc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp +++ /dev/null @@ -1,219 +0,0 @@ -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; - -namespace CryptographyXmlDsigBase64Transform -{ - ref class Example - { - public: - static void Produce() - { - - // Encrypt an XML message - EncryptXML(LoadXMLDoc()); - - // Using XmlDsigBase64Transform resolving a Uri. - Uri^ baseUri = gcnew Uri("http://www.microsoft.com"); - String^ relativeUri = "msdn"; - Uri^ absoluteUri = ResolveUris(baseUri, relativeUri); - Console::WriteLine("This sample completed successfully; " - "press Enter to exit."); - Console::ReadLine(); - } - - - private: - - // Encrypt the text in the specified XmlDocument. - static void EncryptXML(XmlDocument^ xmlDoc) - { - - // - XmlDsigBase64Transform^ xmlTransform = - gcnew XmlDsigBase64Transform; - // - // Ensure the transform is using the proper algorithm. - // - xmlTransform->Algorithm = - SignedXml::XmlDsigBase64TransformUrl; - // - // Retrieve the XML representation of the current - // transform. - // - XmlElement^ xmlInTransform = xmlTransform->GetXml(); - // - Console::WriteLine("Xml representation of the " - "current transform: "); - Console::WriteLine(xmlInTransform->OuterXml); - - // Retrieve the valid input types for the current - // transform. - // - array^ validInTypes = xmlTransform->InputTypes; - // - // Verify the xmlTransform can accept the XMLDocument - // as an input type. - for each (Type^ validInType in validInTypes) - { - if (validInType == xmlDoc->GetType()) - { - - // Demonstrate loading the entire Xml Document. - // - xmlTransform->LoadInput(xmlDoc); - // - // This transform is created for demonstration - // purposes. - XmlDsigBase64Transform^ secondTransform = - gcnew XmlDsigBase64Transform; - // - String^ classDescription = - secondTransform->ToString(); - // - // This call does not perform as expected. - // LoadInnerXml is overridden by the - // XmlDsigBase64Transform class, but is - // stubbed out. - // - secondTransform->LoadInnerXml( - xmlDoc->SelectNodes("//.")); - // - break; - } - - } - - // - array^ validOutTypes = xmlTransform->OutputTypes; - // - for each (Type^ validOutType in validOutTypes) - { - if (validOutType == Stream::typeid) - { - try - { - - // - Type^ streamType = Stream::typeid; - CryptoStream^ outputStream = - (CryptoStream^)(xmlTransform->GetOutput( - streamType)); - // - // Read the CryptoStream into a stream reader. - StreamReader^ streamReader = - gcnew StreamReader(outputStream); - - // Read the stream into a string. - String^ outputMessage = - streamReader->ReadToEnd(); - - // Close the streams. - outputStream->Close(); - streamReader->Close(); - - // Display to the console the Xml before and - // after encryption. - Console::WriteLine("Encoding the following " - "message: {0}", xmlDoc->InnerText); - Console::WriteLine("Message encoded: {0}", - outputMessage); - } - catch (CryptographicException^ ex) - { - Console::WriteLine("Cryptographic exception " - "caught: {0}", ex); - } - - break; - } - else - { - - // - Object^ outputObject = xmlTransform->GetOutput(); - // - } - - } - } - - - // Create an XML document with Element and Text nodes. - static XmlDocument^ LoadXMLDoc() - { - XmlDocument^ xmlDoc = gcnew XmlDocument; - XmlNode^ mainNode = - xmlDoc->CreateNode(XmlNodeType::Element, - "ContosoMessages", "http://www.contoso.com"); - XmlNode^ textNode = xmlDoc->CreateTextNode("Some text " - "to encode."); - mainNode->AppendChild(textNode); - xmlDoc->AppendChild(mainNode); - Console::WriteLine("Created the following XML Document " - "for transformation: "); - Console::WriteLine(xmlDoc->InnerXml); - return xmlDoc; - } - - - // Resolve the specified base and relative Uri's. - static Uri^ ResolveUris(Uri^ baseUri, String^ relativeUri) - { - - // - XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver; - xmlResolver->Credentials = - System::Net::CredentialCache::DefaultCredentials; - XmlDsigBase64Transform^ xmlTransform = - gcnew XmlDsigBase64Transform; - xmlTransform->Resolver = xmlResolver; - // - Uri^ absoluteUri = xmlResolver->ResolveUri(baseUri, - relativeUri); - if (absoluteUri != nullptr) - { - Console::WriteLine("Resolved the base Uri and " - "relative Uri to the following:"); - Console::WriteLine(absoluteUri); - } - else - { - Console::WriteLine("Unable to resolve the base " - "Uri and relative Uri"); - } - - return absoluteUri; - } - - }; - -} - -int main() -{ - CryptographyXmlDsigBase64Transform::Example::Produce(); -} - -// -// This sample produces the following output: -// -// Created the following XML Document for transformation: -// Some text to encode. -// -// Xml representation of the current transform: -// -// Encoding the following message: Some text to encode. -// Message encoded: Jmr^ -// Resolved the base Uri and relative Uri to the following: -// http://www.microsoft.com/msdn -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp deleted file mode 100644 index 9c590aba971..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp +++ /dev/null @@ -1,334 +0,0 @@ -// -#using -#using -#using -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Security::Cryptography::X509Certificates; - -ref class Class1 -{ -private: - static String^ Certificate = L"..\\..\\my509.cer"; - -public: - [STAThread] - static void Main() - { - // Encrypt an XML message - XmlDocument^ productsXml = LoadProducts(); - ShowTransformProperties( productsXml ); - SignDocument( productsXml ); - ShowTransformProperties( productsXml ); - - // Use XmlDsigC14NTransform to resolve a Uri. - Uri^ baseUri = gcnew Uri( L"http://www.contoso.com" ); - String^ relativeUri = L"xml"; - Uri^ absoluteUri = ResolveUris( baseUri, relativeUri ); - Console::WriteLine( L"This sample completed successfully; " - L"press Enter to exit." ); - Console::ReadLine(); - } - - -private: - // Encrypt the text in the specified XmlDocument. - static void ShowTransformProperties( XmlDocument^ xmlDoc ) - { - // - XmlDsigC14NTransform^ xmlTransform = - gcnew XmlDsigC14NTransform( true ); - // - - // Ensure the transform is using the appropriate algorithm. - // - xmlTransform->Algorithm = - SignedXml::XmlDsigExcC14NTransformUrl; - // - - // Retrieve the XML representation of the current transform. - // - XmlElement^ xmlInTransform = xmlTransform->GetXml(); - // - - Console::WriteLine( L"\nXml representation of the current transform: " ); - Console::WriteLine( xmlInTransform->OuterXml ); - - // Retrieve the valid input types for the current transform. - // - array^validInTypes = xmlTransform->InputTypes; - // - - // Verify the xmlTransform can accept the XMLDocument as an - // input type. - for ( int i = 0; i < validInTypes->Length; i++ ) - { - if ( validInTypes[ i ] == xmlDoc->GetType() ) - { - // Load the document into the transfrom. - // - xmlTransform->LoadInput( xmlDoc ); - // - - // - XmlDsigC14NTransform^ secondTransform = gcnew XmlDsigC14NTransform; - // - - // - String^ classDescription = secondTransform->ToString(); - // - - // This call does not perform as expected. - // This transform does not contain inner XML elements - // - secondTransform->LoadInnerXml( xmlDoc->SelectNodes( L"//." ) ); - // - - break; - } - } - - // - array^validOutTypes = xmlTransform->OutputTypes; - // - - for ( int i = 0; i < validOutTypes->Length; i++ ) - { - if ( validOutTypes[ i ] == System::IO::Stream::typeid ) - { - try - { - - // - Type^ streamType = System::IO::Stream::typeid; - MemoryStream^ outputStream = static_cast( - xmlTransform->GetOutput( streamType )); - // - - // Read the CryptoStream into a stream reader. - StreamReader^ streamReader = - gcnew StreamReader( outputStream ); - - // Read the stream into a string. - String^ outputMessage = streamReader->ReadToEnd(); - - // Close the streams. - outputStream->Close(); - streamReader->Close(); - - // Display to the console the Xml before and after - // encryption. - Console::WriteLine( L"Encoding the following xml: {0}", - xmlDoc->OuterXml ); - Console::WriteLine( L"Message encoded: {0}", outputMessage ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"Unexpected exception caught: {0}", ex ); - } - - break; - } - else - { - // - Object^ outputObject = xmlTransform->GetOutput(); - // - } - } - } - - // Create an XML document describing various products. - static XmlDocument^ LoadProducts() - { - XmlDocument^ xmlDoc = gcnew XmlDocument; - String^ contosoProducts = L""; - contosoProducts = String::Concat( contosoProducts, - L"123"); - contosoProducts = String::Concat( contosoProducts, - L"Router"); - contosoProducts = String::Concat( contosoProducts, - L"456"); - contosoProducts = String::Concat( contosoProducts, - L"Keyboard"); - - // Include a comment to test the comments feature of the transform. - contosoProducts = String::Concat( contosoProducts, - L"" ); - - // Include the CDATA tag to test the transform results. - contosoProducts = String::Concat( contosoProducts, - L"" ); - contosoProducts = String::Concat( contosoProducts, - L"" ); - - xmlDoc->LoadXml( contosoProducts ); - return xmlDoc; - } - - // Create a signature and add it to the specified document. - static void SignDocument( XmlDocument^ xmlDoc ) - { - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( xmlDoc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = L""; - - // Add an enveloped transformation to the reference. - reference->AddTransform( gcnew XmlDsigC14NTransform ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - try - { - // Create a new KeyInfo object. - KeyInfo^ keyInfo = gcnew KeyInfo; - - // Load the X509 certificate. - X509Certificate^ MSCert = - X509Certificate::CreateFromCertFile( Certificate ); - - // Load the certificate into a KeyInfoX509Data object - // and add it to the KeyInfo object. - keyInfo->AddClause( gcnew KeyInfoX509Data( MSCert ) ); - - // Add the KeyInfo object to the SignedXml object. - signedXml->KeyInfo = keyInfo; - } - catch ( FileNotFoundException^ ) - { - Console::WriteLine( L"Unable to locate the following file: {0}", - Certificate ); - } - catch ( CryptographicException^ ex ) - { - Console::WriteLine( L"Unexpected exception caught while creating " - L"the certificate:{0}", ex ); - } - - // Compute the signature. - signedXml->ComputeSignature(); - - // Add the signature branch to the original tree so it is enveloped. - xmlDoc->DocumentElement->AppendChild( signedXml->GetXml() ); - } - - // Resolve the specified base and relative Uri's . - static Uri^ ResolveUris( Uri^ baseUri, String^ relativeUri ) - { - // - XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver; - xmlResolver->Credentials = - System::Net::CredentialCache::DefaultCredentials; - XmlDsigC14NTransform^ xmlTransform = gcnew XmlDsigC14NTransform; - xmlTransform->Resolver = xmlResolver; - // - - Uri^ absoluteUri = xmlResolver->ResolveUri( baseUri, relativeUri ); - if ( absoluteUri != nullptr ) - { - Console::WriteLine( - L"\nResolved the base Uri and relative Uri to the following:" ); - Console::WriteLine( absoluteUri ); - } - else - { - Console::WriteLine( L"Unable to resolve the base Uri and relative Uri" ); - } - - return absoluteUri; - } -}; - -int main() -{ - Class1::Main(); -} - -// -// This sample produces the following output: -// -// Xml representation of the current transform: -// -// Encoding the following xml: 123Rou -// ter456Keyboard -// Message encoded: 123Rou -// ter456Keyboard'http:\\www.contoso.com\partner.asp?h1=en&h2=cr' -// Xml representation of the current transform: -// -// Encoding the following xml: 123Rou -// ter456Keyboard -// BFN2s0/NA2NGgb/R0mvfnNM0Ito= -// vSfZUG5xHuNxzOSEbQjN -// dtEt1D+O7I1LTJ13RrwLaJSfQPrdT/s8IeaA+idw2f2WGuGrdqMJUddpE4GxfK61HmPQ6S7lBG+ -// +ND+YaUYf2AtTRs3SnToXQQrARa/pHVjsKxYHR/9tjy6maHBwxjgjFQABvYZu0gZHYRuXvvfxv0 -// 8=MIICCzCCAXSgAwIBAgIQ5eVQY8pRZ5xBF2WLkYPjijANBgkqhkiG -// 9w0BAQQFADAbMRkwFwYDVQQDExBHcmVnc0NlcnRpZmljYXRlMB4XDTAzMDkxNzIzMzU0N1oXDTM -// 5MTIzMTIzNTk1OVowGzEZMBcGA1UEAxMQR3JlZ3NDZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQ -// EFAAOBjQAwgYkCgYEAmFJ4v7rS3BYTXgVW9PgBFfTYAcB/m9mOFCmUrrChcBpoEtu/tSESlNfEH -// pECIdqg9vUrCNSkY08HRn3ueNeBSnSpssWd8/XoOboWLh1nd+79Y5uZd1WOJI4s0XM0MegZgCoJ -// cEEhpxCd/HOPIQvEsbpN/DuFiovZLo+Ek3hHoxMCAwEAAaNQME4wTAYDVR0BBEUwQ4AQaCb19dl -// yf/zSxPVYQZY9AKEdMBsxGTAXBgNVBAMTEEdyZWdzQ2VydGlmaWNhdGWCEOXlUGPKUWecQRdli5 -// GD44owDQYJKoZIhvcNAQEEBQADgYEAZuZaFDGDJogh7FuT0hfaMAVlRONv6wWVBJVV++eUo38Xu -// RfJ5nNJ0UnhiV2sEtLobYBPEIrNhuk8skdU0AHgx4ILiA4rR96ifWwxtrFQF+h+DL2ZB7xhwcOJ -// +Pa7IC4wIaEp/oBmmX+JHSzfQt6/If4ohwikfxfljKMyIcMlwl4= -// -// Message encoded: 123Router456Keyboard

'http:\\ww -// w.contoso.com\partner.asp?h1=en&h2=cr'BFN2s0/NA2NGgb/R0mvfnNM0Ito= -// vSfZUG5xHuNxzOSEbQjN -// dtEt1D+O7I1LTJ13RrwLaJSfQPrdT/s8IeaA+idw2f2WGuGrdqMJUddpE4GxfK61HmPQ6S7lBG+ -// +ND+YaUYf2AtTRs3SnToXQQrARa/pHVjsKxYHR/9tjy6maHBwxjgjFQABvYZu0gZHYRuXvvfxv0 -// 8=MIICCzCCAXSgAwIBAgIQ5eVQY8pRZ5xBF2WLkYPjijANBgkqhkiG -// 9w0BAQQFADAbMRkwFwYDVQQDExBHcmVnc0NlcnRpZmljYXRlMB4XDTAzMDkxNzIzMzU0N1oXDTM -// 5MTIzMTIzNTk1OVowGzEZMBcGA1UEAxMQR3JlZ3NDZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQ -// EFAAOBjQAwgYkCgYEAmFJ4v7rS3BYTXgVW9PgBFfTYAcB/m9mOFCmUrrChcBpoEtu/tSESlNfEH -// pECIdqg9vUrCNSkY08HRn3ueNeBSnSpssWd8/XoOboWLh1nd+79Y5uZd1WOJI4s0XM0MegZgCoJ -// cEEhpxCd/HOPIQvEsbpN/DuFiovZLo+Ek3hHoxMCAwEAAaNQME4wTAYDVR0BBEUwQ4AQaCb19dl -// yf/zSxPVYQZY9AKEdMBsxGTAXBgNVBAMTEEdyZWdzQ2VydGlmaWNhdGWCEOXlUGPKUWecQRdli5 -// GD44owDQYJKoZIhvcNAQEEBQADgYEAZuZaFDGDJogh7FuT0hfaMAVlRONv6wWVBJVV++eUo38Xu -// RfJ5nNJ0UnhiV2sEtLobYBPEIrNhuk8skdU0AHgx4ILiA4rR96ifWwxtrFQF+h+DL2ZB7xhwcOJ -// +Pa7IC4wIaEp/oBmmX+JHSzfQt6/If4ohwikfxfljKMyIcMlwl4=
-// -// Resolved the base Uri and relative Uri to the following: -// http://www.contoso.com/xml -// This sample completed successfully; press Enter to exit. -//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp deleted file mode 100644 index bf4107ed47b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp +++ /dev/null @@ -1,290 +0,0 @@ -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Security::Cryptography::X509Certificates; - -public ref class EnvelopedSignatureSample -{ -private: - static String^ Certificate = "..\\..\\my509.cer"; - - // Encrypt the text in the specified XmlDocument. -public: - static void ShowTransformProperties(XmlDocument^ xmlDoc) - { - // - XmlDsigEnvelopedSignatureTransform^ xmlTransform = - gcnew XmlDsigEnvelopedSignatureTransform(); - // - - // Ensure the transform is using the proper algorithm. - // - xmlTransform->Algorithm = - SignedXml::XmlDsigEnvelopedSignatureTransformUrl; - // - - // Retrieve the XML representation of the current transform. - // - XmlElement^ xmlInTransform = xmlTransform->GetXml(); - // - - Console::WriteLine("\nXml representation of the current transform: "); - Console::WriteLine(xmlInTransform->OuterXml); - - // Retrieve the valid input types for the current transform. - // - array^ validInTypes = xmlTransform->InputTypes; - // - - // Verify the xmlTransform can accept the XMLDocument as an - // input type. - for (int i = 0; i < validInTypes->Length; i++) - { - if (validInTypes[i] == xmlDoc->GetType()) - { - // Load the document into the transfrom. - // - xmlTransform->LoadInput(xmlDoc); - // - - // - bool IncludeComments = true; - // This transform is created for demonstration purposes. - XmlDsigEnvelopedSignatureTransform^ secondTransform = - gcnew XmlDsigEnvelopedSignatureTransform(IncludeComments); - // - - // - String^ classDescription = secondTransform->ToString(); - // - - // This call does not perform as expected. - // - // An enveloped signature has no inner XML elements - secondTransform->LoadInnerXml(xmlDoc->SelectNodes("//.")); - // - - break; - } - } - - // - array^ validOutTypes = xmlTransform->OutputTypes; - // - - for (int i = validOutTypes->Length-1; i >= 0; i--) - { - if (validOutTypes[i] == System::Xml::XmlDocument::typeid) - { - // - Type^ xmlDocumentType = System::Xml::XmlDocument::typeid; - XmlDocument^ xmlDocumentOutput = (XmlDocument^) - xmlTransform->GetOutput(xmlDocumentType); - // - - // Display to the console the Xml before and after - // encryption. - Console::WriteLine("Result of the GetOutput method call" + - " from the current transform: " + - xmlDocumentOutput->OuterXml); - - break; - } - else if (validOutTypes[i] == System::Xml::XmlNodeList::typeid) - { - Type^ xmlNodeListType = System::Xml::XmlNodeList::typeid; - XmlNodeList^ xmlNodes = (XmlNodeList^) - xmlTransform->GetOutput(xmlNodeListType); - - // Display to the console the Xml before and after - // encryption. - Console::WriteLine("Encoding the following message: " + - xmlDoc->InnerText); - - Console::WriteLine("Nodes of the XmlNodeList retrieved " + - "from GetOutput:"); - for (int j = 0; j < xmlNodes->Count; j++) - { - Console::WriteLine("Node " + j + - " has the following name: " + - xmlNodes->Item(j)->Name + - " and the following InnerXml: " + - xmlNodes->Item(j)->InnerXml); - } - - break; - } - else - { - // - Object^ outputObject = xmlTransform->GetOutput(); - // - } - } - } - - // Create an XML document describing various products. -public: - static XmlDocument^ LoadProducts() - { - XmlDocument^ xmlDoc = gcnew XmlDocument(); - - String^ contosoProducts = "" + - "123Router" + - "" + - "456Keyboard" + - "" + - "789Monitor" + - "" + - ""; - - xmlDoc->LoadXml(contosoProducts); - return xmlDoc; - } - - // Create a signature and add it to the specified document. -public: - static void SignDocument(XmlDocument^ xmlDoc) - { - // Generate a signing key. - RSA^ key = RSA::Create(); - - // Create a SignedXml object. - SignedXml^ signedDocument = gcnew SignedXml(xmlDoc); - - // Add the key to the SignedXml document. - signedDocument->SigningKey = key; - - // Create a reference to be signed. - Reference^ referenceToBeSigned = gcnew Reference(); - referenceToBeSigned->Uri = ""; - - // Add an enveloped transformation to the reference. - referenceToBeSigned->AddTransform( - gcnew XmlDsigEnvelopedSignatureTransform()); - - // Add the reference to the SignedXml object. - signedDocument->AddReference(referenceToBeSigned); - - if(File::Exists(Certificate)) - { - // Create a new KeyInfo object. - KeyInfo^ info = gcnew KeyInfo(); - - // Load the X509 certificate. - X509Certificate^ certFromFile = - X509Certificate::CreateFromCertFile(Certificate); - - // Load the certificate into a KeyInfoX509Data object - // and add it to the KeyInfo object. - info->AddClause(gcnew KeyInfoX509Data(certFromFile)); - - // Add the KeyInfo object to the SignedXml object. - signedDocument->KeyInfo = info; - } - else - { - Console::WriteLine("Unable to locate the following file: " + - Certificate); - } - - // Compute the signature. - signedDocument->ComputeSignature(); - - // Add the signature branch to the original tree so it is enveloped. - xmlDoc->DocumentElement->AppendChild(signedDocument->GetXml()); - } - - // Resolve the specified base and relative Uri's . -public: - static Uri^ ResolveUris(Uri^ baseUri, String^ relativeUri) - { - // - XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver(); - xmlResolver->Credentials = - System::Net::CredentialCache::DefaultCredentials; - - XmlDsigEnvelopedSignatureTransform^ xmlTransform = - gcnew XmlDsigEnvelopedSignatureTransform(); - xmlTransform->Resolver = xmlResolver; - // - - Uri^ absoluteUri = xmlResolver->ResolveUri(baseUri, relativeUri); - - if (absoluteUri != nullptr) - { - Console::WriteLine( - "\nResolved the base Uri and relative Uri to the following:"); - Console::WriteLine(absoluteUri->ToString()); - } - else - { - Console::WriteLine( - "Unable to resolve the base Uri and relative Uri"); - } - return absoluteUri; - } -}; - -[STAThread] -int main() -{ - // Encrypt an XML message - XmlDocument^ productsXml = EnvelopedSignatureSample::LoadProducts(); - EnvelopedSignatureSample::ShowTransformProperties(productsXml); - - EnvelopedSignatureSample::SignDocument(productsXml); - EnvelopedSignatureSample::ShowTransformProperties(productsXml); - - // Use XmlDsigEnvelopedSignatureTransform to resolve a Uri. - Uri^ baseUri = gcnew Uri("http://www.contoso.com"); - String^ relativeUri = "xml"; - Uri^ absoluteUri = - EnvelopedSignatureSample::ResolveUris(baseUri, relativeUri); - - Console::WriteLine("This sample completed successfully; " + - "press Enter to exit."); - Console::ReadLine(); -} - -// -// This sample produces the following output: -// -// Xml representation of the current transform: -// -// Result of the GetOutput method call from the current transform: -// 123Router -// 456Keyboard789 -// Monitor -// Unable to load the following file: ..\\my509.cer -// -// Xml representation of the current transform: -// -// Result of the GetOutput method call from the current transform: -// 123Router -// 456Keyboard789 -// Monitor -// -// KvPW6HUiIUMEDS0YSoT -// gpo2JPbA=c/njCGDru/a -// WAmWG83I+mWO040xOzxvmNx0b0o8ZyPc9j5VwApdAt103OGBtB1H6EkOvt7Ekw+PVuUo8m5LzLP -// yaTxUDMbb2kZZ5itSkGD4rmMUMUMuzrkAoquJZjxeOydBJ2CMehV2rE3RMPLIwRX176DZVy5JKU -// 6Cb7PR2Rpw= -// -// Resolved the base Uri and relative Uri to the following: -// http://www.contoso.com/xml -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp deleted file mode 100644 index 5a53f0d8e0a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp +++ /dev/null @@ -1,261 +0,0 @@ -// -#using -#using -#using -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; - -ref class Class1 -{ -public: - [STAThread] - static void Main() - { - XmlDocument^ productsXml = LoadProducts(); - XmlNodeList^ xsltNodeList = GetXsltAsNodeList(); - TransformDoc( productsXml, xsltNodeList ); - - // Use XmlDsigXsltTransform to resolve a Uri. - Uri^ baseUri = gcnew Uri( L"http://www.contoso.com" ); - String^ relativeUri = L"xml"; - Uri^ absoluteUri = ResolveUris( baseUri, relativeUri ); - Console::WriteLine( L"This sample completed successfully; " - L"press Enter to exit." ); - Console::ReadLine(); - } - -private: - static void TransformDoc( XmlDocument^ xmlDoc, XmlNodeList^ xsltNodeList ) - { - try - { - // Construct a new XmlDsigXsltTransform. - // - XmlDsigXsltTransform^ xmlTransform = gcnew XmlDsigXsltTransform; - // - - // Load the Xslt tranform as a node list. - // - xmlTransform->LoadInnerXml( xsltNodeList ); - // - - // Load the Xml document to perform the tranform on. - // - XmlNamespaceManager^ namespaceManager; - namespaceManager = gcnew XmlNamespaceManager( xmlDoc->NameTable ); - XmlNodeList^ productsNodeList; - productsNodeList = xmlDoc->SelectNodes( L"//.", namespaceManager ); - xmlTransform->LoadInput( productsNodeList ); - // - - // Retrieve the output from the transform. - // - Stream^ outputStream = (Stream^)xmlTransform->GetOutput( - System::IO::Stream::typeid ); - // - - // Read the output stream into a stream reader. - StreamReader^ streamReader = gcnew StreamReader( outputStream ); - - // Read the stream into a string. - String^ outputMessage = streamReader->ReadToEnd(); - - // Close the streams. - outputStream->Close(); - streamReader->Close(); - - // Display to the console the Xml before and after - // encryption. - Console::WriteLine( L"\nResult of transformation: {0}", outputMessage ); - ShowTransformProperties( xmlTransform ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"Caught exception in TransformDoc method: {0}", ex ); - } - } - - static XmlNodeList^ GetXsltAsNodeList() - { - String^ transformXml = L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"
ProductIdName
" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"
" ); - Console::WriteLine( L"\nCreated the following Xslt tranform:" ); - Console::WriteLine( transformXml ); - XmlDocument^ xmlDoc = gcnew XmlDocument; - xmlDoc->LoadXml( transformXml ); - return xmlDoc->GetElementsByTagName( L"xsl:transform" ); - } - - // Encrypt the text in the specified XmlDocument. - static void ShowTransformProperties( XmlDsigXsltTransform^ xmlTransform ) - { - // - String^ classDescription = xmlTransform->ToString(); - // - Console::WriteLine( L"\n** Summary for {0} **", classDescription ); - - // Retrieve the XML representation of the current transform. - // - XmlElement^ xmlInTransform = xmlTransform->GetXml(); - // - Console::WriteLine( L"Xml representation of the current transform:\n{0}", - xmlInTransform->OuterXml ); - - // Ensure the transform is using the proper algorithm. - // - xmlTransform->Algorithm = SignedXml::XmlDsigXsltTransformUrl; - // - Console::WriteLine( L"Algorithm used: {0}", classDescription ); - - // Retrieve the valid input types for the current transform. - // - array^validInTypes = xmlTransform->InputTypes; - // - Console::WriteLine( L"Transform accepts the following inputs:" ); - for ( int i = 0; i < validInTypes->Length; i++ ) - { - Console::WriteLine( L"\t{0}", validInTypes[ i ] ); - - } - - // - array^validOutTypes = xmlTransform->OutputTypes; - // - Console::WriteLine( L"Transform outputs in the following types:" ); - for ( int i = validOutTypes->Length - 1; i >= 0; i-- ) - { - Console::WriteLine( L"\t {0}", validOutTypes[ i ] ); - if ( validOutTypes[ i ] == Object::typeid ) - { - // - Object^ outputObject = xmlTransform->GetOutput(); - // - } - } - } - - // Create an XML document describing various products. - static XmlDocument^ LoadProducts() - { - String^ contosoProducts = L""; - contosoProducts = String::Concat( contosoProducts, - L"" ); - contosoProducts = String::Concat( contosoProducts, - L"1" ); - contosoProducts = String::Concat( contosoProducts, - L"Widgets" ); - contosoProducts = String::Concat( contosoProducts, - L"2" ); - contosoProducts = String::Concat( contosoProducts, - L"Gadgits" ); - contosoProducts = String::Concat( contosoProducts, - L"" ); - Console::WriteLine( - L"\nCreated the following Xml document for tranformation:" ); - Console::WriteLine( contosoProducts ); - XmlDocument^ xmlDoc = gcnew XmlDocument; - xmlDoc->LoadXml( contosoProducts ); - return xmlDoc; - } - - // Resolve the specified base and relative Uri's . - static Uri^ ResolveUris( Uri^ baseUri, String^ relativeUri ) - { - // - XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver; - xmlResolver->Credentials = - System::Net::CredentialCache::DefaultCredentials; - - XmlDsigXsltTransform^ xmlTransform = gcnew XmlDsigXsltTransform; - xmlTransform->Resolver = xmlResolver; - // - - Uri^ absoluteUri = xmlResolver->ResolveUri( baseUri, relativeUri ); - if ( absoluteUri != nullptr ) - { - Console::WriteLine( - L"\nResolved the base Uri and relative Uri to the following:" ); - Console::WriteLine( absoluteUri ); - } - else - { - Console::WriteLine( L"Unable to resolve the base Uri and relative Uri" ); - } - - return absoluteUri; - } -}; - -int main() -{ - Class1::Main(); -} - -// -// This sample produces the following output: -// -// Created the following Xml document for tranformation: -// 1Widgets2Gadgits -// -// Created the following Xslt tranform: -//
ProductIdName
-// -// Result of transformation:
ProductIdName
1Widgets
2Gadgits
-// -// ** Summary for System.Security.Cryptography.Xml.XmlDsigXsltTransform ** -// Xml representation of the current transform: -// -// Algorithm used: System.Security.Cryptography.Xml.XmlDsigXsltTransform -// Transform accepts the following inputs: -// System.IO.Stream -// System.Xml.XmlDocument -// System.Xml.XmlNodeList -// Transform outputs in the following types: -// System.IO.Stream -// -// Resolved the base Uri and relative Uri to the following: -// http://www.contoso.com/xml -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor2.cpp deleted file mode 100644 index 6f27c73ab00..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor2.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -using namespace System; -using namespace System::Security; - -int main(array ^args) -{ - // Define the string value to assign to a new secure string. - Char chars[4] = { 't', 'e', 's', 't' }; - // Instantiate the secure string. - SecureString^ testString = gcnew SecureString(); - // Assign the character array to the secure string. - for each (Char ch in chars) - { - testString->AppendChar(ch); - } - // Display secure string length. - Console::WriteLine("The length of the string is {0} characters.", - testString->Length); - - delete testString; - return 0; -} -// The example displays the following output: -// The length of the string is 4 characters. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor3.cpp deleted file mode 100644 index 103271ae878..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor3.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -using namespace System; -using namespace System::Security; - -int main(array ^args) -{ - // Define the string value to be assigned to the secure string. - String^ initString = "TestString"; - // Instantiate the secure string. - SecureString^ testString = gcnew SecureString(); - // Assign the character array to the secure string. - for each (Char ch in initString) - { - testString->AppendChar(ch); - } - // Display secure string length. - Console::WriteLine("The length of the string is {0} characters.", - testString->Length); - - delete testString; - return 0; -} -// The example displays the following output: -// The length of the string is 10 characters. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding Example/CPP/snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding Example/CPP/snippet.cpp deleted file mode 100644 index b1cbd4a7c59..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding Example/CPP/snippet.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -using namespace System::Text; -int main() -{ - - // The encoding. - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - - // A Unicode string with two characters outside the ASCII code range. - String^ unicodeString = L"This Unicode String* contains two characters with codes outside the ASCII code range, Pi (\u03a0) and Sigma (\u03a3)."; - Console::WriteLine( "Original String*:" ); - Console::WriteLine( unicodeString ); - - // Save positions of the special characters for later reference. - int indexOfPi = unicodeString->IndexOf( L'\u03a0' ); - int indexOfSigma = unicodeString->IndexOf( L'\u03a3' ); - - // Encode string. - array^encodedBytes = ascii->GetBytes( unicodeString ); - Console::WriteLine(); - Console::WriteLine( "Encoded bytes:" ); - IEnumerator^ myEnum = encodedBytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "->Item[ {0}]", b ); - } - - Console::WriteLine(); - - // Notice that the special characters have been replaced with - // the value 63, which is the ASCII character code for '?'. - Console::WriteLine(); - Console::WriteLine( "Value at position of Pi character: {0}", encodedBytes[ indexOfPi ] ); - Console::WriteLine( "Value at position of Sigma character: {0}", encodedBytes[ indexOfSigma ] ); - - // Decode bytes back to string. - // Notice missing Pi and Sigma characters. - String^ decodedString = ascii->GetString( encodedBytes ); - Console::WriteLine(); - Console::WriteLine( "Decoded bytes:" ); - Console::WriteLine( decodedString ); -} -// The example displays the following output: -// Original string: -// This Unicode string contains two characters with codes outside the ASCII code ra -// nge, Pi (Π) and Sigma (Σ). -// -// Encoded bytes: -// [84][104][105][115][32][85][110][105][99][111][100][101][32][115][116][114][105] -// [110][103][32][99][111][110][116][97][105][110][115][32][116][119][111][32][99][ -// 104][97][114][97][99][116][101][114][115][32][119][105][116][104][32][99][111][1 -// 00][101][115][32][111][117][116][115][105][100][101][32][116][104][101][32][65][ -// 83][67][73][73][32][99][111][100][101][32][114][97][110][103][101][44][32][80][1 -// 05][32][40][63][41][32][97][110][100][32][83][105][103][109][97][32][40][63][41] -// [46] -// -// Value at position of Pi character: 63 -// Value at position of Sigma character: 63 -// -// Decoded bytes: -// This Unicode string contains two characters with codes outside the ASCII code ra -// nge, Pi (?) and Sigma (?). -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount1 Example/CPP/getbytecount-char[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount1 Example/CPP/getbytecount-char[]-int32-int32.cpp deleted file mode 100644 index 6c219637683..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount1 Example/CPP/getbytecount-char[]-int32-int32.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int byteCount = ascii->GetByteCount( chars, 1, 2 ); - Console::WriteLine( " {0} bytes needed to encode characters.", byteCount.ToString() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount2 Example/CPP/getbytecount-string.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount2 Example/CPP/getbytecount-string.cpp deleted file mode 100644 index 9cca1f732fb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount2 Example/CPP/getbytecount-string.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - String^ chars = "ASCII Encoding Example"; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int byteCount = ascii->GetByteCount( chars ); - Console::WriteLine( " {0} bytes needed to encode string.", byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes1 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes1 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 8c299b71779..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes1 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - String^ chars = "ASCII Encoding Example"; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int byteCount = ascii->GetByteCount( chars->ToCharArray(), 6, 8 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = ascii->GetBytes( chars, 6, 8, bytes, 0 ); - Console::WriteLine( " {0} bytes used to encode string.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes2/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes2/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 50c3b1c6605..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes2/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int byteCount = ascii->GetByteCount( chars, 1, 2 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = ascii->GetBytes( chars, 1, 2, bytes, 0 ); - Console::WriteLine( " {0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp deleted file mode 100644 index 9a924b51b64..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - array^bytes = {65,83,67,73,73,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101}; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int charCount = ascii->GetCharCount( bytes, 6, 8 ); - Console::WriteLine( "{0} characters needed to decode bytes.", charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp deleted file mode 100644 index 7185ebd1815..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {65,83,67,73,73,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101}; - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int charCount = ascii->GetCharCount( bytes, 6, 8 ); - chars = gcnew array(charCount); - int charsDecodedCount = ascii->GetChars( bytes, 6, 8, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp deleted file mode 100644 index 2f2f78f27ff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int charCount = 2; - int maxByteCount = ascii->GetMaxByteCount( charCount ); - Console::WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", maxByteCount, charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp deleted file mode 100644 index b6d834c02f9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - int byteCount = 8; - int maxCharCount = ascii->GetMaxCharCount( byteCount ); - Console::WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", maxCharCount, byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetString1 Example/CPP/getstring-byte[].cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetString1 Example/CPP/getstring-byte[].cpp deleted file mode 100644 index b8f188b7df6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetString1 Example/CPP/getstring-byte[].cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::Text; - -int main() -{ - // Define a string. - String^ original = "ASCII Encoding Example"; - // Instantiate an ASCII encoding object. - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - - // Create an ASCII byte array. - array^ bytes = ascii->GetBytes(original); - - // Display encoded bytes. - Console::Write("Encoded bytes (in hex): "); - for each (Byte value in bytes) - Console::Write("{0:X2} ", value); - Console::WriteLine(); - - // Decode the bytes and display the resulting Unicode string. - String^ decoded = ascii->GetString(bytes); - Console::WriteLine("Decoded string: '{0}'", decoded); -} -// The example displays the following output: -// Encoded bytes (in hex): 41 53 43 49 49 20 45 6E 63 6F 64 69 6E 67 20 45 78 61 6D 70 6C 65 -// Decoded string: 'ASCII Encoding Example' -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.ctor Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.ctor Example/CPP/ctor.cpp deleted file mode 100644 index 962a0f07f41..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.ctor Example/CPP/ctor.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - ASCIIEncoding^ ascii = gcnew ASCIIEncoding; - String^ encodingName = ascii->EncodingName; - Console::WriteLine( "Encoding name: {0}", encodingName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp deleted file mode 100644 index 370f5662328..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - array^bytes = {85,0,110,0,105,0,99,0,111,0,100,0,101,0}; - Decoder^ uniDecoder = Encoding::Unicode->GetDecoder(); - int charCount = uniDecoder->GetCharCount( bytes, 0, bytes->Length ); - Console::WriteLine( "{0} characters needed to decode bytes.", charCount ); -} - -/* This code example produces the following output. - -7 characters needed to decode bytes. - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp deleted file mode 100644 index 7183cd449b3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {85,0,110,0,105,0,99,0,111,0,100,0,101,0}; - Decoder^ uniDecoder = Encoding::Unicode->GetDecoder(); - int charCount = uniDecoder->GetCharCount( bytes, 0, bytes->Length ); - chars = gcnew array(charCount); - int charsDecodedCount = uniDecoder->GetChars( bytes, 0, bytes->Length, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -/* This code example produces the following output. - -7 characters used to decode bytes. -Decoded chars: [U][n][i][c][o][d][e] - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.ctor Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.ctor Example/CPP/ctor.cpp deleted file mode 100644 index 70bd454cc25..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.ctor Example/CPP/ctor.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // A Decoder is obtained from an Encoding. - UnicodeEncoding^ uni = gcnew UnicodeEncoding; - Decoder^ dec1 = uni->GetDecoder(); - - // A more direct technique. - Decoder^ dec2 = Encoding::Unicode->GetDecoder(); - - // dec1 and dec2 seem to be the same. - Console::WriteLine( dec1 ); - Console::WriteLine( dec2 ); - - // Note that their hash codes differ. - Console::WriteLine( dec1->GetHashCode() ); - Console::WriteLine( dec2->GetHashCode() ); -} - -/* This code example produces the following output. - -System.Text.UnicodeEncoding+Decoder -System.Text.UnicodeEncoding+Decoder -54267293 -18643596 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp deleted file mode 100644 index 74bd7968408..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp +++ /dev/null @@ -1,125 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -void ShowArray( Array^ theArray ) -{ - IEnumerator^ myEnum = theArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::Write( "[{0}]", o ); - } - - Console::WriteLine( "\n" ); -} - -int main() -{ - - // The characters to encode. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - - // Encode characters using an Encoding Object*. - Encoding^ encoding = Encoding::UTF7; - Console::WriteLine( "Using Encoding\n--------------" ); - - // Encode complete array for comparison. - array^allCharactersFromEncoding = encoding->GetBytes( chars ); - Console::WriteLine( "All characters encoded:" ); - ShowArray( allCharactersFromEncoding ); - - // Encode characters, one-by-one. - // The Encoding Object* will NOT maintain state between calls. - array^firstchar = encoding->GetBytes( chars, 0, 1 ); - Console::WriteLine( "First character:" ); - ShowArray( firstchar ); - array^secondchar = encoding->GetBytes( chars, 1, 1 ); - Console::WriteLine( "Second character:" ); - ShowArray( secondchar ); - array^thirdchar = encoding->GetBytes( chars, 2, 1 ); - Console::WriteLine( "Third character:" ); - ShowArray( thirdchar ); - array^fourthchar = encoding->GetBytes( chars, 3, 1 ); - Console::WriteLine( "Fourth character:" ); - ShowArray( fourthchar ); - - // Now, encode characters using an Encoder Object*. - Encoder^ encoder = encoding->GetEncoder(); - Console::WriteLine( "Using Encoder\n-------------" ); - - // Encode complete array for comparison. - array^allCharactersFromEncoder = gcnew array(encoder->GetByteCount( chars, 0, chars->Length, true )); - encoder->GetBytes( chars, 0, chars->Length, allCharactersFromEncoder, 0, true ); - Console::WriteLine( "All characters encoded:" ); - ShowArray( allCharactersFromEncoder ); - - // Do not flush state; i.e. maintain state between calls. - bool bFlushState = false; - - // Encode characters one-by-one. - // By maintaining state, the Encoder will not store extra bytes in the output. - array^firstcharNoFlush = gcnew array(encoder->GetByteCount( chars, 0, 1, bFlushState )); - encoder->GetBytes( chars, 0, 1, firstcharNoFlush, 0, bFlushState ); - Console::WriteLine( "First character:" ); - ShowArray( firstcharNoFlush ); - array^secondcharNoFlush = gcnew array(encoder->GetByteCount( chars, 1, 1, bFlushState )); - encoder->GetBytes( chars, 1, 1, secondcharNoFlush, 0, bFlushState ); - Console::WriteLine( "Second character:" ); - ShowArray( secondcharNoFlush ); - array^thirdcharNoFlush = gcnew array(encoder->GetByteCount( chars, 2, 1, bFlushState )); - encoder->GetBytes( chars, 2, 1, thirdcharNoFlush, 0, bFlushState ); - Console::WriteLine( "Third character:" ); - ShowArray( thirdcharNoFlush ); - - // Must flush state on last call to GetBytes(). - bFlushState = true; - array^fourthcharNoFlush = gcnew array(encoder->GetByteCount( chars, 3, 1, bFlushState )); - encoder->GetBytes( chars, 3, 1, fourthcharNoFlush, 0, bFlushState ); - Console::WriteLine( "Fourth character:" ); - ShowArray( fourthcharNoFlush ); -} - -/* This code example produces the following output. - -Using Encoding --------------- -All characters encoded: -[43][65][54][65][68][111][119][79][109][65][54][107][45] - -First character: -[43][65][54][65][45] - -Second character: -[43][65][54][77][45] - -Third character: -[43][65][54][89][45] - -Fourth character: -[43][65][54][107][45] - -Using Encoder -------------- -All characters encoded: -[43][65][54][65][68][111][119][79][109][65][54][107][45] - -First character: -[43][65][54] - -Second character: -[65][68][111] - -Third character: -[119][79][109] - -Fourth character: -[65][54][107][45] - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp deleted file mode 100644 index d8af6efc812..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - Encoder^ uniEncoder = Encoding::Unicode->GetEncoder(); - int byteCount = uniEncoder->GetByteCount( chars, 0, chars->Length, true ); - Console::WriteLine( "{0} bytes needed to encode characters.", byteCount ); -} - -/* This code example produces the following output. - -8 bytes needed to encode characters. - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 1430f4918f5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - Encoder^ uniEncoder = Encoding::Unicode->GetEncoder(); - int byteCount = uniEncoder->GetByteCount( chars, 0, chars->Length, true ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = uniEncoder->GetBytes( chars, 0, chars->Length, bytes, 0, true ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -/* This code example produces the following output. - -8 bytes used to encode characters. -Encoded bytes: [160][3][163][3][166][3][169][3] - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.ctor Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.ctor Example/CPP/ctor.cpp deleted file mode 100644 index 0f8e033017f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.ctor Example/CPP/ctor.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // An Encoder is obtained from an Encoding. - UnicodeEncoding^ uni = gcnew UnicodeEncoding; - Encoder^ enc1 = uni->GetEncoder(); - - // A more direct technique. - Encoder^ enc2 = Encoding::Unicode->GetEncoder(); - - // enc1 and enc2 seem to be the same. - Console::WriteLine( enc1 ); - Console::WriteLine( enc2 ); - - // Note that their hash codes differ. - Console::WriteLine( enc1->GetHashCode() ); - Console::WriteLine( enc2->GetHashCode() ); -} - -/* This code example produces the following output. - -System.Text.EncoderNLS -System.Text.EncoderNLS -54267293 -18643596 - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.ASCII Example/CPP/ascii.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.ASCII Example/CPP/ascii.cpp deleted file mode 100644 index 3ea34429d23..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.ASCII Example/CPP/ascii.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - - // Create an ASCII encoding. - Encoding^ ascii = Encoding::ASCII; - - // A Unicode String* with two characters outside the ASCII code range. - String^ unicodeString = L"This unicode string contains two characters with codes outside the ASCII code range, Pi (\u03a0) and Sigma (\u03a3)."; - Console::WriteLine( "Original string:" ); - Console::WriteLine( unicodeString ); - - // Save the positions of the special characters for later reference. - int indexOfPi = unicodeString->IndexOf( L'\u03a0' ); - int indexOfSigma = unicodeString->IndexOf( L'\u03a3' ); - - // Encode the String*. - array^encodedBytes = ascii->GetBytes( unicodeString ); - Console::WriteLine(); - Console::WriteLine( "Encoded bytes:" ); - IEnumerator^ myEnum = encodedBytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); - - // Notice that the special characters have been replaced with - // the value 63, which is the ASCII character code for '?'. - Console::WriteLine(); - Console::WriteLine( "Value at position of Pi character: {0}", encodedBytes[ indexOfPi ] ); - Console::WriteLine( "Value at position of Sigma character: {0}", encodedBytes[ indexOfSigma ] ); - - // Decode bytes back to String*. - // Notice the missing Pi and Sigma characters. - String^ decodedString = ascii->GetString( encodedBytes ); - Console::WriteLine(); - Console::WriteLine( "Decoded bytes:" ); - Console::WriteLine( decodedString ); -} - -/* -This code produces the following output. - -Original string: -This unicode string contains two characters with codes outside the ASCII code range, Pi (Π) and Sigma (Σ). - -Encoded bytes: -[84][104][105][115][32][117][110][105][99][111][100][101][32][115][116][114][105][110][103][32][99][111][110][116][97][105][110][115][32][116][119][111][32][99][104][97][114][97][99][116][101][114][115][32][119][105][116][104][32][99][111][100][101][115][32][111][117][116][115][105][100][101][32][116][104][101][32][65][83][67][73][73][32][99][111][100][101][32][114][97][110][103][101][44][32][80][105][32][40][63][41][32][97][110][100][32][83][105][103][109][97][32][40][63][41][46] - -Value at position of Pi character: 63 -Value at position of Sigma character: 63 - -Decoded bytes: -This unicode string contains two characters with codes outside the ASCII code range, Pi (?) and Sigma (?). - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.BigEndianUnicode/CPP/bigendianunicode.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.BigEndianUnicode/CPP/bigendianunicode.cpp deleted file mode 100644 index 8e692e11ce8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.BigEndianUnicode/CPP/bigendianunicode.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Read a text file saved with Big Endian Unicode encoding. - System::Text::Encoding^ encoding = System::Text::Encoding::BigEndianUnicode; - StreamReader^ reader = gcnew StreamReader( "TextFile.txt",encoding ); - String^ line = reader->ReadLine(); - while ( line != nullptr ) - { - Console::WriteLine( line ); - line = reader->ReadLine(); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.CodePage/CPP/codepage.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.CodePage/CPP/codepage.cpp deleted file mode 100644 index 1c3ea4a7481..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.CodePage/CPP/codepage.cpp +++ /dev/null @@ -1,176 +0,0 @@ - -// The following code example determines the Windows code page that most closely corresponds to each encoding. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Print the header. - Console::Write( "CodePage identifier and name " ); - Console::WriteLine( "WindowsCodePage" ); - - // For every encoding, get the Windows code page for it. - System::Collections::IEnumerator^ myEnum = Encoding::GetEncodings()->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EncodingInfo ^ ei = safe_cast(myEnum->Current); - Encoding^ e = ei->GetEncoding(); - Console::Write( "{0,-6} {1,-25} ", ei->CodePage, ei->Name ); - Console::Write( "{0,-6} ", e->WindowsCodePage ); - - // Mark the ones that are different. - if ( ei->CodePage != e->WindowsCodePage ) - Console::Write( "*" ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -CodePage identifier and name WindowsCodePage -37 IBM037 1252 * -437 IBM437 1252 * -500 IBM500 1252 * -708 ASMO-708 1256 * -720 DOS-720 1256 * -737 ibm737 1253 * -775 ibm775 1257 * -850 ibm850 1252 * -852 ibm852 1250 * -855 IBM855 1252 * -857 ibm857 1254 * -858 IBM00858 1252 * -860 IBM860 1252 * -861 ibm861 1252 * -862 DOS-862 1255 * -863 IBM863 1252 * -864 IBM864 1256 * -865 IBM865 1252 * -866 cp866 1251 * -869 ibm869 1253 * -870 IBM870 1250 * -874 windows-874 874 -875 cp875 1253 * -932 shift_jis 932 -936 gb2312 936 -949 ks_c_5601-1987 949 -950 big5 950 -1026 IBM1026 1254 * -1047 IBM01047 1252 * -1140 IBM01140 1252 * -1141 IBM01141 1252 * -1142 IBM01142 1252 * -1143 IBM01143 1252 * -1144 IBM01144 1252 * -1145 IBM01145 1252 * -1146 IBM01146 1252 * -1147 IBM01147 1252 * -1148 IBM01148 1252 * -1149 IBM01149 1252 * -1200 utf-16 1200 -1201 unicodeFFFE 1200 * -1250 windows-1250 1250 -1251 windows-1251 1251 -1252 Windows-1252 1252 -1253 windows-1253 1253 -1254 windows-1254 1254 -1255 windows-1255 1255 -1256 windows-1256 1256 -1257 windows-1257 1257 -1258 windows-1258 1258 -1361 Johab 949 * -10000 macintosh 1252 * -10001 x-mac-japanese 932 * -10002 x-mac-chinesetrad 950 * -10003 x-mac-korean 949 * -10004 x-mac-arabic 1256 * -10005 x-mac-hebrew 1255 * -10006 x-mac-greek 1253 * -10007 x-mac-cyrillic 1251 * -10008 x-mac-chinesesimp 936 * -10010 x-mac-romanian 1250 * -10017 x-mac-ukrainian 1251 * -10021 x-mac-thai 874 * -10029 x-mac-ce 1250 * -10079 x-mac-icelandic 1252 * -10081 x-mac-turkish 1254 * -10082 x-mac-croatian 1250 * -12000 utf-32 1200 * -12001 utf-32BE 1200 * -20000 x-Chinese-CNS 950 * -20001 x-cp20001 950 * -20002 x-Chinese-Eten 950 * -20003 x-cp20003 950 * -20004 x-cp20004 950 * -20005 x-cp20005 950 * -20105 x-IA5 1252 * -20106 x-IA5-German 1252 * -20107 x-IA5-Swedish 1252 * -20108 x-IA5-Norwegian 1252 * -20127 us-ascii 1252 * -20261 x-cp20261 1252 * -20269 x-cp20269 1252 * -20273 IBM273 1252 * -20277 IBM277 1252 * -20278 IBM278 1252 * -20280 IBM280 1252 * -20284 IBM284 1252 * -20285 IBM285 1252 * -20290 IBM290 932 * -20297 IBM297 1252 * -20420 IBM420 1256 * -20423 IBM423 1253 * -20424 IBM424 1255 * -20833 x-EBCDIC-KoreanExtended 949 * -20838 IBM-Thai 874 * -20866 koi8-r 1251 * -20871 IBM871 1252 * -20880 IBM880 1251 * -20905 IBM905 1254 * -20924 IBM00924 1252 * -20932 EUC-JP 932 * -20936 x-cp20936 936 * -20949 x-cp20949 949 * -21025 cp1025 1251 * -21866 koi8-u 1251 * -28591 iso-8859-1 1252 * -28592 iso-8859-2 1250 * -28593 iso-8859-3 1254 * -28594 iso-8859-4 1257 * -28595 iso-8859-5 1251 * -28596 iso-8859-6 1256 * -28597 iso-8859-7 1253 * -28598 iso-8859-8 1255 * -28599 iso-8859-9 1254 * -28603 iso-8859-13 1257 * -28605 iso-8859-15 1252 * -29001 x-Europa 1252 * -38598 iso-8859-8-i 1255 * -50220 iso-2022-jp 932 * -50221 csISO2022JP 932 * -50222 iso-2022-jp 932 * -50225 iso-2022-kr 949 * -50227 x-cp50227 936 * -51932 euc-jp 932 * -51936 EUC-CN 936 * -51949 euc-kr 949 * -52936 hz-gb-2312 936 * -54936 GB18030 936 * -57002 x-iscii-de 57002 -57003 x-iscii-be 57003 -57004 x-iscii-ta 57004 -57005 x-iscii-te 57005 -57006 x-iscii-as 57006 -57007 x-iscii-or 57007 -57008 x-iscii-ka 57008 -57009 x-iscii-ma 57009 -57010 x-iscii-gu 57010 -57011 x-iscii-pa 57011 -65000 utf-7 1200 * -65001 utf-8 1200 * - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/CPP/convert.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/CPP/convert.cpp deleted file mode 100644 index 90b8851bb09..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/CPP/convert.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -using namespace System::Text; - -int main() -{ - String^ unicodeString = "This string contains the unicode character Pi (\u03a0)"; - - // Create two different encodings. - Encoding^ ascii = Encoding::ASCII; - Encoding^ unicode = Encoding::Unicode; - - // Convert the string into a byte array. - array^unicodeBytes = unicode->GetBytes( unicodeString ); - - // Perform the conversion from one encoding to the other. - array^asciiBytes = Encoding::Convert( unicode, ascii, unicodeBytes ); - - // Convert the new Byte into[] a char and[] then into a string. - array^asciiChars = gcnew array(ascii->GetCharCount( asciiBytes, 0, asciiBytes->Length )); - ascii->GetChars( asciiBytes, 0, asciiBytes->Length, asciiChars, 0 ); - String^ asciiString = gcnew String( asciiChars ); - - // Display the strings created before and after the conversion. - Console::WriteLine( "Original String*: {0}", unicodeString ); - Console::WriteLine( "Ascii converted String*: {0}", asciiString ); -} -// The example displays the following output: -// Original string: This string contains the unicode character Pi (Π) -// Ascii converted string: This string contains the unicode character Pi (?) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Equals/CPP/equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Equals/CPP/equals.cpp deleted file mode 100644 index cfdede118a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Equals/CPP/equals.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// The following code example gets two instances of the same encoding (one by codepage and another by name), and checks their equality. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Get a UTF-32 encoding by codepage. - Encoding^ e1 = Encoding::GetEncoding( 12000 ); - - // Get a UTF-32 encoding by name. - Encoding^ e2 = Encoding::GetEncoding( "utf-32" ); - - // Check their equality. - Console::WriteLine( "e1 equals e2? {0}", e1->Equals( e2 ) ); -} - -/* -This code produces the following output. - -e1 equals e2? True - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp deleted file mode 100644 index b6762b0e360..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -// The following code example determines the number of bytes required to encode a character array, -// encodes the characters, and displays the resulting bytes. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndBytes( array^chars, Encoding^ enc ); -void PrintHexBytes( array^bytes ); -int main() -{ - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // a high-surrogate value (U+D8FF) - // a low-surrogate value (U+DCFF) - array^myChars = gcnew array{ - L'z','a',L'\u0306',L'\u01FD',L'\u03B2',L'\xD8FF',L'\xDCFF' - }; - - // Get different encodings. - Encoding^ u7 = Encoding::UTF7; - Encoding^ u8 = Encoding::UTF8; - Encoding^ u16LE = Encoding::Unicode; - Encoding^ u16BE = Encoding::BigEndianUnicode; - Encoding^ u32 = Encoding::UTF32; - - // Encode the entire array, and print out the counts and the resulting bytes. - PrintCountsAndBytes( myChars, u7 ); - PrintCountsAndBytes( myChars, u8 ); - PrintCountsAndBytes( myChars, u16LE ); - PrintCountsAndBytes( myChars, u16BE ); - PrintCountsAndBytes( myChars, u32 ); -} - -void PrintCountsAndBytes( array^chars, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-30} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( chars ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( chars->Length ); - Console::Write( " {0,-3} :", iMBC ); - - // Encode the array of chars. - array^bytes = enc->GetBytes( chars ); - - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -System.Text.UTF7Encoding : 18 23 :7A 61 2B 41 77 59 42 2F 51 4F 79 32 50 2F 63 2F 77 2D -System.Text.UTF8Encoding : 12 24 :7A 61 CC 86 C7 BD CE B2 F1 8F B3 BF -System.Text.UnicodeEncoding : 14 16 :7A 00 61 00 06 03 FD 01 B2 03 FF D8 FF DC -System.Text.UnicodeEncoding : 14 16 :00 7A 00 61 03 06 01 FD 03 B2 D8 FF DC FF -System.Text.UTF32Encoding : 24 32 :7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00 FF FC 04 00 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArrIC/CPP/getbytes_chararric.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArrIC/CPP/getbytes_chararric.cpp deleted file mode 100644 index 2fd11ecfbd4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArrIC/CPP/getbytes_chararric.cpp +++ /dev/null @@ -1,85 +0,0 @@ - -// The following code example determines the number of bytes required to encode three characters from a character array, -// encodes the characters, and displays the resulting bytes. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndBytes( array^chars, int index, int count, Encoding^ enc ); -void PrintHexBytes( array^bytes ); -int main() -{ - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // a high-surrogate value (U+D8FF) - // a low-surrogate value (U+DCFF) - array^myChars = gcnew array{ - L'z',L'a',L'\u0306',L'\u01FD',L'\u03B2',L'\xD8FF',L'\xDCFF' - }; - - // Get different encodings. - Encoding^ u7 = Encoding::UTF7; - Encoding^ u8 = Encoding::UTF8; - Encoding^ u16LE = Encoding::Unicode; - Encoding^ u16BE = Encoding::BigEndianUnicode; - Encoding^ u32 = Encoding::UTF32; - - // Encode three characters starting at index 4, and print out the counts and the resulting bytes. - PrintCountsAndBytes( myChars, 4, 3, u7 ); - PrintCountsAndBytes( myChars, 4, 3, u8 ); - PrintCountsAndBytes( myChars, 4, 3, u16LE ); - PrintCountsAndBytes( myChars, 4, 3, u16BE ); - PrintCountsAndBytes( myChars, 4, 3, u32 ); -} - -void PrintCountsAndBytes( array^chars, int index, int count, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-30} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( chars, index, count ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( count ); - Console::Write( " {0,-3} :", iMBC ); - - // Encode the array of chars. - array^bytes = enc->GetBytes( chars, index, count ); - - // The following is an alternative way to encode the array of chars: - // byte[] bytes = new byte[iBC]; - // enc.GetBytes( chars, index, count, bytes, bytes.GetLowerBound(0) ); - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -System.Text.UTF7Encoding : 10 11 :2B 41 37 4C 59 2F 39 7A 2F 2D -System.Text.UTF8Encoding : 6 12 :CE B2 F1 8F B3 BF -System.Text.UnicodeEncoding : 6 8 :B2 03 FF D8 FF DC -System.Text.UnicodeEncoding : 6 8 :03 B2 D8 FF DC FF -System.Text.UTF32Encoding : 8 16 :B2 03 00 00 FF FC 04 00 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_String/CPP/getbytes_string.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_String/CPP/getbytes_string.cpp deleted file mode 100644 index bf43b1262a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_String/CPP/getbytes_string.cpp +++ /dev/null @@ -1,121 +0,0 @@ - -// The following code example determines the number of bytes required to encode a string or a range in the string, -// encodes the characters, and displays the resulting bytes. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndBytes( String^ s, Encoding^ enc ); -void PrintCountsAndBytes( String^ s, int index, int count, Encoding^ enc ); -void PrintHexBytes( array^bytes ); -int main() -{ - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // a high-surrogate value (U+D8FF) - // a low-surrogate value (U+DCFF) - String^ myStr = L"za\u0306\u01FD\u03B2\xD8FF\xDCFF"; - - // Get different encodings. - Encoding^ u7 = Encoding::UTF7; - Encoding^ u8 = Encoding::UTF8; - Encoding^ u16LE = Encoding::Unicode; - Encoding^ u16BE = Encoding::BigEndianUnicode; - Encoding^ u32 = Encoding::UTF32; - - // Encode the entire string, and print out the counts and the resulting bytes. - Console::WriteLine( "Encoding the entire string:" ); - PrintCountsAndBytes( myStr, u7 ); - PrintCountsAndBytes( myStr, u8 ); - PrintCountsAndBytes( myStr, u16LE ); - PrintCountsAndBytes( myStr, u16BE ); - PrintCountsAndBytes( myStr, u32 ); - Console::WriteLine(); - - // Encode three characters starting at index 4, and print out the counts and the resulting bytes. - Console::WriteLine( "Encoding the characters from index 4 through 6:" ); - PrintCountsAndBytes( myStr, 4, 3, u7 ); - PrintCountsAndBytes( myStr, 4, 3, u8 ); - PrintCountsAndBytes( myStr, 4, 3, u16LE ); - PrintCountsAndBytes( myStr, 4, 3, u16BE ); - PrintCountsAndBytes( myStr, 4, 3, u32 ); -} - -void PrintCountsAndBytes( String^ s, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-30} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( s ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( s->Length ); - Console::Write( " {0,-3} :", iMBC ); - - // Encode the entire string. - array^bytes = enc->GetBytes( s ); - - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintCountsAndBytes( String^ s, int index, int count, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-30} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( s->ToCharArray(), index, count ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( count ); - Console::Write( " {0,-3} :", iMBC ); - - // Encode a range of characters in the string. - array^bytes = gcnew array(iBC); - enc->GetBytes( s, index, count, bytes, bytes->GetLowerBound( 0 ) ); - - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -Encoding the entire string: -System.Text.UTF7Encoding : 18 23 :7A 61 2B 41 77 59 42 2F 51 4F 79 32 50 2F 63 2F 77 2D -System.Text.UTF8Encoding : 12 24 :7A 61 CC 86 C7 BD CE B2 F1 8F B3 BF -System.Text.UnicodeEncoding : 14 16 :7A 00 61 00 06 03 FD 01 B2 03 FF D8 FF DC -System.Text.UnicodeEncoding : 14 16 :00 7A 00 61 03 06 01 FD 03 B2 D8 FF DC FF -System.Text.UTF32Encoding : 24 32 :7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00 FF FC 04 00 - -Encoding the characters from index 4 through 6: -System.Text.UTF7Encoding : 10 11 :2B 41 37 4C 59 2F 39 7A 2F 2D -System.Text.UTF8Encoding : 6 12 :CE B2 F1 8F B3 BF -System.Text.UnicodeEncoding : 6 8 :B2 03 FF D8 FF DC -System.Text.UnicodeEncoding : 6 8 :03 B2 D8 FF DC FF -System.Text.UTF32Encoding : 8 16 :B2 03 00 00 FF FC 04 00 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetChars/CPP/getchars.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetChars/CPP/getchars.cpp deleted file mode 100644 index 14988aae74c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetChars/CPP/getchars.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -// The following code example encodes a string into an array of bytes, -// and then decodes the bytes into an array of characters. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndChars( array^bytes, Encoding^ enc ); -int main() -{ - - // Create two instances of UTF32Encoding: one with little-endian byte order and one with big-endian byte order. - Encoding^ u32LE = Encoding::GetEncoding( "utf-32" ); - Encoding^ u32BE = Encoding::GetEncoding( "utf-32BE" ); - - // Use a string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - String^ myStr = "za\u0306\u01FD\u03B2"; - - // Encode the string using the big-endian byte order. - array^barrBE = gcnew array(u32BE->GetByteCount( myStr )); - u32BE->GetBytes( myStr, 0, myStr->Length, barrBE, 0 ); - - // Encode the string using the little-endian byte order. - array^barrLE = gcnew array(u32LE->GetByteCount( myStr )); - u32LE->GetBytes( myStr, 0, myStr->Length, barrLE, 0 ); - - // Get the char counts, and decode the byte arrays. - Console::Write( "BE array with BE encoding : " ); - PrintCountsAndChars( barrBE, u32BE ); - Console::Write( "LE array with LE encoding : " ); - PrintCountsAndChars( barrLE, u32LE ); -} - -void PrintCountsAndChars( array^bytes, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-25} :", enc ); - - // Display the exact character count. - int iCC = enc->GetCharCount( bytes ); - Console::Write( " {0,-3}", iCC ); - - // Display the maximum character count. - int iMCC = enc->GetMaxCharCount( bytes->Length ); - Console::Write( " {0,-3} :", iMCC ); - - // Decode the bytes and display the characters. - array^chars = enc->GetChars( bytes ); - Console::WriteLine( chars ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -BE array with BE encoding : System.Text.UTF32Encoding : 5 12 :zăǽβ -LE array with LE encoding : System.Text.UTF32Encoding : 5 12 :zăǽβ - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetCharsIC/CPP/getcharsic.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetCharsIC/CPP/getcharsic.cpp deleted file mode 100644 index 5d42df4246f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetCharsIC/CPP/getcharsic.cpp +++ /dev/null @@ -1,69 +0,0 @@ - -// The following code example encodes a string into an array of bytes, -// and then decodes a range of the bytes into an array of characters. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndChars( array^bytes, int index, int count, Encoding^ enc ); -int main() -{ - - // Create two instances of UTF32Encoding: one with little-endian byte order and one with big-endian byte order. - Encoding^ u32LE = Encoding::GetEncoding( "utf-32" ); - Encoding^ u32BE = Encoding::GetEncoding( "utf-32BE" ); - - // Use a string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - String^ myStr = "za\u0306\u01FD\u03B2"; - - // Encode the string using the big-endian byte order. - array^barrBE = gcnew array(u32BE->GetByteCount( myStr )); - u32BE->GetBytes( myStr, 0, myStr->Length, barrBE, 0 ); - - // Encode the string using the little-endian byte order. - array^barrLE = gcnew array(u32LE->GetByteCount( myStr )); - u32LE->GetBytes( myStr, 0, myStr->Length, barrLE, 0 ); - - // Get the char counts, decode eight bytes starting at index 0, - // and print out the counts and the resulting bytes. - Console::Write( "BE array with BE encoding : " ); - PrintCountsAndChars( barrBE, 0, 8, u32BE ); - Console::Write( "LE array with LE encoding : " ); - PrintCountsAndChars( barrLE, 0, 8, u32LE ); -} - -void PrintCountsAndChars( array^bytes, int index, int count, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-25} :", enc ); - - // Display the exact character count. - int iCC = enc->GetCharCount( bytes, index, count ); - Console::Write( " {0,-3}", iCC ); - - // Display the maximum character count. - int iMCC = enc->GetMaxCharCount( count ); - Console::Write( " {0,-3} :", iMCC ); - - // Decode the bytes and display the characters. - array^chars = enc->GetChars( bytes, index, count ); - - // The following is an alternative way to decode the bytes: - // Char[] chars = new Char[iCC]; - // enc->GetChars( bytes, index, count, chars, 0 ); - Console::WriteLine( chars ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -BE array with BE encoding : System.Text.UTF32Encoding : 2 6 :za -LE array with LE encoding : System.Text.UTF32Encoding : 2 6 :za - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetPreamble Example/CPP/preamble.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetPreamble Example/CPP/preamble.cpp deleted file mode 100644 index 8b3e3c0da25..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetPreamble Example/CPP/preamble.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - Encoding^ unicode = Encoding::Unicode; - - // Get the preamble for the Unicode encoder. - // In this case the preamblecontains the Byte order mark (BOM). - array^preamble = unicode->GetPreamble(); - - // Make sure a preamble was returned - // and is large enough to contain a BOM. - if ( preamble->Length >= 2 ) - { - - // if (preamble->Item[0] == 0xFE && preamble->Item[1] == 0xFF) - if ( preamble[ 0 ] == 0xFE && preamble[ 1 ] == 0xFF ) - { - Console::WriteLine( "The Unicode encoder is encoding in big-endian order." ); - } - // else if (preamble->Item[0] == 0xFF && preamble->Item[1] == 0xFE) - else - - // else if (preamble->Item[0] == 0xFF && preamble->Item[1] == 0xFE) - if ( preamble[ 0 ] == 0xFF && preamble[ 1 ] == 0xFE ) - { - Console::WriteLine( "The Unicode encoder is encoding in little-endian order." ); - } - } -} - -/* -This code produces the following output. - -The Unicode encoder is encoding in little-endian order. - -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp deleted file mode 100644 index 79ba4ed7a77..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp +++ /dev/null @@ -1,173 +0,0 @@ - -// The following code example checks the values of the Boolean properties of each encoding. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Print the header. - Console::Write( "CodePage identifier and name " ); - Console::Write( "BrDisp BrSave " ); - Console::Write( "MNDisp MNSave " ); - Console::WriteLine( "1-Byte ReadOnly " ); - - // For every encoding, get the property values. - System::Collections::IEnumerator^ myEnum = Encoding::GetEncodings()->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EncodingInfo ^ ei = safe_cast(myEnum->Current); - Encoding^ e = ei->GetEncoding(); - Console::Write( "{0,-6} {1,-25} ", ei->CodePage, ei->Name ); - Console::Write( "{0,-8} {1,-8} ", e->IsBrowserDisplay, e->IsBrowserSave ); - Console::Write( "{0,-8} {1,-8} ", e->IsMailNewsDisplay, e->IsMailNewsSave ); - Console::WriteLine( "{0,-8} {1,-8} ", e->IsSingleByte, e->IsReadOnly ); - } -} - -/* -This code produces the following output. - -CodePage identifier and name BrDisp BrSave MNDisp MNSave 1-Byte ReadOnly -37 IBM037 False False False False True True -437 IBM437 False False False False True True -500 IBM500 False False False False True True -708 ASMO-708 True True False False True True -720 DOS-720 True True False False True True -737 ibm737 False False False False True True -775 ibm775 False False False False True True -850 ibm850 False False False False True True -852 ibm852 True True False False True True -855 IBM855 False False False False True True -857 ibm857 False False False False True True -858 IBM00858 False False False False True True -860 IBM860 False False False False True True -861 ibm861 False False False False True True -862 DOS-862 True True False False True True -863 IBM863 False False False False True True -864 IBM864 False False False False True True -865 IBM865 False False False False True True -866 cp866 True True False False True True -869 ibm869 False False False False True True -870 IBM870 False False False False True True -874 windows-874 True True True True True True -875 cp875 False False False False True True -932 shift_jis True True True True False True -936 gb2312 True True True True False True -949 ks_c_5601-1987 True True True True False True -950 big5 True True True True False True -1026 IBM1026 False False False False True True -1047 IBM01047 False False False False True True -1140 IBM01140 False False False False True True -1141 IBM01141 False False False False True True -1142 IBM01142 False False False False True True -1143 IBM01143 False False False False True True -1144 IBM01144 False False False False True True -1145 IBM01145 False False False False True True -1146 IBM01146 False False False False True True -1147 IBM01147 False False False False True True -1148 IBM01148 False False False False True True -1149 IBM01149 False False False False True True -1200 utf-16 False True False False False True -1201 unicodeFFFE False False False False False True -1250 windows-1250 True True True True True True -1251 windows-1251 True True True True True True -1252 Windows-1252 True True True True True True -1253 windows-1253 True True True True True True -1254 windows-1254 True True True True True True -1255 windows-1255 True True True True True True -1256 windows-1256 True True True True True True -1257 windows-1257 True True True True True True -1258 windows-1258 True True True True True True -1361 Johab False False False False False True -10000 macintosh False False False False True True -10001 x-mac-japanese False False False False False True -10002 x-mac-chinesetrad False False False False False True -10003 x-mac-korean False False False False False True -10004 x-mac-arabic False False False False True True -10005 x-mac-hebrew False False False False True True -10006 x-mac-greek False False False False True True -10007 x-mac-cyrillic False False False False True True -10008 x-mac-chinesesimp False False False False False True -10010 x-mac-romanian False False False False True True -10017 x-mac-ukrainian False False False False True True -10021 x-mac-thai False False False False True True -10029 x-mac-ce False False False False True True -10079 x-mac-icelandic False False False False True True -10081 x-mac-turkish False False False False True True -10082 x-mac-croatian False False False False True True -12000 utf-32 False False False False False True -12001 utf-32BE False False False False False True -20000 x-Chinese-CNS False False False False False True -20001 x-cp20001 False False False False False True -20002 x-Chinese-Eten False False False False False True -20003 x-cp20003 False False False False False True -20004 x-cp20004 False False False False False True -20005 x-cp20005 False False False False False True -20105 x-IA5 False False False False True True -20106 x-IA5-German False False False False True True -20107 x-IA5-Swedish False False False False True True -20108 x-IA5-Norwegian False False False False True True -20127 us-ascii False False True True True True -20261 x-cp20261 False False False False False True -20269 x-cp20269 False False False False True True -20273 IBM273 False False False False True True -20277 IBM277 False False False False True True -20278 IBM278 False False False False True True -20280 IBM280 False False False False True True -20284 IBM284 False False False False True True -20285 IBM285 False False False False True True -20290 IBM290 False False False False True True -20297 IBM297 False False False False True True -20420 IBM420 False False False False True True -20423 IBM423 False False False False True True -20424 IBM424 False False False False True True -20833 x-EBCDIC-KoreanExtended False False False False True True -20838 IBM-Thai False False False False True True -20866 koi8-r True True True True True True -20871 IBM871 False False False False True True -20880 IBM880 False False False False True True -20905 IBM905 False False False False True True -20924 IBM00924 False False False False True True -20932 EUC-JP False False False False False True -20936 x-cp20936 False False False False False True -20949 x-cp20949 False False False False False True -21025 cp1025 False False False False True True -21866 koi8-u True True True True True True -28591 iso-8859-1 True True True True True True -28592 iso-8859-2 True True True True True True -28593 iso-8859-3 False False True True True True -28594 iso-8859-4 True True True True True True -28595 iso-8859-5 True True True True True True -28596 iso-8859-6 True True True True True True -28597 iso-8859-7 True True True True True True -28598 iso-8859-8 True True False False True True -28599 iso-8859-9 True True True True True True -28603 iso-8859-13 False False True True True True -28605 iso-8859-15 False True True True True True -29001 x-Europa False False False False True True -38598 iso-8859-8-i True True True True True True -50220 iso-2022-jp False False True True False True -50221 csISO2022JP False True True True False True -50222 iso-2022-jp False False False False False True -50225 iso-2022-kr False False True False False True -50227 x-cp50227 False False False False False True -51932 euc-jp True True True True False True -51936 EUC-CN False False False False False True -51949 euc-kr False False True True False True -52936 hz-gb-2312 True True True True False True -54936 GB18030 True True True True False True -57002 x-iscii-de False False False False False True -57003 x-iscii-be False False False False False True -57004 x-iscii-ta False False False False False True -57005 x-iscii-te False False False False False True -57006 x-iscii-as False False False False False True -57007 x-iscii-or False False False False False True -57008 x-iscii-ka False False False False False True -57009 x-iscii-ma False False False False False True -57010 x-iscii-gu False False False False False True -57011 x-iscii-pa False False False False False True -65001 utf-8 True True True True False True - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp deleted file mode 100644 index 53f98f67454..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -// The following code example retrieves the different names for each encoding -// and displays the encodings with one or more names that are different from EncodingInfo.Name. -// It displays EncodingName but does not compare against it. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Print the header. - Console::Write( "Name " ); - Console::Write( "CodePage " ); - Console::Write( "BodyName " ); - Console::Write( "HeaderName " ); - Console::Write( "WebName " ); - Console::WriteLine( "Encoding.EncodingName" ); - - // For every encoding, compare the name properties with EncodingInfo.Name. - // Display only the encodings that have one or more different names. - System::Collections::IEnumerator^ myEnum = Encoding::GetEncodings()->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EncodingInfo ^ ei = safe_cast(myEnum->Current); - Encoding^ e = ei->GetEncoding(); - if ( !ei->Name->Equals( e->BodyName ) || !ei->Name->Equals( e->HeaderName ) || !ei->Name->Equals( e->WebName ) ) - { - Console::Write( "{0,-18} ", ei->Name ); - Console::Write( "{0,-9} ", e->CodePage ); - Console::Write( "{0,-18} ", e->BodyName ); - Console::Write( "{0,-18} ", e->HeaderName ); - Console::Write( "{0,-18} ", e->WebName ); - Console::WriteLine( "{0} ", e->EncodingName ); - } - } -} - -/* -This code produces the following output. - -Name CodePage BodyName HeaderName WebName Encoding.EncodingName -shift_jis 932 iso-2022-jp iso-2022-jp shift_jis Japanese (Shift-JIS) -windows-1250 1250 iso-8859-2 windows-1250 windows-1250 Central European (Windows) -windows-1251 1251 koi8-r windows-1251 windows-1251 Cyrillic (Windows) -Windows-1252 1252 iso-8859-1 Windows-1252 Windows-1252 Western European (Windows) -windows-1253 1253 iso-8859-7 windows-1253 windows-1253 Greek (Windows) -windows-1254 1254 iso-8859-9 windows-1254 windows-1254 Turkish (Windows) -csISO2022JP 50221 iso-2022-jp iso-2022-jp csISO2022JP Japanese (JIS-Allow 1 byte Kana) -iso-2022-kr 50225 iso-2022-kr euc-kr iso-2022-kr Korean (ISO) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.WebName/CPP/webname.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.WebName/CPP/webname.cpp deleted file mode 100644 index 7b3357371c8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.WebName/CPP/webname.cpp +++ /dev/null @@ -1,39 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Web; -int main() -{ - - // Use UTF8 encoding. - Encoding^ encoding = Encoding::UTF8; - StreamWriter^ writer = gcnew StreamWriter( "Encoding.html",false,encoding ); - writer->WriteLine( "" ); - - // Write charset attribute to the html file. - // writer -> WriteLine(S""); - writer->WriteLine( String::Concat( "" ) ); - writer->WriteLine( "" ); - writer->WriteLine( "

{0}

", HttpUtility::HtmlEncode( encoding->EncodingName ) ); - writer->WriteLine( "" ); - writer->Flush(); - writer->Close(); -} - -/* -This code produces the following output in an HTML file. - - - - -

Unicode (UTF-8)

- - -*/ -//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp deleted file mode 100644 index 60ac3dd0f2b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp +++ /dev/null @@ -1,188 +0,0 @@ - -// The following code example retrieves the different names for each encoding -// and compares them with the equivalent Encoding names. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Print the header. - Console::Write( "Info.CodePage " ); - Console::Write( "Info.Name " ); - Console::Write( "Info.DisplayName" ); - Console::WriteLine(); - - // Display the EncodingInfo names for every encoding, and compare with the equivalent Encoding names. - System::Collections::IEnumerator^ myEnum = Encoding::GetEncodings()->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - EncodingInfo ^ ei = safe_cast(myEnum->Current); - Encoding^ e = ei->GetEncoding(); - Console::Write( "{0,-15}", ei->CodePage ); - if ( ei->CodePage == e->CodePage ) - Console::Write( " " ); - else - Console::Write( "*** " ); - Console::Write( "{0,-25}", ei->Name ); - if ( ei->CodePage == e->CodePage ) - Console::Write( " " ); - else - Console::Write( "*** " ); - Console::Write( "{0,-25}", ei->DisplayName ); - if ( ei->CodePage == e->CodePage ) - Console::Write( " " ); - else - Console::Write( "*** " ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -Info.CodePage Info.Name Info.DisplayName -37 IBM037 IBM EBCDIC (US-Canada) -437 IBM437 OEM United States -500 IBM500 IBM EBCDIC (International) -708 ASMO-708 Arabic (ASMO 708) -720 DOS-720 Arabic (DOS) -737 ibm737 Greek (DOS) -775 ibm775 Baltic (DOS) -850 ibm850 Western European (DOS) -852 ibm852 Central European (DOS) -855 IBM855 OEM Cyrillic -857 ibm857 Turkish (DOS) -858 IBM00858 OEM Multilingual Latin I -860 IBM860 Portuguese (DOS) -861 ibm861 Icelandic (DOS) -862 DOS-862 Hebrew (DOS) -863 IBM863 French Canadian (DOS) -864 IBM864 Arabic (864) -865 IBM865 Nordic (DOS) -866 cp866 Cyrillic (DOS) -869 ibm869 Greek, Modern (DOS) -870 IBM870 IBM EBCDIC (Multilingual Latin-2) -874 windows-874 Thai (Windows) -875 cp875 IBM EBCDIC (Greek Modern) -932 shift_jis Japanese (Shift-JIS) -936 gb2312 Chinese Simplified (GB2312) -949 ks_c_5601-1987 Korean -950 big5 Chinese Traditional (Big5) -1026 IBM1026 IBM EBCDIC (Turkish Latin-5) -1047 IBM01047 IBM Latin-1 -1140 IBM01140 IBM EBCDIC (US-Canada-Euro) -1141 IBM01141 IBM EBCDIC (Germany-Euro) -1142 IBM01142 IBM EBCDIC (Denmark-Norway-Euro) -1143 IBM01143 IBM EBCDIC (Finland-Sweden-Euro) -1144 IBM01144 IBM EBCDIC (Italy-Euro) -1145 IBM01145 IBM EBCDIC (Spain-Euro) -1146 IBM01146 IBM EBCDIC (UK-Euro) -1147 IBM01147 IBM EBCDIC (France-Euro) -1148 IBM01148 IBM EBCDIC (International-Euro) -1149 IBM01149 IBM EBCDIC (Icelandic-Euro) -1200 utf-16 Unicode -1201 unicodeFFFE Unicode (Big-Endian) -1250 windows-1250 Central European (Windows) -1251 windows-1251 Cyrillic (Windows) -1252 Windows-1252 Western European (Windows) -1253 windows-1253 Greek (Windows) -1254 windows-1254 Turkish (Windows) -1255 windows-1255 Hebrew (Windows) -1256 windows-1256 Arabic (Windows) -1257 windows-1257 Baltic (Windows) -1258 windows-1258 Vietnamese (Windows) -1361 Johab Korean (Johab) -10000 macintosh Western European (Mac) -10001 x-mac-japanese Japanese (Mac) -10002 x-mac-chinesetrad Chinese Traditional (Mac) -10003 x-mac-korean Korean (Mac) -10004 x-mac-arabic Arabic (Mac) -10005 x-mac-hebrew Hebrew (Mac) -10006 x-mac-greek Greek (Mac) -10007 x-mac-cyrillic Cyrillic (Mac) -10008 x-mac-chinesesimp Chinese Simplified (Mac) -10010 x-mac-romanian Romanian (Mac) -10017 x-mac-ukrainian Ukrainian (Mac) -10021 x-mac-thai Thai (Mac) -10029 x-mac-ce Central European (Mac) -10079 x-mac-icelandic Icelandic (Mac) -10081 x-mac-turkish Turkish (Mac) -10082 x-mac-croatian Croatian (Mac) -12000 utf-32 Unicode (UTF-32) -12001 utf-32BE Unicode (UTF-32 Big-Endian) -20000 x-Chinese-CNS Chinese Traditional (CNS) -20001 x-cp20001 TCA Taiwan -20002 x-Chinese-Eten Chinese Traditional (Eten) -20003 x-cp20003 IBM5550 Taiwan -20004 x-cp20004 TeleText Taiwan -20005 x-cp20005 Wang Taiwan -20105 x-IA5 Western European (IA5) -20106 x-IA5-German German (IA5) -20107 x-IA5-Swedish Swedish (IA5) -20108 x-IA5-Norwegian Norwegian (IA5) -20127 us-ascii US-ASCII -20261 x-cp20261 T.61 -20269 x-cp20269 ISO-6937 -20273 IBM273 IBM EBCDIC (Germany) -20277 IBM277 IBM EBCDIC (Denmark-Norway) -20278 IBM278 IBM EBCDIC (Finland-Sweden) -20280 IBM280 IBM EBCDIC (Italy) -20284 IBM284 IBM EBCDIC (Spain) -20285 IBM285 IBM EBCDIC (UK) -20290 IBM290 IBM EBCDIC (Japanese katakana) -20297 IBM297 IBM EBCDIC (France) -20420 IBM420 IBM EBCDIC (Arabic) -20423 IBM423 IBM EBCDIC (Greek) -20424 IBM424 IBM EBCDIC (Hebrew) -20833 x-EBCDIC-KoreanExtended IBM EBCDIC (Korean Extended) -20838 IBM-Thai IBM EBCDIC (Thai) -20866 koi8-r Cyrillic (KOI8-R) -20871 IBM871 IBM EBCDIC (Icelandic) -20880 IBM880 IBM EBCDIC (Cyrillic Russian) -20905 IBM905 IBM EBCDIC (Turkish) -20924 IBM00924 IBM Latin-1 -20932 EUC-JP Japanese (JIS 0208-1990 and 0212-1990) -20936 x-cp20936 Chinese Simplified (GB2312-80) -20949 x-cp20949 Korean Wansung -21025 cp1025 IBM EBCDIC (Cyrillic Serbian-Bulgarian) -21866 koi8-u Cyrillic (KOI8-U) -28591 iso-8859-1 Western European (ISO) -28592 iso-8859-2 Central European (ISO) -28593 iso-8859-3 Latin 3 (ISO) -28594 iso-8859-4 Baltic (ISO) -28595 iso-8859-5 Cyrillic (ISO) -28596 iso-8859-6 Arabic (ISO) -28597 iso-8859-7 Greek (ISO) -28598 iso-8859-8 Hebrew (ISO-Visual) -28599 iso-8859-9 Turkish (ISO) -28603 iso-8859-13 Estonian (ISO) -28605 iso-8859-15 Latin 9 (ISO) -29001 x-Europa Europa -38598 iso-8859-8-i Hebrew (ISO-Logical) -50220 iso-2022-jp Japanese (JIS) -50221 csISO2022JP Japanese (JIS-Allow 1 byte Kana) -50222 iso-2022-jp Japanese (JIS-Allow 1 byte Kana - SO/SI) -50225 iso-2022-kr Korean (ISO) -50227 x-cp50227 Chinese Simplified (ISO-2022) -51932 euc-jp Japanese (EUC) -51936 EUC-CN Chinese Simplified (EUC) -51949 euc-kr Korean (EUC) -52936 hz-gb-2312 Chinese Simplified (HZ) -54936 GB18030 Chinese Simplified (GB18030) -57002 x-iscii-de ISCII Devanagari -57003 x-iscii-be ISCII Bengali -57004 x-iscii-ta ISCII Tamil -57005 x-iscii-te ISCII Telugu -57006 x-iscii-as ISCII Assamese -57007 x-iscii-or ISCII Oriya -57008 x-iscii-ka ISCII Kannada -57009 x-iscii-ma ISCII Malayalam -57010 x-iscii-gu ISCII Gujarati -57011 x-iscii-pa ISCII Punjabi -65000 utf-7 Unicode (UTF-7) -65001 utf-8 Unicode (UTF-8) - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp deleted file mode 100644 index b70e9f7092d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// This sample demonstrates how to use each member of the StringBuilder class. -// -using namespace System; -using namespace System::Text; - -ref class Constructors -{ -public: - static void Main() - { - ConstructorWithNothing(); - ConstructorWithCapacity(); - ConstructorWithString(); - ConstructorWithCapacityAndMax(); - ConstructorWithSubstring(); - ConstructorWithStringAndMax(); - - Console::Write( L"This sample completed successfully; " ); - Console::WriteLine( L"press Enter to exit." ); - Console::ReadLine(); - } - -private: - static void ConstructorWithNothing() - { - // Initialize a new StringBuilder object. - // - StringBuilder^ stringBuilder = gcnew StringBuilder; - // - } - - static void ConstructorWithCapacity() - { - // Initialize a new StringBuilder object with the specified capacity. - // - int capacity = 255; - StringBuilder^ stringBuilder = gcnew StringBuilder( capacity ); - // - } - - static void ConstructorWithString() - { - // Initialize a new StringBuilder object with the specified string. - // - String^ initialString = L"Initial string."; - StringBuilder^ stringBuilder = gcnew StringBuilder( initialString ); - // - } - - static void ConstructorWithCapacityAndMax() - { - // Initialize a new StringBuilder object with the specified capacity - // and maximum capacity. - // - int capacity = 255; - int maxCapacity = 1024; - StringBuilder^ stringBuilder = gcnew StringBuilder( capacity,maxCapacity ); - // - } - - static void ConstructorWithSubstring() - { - // Initialize a new StringBuilder object with the specified substring. - // - String^ initialString = L"Initial string for stringbuilder."; - int startIndex = 0; - int substringLength = 14; - int capacity = 255; - StringBuilder^ stringBuilder = gcnew StringBuilder( - initialString,startIndex,substringLength,capacity ); - // - } - - static void ConstructorWithStringAndMax() - { - // Initialize a new StringBuilder object with the specified string - // and maximum capacity. - // - String^ initialString = L"Initial string. "; - int capacity = 255; - StringBuilder^ stringBuilder = gcnew StringBuilder( - initialString,capacity ); - // - - // Ensure that appending the specified string will not exceed the - // maximum capacity of the object. - // - String^ phraseToAdd = L"Sentence to be appended."; - if ( (stringBuilder->Length + phraseToAdd->Length) <= - stringBuilder->MaxCapacity ) - { - stringBuilder->Append( phraseToAdd ); - } - // - - // Retrieve the string value of the StringBuilder object. - // - String^ builderResults = stringBuilder->ToString(); - // - - // Retrieve the last 10 characters of the StringBuilder object. - // - int sentenceLength = 10; - int startPosition = stringBuilder->Length - sentenceLength; - String^ endPhrase = stringBuilder->ToString( startPosition, - sentenceLength ); - // - - // Retrieve the last character of the StringBuilder object. - // - int lastCharacterPosition = stringBuilder->Length - 1; - char lastCharacter = static_cast( - stringBuilder->default[ lastCharacterPosition ] ); - // - } -}; - -int main() -{ - Constructors::Main(); -} - -// -// This sample produces the following output: -// -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/CPP/encdec.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/CPP/encdec.cpp deleted file mode 100644 index 86fc73cb09c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/CPP/encdec.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// The following code example uses an encoder and a decoder to encode a string into an array of bytes, -// and then decode the bytes into an array of characters. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Get an encoder and a decoder from UTF32Encoding. - UTF32Encoding ^ u32 = gcnew UTF32Encoding( false,true,true ); - Encoder^ myEnc = u32->GetEncoder(); - Decoder^ myDec = u32->GetDecoder(); - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - array^myChars = gcnew array(5){ - L'z',L'a',L'\u0306',L'\u01FD',L'\u03B2' - }; - Console::Write( "The original characters : " ); - Console::WriteLine( myChars ); - - // Encode the character array. - int iBC = myEnc->GetByteCount( myChars, 0, myChars.Length, true ); - array^myBytes = gcnew array(iBC); - myEnc->GetBytes( myChars, 0, myChars.Length, myBytes, 0, true ); - - // Print the resulting bytes. - Console::Write( "Using the encoder : " ); - for ( int i = 0; i < myBytes.Length; i++ ) - Console::Write( "{0:X2} ", myBytes[ i ] ); - Console::WriteLine(); - - // Decode the byte array back into an array of characters. - int iCC = myDec->GetCharCount( myBytes, 0, myBytes.Length, true ); - array^myDecodedChars = gcnew array(iCC); - myDec->GetChars( myBytes, 0, myBytes.Length, myDecodedChars, 0, true ); - - // Print the resulting characters. - Console::Write( "Using the decoder : " ); - Console::WriteLine( myDecodedChars ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -The original characters : za?? -Using the encoder : 7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00 -Using the decoder : za?? - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.Equals/CPP/equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.Equals/CPP/equals.cpp deleted file mode 100644 index a627b7388d4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.Equals/CPP/equals.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -// The following code example creates instances of the UTF32Encoding class using different parameter values and then checks them for equality. -// -using namespace System; -using namespace System::Text; -void CompareEncodings( UTF32Encoding ^ a, String^ name ); -int main() -{ - - // Create different instances of UTF32Encoding. - UTF32Encoding ^ u32 = gcnew UTF32Encoding; - UTF32Encoding ^ u32tt = gcnew UTF32Encoding( true,true ); - UTF32Encoding ^ u32tf = gcnew UTF32Encoding( true,false ); - UTF32Encoding ^ u32ft = gcnew UTF32Encoding( false,true ); - UTF32Encoding ^ u32ff = gcnew UTF32Encoding( false,false ); - - // Compare these instances with instances created using the ctor with three parameters. - CompareEncodings( u32, "u32 " ); - CompareEncodings( u32tt, "u32tt" ); - CompareEncodings( u32tf, "u32tf" ); - CompareEncodings( u32ft, "u32ft" ); - CompareEncodings( u32ff, "u32ff" ); -} - -void CompareEncodings( UTF32Encoding ^ a, String^ name ) -{ - - // Create different instances of UTF32Encoding using the ctor with three parameters. - UTF32Encoding ^ u32ttt = gcnew UTF32Encoding( true,true,true ); - UTF32Encoding ^ u32ttf = gcnew UTF32Encoding( true,true,false ); - UTF32Encoding ^ u32tft = gcnew UTF32Encoding( true,false,true ); - UTF32Encoding ^ u32tff = gcnew UTF32Encoding( true,false,false ); - UTF32Encoding ^ u32ftt = gcnew UTF32Encoding( false,true,true ); - UTF32Encoding ^ u32ftf = gcnew UTF32Encoding( false,true,false ); - UTF32Encoding ^ u32fft = gcnew UTF32Encoding( false,false,true ); - UTF32Encoding ^ u32fff = gcnew UTF32Encoding( false,false,false ); - - // Compare the specified instance with each of the instances that were just created. - Console::WriteLine( "{0} and u32ttt : {1}", name, a->Equals( u32ttt ) ); - Console::WriteLine( "{0} and u32ttf : {1}", name, a->Equals( u32ttf ) ); - Console::WriteLine( "{0} and u32tft : {1}", name, a->Equals( u32tft ) ); - Console::WriteLine( "{0} and u32tff : {1}", name, a->Equals( u32tff ) ); - Console::WriteLine( "{0} and u32ftt : {1}", name, a->Equals( u32ftt ) ); - Console::WriteLine( "{0} and u32ftf : {1}", name, a->Equals( u32ftf ) ); - Console::WriteLine( "{0} and u32fft : {1}", name, a->Equals( u32fft ) ); - Console::WriteLine( "{0} and u32fff : {1}", name, a->Equals( u32fff ) ); -} - -/* -This code produces the following output. - -u32 vs u32ttt : False -u32 vs u32ttf : False -u32 vs u32tft : False -u32 vs u32tff : False -u32 vs u32ftt : False -u32 vs u32ftf : False -u32 vs u32fft : False -u32 vs u32fff : True -u32tt vs u32ttt : False -u32tt vs u32ttf : True -u32tt vs u32tft : False -u32tt vs u32tff : False -u32tt vs u32ftt : False -u32tt vs u32ftf : False -u32tt vs u32fft : False -u32tt vs u32fff : False -u32tf vs u32ttt : False -u32tf vs u32ttf : False -u32tf vs u32tft : False -u32tf vs u32tff : True -u32tf vs u32ftt : False -u32tf vs u32ftf : False -u32tf vs u32fft : False -u32tf vs u32fff : False -u32ft vs u32ttt : False -u32ft vs u32ttf : False -u32ft vs u32tft : False -u32ft vs u32tff : False -u32ft vs u32ftt : False -u32ft vs u32ftf : True -u32ft vs u32fft : False -u32ft vs u32fff : False -u32ff vs u32ttt : False -u32ff vs u32ttf : False -u32ff vs u32tft : False -u32ff vs u32tff : False -u32ff vs u32ftt : False -u32ff vs u32ftf : False -u32ff vs u32fft : False -u32ff vs u32fff : True - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/CPP/errordetection.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/CPP/errordetection.cpp deleted file mode 100644 index c1436193d7b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/CPP/errordetection.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// The following code example demonstrates the behavior of UTF32Encoding with error detection enabled and without. -// -using namespace System; -using namespace System::Text; -void PrintDecodedString( array^bytes, Encoding^ enc ); -int main() -{ - - // Create an instance of UTF32Encoding using little-endian byte order. - // This will be used for encoding. - UTF32Encoding^ u32LE = gcnew UTF32Encoding( false,true ); - - // Create two instances of UTF32Encoding using big-endian byte order: one with error detection and one without. - // These will be used for decoding. - UTF32Encoding^ u32withED = gcnew UTF32Encoding( true,true,true ); - UTF32Encoding^ u32noED = gcnew UTF32Encoding( true,true,false ); - - // Create byte arrays from the same string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - String^ myStr = L"za\u0306\u01FD\u03B2\xD8FF\xDCFF"; - - // Encode the string using little-endian byte order. - array^myBytes = gcnew array(u32LE->GetByteCount( myStr )); - u32LE->GetBytes( myStr, 0, myStr->Length, myBytes, 0 ); - - // Decode the byte array with error detection. - Console::WriteLine( "Decoding with error detection:" ); - PrintDecodedString( myBytes, u32withED ); - - // Decode the byte array without error detection. - Console::WriteLine( "Decoding without error detection:" ); - PrintDecodedString( myBytes, u32noED ); -} - - -// Decode the bytes and display the string. -void PrintDecodedString( array^bytes, Encoding^ enc ) -{ - try - { - Console::WriteLine( " Decoded string: {0}", enc->GetString( bytes, 0, bytes->Length ) ); - } - catch ( System::ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - Console::WriteLine(); -} - -// -/* -This code produces the following output. - -Decoding with error detection: -System.ArgumentException: Invalid byte was found at byte index 3. - at System.Text.UTF32Encoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS baseDecoder) - at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encoding) - at System.Text.UTF32Encoding.GetString(Byte[] bytes, Int32 index, Int32 count) - at SamplesUTF32Encoding.PrintDecodedString(Byte[] bytes, Encoding enc) - -Decoding without error detection: - Decoded string: - -*/ diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp deleted file mode 100644 index 019b60c8871..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp +++ /dev/null @@ -1,87 +0,0 @@ - -// The following code example determines the number of bytes required to encode three characters from a character array, -// then encodes the characters and displays the resulting bytes. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndBytes( array^chars, int index, int count, Encoding^ enc ); -void PrintHexBytes( array^bytes ); -int main() -{ - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // a high-surrogate value (U+D8FF) - // a low-surrogate value (U+DCFF) - array^myChars = gcnew array(7){ - L'z',L'a',L'\u0306',L'\u01FD',L'\u03B2',L'\xD8FF',L'\xDCFF' - }; - - // Create instances of different encodings. - UTF7Encoding^ u7 = gcnew UTF7Encoding; - UTF8Encoding^ u8Nobom = gcnew UTF8Encoding( false,true ); - UTF8Encoding^ u8Bom = gcnew UTF8Encoding( true,true ); - UTF32Encoding ^ u32Nobom = gcnew UTF32Encoding( false,false,true ); - UTF32Encoding ^ u32Bom = gcnew UTF32Encoding( false,true,true ); - - // Encode three characters starting at index 4 and print out the counts and the resulting bytes. - PrintCountsAndBytes( myChars, 4, 3, u7 ); - PrintCountsAndBytes( myChars, 4, 3, u8Nobom ); - PrintCountsAndBytes( myChars, 4, 3, u8Bom ); - PrintCountsAndBytes( myChars, 4, 3, u32Nobom ); - PrintCountsAndBytes( myChars, 4, 3, u32Bom ); -} - -void PrintCountsAndBytes( array^chars, int index, int count, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-25} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( chars, index, count ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( count ); - Console::Write( " {0,-3} :", iMBC ); - - // Get the byte order mark, if any. - array^preamble = enc->GetPreamble(); - - // Combine the preamble and the encoded bytes. - array^bytes = gcnew array(preamble->Length + iBC); - Array::Copy( preamble, bytes, preamble->Length ); - enc->GetBytes( chars, index, count, bytes, preamble->Length ); - - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -System.Text.UTF7Encoding : 10 11 :2B 41 37 4C 59 2F 39 7A 2F 2D -System.Text.UTF8Encoding : 6 12 :CE B2 F1 8F B3 BF -System.Text.UTF8Encoding : 6 12 :EF BB BF CE B2 F1 8F B3 BF -System.Text.UTF32Encoding : 8 12 :B2 03 00 00 FF FC 04 00 -System.Text.UTF32Encoding : 8 12 :FF FE 00 00 B2 03 00 00 FF FC 04 00 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/CPP/getbytes_string.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/CPP/getbytes_string.cpp deleted file mode 100644 index d554ef4eb8b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/CPP/getbytes_string.cpp +++ /dev/null @@ -1,85 +0,0 @@ - -// The following code example determines the number of bytes required to encode a string, -// then encodes the string and displays the resulting bytes. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndBytes( String^ s, Encoding^ enc ); -void PrintHexBytes( array^bytes ); -int main() -{ - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // a high-surrogate value (U+D8FF) - // a low-surrogate value (U+DCFF) - String^ myStr = L"za\u0306\u01FD\u03B2\xD8FF\xDCFF"; - - // Create instances of different encodings. - UTF7Encoding^ u7 = gcnew UTF7Encoding; - UTF8Encoding^ u8Nobom = gcnew UTF8Encoding( false,true ); - UTF8Encoding^ u8Bom = gcnew UTF8Encoding( true,true ); - UTF32Encoding ^ u32Nobom = gcnew UTF32Encoding( false,false,true ); - UTF32Encoding ^ u32Bom = gcnew UTF32Encoding( false,true,true ); - - // Get the byte counts and the bytes. - PrintCountsAndBytes( myStr, u7 ); - PrintCountsAndBytes( myStr, u8Nobom ); - PrintCountsAndBytes( myStr, u8Bom ); - PrintCountsAndBytes( myStr, u32Nobom ); - PrintCountsAndBytes( myStr, u32Bom ); -} - -void PrintCountsAndBytes( String^ s, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-25} :", enc ); - - // Display the exact byte count. - int iBC = enc->GetByteCount( s ); - Console::Write( " {0,-3}", iBC ); - - // Display the maximum byte count. - int iMBC = enc->GetMaxByteCount( s->Length ); - Console::Write( " {0,-3} :", iMBC ); - - // Get the byte order mark, if any. - array^preamble = enc->GetPreamble(); - - // Combine the preamble and the encoded bytes. - array^bytes = gcnew array(preamble->Length + iBC); - Array::Copy( preamble, bytes, preamble->Length ); - enc->GetBytes( s, 0, s->Length, bytes, preamble->Length ); - - // Display all the encoded bytes. - PrintHexBytes( bytes ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This code produces the following output. - -System.Text.UTF7Encoding : 18 23 :7A 61 2B 41 77 59 42 2F 51 4F 79 32 50 2F 63 2F 77 2D -System.Text.UTF8Encoding : 12 24 :7A 61 CC 86 C7 BD CE B2 F1 8F B3 BF -System.Text.UTF8Encoding : 12 24 :EF BB BF 7A 61 CC 86 C7 BD CE B2 F1 8F B3 BF -System.Text.UTF32Encoding : 24 28 :7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00 FF FC 04 00 -System.Text.UTF32Encoding : 24 28 :FF FE 00 00 7A 00 00 00 61 00 00 00 06 03 00 00 FD 01 00 00 B2 03 00 00 FF FC 04 00 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp deleted file mode 100644 index beeadd8f48b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp +++ /dev/null @@ -1,88 +0,0 @@ - -// The following code example encodes a string into an array of bytes, and then decodes the bytes into an array of characters. -// -using namespace System; -using namespace System::Text; -void PrintCountsAndChars( array^bytes, Encoding^ enc ); -int main() -{ - - // Create two instances of UTF32Encoding: one with little-endian byte order and one with big-endian byte order. - UTF32Encoding^ u32LE = gcnew UTF32Encoding( false,true,true ); - UTF32Encoding^ u32BE = gcnew UTF32Encoding( true,true,true ); - - // Create byte arrays from the same string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - String^ myStr = L"za\u0306\u01FD\u03B2\xD8FF\xDCFF"; - - // barrBE uses the big-endian byte order. - array^barrBE = gcnew array(u32BE->GetByteCount( myStr )); - u32BE->GetBytes( myStr, 0, myStr->Length, barrBE, 0 ); - - // barrLE uses the little-endian byte order. - array^barrLE = gcnew array(u32LE->GetByteCount( myStr )); - u32LE->GetBytes( myStr, 0, myStr->Length, barrLE, 0 ); - - // Get the char counts and decode the byte arrays. - Console::Write( "BE array with BE encoding : " ); - PrintCountsAndChars( barrBE, u32BE ); - Console::Write( "LE array with LE encoding : " ); - PrintCountsAndChars( barrLE, u32LE ); - - // Decode the byte arrays using an encoding with a different byte order. - Console::Write( "BE array with LE encoding : " ); - try - { - PrintCountsAndChars( barrBE, u32LE ); - } - catch ( System::ArgumentException^ e ) - { - Console::WriteLine( e->Message ); - } - - Console::Write( "LE array with BE encoding : " ); - try - { - PrintCountsAndChars( barrLE, u32BE ); - } - catch ( System::ArgumentException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -void PrintCountsAndChars( array^bytes, Encoding^ enc ) -{ - - // Display the name of the encoding used. - Console::Write( "{0,-25} :", enc ); - - // Display the exact character count. - int iCC = enc->GetCharCount( bytes ); - Console::Write( " {0,-3}", iCC ); - - // Display the maximum character count. - int iMCC = enc->GetMaxCharCount( bytes->Length ); - Console::Write( " {0,-3} :", iMCC ); - - // Decode the bytes and display the characters. - array^chars = gcnew array(iCC); - enc->GetChars( bytes, 0, bytes->Length, chars, 0 ); - Console::WriteLine( chars ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -BE array with BE encoding : System.Text.UTF32Encoding : 7 14 :za??? -LE array with LE encoding : System.Text.UTF32Encoding : 7 14 :za??? -BE array with LE encoding : System.Text.UTF32Encoding :Invalid byte was found at byte index 3. -LE array with BE encoding : System.Text.UTF32Encoding :Invalid byte was found at byte index 3. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp deleted file mode 100644 index 9d05673135c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// The following code example retrieves and displays the byte order mark for different UTF32Encoding instances. -// -using namespace System; -using namespace System::Text; - -void PrintHexBytes( array^bytes ); - -int main() -{ - - // Create instances of UTF32Encoding, with the byte order mark and without. - UTF32Encoding ^ u32LeNone = gcnew UTF32Encoding; - UTF32Encoding ^ u32BeNone = gcnew UTF32Encoding( true,false ); - UTF32Encoding ^ u32LeBom = gcnew UTF32Encoding( false,true ); - UTF32Encoding ^ u32BeBom = gcnew UTF32Encoding( true,true ); - - // Display the preamble for each instance. - PrintHexBytes( u32LeNone->GetPreamble() ); - PrintHexBytes( u32BeNone->GetPreamble() ); - PrintHexBytes( u32LeBom->GetPreamble() ); - PrintHexBytes( u32BeBom->GetPreamble() ); -} - -void PrintHexBytes( array^bytes ) -{ - if ( (bytes == nullptr) || (bytes->Length == 0) ) - Console::WriteLine( "" ); - else - { - for ( int i = 0; i < bytes->Length; i++ ) - Console::Write( "{0:X2} ", bytes[ i ] ); - Console::WriteLine(); - } -} - -/* -This example displays the following output: - FF FE 00 00 - - FF FE 00 00 - 00 00 FE FF -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding Example/CPP/snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding Example/CPP/snippet.cpp deleted file mode 100644 index c84f8ce2a84..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding Example/CPP/snippet.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - - // Create a UTF-7 encoding. - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - - // A Unicode string with two characters outside a 7-bit code range. - String^ unicodeString = L"This Unicode string contains two characters with codes outside a 7-bit code range, Pi (\u03a0) and Sigma (\u03a3)."; - Console::WriteLine( "Original string:" ); - Console::WriteLine( unicodeString ); - - // Encode the string. - array^encodedBytes = utf7->GetBytes( unicodeString ); - Console::WriteLine(); - Console::WriteLine( "Encoded bytes:" ); - IEnumerator^ myEnum = encodedBytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); - - // Decode bytes back to string. - // Notice Pi and Sigma characters are still present. - String^ decodedString = utf7->GetString( encodedBytes ); - Console::WriteLine(); - Console::WriteLine( "Decoded bytes:" ); - Console::WriteLine( decodedString ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp deleted file mode 100644 index ddc015fa0f3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - int byteCount = utf7->GetByteCount( chars, 1, 2 ); - Console::WriteLine( "{0} bytes needed to encode characters.", byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 97b50574c01..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - int byteCount = utf7->GetByteCount( chars, 1, 2 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = utf7->GetBytes( chars, 1, 2, bytes, 0 ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp deleted file mode 100644 index b5e8fc2023a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {85,84,70,55,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101}; - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - int charCount = utf7->GetCharCount( bytes, 2, 8 ); - chars = gcnew array(charCount); - int charsDecodedCount = utf7->GetChars( bytes, 2, 8, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetDecoder Example/CPP/getdecoder-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetDecoder Example/CPP/getdecoder-.cpp deleted file mode 100644 index 7fb0ea443fe..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetDecoder Example/CPP/getdecoder-.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {99,43,65,119,67,103,111,65,45}; - Decoder^ utf7Decoder = Encoding::UTF7->GetDecoder(); - int charCount = utf7Decoder->GetCharCount( bytes, 0, bytes->Length ); - chars = gcnew array(charCount); - int charsDecodedCount = utf7Decoder->GetChars( bytes, 0, bytes->Length, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetEncoder Example/CPP/getencoder-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetEncoder Example/CPP/getencoder-.cpp deleted file mode 100644 index 60c28256953..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetEncoder Example/CPP/getencoder-.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars = {'a','b','c',L'\u0300',L'\ua0a0'}; - array^bytes; - Encoder^ utf7Encoder = Encoding::UTF7->GetEncoder(); - int byteCount = utf7Encoder->GetByteCount( chars, 2, 3, true ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = utf7Encoder->GetBytes( chars, 2, 3, bytes, 0, true ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp deleted file mode 100644 index e368c581615..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - int charCount = 2; - int maxByteCount = utf7->GetMaxByteCount( charCount ); - Console::WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", maxByteCount, charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp deleted file mode 100644 index e11609a9b4f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - int byteCount = 8; - int maxCharCount = utf7->GetMaxCharCount( byteCount ); - Console::WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", maxCharCount, byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor1 Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor1 Example/CPP/ctor.cpp deleted file mode 100644 index 3474715e028..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor1 Example/CPP/ctor.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - String^ encodingName = utf7->EncodingName; - Console::WriteLine( "Encoding name: {0}", encodingName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor2 Example/CPP/ctor-boolean.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor2 Example/CPP/ctor-boolean.cpp deleted file mode 100644 index 0af6372132d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor2 Example/CPP/ctor-boolean.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -void ShowArray( Array^ theArray ) -{ - IEnumerator^ myEnum = theArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::Write( "[{0}]", o ); - } - - Console::WriteLine(); -} - -int main() -{ - - // A few optional characters. - String^ chars = "!@#$"; - - // The default Encoding does not allow optional characters. - // Alternate Byte values are used. - UTF7Encoding^ utf7 = gcnew UTF7Encoding; - array^bytes1 = utf7->GetBytes( chars ); - Console::WriteLine( "Default UTF7 Encoding:" ); - ShowArray( bytes1 ); - - // Convert back to characters. - Console::WriteLine( "Characters:" ); - ShowArray( utf7->GetChars( bytes1 ) ); - - // Now, allow optional characters. - // Optional characters are encoded with their normal code points. - UTF7Encoding^ utf7AllowOptionals = gcnew UTF7Encoding( true ); - array^bytes2 = utf7AllowOptionals->GetBytes( chars ); - Console::WriteLine( "UTF7 Encoding with optional characters allowed:" ); - ShowArray( bytes2 ); - - // Convert back to characters. - Console::WriteLine( "Characters:" ); - ShowArray( utf7AllowOptionals->GetChars( bytes2 ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.getstring/CPP/getstring.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.getstring/CPP/getstring.cpp deleted file mode 100644 index 0f2e71a46f4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.getstring/CPP/getstring.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// The following code example encodes a string into an array of bytes, and then decodes the bytes back into a string. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Create an instance of UTF7Encoding. - UTF7Encoding^ u7 = gcnew UTF7Encoding( true ); - - // Create byte arrays from the same string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - String^ myStr = "za\u0306\u01FD\u03B2"; - - // Encode the string. - array^myBArr = gcnew array(u7->GetByteCount( myStr )); - u7->GetBytes( myStr, 0, myStr->Length, myBArr, 0 ); - - // Decode the byte array. - Console::WriteLine( "The new string is: {0}", u7->GetString( myBArr, 0, myBArr->Length ) ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -The new string is: za?? - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding Example/CPP/snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding Example/CPP/snippet.cpp deleted file mode 100644 index 207ede33c02..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding Example/CPP/snippet.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -//using namespace System::Collections; - -int main() -{ - // Create a UTF-8 encoding. - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - - // A Unicode string with two characters outside an 8-bit code range. - String^ unicodeString = L"This Unicode string has 2 characters " + - L"outside the ASCII range:\n" + - L"Pi (\u03a0), and Sigma (\u03a3)."; - Console::WriteLine("Original string:"); - Console::WriteLine(unicodeString); - - // Encode the string. - array^ encodedBytes = utf8->GetBytes(unicodeString ); - Console::WriteLine(); - Console::WriteLine("Encoded bytes:"); - for (int ctr = 0; ctr < encodedBytes->Length; ctr++) { - Console::Write( "{0:X2} ", encodedBytes[ctr]); - if ((ctr + 1) % 25 == 0) - Console::WriteLine(); - } - - Console::WriteLine(); - - // Decode bytes back to string. - String^ decodedString = utf8->GetString(encodedBytes); - Console::WriteLine(); - Console::WriteLine("Decoded bytes:"); - Console::WriteLine(decodedString); -} -// The example displays the following output: -// Original string: -// This Unicode string has 2 characters outside the ASCII range: -// Pi (π), and Sigma (Σ). -// -// Encoded bytes: -// 54 68 69 73 20 55 6E 69 63 6F 64 65 20 73 74 72 69 6E 67 20 68 61 73 20 32 -// 20 63 68 61 72 61 63 74 65 72 73 20 6F 75 74 73 69 64 65 20 74 68 65 20 41 -// 53 43 49 49 20 72 61 6E 67 65 3A 20 0D 0A 50 69 20 28 CE A0 29 2C 20 61 6E -// 64 20 53 69 67 6D 61 20 28 CE A3 29 2E -// -// Decoded bytes: -// This Unicode string has 2 characters outside the ASCII range: -// Pi (π), and Sigma (Σ). -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CPP/equals-object.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CPP/equals-object.cpp deleted file mode 100644 index 5e6ae2e299e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CPP/equals-object.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -void DescribeEquivalence( Boolean isEquivalent ) -{ - Console::WriteLine( "{0} equivalent encoding.", (isEquivalent ? (String^)"An" : "Not an") ); -} - -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - UTF8Encoding^ utf8true = gcnew UTF8Encoding( true ); - UTF8Encoding^ utf8truetrue = gcnew UTF8Encoding( true,true ); - UTF8Encoding^ utf8falsetrue = gcnew UTF8Encoding( false,true ); - DescribeEquivalence( utf8->Equals( utf8 ) ); - DescribeEquivalence( utf8->Equals( utf8true ) ); - DescribeEquivalence( utf8->Equals( utf8truetrue ) ); - DescribeEquivalence( utf8->Equals( utf8falsetrue ) ); - DescribeEquivalence( utf8true->Equals( utf8 ) ); - DescribeEquivalence( utf8true->Equals( utf8true ) ); - DescribeEquivalence( utf8true->Equals( utf8truetrue ) ); - DescribeEquivalence( utf8true->Equals( utf8falsetrue ) ); - DescribeEquivalence( utf8truetrue->Equals( utf8 ) ); - DescribeEquivalence( utf8truetrue->Equals( utf8true ) ); - DescribeEquivalence( utf8truetrue->Equals( utf8truetrue ) ); - DescribeEquivalence( utf8truetrue->Equals( utf8falsetrue ) ); - DescribeEquivalence( utf8falsetrue->Equals( utf8 ) ); - DescribeEquivalence( utf8falsetrue->Equals( utf8true ) ); - DescribeEquivalence( utf8falsetrue->Equals( utf8truetrue ) ); - DescribeEquivalence( utf8falsetrue->Equals( utf8falsetrue ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 5adc3b4928a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int byteCount = utf8->GetByteCount( chars, 1, 2 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = utf8->GetBytes( chars, 1, 2, bytes, 0 ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp deleted file mode 100644 index e89bbb84c9e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - String^ chars = "UTF8 Encoding Example"; - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int byteCount = utf8->GetByteCount( chars->ToCharArray(), 0, 13 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = utf8->GetBytes( chars, 0, 13, bytes, 0 ); - Console::WriteLine( "{0} bytes used to encode string.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp deleted file mode 100644 index 7456dd1e21a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - array^bytes = {85,84,70,56,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101}; - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int charCount = utf8->GetCharCount( bytes, 2, 8 ); - Console::WriteLine( "{0} characters needed to decode bytes.", charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp deleted file mode 100644 index 6d629f2db9b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {85,84,70,56,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101}; - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int charCount = utf8->GetCharCount( bytes, 2, 13 ); - chars = gcnew array(charCount); - int charsDecodedCount = utf8->GetChars( bytes, 2, 13, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CPP/getdecoder-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CPP/getdecoder-.cpp deleted file mode 100644 index 3e5900dd0e4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CPP/getdecoder-.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {99,204,128,234,130,160}; - Decoder^ utf8Decoder = Encoding::UTF8->GetDecoder(); - int charCount = utf8Decoder->GetCharCount( bytes, 0, bytes->Length ); - chars = gcnew array(charCount); - int charsDecodedCount = utf8Decoder->GetChars( bytes, 0, bytes->Length, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CPP/getencoder-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CPP/getencoder-.cpp deleted file mode 100644 index 2969f330f96..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CPP/getencoder-.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars = {'a','b','c',L'\u0300',L'\ua0a0'}; - array^bytes; - Encoder^ utf8Encoder = Encoding::UTF8->GetEncoder(); - int byteCount = utf8Encoder->GetByteCount( chars, 2, 3, true ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = utf8Encoder->GetBytes( chars, 2, 3, bytes, 0, true ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetHashCode Example/CPP/gethashcode-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetHashCode Example/CPP/gethashcode-.cpp deleted file mode 100644 index 00934592f35..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetHashCode Example/CPP/gethashcode-.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Many ways to instantiate a UTF8 encoding. - UTF8Encoding^ UTF8a = gcnew UTF8Encoding; - Encoding^ UTF8b = Encoding::UTF8; - Encoding^ UTF8c = gcnew UTF8Encoding( true,true ); - Encoding^ UTF8d = gcnew UTF8Encoding( false,false ); - - // But not all are the same. - Console::WriteLine( UTF8a->GetHashCode() ); - Console::WriteLine( UTF8b->GetHashCode() ); - Console::WriteLine( UTF8c->GetHashCode() ); - Console::WriteLine( UTF8d->GetHashCode() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp deleted file mode 100644 index eaf84b21006..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int charCount = 2; - int maxByteCount = utf8->GetMaxByteCount( charCount ); - Console::WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", maxByteCount, charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp deleted file mode 100644 index 624c31a8ccf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - int byteCount = 8; - int maxCharCount = utf8->GetMaxCharCount( byteCount ); - Console::WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", maxCharCount, byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp deleted file mode 100644 index 8bc22343a5c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; - -void ShowArray(array^ bytes) -{ - for each (Byte b in bytes) - Console::Write( "{0:X2} ", b); - - Console::WriteLine(); -} - -int main() -{ - // The default constructor does not provide a preamble. - UTF8Encoding^ UTF8NoPreamble = gcnew UTF8Encoding; - UTF8Encoding^ UTF8WithPreamble = gcnew UTF8Encoding( true ); - array^preamble; - preamble = UTF8NoPreamble->GetPreamble(); - Console::WriteLine( "UTF8NoPreamble" ); - Console::WriteLine( " preamble length: {0}", preamble->Length ); - Console::Write( " preamble: " ); - ShowArray( preamble ); - Console::WriteLine(); - - preamble = UTF8WithPreamble->GetPreamble(); - Console::WriteLine( "UTF8WithPreamble" ); - Console::WriteLine( " preamble length: {0}", preamble->Length ); - Console::Write( " preamble: " ); - ShowArray( preamble ); -} -// The example displays the following output: -// UTF8NoPreamble -// preamble length: 0 -// preamble: -// -// UTF8WithPreamble -// preamble length: 3 -// preamble: EF BB BF -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor1 Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor1 Example/CPP/ctor.cpp deleted file mode 100644 index 862c4ca0aec..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor1 Example/CPP/ctor.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - String^ encodingName = utf8->EncodingName; - Console::WriteLine( "Encoding name: {0}", encodingName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor2 Example/CPP/ctor-boolean.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor2 Example/CPP/ctor-boolean.cpp deleted file mode 100644 index 0dafbdef102..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor2 Example/CPP/ctor-boolean.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -void ShowArray( Array^ theArray ) -{ - IEnumerator^ myEnum = theArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Object^ o = safe_cast(myEnum->Current); - Console::Write( "[{0}]", o ); - } - - Console::WriteLine(); -} - -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - UTF8Encoding^ utf8EmitBOM = gcnew UTF8Encoding( true ); - Console::WriteLine( "utf8 preamble:" ); - ShowArray( utf8->GetPreamble() ); - Console::WriteLine( "utf8EmitBOM:" ); - ShowArray( utf8EmitBOM->GetPreamble() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor3 Example/CPP/ctor-boolean-boolean.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor3 Example/CPP/ctor-boolean-boolean.cpp deleted file mode 100644 index 9f6b9081759..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor3 Example/CPP/ctor-boolean-boolean.cpp +++ /dev/null @@ -1,39 +0,0 @@ - -// -using namespace System; -using namespace System::Text; - -void ShowArray(Array^ theArray) -{ - for each (Byte b in theArray) { - Console::Write( "{0:X2} ", b); - } - Console::WriteLine(); -} - -int main() -{ - UTF8Encoding^ utf8 = gcnew UTF8Encoding; - UTF8Encoding^ utf8ThrowException = gcnew UTF8Encoding(false,true); - - // This array contains two high surrogates in a row (\uD801, \uD802). - array^chars = {'a','b','c',L'\xD801',L'\xD802','d'}; - - // The following method call will not throw an exception. - array^bytes = utf8->GetBytes( chars ); - ShowArray( bytes ); - Console::WriteLine(); - - try { - - // The following method call will throw an exception. - bytes = utf8ThrowException->GetBytes( chars ); - } - catch (EncoderFallbackException^ e ) { - Console::WriteLine("{0} exception\nMessage:\n{1}", - e->GetType()->Name, e->Message); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding Example/CPP/snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding Example/CPP/snippet.cpp deleted file mode 100644 index c498942c8f5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding Example/CPP/snippet.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - - // The encoding. - UnicodeEncoding^ unicode = gcnew UnicodeEncoding; - - // Create a String* that contains Unicode characters. - String^ unicodeString = L"This Unicode string contains two characters with codes outside the traditional ASCII code range, Pi (\u03a0) and Sigma (\u03a3)."; - Console::WriteLine( "Original string:" ); - Console::WriteLine( unicodeString ); - - // Encode the String*. - array^encodedBytes = unicode->GetBytes( unicodeString ); - Console::WriteLine(); - Console::WriteLine( "Encoded bytes:" ); - IEnumerator^ myEnum = encodedBytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); - - // Decode bytes back to String*. - // Notice Pi and Sigma characters are still present. - String^ decodedString = unicode->GetString( encodedBytes ); - Console::WriteLine(); - Console::WriteLine( "Decoded bytes:" ); - Console::WriteLine( decodedString ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.CharSize Example/CPP/charsize.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.CharSize Example/CPP/charsize.cpp deleted file mode 100644 index 39d50f0b408..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.CharSize Example/CPP/charsize.cpp +++ /dev/null @@ -1,10 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - Console::WriteLine( "Unicode character size: {0} bytes", UnicodeEncoding::CharSize ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/CPP/encdec.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/CPP/encdec.cpp deleted file mode 100644 index 7f46e6d47b0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/CPP/encdec.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// The following code example uses an encoder and a decoder to encode a string into an array of bytes, -// and then decode the bytes into an array of characters. -// -using namespace System; -using namespace System::Text; -int main() -{ - - // Get an encoder and a decoder from UnicodeEncoding. - UnicodeEncoding^ u16 = gcnew UnicodeEncoding( false,true,true ); - Encoder^ myEnc = u16->GetEncoder(); - Decoder^ myDec = u16->GetDecoder(); - - // The characters to encode: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - array^myChars = gcnew array(5){ - L'z',L'a',L'\u0306',L'\u01FD',L'\u03B2' - }; - Console::Write( "The original characters : " ); - Console::WriteLine( myChars ); - - // Encode the character array. - int iBC = myEnc->GetByteCount( myChars, 0, myChars->Length, true ); - array^myBytes = gcnew array(iBC); - myEnc->GetBytes( myChars, 0, myChars->Length, myBytes, 0, true ); - - // Print the resulting bytes. - Console::Write( "Using the encoder : " ); - for ( int i = 0; i < myBytes->Length; i++ ) - Console::Write( "{0:X2} ", myBytes[ i ] ); - Console::WriteLine(); - - // Decode the byte array back into an array of characters. - int iCC = myDec->GetCharCount( myBytes, 0, myBytes->Length, true ); - array^myDecodedChars = gcnew array(iCC); - myDec->GetChars( myBytes, 0, myBytes->Length, myDecodedChars, 0, true ); - - // Print the resulting characters. - Console::Write( "Using the decoder : " ); - Console::WriteLine( myDecodedChars ); -} - -/* -This code produces the following output. The question marks take the place of characters that cannot be displayed at the console. - -The original characters : za?? -Using the encoder : 7A 00 61 00 06 03 FD 01 B2 03 -Using the decoder : za?? - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ErrorDetection/CPP/errordetection.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ErrorDetection/CPP/errordetection.cpp deleted file mode 100644 index de042ae169e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ErrorDetection/CPP/errordetection.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// The following code example demonstrates the behavior of UnicodeEncoding with error detection enabled and without. -// -using namespace System; -using namespace System::Text; -void PrintDecodedString( array^bytes, Encoding^ enc ); -int main() -{ - - // Create an instance of UnicodeEncoding using little-endian byte order. - // This will be used for encoding. - UnicodeEncoding^ u16LE = gcnew UnicodeEncoding( false,true ); - - // Create two instances of UnicodeEncoding using big-endian byte order: one with error detection and one without. - // These will be used for decoding. - UnicodeEncoding^ u16withED = gcnew UnicodeEncoding( true,true,true ); - UnicodeEncoding^ u16noED = gcnew UnicodeEncoding( true,true,false ); - - // Create byte arrays from the same string containing the following characters: - // Latin Small Letter Z (U+007A) - // Latin Small Letter A (U+0061) - // Combining Breve (U+0306) - // Latin Small Letter AE With Acute (U+01FD) - // Greek Small Letter Beta (U+03B2) - // Latin Capital Letter U with Diaeresis (U+00DC) - String^ myStr = "za\u0306\u01FD\u03B2\u00DC"; - - // Encode the string using little-endian byte order. - array^myBytes = gcnew array(u16LE->GetByteCount( myStr )); - u16LE->GetBytes( myStr, 0, myStr->Length, myBytes, 0 ); - - // Decode the byte array with error detection. - Console::WriteLine( "Decoding with error detection:" ); - PrintDecodedString( myBytes, u16withED ); - - // Decode the byte array without error detection. - Console::WriteLine( "Decoding without error detection:" ); - PrintDecodedString( myBytes, u16noED ); -} - - -// Decode the bytes and display the string. -void PrintDecodedString( array^bytes, Encoding^ enc ) -{ - try - { - Console::WriteLine( " Decoded string: {0}", enc->GetString( bytes, 0, bytes->Length ) ); - } - catch ( System::ArgumentException^ e ) - { - Console::WriteLine( e ); - } - - Console::WriteLine(); -} - -// -/* BUGBUG: Reproduce this output in retail build, then add to the snippet. -This code produces the following output. - -Decoding with error detection: -System.ArgumentException: Invalid byte was found at byte index 3. - at System.Text.UnicodeEncoding.GetCharCount(Byte* bytes, Int32 count, DecoderNLS baseDecoder) - at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encoding) - at System.Text.UnicodeEncoding.GetString(Byte[] bytes, Int32 index, Int32 count) - at SamplesUnicodeEncoding.PrintDecodedString(Byte[] bytes, Encoding enc) - -Decoding without error detection: - Decoded string: - -*/ diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp deleted file mode 100644 index bbefc038187..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - - // Unicode characters. - - // Pi - // Sigma - array^chars = {L'\u03a0',L'\u03a3',L'\u03a6',L'\u03a9'}; - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int byteCount = Unicode->GetByteCount( chars, 1, 2 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = Unicode->GetBytes( chars, 1, 2, bytes, 0 ); - Console::WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp deleted file mode 100644 index 25dee60bee6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^bytes; - String^ chars = "Unicode Encoding Example"; - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int byteCount = Unicode->GetByteCount( chars->ToCharArray(), 8, 8 ); - bytes = gcnew array(byteCount); - int bytesEncodedCount = Unicode->GetBytes( chars, 8, 8, bytes, 0 ); - Console::WriteLine( "{0} bytes used to encode string.", bytesEncodedCount ); - Console::Write( "Encoded bytes: " ); - IEnumerator^ myEnum = bytes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp deleted file mode 100644 index 0925c759295..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - array^bytes = {85,0,110,0,105,0,99,0,111,0,100,0,101,0}; - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int charCount = Unicode->GetCharCount( bytes, 2, 8 ); - Console::WriteLine( "{0} characters needed to decode bytes.", charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp deleted file mode 100644 index e68162a021c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^chars; - array^bytes = {85,0,110,0,105,0,99,0,111,0,100,0,101,0}; - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int charCount = Unicode->GetCharCount( bytes, 2, 8 ); - chars = gcnew array(charCount); - int charsDecodedCount = Unicode->GetChars( bytes, 2, 8, chars, 0 ); - Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount ); - Console::Write( "Decoded chars: " ); - IEnumerator^ myEnum = chars->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::Write( "[{0}]", c.ToString() ); - } - - Console::WriteLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp deleted file mode 100644 index 08545fa0a5e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int charCount = 2; - int maxByteCount = Unicode->GetMaxByteCount( charCount ); - Console::WriteLine( "Maximum of {0} bytes needed to encode {1} characters.", maxByteCount, charCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp deleted file mode 100644 index c956533d9a8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UnicodeEncoding^ Unicode = gcnew UnicodeEncoding; - int byteCount = 8; - int maxCharCount = Unicode->GetMaxCharCount( byteCount ); - Console::WriteLine( "Maximum of {0} characters needed to decode {1} bytes.", maxCharCount, byteCount ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetPreamble Example/CPP/getpreamble-.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetPreamble Example/CPP/getpreamble-.cpp deleted file mode 100644 index b2e176ae267..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetPreamble Example/CPP/getpreamble-.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; -int main() -{ - array^byteOrderMark; - byteOrderMark = Encoding::Unicode->GetPreamble(); - Console::WriteLine( "Default (little-endian) Unicode Preamble:" ); - IEnumerator^ myEnum = byteOrderMark->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } - - Console::WriteLine( "\n" ); - UnicodeEncoding^ bigEndianUnicode = gcnew UnicodeEncoding( true,true ); - byteOrderMark = bigEndianUnicode->GetPreamble(); - Console::WriteLine( "Big-endian Unicode Preamble:" ); - myEnum = byteOrderMark->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte b = safe_cast(myEnum->Current); - Console::Write( "[{0}]", b ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor Example/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor Example/CPP/ctor.cpp deleted file mode 100644 index 13dd01a98bb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor Example/CPP/ctor.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -int main() -{ - UnicodeEncoding^ unicode = gcnew UnicodeEncoding; - String^ encodingName = unicode->EncodingName; - Console::WriteLine( "Encoding name: {0}", encodingName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/CPP/ctor-boolean-boolean.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/CPP/ctor-boolean-boolean.cpp deleted file mode 100644 index e295b687fdd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/CPP/ctor-boolean-boolean.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -void DescribeEquivalence( Boolean isEquivalent ) -{ - Console::WriteLine( " {0} equivalent encoding.", (isEquivalent ? (String^)"An" : "Not an") ); -} - -int main() -{ - - // Create a UnicodeEncoding without parameters. - UnicodeEncoding^ unicode = gcnew UnicodeEncoding; - - // Create a UnicodeEncoding to support little-endian Byte ordering - // and include the Unicode Byte order mark. - UnicodeEncoding^ unicodeLittleEndianBOM = gcnew UnicodeEncoding( false,true ); - - // Compare this UnicodeEncoding to the UnicodeEncoding without parameters. - DescribeEquivalence( unicode->Equals( unicodeLittleEndianBOM ) ); - - // Create a UnicodeEncoding to support little-endian Byte ordering - // and not include the Unicode Byte order mark. - UnicodeEncoding^ unicodeLittleEndianNoBOM = gcnew UnicodeEncoding( false,false ); - - // Compare this UnicodeEncoding to the UnicodeEncoding without parameters. - DescribeEquivalence( unicode->Equals( unicodeLittleEndianNoBOM ) ); - - // Create a UnicodeEncoding to support big-endian Byte ordering - // and include the Unicode Byte order mark. - UnicodeEncoding^ unicodeBigEndianBOM = gcnew UnicodeEncoding( true,true ); - - // Compare this UnicodeEncoding to the UnicodeEncoding without parameters. - DescribeEquivalence( unicode->Equals( unicodeBigEndianBOM ) ); - - // Create a UnicodeEncoding to support big-endian Byte ordering - // and not include the Unicode Byte order mark. - UnicodeEncoding^ unicodeBigEndianNoBOM = gcnew UnicodeEncoding( true,false ); - - // Compare this UnicodeEncoding to the UnicodeEncoding without parameters. - DescribeEquivalence( unicode->Equals( unicodeBigEndianNoBOM ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/CPP/koax.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/CPP/koax.cpp deleted file mode 100644 index ea0fa55c83a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/CPP/koax.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -namespace SystemThreadingExample -{ - public ref class Example - { - private: - static ManualResetEvent^ dummyEvent = - gcnew ManualResetEvent(false); - - static Mutex^ orphanMutex1 = gcnew Mutex; - static Mutex^ orphanMutex2 = gcnew Mutex; - static Mutex^ orphanMutex3 = gcnew Mutex; - static Mutex^ orphanMutex4 = gcnew Mutex; - static Mutex^ orphanMutex5 = gcnew Mutex; - - public: - static void ProduceAbandonMutexException(void) - { - - // Start a thread that grabs all five mutexes, and then - // abandons them. - Thread^ abandonThread = - gcnew Thread(gcnew ThreadStart(AbandonMutex)); - - abandonThread->Start(); - - // Make sure the thread is finished. - abandonThread->Join(); - - // Wait on one of the abandoned mutexes. The WaitOne - // throws an AbandonedMutexException. - try - { - orphanMutex1->WaitOne(); - Console::WriteLine("WaitOne succeeded."); - } - catch (AbandonedMutexException^ ex) - { - Console::WriteLine("Exception in WaitOne: {0}", - ex->Message); - } - finally - { - - // Whether or not the exception was thrown, - // the current thread owns the mutex, and - // must release it. - orphanMutex1->ReleaseMutex(); - } - - - // Create an array of wait handles, consisting of one - // ManualResetEvent and two mutexes, using two more of - // the abandoned mutexes. - array ^ waitFor = {dummyEvent, - orphanMutex2, orphanMutex3}; - - // WaitAny returns when any of the wait handles in the - // array is signaled. Either of the two abandoned mutexes - // satisfy the wait, but lower of the two index values is - // returned by MutexIndex. Note that the Try block and - // the Catch block obtain the index in different ways. - try - { - int index = WaitHandle::WaitAny(waitFor); - Console::WriteLine("WaitAny succeeded."); - (safe_cast(waitFor[index]))->ReleaseMutex(); - } - catch (AbandonedMutexException^ ex) - { - Console::WriteLine("Exception in WaitAny at index {0}" - "\r\n\tMessage: {1}", ex->MutexIndex, - ex->Message); - (safe_cast(waitFor[ex->MutexIndex]))-> - ReleaseMutex(); - } - - orphanMutex3->ReleaseMutex(); - - // Use two more of the abandoned mutexes for the WaitAll - // call. WaitAll doesn't return until all wait handles - // are signaled, so the ManualResetEvent must be signaled - // by calling Set(). - dummyEvent->Set(); - waitFor[1] = orphanMutex4; - waitFor[2] = orphanMutex5; - - // Because WaitAll requires all the wait handles to be - // signaled, both mutexes must be released even if the - // exception is thrown. Thus, the ReleaseMutex calls are - // placed in the Finally block. Again, MutexIndex returns - // the lower of the two index values for the abandoned - // mutexes. - // - try - { - WaitHandle::WaitAll(waitFor); - Console::WriteLine("WaitAll succeeded."); - } - catch (AbandonedMutexException^ ex) - { - Console::WriteLine("Exception in WaitAny at index {0}" - "\r\n\tMessage: {1}", ex->MutexIndex, - ex->Message); - } - finally - { - orphanMutex4->ReleaseMutex(); - orphanMutex5->ReleaseMutex(); - } - - } - - - private: - [MTAThread] - static void AbandonMutex() - { - orphanMutex1->WaitOne(); - orphanMutex2->WaitOne(); - orphanMutex3->WaitOne(); - orphanMutex4->WaitOne(); - orphanMutex5->WaitOne(); - Console::WriteLine( - "Thread exits without releasing the mutexes."); - } - }; -} - -//Entry point of example application -[MTAThread] -int main(void) -{ - SystemThreadingExample::Example::ProduceAbandonMutexException(); -} - -// This code example produces the following output: -// Thread exits without releasing the mutexes. -// Exception in WaitOne: The wait completed due to an abandoned mutex. -// Exception in WaitAny at index 1 -// Message: The wait completed due to an abandoned mutex. -// Exception in WaitAll at index -1 -// Message: The wait completed due to an abandoned mutex. - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/class1.cpp deleted file mode 100644 index 286d1b48439..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/class1.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class MyMainClass -{ -public: - static void MyReadThreadProc() - { - while ( true ) - { - - //The value will not be read until the writer has written - // at least once since the last read. - myResetEvent->WaitOne(); - Console::WriteLine( " {0} reading value: {1}", Thread::CurrentThread->Name, number ); - } - } - - - //Initially not signaled. - static AutoResetEvent^ myResetEvent = gcnew AutoResetEvent( false ); - static int number; - literal int numIterations = 100; -}; - -int main() -{ - - //Create and start the reader thread. - Thread^ myReaderThread = gcnew Thread( gcnew ThreadStart( MyMainClass::MyReadThreadProc ) ); - myReaderThread->Name = "ReaderThread"; - myReaderThread->Start(); - for ( int i = 1; i <= MyMainClass::numIterations; i++ ) - { - Console::WriteLine( "Writer thread writing value: {0}", i ); - MyMainClass::number = i; - - //Signal that a value has been written. - MyMainClass::myResetEvent->Set(); - - //Give the Reader thread an opportunity to act. - Thread::Sleep( 1 ); - - } - - //Terminate the reader thread. - myReaderThread->Abort(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/simplerisbetter.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/simplerisbetter.cpp deleted file mode 100644 index 96444ba3776..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/simplerisbetter.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -ref class Example -{ -private: - static AutoResetEvent^ event_1 = gcnew AutoResetEvent(true); - static AutoResetEvent^ event_2 = gcnew AutoResetEvent(false); - - static void ThreadProc() - { - String^ name = Thread::CurrentThread->Name; - - Console::WriteLine("{0} waits on AutoResetEvent #1.", name); - event_1->WaitOne(); - Console::WriteLine("{0} is released from AutoResetEvent #1.", name); - - Console::WriteLine("{0} waits on AutoResetEvent #2.", name); - event_2->WaitOne(); - Console::WriteLine("{0} is released from AutoResetEvent #2.", name); - - Console::WriteLine("{0} ends.", name); - } - -public: - static void Demo() - { - Console::WriteLine("Press Enter to create three threads and start them.\r\n" + - "The threads wait on AutoResetEvent #1, which was created\r\n" + - "in the signaled state, so the first thread is released.\r\n" + - "This puts AutoResetEvent #1 into the unsignaled state."); - Console::ReadLine(); - - for (int i = 1; i < 4; i++) - { - Thread^ t = gcnew Thread(gcnew ThreadStart(&ThreadProc)); - t->Name = "Thread_" + i; - t->Start(); - } - Thread::Sleep(250); - - for (int i = 0; i < 2; i++) - { - Console::WriteLine("Press Enter to release another thread."); - Console::ReadLine(); - event_1->Set(); - Thread::Sleep(250); - } - - Console::WriteLine("\r\nAll threads are now waiting on AutoResetEvent #2."); - for (int i = 0; i < 3; i++) - { - Console::WriteLine("Press Enter to release a thread."); - Console::ReadLine(); - event_2->Set(); - Thread::Sleep(250); - } - - // Visual Studio: Uncomment the following line. - //Console::Readline(); - } -}; - -void main() -{ - Example::Demo(); -} - -/* This example produces output similar to the following: - -Press Enter to create three threads and start them. -The threads wait on AutoResetEvent #1, which was created -in the signaled state, so the first thread is released. -This puts AutoResetEvent #1 into the unsignaled state. - -Thread_1 waits on AutoResetEvent #1. -Thread_1 is released from AutoResetEvent #1. -Thread_1 waits on AutoResetEvent #2. -Thread_3 waits on AutoResetEvent #1. -Thread_2 waits on AutoResetEvent #1. -Press Enter to release another thread. - -Thread_3 is released from AutoResetEvent #1. -Thread_3 waits on AutoResetEvent #2. -Press Enter to release another thread. - -Thread_2 is released from AutoResetEvent #1. -Thread_2 waits on AutoResetEvent #2. - -All threads are now waiting on AutoResetEvent #2. -Press Enter to release a thread. - -Thread_2 is released from AutoResetEvent #2. -Thread_2 ends. -Press Enter to release a thread. - -Thread_1 is released from AutoResetEvent #2. -Thread_1 ends. -Press Enter to release a thread. - -Thread_3 is released from AutoResetEvent #2. -Thread_3 ends. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp deleted file mode 100644 index 9545b8e2fae..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// -using namespace System; -using namespace System::Threading; -using namespace System::Security::AccessControl; -using namespace System::Security::Permissions; - -public ref class Example -{ -public: - [SecurityPermissionAttribute(SecurityAction::Demand,Flags=SecurityPermissionFlag::UnmanagedCode)] - static void Main() - { - // - String^ ewhName = L"EventWaitHandleExample5"; - - EventWaitHandle^ ewh = nullptr; - bool doesNotExist = false; - bool unauthorized = false; - - // The value of this variable is set by the event - // constructor. It is true if the named system event was - // created, and false if the named event already existed. - // - bool wasCreated; - - // Attempt to open the named event. - try - { - // Open the event with (EventWaitHandleRights.Synchronize - // | EventWaitHandleRights.Modify), to wait on and - // signal the named event. - // - ewh = EventWaitHandle::OpenExisting( ewhName ); - } - catch ( WaitHandleCannotBeOpenedException^ ) - { - Console::WriteLine( L"Named event does not exist." ); - doesNotExist = true; - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", ex->Message ); - unauthorized = true; - } - // - - // There are three cases: (1) The event does not exist. - // (2) The event exists, but the current user doesn't - // have access. (3) The event exists and the user has - // access. - // - if ( doesNotExist ) - { - // - // The event does not exist, so create it. - - // Create an access control list (ACL) that denies the - // current user the right to wait on or signal the - // event, but allows the right to read and change - // security information for the event. - // - String^ user = String::Concat( Environment::UserDomainName, L"\\", - Environment::UserName ); - EventWaitHandleSecurity^ ewhSec = gcnew EventWaitHandleSecurity; - //following constructor fails - EventWaitHandleAccessRule^ rule = gcnew EventWaitHandleAccessRule( - user, - static_cast( - EventWaitHandleRights::Synchronize | - EventWaitHandleRights::Modify), - AccessControlType::Deny ); - ewhSec->AddAccessRule( rule ); - - rule = gcnew EventWaitHandleAccessRule( user, - static_cast( - EventWaitHandleRights::ReadPermissions | - EventWaitHandleRights::ChangePermissions), - AccessControlType::Allow ); - ewhSec->AddAccessRule( rule ); - - // Create an EventWaitHandle object that represents - // the system event named by the constant 'ewhName', - // initially signaled, with automatic reset, and with - // the specified security access. The Boolean value that - // indicates creation of the underlying system object - // is placed in wasCreated. - // - ewh = gcnew EventWaitHandle( true, - EventResetMode::AutoReset, - ewhName, - wasCreated, - ewhSec ); - - // If the named system event was created, it can be - // used by the current instance of this program, even - // though the current user is denied access. The current - // program owns the event. Otherwise, exit the program. - // - if ( wasCreated ) - { - Console::WriteLine( L"Created the named event." ); - } - else - { - Console::WriteLine( L"Unable to create the event." ); - return; - } - // - } - else if ( unauthorized ) - { - // - // Open the event to read and change the access control - // security. The access control security defined above - // allows the current user to do this. - // - try - { - ewh = EventWaitHandle::OpenExisting( ewhName, - static_cast( - EventWaitHandleRights::ReadPermissions | - EventWaitHandleRights::ChangePermissions) ); - - // Get the current ACL. This requires - // EventWaitHandleRights.ReadPermissions. - EventWaitHandleSecurity^ ewhSec = ewh->GetAccessControl(); - String^ user = String::Concat( Environment::UserDomainName, L"\\", - Environment::UserName ); - - // First, the rule that denied the current user - // the right to enter and release the event must - // be removed. - EventWaitHandleAccessRule^ rule = gcnew EventWaitHandleAccessRule( - user, - static_cast( - EventWaitHandleRights::Synchronize | - EventWaitHandleRights::Modify), - AccessControlType::Deny ); - ewhSec->RemoveAccessRule( rule ); - - // Now grant the user the correct rights. - // - rule = gcnew EventWaitHandleAccessRule( user, - static_cast( - EventWaitHandleRights::Synchronize | - EventWaitHandleRights::Modify), - AccessControlType::Allow ); - ewhSec->AddAccessRule( rule ); - - // Update the ACL. This requires - // EventWaitHandleRights.ChangePermissions. - ewh->SetAccessControl( ewhSec ); - Console::WriteLine( L"Updated event security." ); - - // Open the event with (EventWaitHandleRights.Synchronize - // | EventWaitHandleRights.Modify), the rights required - // to wait on and signal the event. - // - ewh = EventWaitHandle::OpenExisting( ewhName ); - // - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unable to change permissions: {0}", - ex->Message ); - return; - } - - } - - // Wait on the event, and hold it until the program - // exits. - // - try - { - Console::WriteLine( L"Wait on the event." ); - ewh->WaitOne(); - Console::WriteLine( L"Event was signaled." ); - Console::WriteLine( L"Press the Enter key to signal the event and exit." ); - Console::ReadLine(); - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", ex->Message ); - } - finally - { - ewh->Set(); - } - } -}; - -int main() -{ - Example::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked CompareExchange0/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked CompareExchange0/CPP/source.cpp deleted file mode 100644 index 37370e944c5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked CompareExchange0/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - - -// -// This example demonstrates a thread-safe method that adds to a -// running total. It cannot be run directly. You can compile it -// as a library, or add the class to a project. -#using - -using namespace System::Threading; -public ref class ThreadSafe -{ -private: - - // totalValue contains a running total that can be updated - // by multiple threads. It must be protected from unsynchronized - // access. - int totalValue; - -public: - - property int Total - { - - // The Total property returns the running total. - int get() - { - return totalValue; - } - - } - - // AddToTotal safely adds a value to the running total. - int AddToTotal( int addend ) - { - int initialValue; - int computedValue; - do - { - - // Save the current running total in a local variable. - initialValue = totalValue; - - // Add the new value to the running total. - computedValue = initialValue + addend; - - // CompareExchange compares totalValue to initialValue. If - // they are not equal, then another thread has updated the - // running total since this loop started. CompareExchange - // does not update totalValue. CompareExchange returns the - // contents of totalValue, which do not equal initialValue, - // so the loop executes again. - } - while ( initialValue != Interlocked::CompareExchange( totalValue, computedValue, initialValue ) ); - - - // If no other thread updated the running total, then - // totalValue and initialValue are equal when CompareExchange - // compares them, and computedValue is stored in totalValue. - // CompareExchange returns the value that was in totalValue - // before the update, which is equal to initialValue, so the - // loop ends. - // The function returns computedValue, not totalValue, because - // totalValue could be changed by another thread between - // the time the loop ends and the function returns. - return computedValue; - } - -}; - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/CPP/class1.cpp deleted file mode 100644 index a04b9df75bd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/CPP/class1.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -const int numThreads = 10; -const int numThreadIterations = 5; -ref class MyInterlockedExchangeExampleClass -{ -public: - static void MyThreadProc() - { - for ( int i = 0; i < numThreadIterations; i++ ) - { - UseResource(); - - //Wait 1 second before next attempt. - Thread::Sleep( 1000 ); - - } - } - - -private: - //A simple method that denies reentrancy. - static bool UseResource() - { - - //0 indicates that the method is not in use. - if ( 0 == Interlocked::Exchange( usingResource, 1 ) ) - { - Console::WriteLine( " {0} acquired the lock", Thread::CurrentThread->Name ); - - //Code to access a resource that is not thread safe would go here. - //Simulate some work - Thread::Sleep( 500 ); - Console::WriteLine( " {0} exiting lock", Thread::CurrentThread->Name ); - - //Release the lock - Interlocked::Exchange( usingResource, 0 ); - return true; - } - else - { - Console::WriteLine( " {0} was denied the lock", Thread::CurrentThread->Name ); - return false; - } - } - - - //0 for false, 1 for true. - static int usingResource; -}; - -int main() -{ - Thread^ myThread; - Random^ rnd = gcnew Random; - for ( int i = 0; i < numThreads; i++ ) - { - myThread = gcnew Thread( gcnew ThreadStart( MyInterlockedExchangeExampleClass::MyThreadProc ) ); - myThread->Name = String::Format( "Thread {0}", i + 1 ); - - //Wait a random amount of time before starting next thread. - Thread::Sleep( rnd->Next( 0, 1000 ) ); - myThread->Start(); - - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/CPP/source.cpp deleted file mode 100644 index f89e7184409..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/CPP/source.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -ref class Example -{ -private: - // mre is used to block and release threads manually. It is - // created in the unsignaled state. - static ManualResetEvent^ mre = gcnew ManualResetEvent(false); - - static void ThreadProc() - { - String^ name = Thread::CurrentThread->Name; - - Console::WriteLine(name + " starts and calls mre->WaitOne()"); - - mre->WaitOne(); - - Console::WriteLine(name + " ends."); - } - -public: - static void Demo() - { - Console::WriteLine("\nStart 3 named threads that block on a ManualResetEvent:\n"); - - for(int i = 0; i <=2 ; i++) - { - Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc)); - t->Name = "Thread_" + i; - t->Start(); - } - - Thread::Sleep(500); - Console::WriteLine("\nWhen all three threads have started, press Enter to call Set()" + - "\nto release all the threads.\n"); - Console::ReadLine(); - - mre->Set(); - - Thread::Sleep(500); - Console::WriteLine("\nWhen a ManualResetEvent is signaled, threads that call WaitOne()" + - "\ndo not block. Press Enter to show this.\n"); - Console::ReadLine(); - - for(int i = 3; i <= 4; i++) - { - Thread^ t = gcnew Thread(gcnew ThreadStart(ThreadProc)); - t->Name = "Thread_" + i; - t->Start(); - } - - Thread::Sleep(500); - Console::WriteLine("\nPress Enter to call Reset(), so that threads once again block" + - "\nwhen they call WaitOne().\n"); - Console::ReadLine(); - - mre->Reset(); - - // Start a thread that waits on the ManualResetEvent. - Thread^ t5 = gcnew Thread(gcnew ThreadStart(ThreadProc)); - t5->Name = "Thread_5"; - t5->Start(); - - Thread::Sleep(500); - Console::WriteLine("\nPress Enter to call Set() and conclude the demo."); - Console::ReadLine(); - - mre->Set(); - - // If you run this example in Visual Studio, uncomment the following line: - //Console::ReadLine(); - } -}; - -int main() -{ - Example::Demo(); -} - -/* This example produces output similar to the following: - -Start 3 named threads that block on a ManualResetEvent: - -Thread_0 starts and calls mre->WaitOne() -Thread_1 starts and calls mre->WaitOne() -Thread_2 starts and calls mre->WaitOne() - -When all three threads have started, press Enter to call Set() -to release all the threads. - - -Thread_2 ends. -Thread_1 ends. -Thread_0 ends. - -When a ManualResetEvent is signaled, threads that call WaitOne() -do not block. Press Enter to show this. - - -Thread_3 starts and calls mre->WaitOne() -Thread_3 ends. -Thread_4 starts and calls mre->WaitOne() -Thread_4 ends. - -Press Enter to call Reset(), so that threads once again block -when they call WaitOne(). - - -Thread_5 starts and calls mre->WaitOne() - -Press Enter to call Set() and conclude the demo. - -Thread_5 ends. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 1Arg Ctor Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 1Arg Ctor Example/CPP/class1.cpp deleted file mode 100644 index b46723cfa04..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 1Arg Ctor Example/CPP/class1.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -const int numIterations = 1; -const int numThreads = 3; - -ref class Test -{ -public: - - // Create a new Mutex. The creating thread owns the - // Mutex. - static Mutex^ mut = gcnew Mutex( true ); - static void MyThreadProc() - { - for ( int i = 0; i < numIterations; i++ ) - { - UseResource(); - - } - } - - -private: - - // This method represents a resource that must be synchronized - // so that only one thread at a time can enter. - static void UseResource() - { - - //Wait until it is OK to enter. - mut->WaitOne(); - Console::WriteLine( "{0} has entered protected the area", Thread::CurrentThread->Name ); - - // Place code to access non-reentrant resources here. - // Simulate some work. - Thread::Sleep( 500 ); - Console::WriteLine( "{0} is leaving protected the area\r\n", Thread::CurrentThread->Name ); - - // Release the Mutex. - mut->ReleaseMutex(); - } - -}; - -int main() -{ - - // Initialize the Mutex. - Mutex^ mut = Test::mut; - - // Create the threads that will use the protected resource. - for ( int i = 0; i < numThreads; i++ ) - { - Thread^ myThread = gcnew Thread( gcnew ThreadStart( Test::MyThreadProc ) ); - myThread->Name = String::Format( "Thread {0}", i + 1 ); - myThread->Start(); - - } - - // Wait one second before allowing other threads to - // acquire the Mutex. - Console::WriteLine( "Creating thread owns the Mutex." ); - Thread::Sleep( 1000 ); - Console::WriteLine( "Creating thread releases the Mutex.\r\n" ); - mut->ReleaseMutex(); -} -// The example displays output like the following: -// Creating thread owns the Mutex. -// Creating thread releases the Mutex. -// -// Thread1 has entered the protected area -// Thread1 is leaving the protected area -// -// Thread2 has entered the protected area -// Thread2 is leaving the protected area -// -// Thread3 has entered the protected area -// Thread3 is leaving the protected area -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 2Arg Ctor Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 2Arg Ctor Example/CPP/class1.cpp deleted file mode 100644 index 4079eedaa6e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 2Arg Ctor Example/CPP/class1.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -int main() -{ - // Create the named mutex. Only one system object named - // "MyMutex" can exist; the local Mutex object represents - // this system object, regardless of which process or thread - // caused "MyMutex" to be created. - Mutex^ m = gcnew Mutex( false,"MyMutex" ); - - // Try to gain control of the named mutex. If the mutex is - // controlled by another thread, wait for it to be released. - Console::WriteLine( "Waiting for the Mutex." ); - m->WaitOne(); - - // Keep control of the mutex until the user presses - // ENTER. - Console::WriteLine( "This application owns the mutex. " - "Press ENTER to release the mutex and exit." ); - Console::ReadLine(); - m->ReleaseMutex(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 3Arg Ctor Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 3Arg Ctor Example/CPP/class1.cpp deleted file mode 100644 index a8d967c7296..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 3Arg Ctor Example/CPP/class1.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// -// This example shows how a named mutex is used to signal between -// processes or threads. -// Run this program from two (or more) command windows. Each process -// creates a Mutex object that represents the named mutex "MyMutex". -// The named mutex is a system object whose lifetime is bounded by the -// lifetimes of the Mutex objects that represent it. The named mutex -// is created when the first process creates its local Mutex; in this -// example, the named mutex is owned by the first process. The named -// mutex is destroyed when all the Mutex objects that represent it -// have been released. -// The second process (and any subsequent process) waits for earlier -// processes to release the named mutex. -using namespace System; -using namespace System::Threading; -int main() -{ - - // Set this variable to false if you do not want to request - // initial ownership of the named mutex. - bool requestInitialOwnership = true; - bool mutexWasCreated; - - // Request initial ownership of the named mutex by passing - // true for the first parameter. Only one system object named - // "MyMutex" can exist; the local Mutex object represents - // this system object. If "MyMutex" is created by this call, - // then mutexWasCreated contains true; otherwise, it contains - // false. - Mutex^ m = gcnew Mutex( requestInitialOwnership, "MyMutex", mutexWasCreated ); - - // This thread owns the mutex only if it both requested - // initial ownership and created the named mutex. Otherwise, - // it can request the named mutex by calling WaitOne. - if ( !(requestInitialOwnership && mutexWasCreated) ) - { - Console::WriteLine( "Waiting for the named mutex." ); - m->WaitOne(); - } - - - // Once the process has gained control of the named mutex, - // hold onto it until the user presses ENTER. - Console::WriteLine( "This process owns the named mutex. " - "Press ENTER to release the mutex and exit." ); - Console::ReadLine(); - - // Call ReleaseMutex to allow other threads to gain control - // of the named mutex. If you keep a reference to the local - // Mutex, you can call WaitOne to request control of the - // named mutex. - m->ReleaseMutex(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/CPP/class1.cpp deleted file mode 100644 index 958035c2e03..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/CPP/class1.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -// This example shows how a Mutex is used to synchronize access -// to a protected resource. Unlike Monitor, Mutex can be used with -// WaitHandle.WaitAll and WaitAny, and can be passed across -// AppDomain boundaries. -using namespace System; -using namespace System::Threading; -const int numIterations = 1; -const int numThreads = 3; -ref class Test -{ -public: - - // Create a new Mutex. The creating thread does not own the - // Mutex. - static Mutex^ mut = gcnew Mutex; - static void MyThreadProc() - { - for ( int i = 0; i < numIterations; i++ ) - { - UseResource(); - - } - } - - -private: - - // This method represents a resource that must be synchronized - // so that only one thread at a time can enter. - static void UseResource() - { - - //Wait until it is OK to enter. - mut->WaitOne(); - Console::WriteLine( "{0} has entered protected the area", Thread::CurrentThread->Name ); - - // Place code to access non-reentrant resources here. - // Simulate some work. - Thread::Sleep( 500 ); - Console::WriteLine( "{0} is leaving protected the area\r\n", Thread::CurrentThread->Name ); - - // Release the Mutex. - mut->ReleaseMutex(); - } - -}; - -int main() -{ - - // Create the threads that will use the protected resource. - for ( int i = 0; i < numThreads; i++ ) - { - Thread^ myThread = gcnew Thread( gcnew ThreadStart( Test::MyThreadProc ) ); - myThread->Name = String::Format( "Thread {0}", i + 1 ); - myThread->Start(); - - } - - // The main thread exits, but the application continues to - // run until all foreground threads have exited. -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp deleted file mode 100644 index 26673315e5e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// -using namespace System; -using namespace System::Threading; -using namespace System::Security::AccessControl; -using namespace System::Security::Permissions; - -public ref class Example -{ -public: - [SecurityPermissionAttribute(SecurityAction::Demand,Flags=SecurityPermissionFlag::UnmanagedCode)] - static void Main() - { - // - String^ mutexName = L"MutexExample4"; - - Mutex^ m = nullptr; - bool doesNotExist = false; - bool unauthorized = false; - - // The value of this variable is set by the mutex - // constructor. It is true if the named system mutex was - // created, and false if the named mutex already existed. - // - bool mutexWasCreated = false; - - // Attempt to open the named mutex. - try - { - // Open the mutex with (MutexRights.Synchronize | - // MutexRights.Modify), to enter and release the - // named mutex. - // - m = Mutex::OpenExisting( mutexName ); - } - catch ( WaitHandleCannotBeOpenedException^ ) - { - Console::WriteLine( L"Mutex does not exist." ); - doesNotExist = true; - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", ex->Message ); - unauthorized = true; - } - // - - // There are three cases: (1) The mutex does not exist. - // (2) The mutex exists, but the current user doesn't - // have access. (3) The mutex exists and the user has - // access. - // - if ( doesNotExist ) - { - // - // The mutex does not exist, so create it. - // Create an access control list (ACL) that denies the - // current user the right to enter or release the - // mutex, but allows the right to read and change - // security information for the mutex. - // - String^ user = String::Concat( Environment::UserDomainName, L"\\", - Environment::UserName ); - MutexSecurity^ mSec = gcnew MutexSecurity; - - MutexAccessRule^ rule = gcnew MutexAccessRule( user, - static_cast( - MutexRights::Synchronize | - MutexRights::Modify), - AccessControlType::Deny ); - mSec->AddAccessRule( rule ); - - rule = gcnew MutexAccessRule( user, - static_cast( - MutexRights::ReadPermissions | - MutexRights::ChangePermissions), - AccessControlType::Allow ); - mSec->AddAccessRule( rule ); - - // Create a Mutex object that represents the system - // mutex named by the constant 'mutexName', with - // initial ownership for this thread, and with the - // specified security access. The Boolean value that - // indicates creation of the underlying system object - // is placed in mutexWasCreated. - // - m = gcnew Mutex( true,mutexName, mutexWasCreated,mSec ); - - // If the named system mutex was created, it can be - // used by the current instance of this program, even - // though the current user is denied access. The current - // program owns the mutex. Otherwise, exit the program. - // - if ( mutexWasCreated ) - { - Console::WriteLine( L"Created the mutex." ); - } - else - { - Console::WriteLine( L"Unable to create the mutex." ); - return; - } - // - } - else if ( unauthorized ) - { - // - // Open the mutex to read and change the access control - // security. The access control security defined above - // allows the current user to do this. - // - try - { - m = Mutex::OpenExisting( mutexName, - static_cast( - MutexRights::ReadPermissions | - MutexRights::ChangePermissions) ); - - // Get the current ACL. This requires - // MutexRights.ReadPermissions. - MutexSecurity^ mSec = m->GetAccessControl(); - - String^ user = String::Concat( Environment::UserDomainName, - L"\\", Environment::UserName ); - - // First, the rule that denied the current user - // the right to enter and release the mutex must - // be removed. - MutexAccessRule^ rule = gcnew MutexAccessRule( user, - static_cast( - MutexRights::Synchronize | - MutexRights::Modify), - AccessControlType::Deny ); - mSec->RemoveAccessRule( rule ); - - // Now grant the user the correct rights. - // - rule = gcnew MutexAccessRule( user, - static_cast( - MutexRights::Synchronize | - MutexRights::Modify), - AccessControlType::Allow ); - mSec->AddAccessRule( rule ); - - // Update the ACL. This requires - // MutexRights.ChangePermissions. - m->SetAccessControl( mSec ); - - Console::WriteLine( L"Updated mutex security." ); - - // Open the mutex with (MutexRights.Synchronize - // | MutexRights.Modify), the rights required to - // enter and release the mutex. - // - m = Mutex::OpenExisting( mutexName ); - // - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( - L"Unable to change permissions: {0}", ex->Message ); - return; - } - } - - // If this program created the mutex, it already owns - // the mutex. - // - if ( !mutexWasCreated ) - { - // Enter the mutex, and hold it until the program - // exits. - // - try - { - Console::WriteLine( L"Wait for the mutex." ); - m->WaitOne(); - Console::WriteLine( L"Entered the mutex." ); - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", - ex->Message ); - } - } - - Console::WriteLine( L"Press the Enter key to exit." ); - Console::ReadLine(); - m->ReleaseMutex(); - m->Dispose(); - } -}; - -int main() -{ - Example::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp deleted file mode 100644 index 6395c7d937d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -namespace SystemThreadingExample -{ - public ref class Work - { - public: - void StartThreads() - { - // Start a thread that calls a parameterized static method. - Thread^ newThread = gcnew - Thread(gcnew ParameterizedThreadStart(Work::DoWork)); - newThread->Start(42); - - // Start a thread that calls a parameterized instance method. - Work^ someWork = gcnew Work; - newThread = gcnew Thread( - gcnew ParameterizedThreadStart(someWork, - &Work::DoMoreWork)); - newThread->Start("The answer."); - } - - static void DoWork(Object^ data) - { - Console::WriteLine("Static thread procedure. Data='{0}'", - data); - } - - void DoMoreWork(Object^ data) - { - Console::WriteLine("Instance thread procedure. Data='{0}'", - data); - } - }; -} - -//Entry point of example application -int main() -{ - SystemThreadingExample::Work^ samplework = - gcnew SystemThreadingExample::Work(); - samplework->StartThreads(); -} -// This example displays output like the following: -// Static thread procedure. Data='42' -// Instance thread procedure. Data='The answer.' -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/CPP/source.cpp deleted file mode 100644 index 36560d92fa5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -int main() -{ - ReaderWriterLock^ rwLock = gcnew ReaderWriterLock; - rwLock->AcquireWriterLock( Timeout::Infinite ); - rwLock->AcquireReaderLock( Timeout::Infinite ); - if ( rwLock->IsReaderLockHeld ) - { - Console::WriteLine( "Reader lock held." ); - rwLock->ReleaseReaderLock(); - } - else - if ( rwLock->IsWriterLockHeld ) - { - Console::WriteLine( "Writer lock held." ); - rwLock->ReleaseWriterLock(); - } - else - { - Console::WriteLine( "No locks held." ); - } - - - if ( rwLock->IsReaderLockHeld ) - { - Console::WriteLine( "Reader lock held." ); - rwLock->ReleaseReaderLock(); - } - else - if ( rwLock->IsWriterLockHeld ) - { - Console::WriteLine( "Writer lock held." ); - rwLock->ReleaseWriterLock(); - } - else - { - Console::WriteLine( "No locks held." ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp deleted file mode 100644 index 1aca8464071..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// -// This example shows a ReaderWriterLock protecting a shared -// resource that is read concurrently and written exclusively -// by multiple threads. -// -// The complete code is located in the ReaderWriterLock -// class topic. -using namespace System; -using namespace System::Threading; -public ref class Test -{ -public: - - // Declaring the ReaderWriterLock at the class level - // makes it visible to all threads. - static ReaderWriterLock^ rwl = gcnew ReaderWriterLock; - - // For this example, the shared resource protected by the - // ReaderWriterLock is just an integer. - static int resource = 0; - - // - literal int numThreads = 26; - static bool running = true; - - // Statistics. - static int readerTimeouts = 0; - static int writerTimeouts = 0; - static int reads = 0; - static int writes = 0; - static void ThreadProc() - { - Random^ rnd = gcnew Random; - - // As long as a thread runs, it randomly selects - // various ways to read and write from the shared - // resource. Each of the methods demonstrates one - // or more features of ReaderWriterLock. - while ( running ) - { - double action = rnd->NextDouble(); - if ( action < .8 ) - ReadFromResource( 10 ); - else - if ( action < .81 ) - ReleaseRestore( rnd, 50 ); - else - if ( action < .90 ) - UpgradeDowngrade( rnd, 100 ); - else - WriteToResource( rnd, 100 ); - } - } - - - // - // Shows how to request and release a reader lock, and - // how to handle time-outs. - static void ReadFromResource( int timeOut ) - { - try - { - rwl->AcquireReaderLock( timeOut ); - try - { - - // It is safe for this thread to read from - // the shared resource. - Display( String::Format( "reads resource value {0}", resource ) ); - Interlocked::Increment( reads ); - } - finally - { - - // Ensure that the lock is released. - rwl->ReleaseReaderLock(); - } - - } - catch ( ApplicationException^ ) - { - - // The reader lock request timed out. - Interlocked::Increment( readerTimeouts ); - } - - } - - - // - // - // Shows how to request and release the writer lock, and - // how to handle time-outs. - static void WriteToResource( Random^ rnd, int timeOut ) - { - try - { - rwl->AcquireWriterLock( timeOut ); - try - { - - // It is safe for this thread to read or write - // from the shared resource. - resource = rnd->Next( 500 ); - Display( String::Format( "writes resource value {0}", resource ) ); - Interlocked::Increment( writes ); - } - finally - { - - // Ensure that the lock is released. - rwl->ReleaseWriterLock(); - } - - } - catch ( ApplicationException^ ) - { - - // The writer lock request timed out. - Interlocked::Increment( writerTimeouts ); - } - - } - - - // - // - // Shows how to request a reader lock, upgrade the - // reader lock to the writer lock, and downgrade to a - // reader lock again. - static void UpgradeDowngrade( Random^ rnd, int timeOut ) - { - try - { - rwl->AcquireReaderLock( timeOut ); - try - { - - // It is safe for this thread to read from - // the shared resource. - Display( String::Format( "reads resource value {0}", resource ) ); - Interlocked::Increment( reads ); - - // If it is necessary to write to the resource, - // you must either release the reader lock and - // then request the writer lock, or upgrade the - // reader lock. Note that upgrading the reader lock - // puts the thread in the write queue, behind any - // other threads that might be waiting for the - // writer lock. - try - { - LockCookie lc = rwl->UpgradeToWriterLock( timeOut ); - try - { - - // It is safe for this thread to read or write - // from the shared resource. - resource = rnd->Next( 500 ); - Display( String::Format( "writes resource value {0}", resource ) ); - Interlocked::Increment( writes ); - } - finally - { - - // Ensure that the lock is released. - rwl->DowngradeFromWriterLock( lc ); - } - - } - catch ( ApplicationException^ ) - { - - // The upgrade request timed out. - Interlocked::Increment( writerTimeouts ); - } - - - // When the lock has been downgraded, it is - // still safe to read from the resource. - Display( String::Format( "reads resource value {0}", resource ) ); - Interlocked::Increment( reads ); - } - finally - { - - // Ensure that the lock is released. - rwl->ReleaseReaderLock(); - } - - } - catch ( ApplicationException^ ) - { - - // The reader lock request timed out. - Interlocked::Increment( readerTimeouts ); - } - - } - - - // - // - // Shows how to release all locks and later restore - // the lock state. Shows how to use sequence numbers - // to determine whether another thread has obtained - // a writer lock since this thread last accessed the - // resource. - static void ReleaseRestore( Random^ rnd, int timeOut ) - { - int lastWriter; - try - { - rwl->AcquireReaderLock( timeOut ); - try - { - - // It is safe for this thread to read from - // the shared resource. Cache the value. (You - // might do this if reading the resource is - // an expensive operation.) - int resourceValue = resource; - Display( String::Format( "reads resource value {0}", resourceValue ) ); - Interlocked::Increment( reads ); - - // Save the current writer sequence number. - lastWriter = rwl->WriterSeqNum; - - // Release the lock, and save a cookie so the - // lock can be restored later. - LockCookie lc = rwl->ReleaseLock(); - - // Wait for a random interval (up to a - // quarter of a second), and then restore - // the previous state of the lock. Note that - // there is no timeout on the Restore method. - Thread::Sleep( rnd->Next( 250 ) ); - rwl->RestoreLock( lc ); - - // Check whether other threads obtained the - // writer lock in the interval. If not, then - // the cached value of the resource is still - // valid. - if ( rwl->AnyWritersSince( lastWriter ) ) - { - resourceValue = resource; - Interlocked::Increment( reads ); - Display( String::Format( "resource has changed {0}", resourceValue ) ); - } - else - { - Display( String::Format( "resource has not changed {0}", resourceValue ) ); - } - } - finally - { - - // Ensure that the lock is released. - rwl->ReleaseReaderLock(); - } - - } - catch ( ApplicationException^ ) - { - - // The reader lock request timed out. - Interlocked::Increment( readerTimeouts ); - } - - } - - - // - // Helper method briefly displays the most recent - // thread action. Comment out calls to Display to - // get a better idea of throughput. - static void Display( String^ msg ) - { - Console::Write( "Thread {0} {1}. \r", Thread::CurrentThread->Name, msg ); - } - - // -}; - - -// -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // Start a series of threads. Each thread randomly - // performs reads and writes on the shared resource. - array^t = gcnew array(Test::numThreads); - for ( int i = 0; i < Test::numThreads; i++ ) - { - t[ i ] = gcnew Thread( gcnew ThreadStart( Test::ThreadProc ) ); - t[ i ]->Name = gcnew String( Convert::ToChar( i + 65 ),1 ); - t[ i ]->Start(); - if ( i > 10 ) - Thread::Sleep( 300 ); - - } - - // Tell the threads to shut down, then wait until they all - // finish. - Test::running = false; - for ( int i = 0; i < Test::numThreads; i++ ) - { - t[ i ]->Join(); - - } - - // Display statistics. - Console::WriteLine( "\r\n {0} reads, {1} writes, {2} reader time-outs, {3} writer time-outs.", Test::reads, Test::writes, Test::readerTimeouts, Test::writerTimeouts ); - Console::WriteLine( "Press ENTER to exit." ); - Console::ReadLine(); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 3/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 3/CPP/source.cpp deleted file mode 100644 index c9829906328..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 3/CPP/source.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -#using -using namespace System; -using namespace System::Threading; - -public ref class Example -{ -public: - static void main() - { - // Create a Semaphore object that represents the named - // system semaphore "SemaphoreExample3". The semaphore has a - // maximum count of five. The initial count is also five. - // There is no point in using a smaller initial count, - // because the initial count is not used if this program - // doesn't create the named system semaphore, and with - // this method overload there is no way to tell. Thus, this - // program assumes that it is competing with other - // programs for the semaphore. - // - Semaphore^ sem = gcnew Semaphore( 5,5,L"SemaphoreExample3" ); - - // Attempt to enter the semaphore three times. If another - // copy of this program is already running, only the first - // two requests can be satisfied. The third blocks. Note - // that in a real application, timeouts should be used - // on the WaitOne calls, to avoid deadlocks. - // - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore once." ); - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore twice." ); - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore three times." ); - - // The thread executing this program has entered the - // semaphore three times. If a second copy of the program - // is run, it will block until this program releases the - // semaphore at least once. - // - Console::WriteLine( L"Enter the number of times to call Release." ); - int n; - if ( Int32::TryParse( Console::ReadLine(),n ) ) - { - sem->Release( n ); - } - - int remaining = 3 - n; - if ( remaining > 0 ) - { - Console::WriteLine( L"Press Enter to release the remaining " - L"count ({0}) and exit the program.", remaining ); - Console::ReadLine(); - sem->Release( remaining ); - } - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 4/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 4/CPP/source.cpp deleted file mode 100644 index a51b308ac9e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 4/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -#using -using namespace System; -using namespace System::Threading; - -public ref class Example -{ -public: - static void main() - { - // The value of this variable is set by the semaphore - // constructor. It is true if the named system semaphore was - // created, and false if the named semaphore already existed. - // - bool semaphoreWasCreated; - - // Create a Semaphore object that represents the named - // system semaphore "SemaphoreExample". The semaphore has a - // maximum count of five, and an initial count of two. The - // Boolean value that indicates creation of the underlying - // system object is placed in semaphoreWasCreated. - // - Semaphore^ sem = gcnew Semaphore( 2,5,L"SemaphoreExample", - semaphoreWasCreated ); - if ( semaphoreWasCreated ) - { - // If the named system semaphore was created, its count is - // set to the initial count requested in the constructor. - // In effect, the current thread has entered the semaphore - // three times. - // - Console::WriteLine( L"Entered the semaphore three times." ); - } - else - { - // If the named system semaphore was not created, - // attempt to enter it three times. If another copy of - // this program is already running, only the first two - // requests can be satisfied. The third blocks. - // - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore once." ); - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore twice." ); - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore three times." ); - } - - // The thread executing this program has entered the - // semaphore three times. If a second copy of the program - // is run, it will block until this program releases the - // semaphore at least once. - // - Console::WriteLine( L"Enter the number of times to call Release." ); - int n; - if ( Int32::TryParse( Console::ReadLine(), n ) ) - { - sem->Release( n ); - } - - int remaining = 3 - n; - if ( remaining > 0 ) - { - Console::WriteLine( L"Press Enter to release the remaining " - L"count ({0}) and exit the program.", remaining ); - Console::ReadLine(); - sem->Release( remaining ); - } - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp deleted file mode 100644 index 471a8d1e8b1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp +++ /dev/null @@ -1,186 +0,0 @@ -// -#using -using namespace System; -using namespace System::Threading; -using namespace System::Security::AccessControl; -using namespace System::Security::Permissions; - -public ref class Example -{ -public: - [SecurityPermissionAttribute(SecurityAction::Demand, Flags = SecurityPermissionFlag::UnmanagedCode)] - static void main() - { - // - String^ semaphoreName = L"SemaphoreExample5"; - - Semaphore^ sem = nullptr; - bool doesNotExist = false; - bool unauthorized = false; - - // Attempt to open the named semaphore. - try - { - // Open the semaphore with (SemaphoreRights.Synchronize - // | SemaphoreRights.Modify), to enter and release the - // named semaphore. - // - sem = Semaphore::OpenExisting( semaphoreName ); - } - catch ( WaitHandleCannotBeOpenedException^ ex ) - { - Console::WriteLine( L"Semaphore does not exist." ); - doesNotExist = true; - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", ex->Message ); - unauthorized = true; - } - // - - // There are three cases: (1) The semaphore does not exist. - // (2) The semaphore exists, but the current user doesn't - // have access. (3) The semaphore exists and the user has - // access. - // - if ( doesNotExist ) - { - // - // The semaphore does not exist, so create it. - // - // The value of this variable is set by the semaphore - // constructor. It is true if the named system semaphore was - // created, and false if the named semaphore already existed. - // - bool semaphoreWasCreated; - - // Create an access control list (ACL) that denies the - // current user the right to enter or release the - // semaphore, but allows the right to read and change - // security information for the semaphore. - // - String^ user = String::Concat( Environment::UserDomainName, - L"\\", Environment::UserName ); - SemaphoreSecurity^ semSec = gcnew SemaphoreSecurity; - - SemaphoreAccessRule^ rule = gcnew SemaphoreAccessRule( user, - static_cast( - SemaphoreRights::Synchronize | - SemaphoreRights::Modify ), - AccessControlType::Deny ); - semSec->AddAccessRule( rule ); - - rule = gcnew SemaphoreAccessRule( user, - static_cast( - SemaphoreRights::ReadPermissions | - SemaphoreRights::ChangePermissions ), - AccessControlType::Allow ); - semSec->AddAccessRule( rule ); - - // Create a Semaphore object that represents the system - // semaphore named by the constant 'semaphoreName', with - // maximum count three, initial count three, and the - // specified security access. The Boolean value that - // indicates creation of the underlying system object is - // placed in semaphoreWasCreated. - // - sem = gcnew Semaphore( 3,3,semaphoreName,semaphoreWasCreated,semSec ); - - // If the named system semaphore was created, it can be - // used by the current instance of this program, even - // though the current user is denied access. The current - // program enters the semaphore. Otherwise, exit the - // program. - // - if ( semaphoreWasCreated ) - { - Console::WriteLine( L"Created the semaphore." ); - } - else - { - Console::WriteLine( L"Unable to create the semaphore." ); - return; - } - // - - } - else if ( unauthorized ) - { - // - // Open the semaphore to read and change the access - // control security. The access control security defined - // above allows the current user to do this. - // - try - { - sem = Semaphore::OpenExisting( semaphoreName, - static_cast( - SemaphoreRights::ReadPermissions | - SemaphoreRights::ChangePermissions )); - - // Get the current ACL. This requires - // SemaphoreRights.ReadPermissions. - SemaphoreSecurity^ semSec = sem->GetAccessControl(); - - String^ user = String::Concat( Environment::UserDomainName, - L"\\", Environment::UserName ); - - // First, the rule that denied the current user - // the right to enter and release the semaphore must - // be removed. - SemaphoreAccessRule^ rule = gcnew SemaphoreAccessRule( user, - static_cast( - SemaphoreRights::Synchronize | - SemaphoreRights::Modify ), - AccessControlType::Deny ); - semSec->RemoveAccessRule( rule ); - - // Now grant the user the correct rights. - // - rule = gcnew SemaphoreAccessRule( user, - static_cast( - SemaphoreRights::Synchronize | - SemaphoreRights::Modify ), - AccessControlType::Allow ); - semSec->AddAccessRule( rule ); - - // Update the ACL. This requires - // SemaphoreRights.ChangePermissions. - sem->SetAccessControl( semSec ); - - Console::WriteLine( L"Updated semaphore security." ); - - // Open the semaphore with (SemaphoreRights.Synchronize - // | SemaphoreRights.Modify), the rights required to - // enter and release the semaphore. - // - sem = Semaphore::OpenExisting( semaphoreName ); - // - - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unable to change permissions: {0}", ex->Message ); - return; - } - } - - // Enter the semaphore, and hold it until the program - // exits. - // - try - { - sem->WaitOne(); - Console::WriteLine( L"Entered the semaphore." ); - Console::WriteLine( L"Press the Enter key to exit." ); - Console::ReadLine(); - sem->Release(); - } - catch ( UnauthorizedAccessException^ ex ) - { - Console::WriteLine( L"Unauthorized access: {0}", ex->Message ); - } - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp deleted file mode 100644 index 13cb5b616e3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -#using -using namespace System; -using namespace System::Threading; - -public ref class Example -{ -private: - // A semaphore that simulates a limited resource pool. - // - static Semaphore^ _pool; - - // A padding interval to make the output more orderly. - static int _padding; - -public: - static void Main() - { - // Create a semaphore that can satisfy up to three - // concurrent requests. Use an initial count of zero, - // so that the entire semaphore count is initially - // owned by the main program thread. - // - _pool = gcnew Semaphore( 0,3 ); - - // Create and start five numbered threads. - // - for ( int i = 1; i <= 5; i++ ) - { - Thread^ t = gcnew Thread( - gcnew ParameterizedThreadStart( Worker ) ); - - // Start the thread, passing the number. - // - t->Start( i ); - } - - // Wait for half a second, to allow all the - // threads to start and to block on the semaphore. - // - Thread::Sleep( 500 ); - - // The main thread starts out holding the entire - // semaphore count. Calling Release(3) brings the - // semaphore count back to its maximum value, and - // allows the waiting threads to enter the semaphore, - // up to three at a time. - // - Console::WriteLine( L"Main thread calls Release(3)." ); - _pool->Release( 3 ); - - Console::WriteLine( L"Main thread exits." ); - } - -private: - static void Worker( Object^ num ) - { - // Each worker thread begins by requesting the - // semaphore. - Console::WriteLine( L"Thread {0} begins and waits for the semaphore.", num ); - _pool->WaitOne(); - - // A padding interval to make the output more orderly. - int padding = Interlocked::Add( _padding, 100 ); - - Console::WriteLine( L"Thread {0} enters the semaphore.", num ); - - // The thread's "work" consists of sleeping for - // about a second. Each thread "works" a little - // longer, just to make the output more orderly. - // - Thread::Sleep( 1000 + padding ); - - Console::WriteLine( L"Thread {0} releases the semaphore.", num ); - Console::WriteLine( L"Thread {0} previous semaphore count: {1}", - num, _pool->Release() ); - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.SemaphoreFullException/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.SemaphoreFullException/CPP/source.cpp deleted file mode 100644 index 91f6e6c03f5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.SemaphoreFullException/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -using namespace System; -using namespace System::Threading; - -public ref class Example -{ -private: - // A semaphore that can satisfy at most two concurrent - // requests. - // - static Semaphore^ _pool = gcnew Semaphore( 2,2 ); - -public: - static void main() - { - // Create and start two threads, A and B. - // - Thread^ tA = gcnew Thread( gcnew ThreadStart( ThreadA ) ); - tA->Start(); - - Thread^ tB = gcnew Thread( gcnew ThreadStart( ThreadB ) ); - tB->Start(); - } - -private: - static void ThreadA() - { - // Thread A enters the semaphore and simulates a task - // that lasts a second. - // - _pool->WaitOne(); - Console::WriteLine( L"Thread A entered the semaphore." ); - - Thread::Sleep( 1000 ); - - try - { - _pool->Release(); - Console::WriteLine( L"Thread A released the semaphore." ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"Thread A: {0}", ex->Message ); - } - } - - static void ThreadB() - { - // Thread B simulates a task that lasts half a second, - // then enters the semaphore. - // - Thread::Sleep( 500 ); - - _pool->WaitOne(); - Console::WriteLine( L"Thread B entered the semaphore." ); - - // Due to a programming error, Thread B releases the - // semaphore twice. To fix the program, delete one line. - _pool->Release(); - _pool->Release(); - Console::WriteLine( L"Thread B exits successfully." ); - } -}; -/* This code example produces the following output: - -Thread A entered the semaphore. -Thread B entered the semaphore. -Thread B exits successfully. -Thread A: Adding the given count to the semaphore would cause it to exceed its maximum count. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/CPP/source.cpp deleted file mode 100644 index 4ae633572bc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Test -{ -private: - Test(){} - - -public: - static void TestMethod() - { - try - { - while ( true ) - { - Console::WriteLine( "New thread running." ); - Thread::Sleep( 1000 ); - } - } - catch ( ThreadAbortException^ abortException ) - { - Console::WriteLine( dynamic_cast(abortException->ExceptionState) ); - } - - } - -}; - -int main() -{ - Thread^ newThread = gcnew Thread( gcnew ThreadStart( &Test::TestMethod ) ); - newThread->Start(); - Thread::Sleep( 1000 ); - - // Abort newThread. - Console::WriteLine( "Main aborting new thread." ); - newThread->Abort( "Information from main." ); - - // Wait for the thread to terminate. - newThread->Join(); - Console::WriteLine( "New thread terminated - main exiting." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/CPP/source.cpp deleted file mode 100644 index 99ee37687eb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -using namespace System::Threading; - -public ref class MyUtility -{ -public: - void PerformTask() - { - // Code in this region can be aborted without affecting - // other tasks. - // - Thread::BeginCriticalRegion(); - // - // The host might decide to unload the application domain - // if a failure occurs in this code region. - // - Thread::EndCriticalRegion(); - // - // Code in this region can be aborted without affecting - // other tasks. - } -}; -// - -int main() {} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/CPP/source.cpp deleted file mode 100644 index 2fd262cc0fa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -using namespace System::Threading; -using namespace System::Security::Permissions; - -public ref class MyUtility -{ -public: - [SecurityPermissionAttribute(SecurityAction::Demand, ControlThread=true)] - void PerformTask() - { - // Code that does not have thread affinity goes here. - // - Thread::BeginThreadAffinity(); - // - // Code that has thread affinity goes here. - // - Thread::EndThreadAffinity(); - // - // More code that does not have thread affinity. - } -}; -// - -int main() {} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Culture/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Culture/CPP/source.cpp deleted file mode 100644 index e91e5179e09..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Culture/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Threading; -using namespace System::Windows::Forms; -ref class UICulture: public Form -{ -public: - UICulture() - { - - // Set the user interface to display in the - // same culture as that set in Control Panel. - Thread::CurrentThread->CurrentUICulture = Thread::CurrentThread->CurrentCulture; - - // Add additional code. - } -}; - - -int main() -{ - Application::Run( gcnew UICulture ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.CurrentPrincipal/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.CurrentPrincipal/CPP/source.cpp deleted file mode 100644 index 1ae83042eb2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.CurrentPrincipal/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Security::Principal; -using namespace System::Threading; - -int main() -{ - array^rolesArray = {"managers","executives"}; - try - { - - // Set the principal to a new generic principal. - Thread::CurrentPrincipal = gcnew GenericPrincipal( gcnew GenericIdentity( "Bob","Passport" ),rolesArray ); - } - catch ( SecurityException^ secureException ) - { - Console::WriteLine( "{0}: Permission to set Principal " - "is denied.", secureException->GetType()->Name ); - } - - IPrincipal^ threadPrincipal = Thread::CurrentPrincipal; - Console::WriteLine( "Name: {0}\nIsAuthenticated: {1}" - "\nAuthenticationType: {2}", threadPrincipal->Identity->Name, threadPrincipal->Identity->IsAuthenticated.ToString(), threadPrincipal->Identity->AuthenticationType ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/CPP/source.cpp deleted file mode 100644 index 88a93c82f9d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Slot -{ -private: - static Random^ randomGenerator; - static LocalDataStoreSlot^ localSlot; - static Slot() - { - randomGenerator = gcnew Random; - localSlot = Thread::AllocateDataSlot(); - } - - -public: - static void SlotTest() - { - - // Set different data in each thread's data slot. - Thread::SetData( localSlot, randomGenerator->Next( 1, 200 ) ); - - // Write the data from each thread's data slot. - Console::WriteLine( "Data in thread_{0}'s data slot: {1,3}", AppDomain::GetCurrentThreadId().ToString(), Thread::GetData( localSlot )->ToString() ); - - // Allow other threads time to execute SetData to show - // that a thread's data slot is unique to the thread. - Thread::Sleep( 1000 ); - Console::WriteLine( "Data in thread_{0}'s data slot: {1,3}", AppDomain::GetCurrentThreadId().ToString(), Thread::GetData( localSlot )->ToString() ); - } - -}; - -int main() -{ - array^newThreads = gcnew array(4); - for ( int i = 0; i < newThreads->Length; i++ ) - { - newThreads[ i ] = gcnew Thread( gcnew ThreadStart( &Slot::SlotTest ) ); - newThreads[ i ]->Start(); - - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp deleted file mode 100644 index 7e368cd0a1c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -ref class ThreadData -{ -private: - [ThreadStatic] - static int threadSpecificData; - -public: - static void ThreadStaticDemo() - { - // Store the managed thread id for each thread in the static - // variable. - threadSpecificData = Thread::CurrentThread->ManagedThreadId; - - // Allow other threads time to execute the same code, to show - // that the static data is unique to each thread. - Thread::Sleep( 1000 ); - - // Display the static data. - Console::WriteLine( "Data for managed thread {0}: {1}", - Thread::CurrentThread->ManagedThreadId, threadSpecificData ); - } -}; - -int main() -{ - for ( int i = 0; i < 3; i++ ) - { - Thread^ newThread = - gcnew Thread( gcnew ThreadStart( ThreadData::ThreadStaticDemo )); - newThread->Start(); - } -} - -/* This code example produces output similar to the following: - -Data for managed thread 4: 4 -Data for managed thread 5: 5 -Data for managed thread 3: 3 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Domain/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Domain/CPP/source.cpp deleted file mode 100644 index 497071f1d0f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Domain/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Test -{ -private: - Test(){} - - -public: - static void ThreadMethod() - { - Console::WriteLine( "Thread {0} started in {1} with AppDomainID = {2}.", AppDomain::GetCurrentThreadId().ToString(), Thread::GetDomain()->FriendlyName, Thread::GetDomainID().ToString() ); - } - -}; - -int main() -{ - Thread^ newThread = gcnew Thread( gcnew ThreadStart( &Test::ThreadMethod ) ); - newThread->Start(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp deleted file mode 100644 index 533813e424f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Permissions; -using namespace System::Threading; - -ref class StayAwake -{ -private: - bool sleepSwitch; - -public: - - property bool SleepSwitch - { - void set( bool value ) - { - sleepSwitch = value; - } - - } - StayAwake() - { - sleepSwitch = false; - } - - void ThreadMethod() - { - Console::WriteLine( "newThread is executing ThreadMethod." ); - while ( !sleepSwitch ) - { - - // Use SpinWait instead of Sleep to demonstrate the - // effect of calling Interrupt on a running thread. - Thread::SpinWait( 10000000 ); - } - - try - { - Console::WriteLine( "newThread going to sleep." ); - - // When newThread goes to sleep, it is immediately - // woken up by a ThreadInterruptedException. - Thread::Sleep( Timeout::Infinite ); - } - catch ( ThreadInterruptedException^ /*e*/ ) - { - Console::WriteLine( "newThread cannot go to sleep - " - "interrupted by main thread." ); - } - - } - -}; - -int main() -{ - StayAwake^ stayAwake = gcnew StayAwake; - Thread^ newThread = gcnew Thread( gcnew ThreadStart( stayAwake, &StayAwake::ThreadMethod ) ); - newThread->Start(); - - // The following line causes an exception to be thrown - // in ThreadMethod if newThread is currently blocked - // or becomes blocked in the future. - newThread->Interrupt(); - Console::WriteLine( "Main thread calls Interrupt on newThread." ); - - // Then tell newThread to go to sleep. - stayAwake->SleepSwitch = true; - - // Wait for newThread to end. - newThread->Join(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsBackground/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsBackground/CPP/source.cpp deleted file mode 100644 index 7743178ff7e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsBackground/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -ref class BackgroundTest -{ -private: - int maxIterations; - -public: - BackgroundTest(int maxIterations) - { - this->maxIterations = maxIterations; - } - - void RunLoop() - { - for (int i = 0; i < maxIterations; i++ ) - { - Console::WriteLine("{0} count: {1}", - Thread::CurrentThread->IsBackground ? - "Background Thread" : "Foreground Thread", i); - Thread::Sleep(250); - - } - Console::WriteLine("{0} finished counting.", - Thread::CurrentThread->IsBackground ? - "Background Thread" : "Foreground Thread"); - } -}; - -int main() -{ - BackgroundTest^ shortTest = gcnew BackgroundTest( 10 ); - Thread^ foregroundThread = gcnew Thread( gcnew ThreadStart( shortTest, &BackgroundTest::RunLoop ) ); - foregroundThread->Name = "ForegroundThread"; - BackgroundTest^ longTest = gcnew BackgroundTest( 50 ); - Thread^ backgroundThread = gcnew Thread( gcnew ThreadStart( longTest, &BackgroundTest::RunLoop ) ); - backgroundThread->Name = "BackgroundThread"; - backgroundThread->IsBackground = true; - foregroundThread->Start(); - backgroundThread->Start(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsThreadPoolThread/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsThreadPoolThread/CPP/source.cpp deleted file mode 100644 index 9ae320e27d8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsThreadPoolThread/CPP/source.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class IsThreadPool -{ -public: - - // - static void ThreadMethod() - { - Console::WriteLine( "ThreadOne, executing ThreadMethod, " - "is {0}from the thread pool.", Thread::CurrentThread->IsThreadPoolThread ? (String^)"" : "not " ); - } - - - // - static void WorkMethod( Object^ stateInfo ) - { - Console::WriteLine( "ThreadTwo, executing WorkMethod, " - "is {0}from the thread pool.", Thread::CurrentThread->IsThreadPoolThread ? (String^)"" : "not " ); - - // Signal that this thread is finished. - dynamic_cast(stateInfo)->Set(); - } - -}; - -int main() -{ - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - Thread^ regularThread = gcnew Thread( gcnew ThreadStart( &IsThreadPool::ThreadMethod ) ); - regularThread->Start(); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &IsThreadPool::WorkMethod ), autoEvent ); - - // Wait for foreground thread to end. - regularThread->Join(); - - // Wait for background thread to end. - autoEvent->WaitOne(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp deleted file mode 100644 index 7ef570a3bad..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -ref class Slot -{ -private: - static Random^ randomGenerator = gcnew Random(); - -public: - static void SlotTest() - { - // Set random data in each thread's data slot. - int slotData = randomGenerator->Next(1, 200); - int threadId = Thread::CurrentThread->ManagedThreadId; - - Thread::SetData( - Thread::GetNamedDataSlot("Random"), - slotData); - - // Show what was saved in the thread's data slot. - Console::WriteLine("Data stored in thread_{0}'s data slot: {1,3}", - threadId, slotData); - - // Allow other threads time to execute SetData to show - // that a thread's data slot is unique to itself. - Thread::Sleep(1000); - - int newSlotData = - (int)Thread::GetData(Thread::GetNamedDataSlot("Random")); - - if (newSlotData == slotData) - { - Console::WriteLine("Data in thread_{0}'s data slot is still: {1,3}", - threadId, newSlotData); - } - else - { - Console::WriteLine("Data in thread_{0}'s data slot changed to: {1,3}", - threadId, newSlotData); - } - } -}; - -ref class Test -{ -public: - static void Main() - { - array^ newThreads = gcnew array(4); - int i; - for (i = 0; i < newThreads->Length; i++) - { - newThreads[i] = - gcnew Thread(gcnew ThreadStart(&Slot::SlotTest)); - newThreads[i]->Start(); - } - Thread::Sleep(2000); - for (i = 0; i < newThreads->Length; i++) - { - newThreads[i]->Join(); - Console::WriteLine("Thread_{0} finished.", - newThreads[i]->ManagedThreadId); - } - } -}; - -int main() -{ - Test::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Timespan/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Timespan/CPP/source.cpp deleted file mode 100644 index 3f8ee654cfc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Timespan/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -static TimeSpan waitTime = TimeSpan(0,0,1); - -ref class Test -{ -public: - static void Work() - { - Thread::Sleep( waitTime ); - } - -}; - -int main() -{ - Thread^ newThread = gcnew Thread( gcnew ThreadStart( Test::Work ) ); - newThread->Start(); - if ( newThread->Join( waitTime + waitTime ) ) - { - Console::WriteLine( "New thread terminated." ); - } - else - { - Console::WriteLine( "Join timed out." ); - } -} -// The example displays the following output: -// New thread terminated. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor/CPP/source.cpp deleted file mode 100644 index d4ca56d299c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Work -{ -private: - Work(){} - - -public: - static void DoWork(){} - -}; - -int main() -{ - Thread^ newThread = gcnew Thread( gcnew ThreadStart( &Work::DoWork ) ); - newThread->Start(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor2/CPP/source.cpp deleted file mode 100644 index 0ac57be1362..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor2/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Work -{ -public: - Work(){} - - void DoWork(){} - -}; - -int main() -{ - Work^ threadWork = gcnew Work; - Thread^ newThread = gcnew Thread( gcnew ThreadStart( threadWork, &Work::DoWork ) ); - newThread->Start(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/CPP/source.cpp deleted file mode 100644 index 2f2ccf1a8d9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -ref class Example -{ -public: - - // This thread procedure performs the task. - static void ThreadProc(Object^ stateInfo) - { - - // No state object was passed to QueueUserWorkItem, so stateInfo is 0. - Console::WriteLine( "Hello from the thread pool." ); - } -}; - -int main() -{ - // Queue the task. - ThreadPool::QueueUserWorkItem(gcnew WaitCallback(Example::ThreadProc)); - - Console::WriteLine("Main thread does some work, then sleeps."); - - Thread::Sleep(1000); - Console::WriteLine("Main thread exits."); - return 0; -} -// The example displays output like the following: -// Main thread does some work, then sleeps. -// Hello from the thread pool. -// Main thread exits. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem1/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem1/CPP/source.cpp deleted file mode 100644 index 94c24506593..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem1/CPP/source.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -public ref class Fibonacci -{ -private: - ManualResetEvent^ _doneEvent; - - int Calculate(int n) - { - if (n <= 1) - { - return n; - } - return Calculate(n - 1) + Calculate(n - 2); - } - -public: - - int ID; - int N; - int FibOfN; - - Fibonacci(int id, int n, ManualResetEvent^ doneEvent) - { - ID = id; - N = n; - _doneEvent = doneEvent; - } - - void Calculate() - { - FibOfN = Calculate(N); - } - - void SetDone() - { - _doneEvent->Set(); - } -}; - -public ref struct Example -{ -public: - - static void ThreadProc(Object^ stateInfo) - { - Fibonacci^ f = dynamic_cast(stateInfo); - Console::WriteLine("Thread {0} started...", f->ID); - f->Calculate(); - Console::WriteLine("Thread {0} result calculated...", f->ID); - f->SetDone(); - } -}; - - -void main() -{ - const int FibonacciCalculations = 5; - - array^ doneEvents = gcnew array(FibonacciCalculations); - array^ fibArray = gcnew array(FibonacciCalculations); - Random^ rand = gcnew Random(); - - Console::WriteLine("Launching {0} tasks...", FibonacciCalculations); - - for (int i = 0; i < FibonacciCalculations; i++) - { - doneEvents[i] = gcnew ManualResetEvent(false); - Fibonacci^ f = gcnew Fibonacci(i, rand->Next(20, 40), doneEvents[i]); - fibArray[i] = f; - ThreadPool::QueueUserWorkItem(gcnew WaitCallback(Example::ThreadProc), f); - } - - WaitHandle::WaitAll(doneEvents); - Console::WriteLine("All calculations are complete."); - - for (int i = 0; i < FibonacciCalculations; i++) - { - Fibonacci^ f = fibArray[i]; - Console::WriteLine("Fibonacci({0}) = {1}", f->N, f->FibOfN); - } -} -// Output is similar to: -// Launching 5 tasks... -// Thread 3 started... -// Thread 2 started... -// Thread 1 started... -// Thread 0 started... -// Thread 4 started... -// Thread 4 result calculated... -// Thread 1 result calculated... -// Thread 2 result calculated... -// Thread 0 result calculated... -// Thread 3 result calculated... -// All calculations are complete. -// Fibonacci(30) = 832040 -// Fibonacci(24) = 46368 -// Fibonacci(26) = 121393 -// Fibonacci(36) = 14930352 -// Fibonacci(20) = 6765 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp deleted file mode 100644 index 290d35f3698..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp +++ /dev/null @@ -1,86 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -// TaskInfo contains data that will be passed to the callback -// method. -public ref class TaskInfo -{ -public: - TaskInfo() - { - Handle = nullptr; - OtherInfo = "default"; - } - - RegisteredWaitHandle^ Handle; - String^ OtherInfo; -}; - -ref class Example -{ -public: - - // The callback method executes when the registered wait times out, - // or when the WaitHandle (in this case AutoResetEvent) is signaled. - // WaitProc unregisters the WaitHandle the first time the event is - // signaled. - static void WaitProc( Object^ state, bool timedOut ) - { - - // The state Object must be cast to the correct type, because the - // signature of the WaitOrTimerCallback delegate specifies type - // Object. - TaskInfo^ ti = static_cast(state); - String^ cause = "TIMED OUT"; - if ( !timedOut ) - { - cause = "SIGNALED"; - - // If the callback method executes because the WaitHandle is - // signaled, stop future execution of the callback method - // by unregistering the WaitHandle. - if ( ti->Handle != nullptr ) - ti->Handle->Unregister( nullptr ); - } - - Console::WriteLine( "WaitProc( {0}) executes on thread {1}; cause = {2}.", ti->OtherInfo, Thread::CurrentThread->GetHashCode(), cause ); - } - -}; - -int main() -{ - - // The main thread uses AutoResetEvent to signal the - // registered wait handle, which executes the callback - // method. - AutoResetEvent^ ev = gcnew AutoResetEvent( false ); - TaskInfo^ ti = gcnew TaskInfo; - ti->OtherInfo = "First task"; - - // The TaskInfo for the task includes the registered wait - // handle returned by RegisterWaitForSingleObject. This - // allows the wait to be terminated when the object has - // been signaled once (see WaitProc). - ti->Handle = ThreadPool::RegisterWaitForSingleObject( ev, gcnew WaitOrTimerCallback( Example::WaitProc ), ti, 1000, false ); - - // The main thread waits three seconds, to demonstrate the - // time-outs on the queued thread, and then signals. - Thread::Sleep( 3100 ); - Console::WriteLine( "Main thread signals." ); - ev->Set(); - - // The main thread sleeps, which should give the callback - // method time to execute. If you comment out this line, the - // program usually ends before the ThreadPool thread can execute. - Thread::Sleep( 1000 ); - - // If you start a thread yourself, you can wait for it to end - // by calling Thread::Join. This option is not available with - // thread pool threads. - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetAvailableThreads/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetAvailableThreads/CPP/source.cpp deleted file mode 100644 index 4d728332eac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetAvailableThreads/CPP/source.cpp +++ /dev/null @@ -1,114 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Permissions; -using namespace System::Threading; - -ref class ThreadPoolTest -{ -private: - - // Maintains state information to be passed to EndWriteCallback. - // This information allows the callback to end the asynchronous - // write operation and signal when it is finished. - ref class State - { - public: - FileStream^ fStream; - AutoResetEvent^ autoEvent; - State( FileStream^ fStream, AutoResetEvent^ autoEvent ) - { - this->fStream = fStream; - this->autoEvent = autoEvent; - } - - }; - - -public: - ThreadPoolTest(){} - - static void EndWriteCallback( IAsyncResult^ asyncResult ) - { - Console::WriteLine( "Starting EndWriteCallback." ); - State^ stateInfo = dynamic_cast(asyncResult->AsyncState); - int workerThreads; - int portThreads; - try - { - ThreadPool::GetAvailableThreads( workerThreads, portThreads ); - Console::WriteLine( "\nAvailable worker threads: \t{0}" - "\nAvailable completion port threads: {1}\n", workerThreads.ToString(), portThreads.ToString() ); - stateInfo->fStream->EndWrite( asyncResult ); - - // Sleep so the other thread has a chance to run - // before the current thread ends. - Thread::Sleep( 1500 ); - } - catch ( Exception^ e ) - { - } - finally - { - - // Signal that the current thread is finished. - stateInfo->autoEvent->Set(); - Console::WriteLine( "Ending EndWriteCallback." ); - } - - } - - static void WorkItemMethod( Object^ mainEvent ) - { - Console::WriteLine( "\nStarting WorkItem.\n" ); - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - - // Create some data. - const int ArraySize = 10000; - const int BufferSize = 1000; - array^byteArray = gcnew array(ArraySize); - (gcnew Random)->NextBytes( byteArray ); - - // Create two files and two State objects. - FileStream^ fileWriter1 = gcnew FileStream( "C:\\Test1@##.dat",FileMode::Create,FileAccess::ReadWrite,FileShare::ReadWrite,BufferSize,true ); - FileStream^ fileWriter2 = gcnew FileStream( "C:\\Test2@##.dat",FileMode::Create,FileAccess::ReadWrite,FileShare::ReadWrite,BufferSize,true ); - State^ stateInfo1 = gcnew State( fileWriter1,autoEvent ); - State^ stateInfo2 = gcnew State( fileWriter2,autoEvent ); - - // Asynchronously write to the files. - fileWriter1->BeginWrite( byteArray, 0, byteArray->Length, gcnew AsyncCallback( &ThreadPoolTest::EndWriteCallback ), stateInfo1 ); - fileWriter2->BeginWrite( byteArray, 0, byteArray->Length, gcnew AsyncCallback( &ThreadPoolTest::EndWriteCallback ), stateInfo2 ); - - // Wait for each callback to finish. - autoEvent->WaitOne(); - autoEvent->WaitOne(); - fileWriter1->Close(); - fileWriter2->Close(); - Console::WriteLine( "\nEnding WorkItem.\n" ); - - // Signal Main that the work item is finished. - dynamic_cast(mainEvent)->Set(); - } - -}; - -int main() -{ - AutoResetEvent^ mainEvent = gcnew AutoResetEvent( false ); - int workerThreads; - int portThreads; - ThreadPool::GetMaxThreads( workerThreads, portThreads ); - Console::WriteLine( "\nMaximum worker threads: \t{0}" - "\nMaximum completion port threads: {1}", workerThreads.ToString(), portThreads.ToString() ); - ThreadPool::GetAvailableThreads( workerThreads, portThreads ); - Console::WriteLine( "\nAvailable worker threads: \t{0}" - "\nAvailable completion port threads: {1}\n", workerThreads.ToString(), portThreads.ToString() ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &ThreadPoolTest::WorkItemMethod ), mainEvent ); - - // Since ThreadPool threads are background threads, - // wait for the work item to signal before ending main(). - mainEvent->WaitOne( 5000, false ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetSetMinThreads/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetSetMinThreads/CPP/source.cpp deleted file mode 100644 index 654530d80b8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetSetMinThreads/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -int main() -{ - int minWorker; - int minIOC; - - // Get the current settings. - ThreadPool::GetMinThreads( minWorker, minIOC ); - - // Change the minimum number of worker threads to four, but - // keep the old setting for minimum asynchronous I/O - // completion threads. - if ( ThreadPool::SetMinThreads( 4, minIOC ) ) - { - - // The minimum number of threads was set successfully. - } - else - { - - // The minimum number of threads was not changed. - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadStart2/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadStart2/CPP/source.cpp deleted file mode 100644 index 3295346dbdc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadStart2/CPP/source.cpp +++ /dev/null @@ -1,49 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class Work -{ -public: - static void DoWork() - { - Console::WriteLine( "Static thread procedure." ); - } - - int Data; - void DoMoreWork() - { - Console::WriteLine( "Instance thread procedure. Data={0}", Data ); - } - -}; - -int main() -{ - - // To start a thread using an instance method for the thread - // procedure, specify the object as the first argument of the - // ThreadStart constructor. - // - Work^ w = gcnew Work; - w->Data = 42; - ThreadStart^ threadDelegate = gcnew ThreadStart( w, &Work::DoMoreWork ); - Thread^ newThread = gcnew Thread( threadDelegate ); - newThread->Start(); - - // To start a thread using a static thread procedure, specify - // only the address of the procedure. This is a change from - // earlier versions of the .NET Framework, which required - // two arguments, the first of which was null (0). - // - threadDelegate = gcnew ThreadStart( &Work::DoWork ); - newThread = gcnew Thread( threadDelegate ); - newThread->Start(); -} - -/* This code example produces the following output (the order - of the lines might vary): -Static thread procedure. -Instance thread procedure. Data=42 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp deleted file mode 100644 index 4dd79b85f2c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -ref class StatusChecker -{ -private: - int invokeCount, maxCount; - -public: - StatusChecker(int count) - { - invokeCount = 0; - maxCount = count; - } - - // This method is called by the timer delegate. - void CheckStatus(Object^ stateInfo) - { - AutoResetEvent^ autoEvent = dynamic_cast(stateInfo); - Console::WriteLine("{0:h:mm:ss.fff} Checking status {1,2}.", - DateTime::Now, ++invokeCount); - - if (invokeCount == maxCount) { - // Reset the counter and signal the waiting thread. - invokeCount = 0; - autoEvent->Set(); - } - } -}; - -ref class TimerExample -{ -public: - static void Main() - { - // Create an AutoResetEvent to signal the timeout threshold in the - // timer callback has been reached. - AutoResetEvent^ autoEvent = gcnew AutoResetEvent(false); - - StatusChecker^ statusChecker = gcnew StatusChecker(10); - - // Create a delegate that invokes methods for the timer. - TimerCallback^ tcb = - gcnew TimerCallback(statusChecker, &StatusChecker::CheckStatus); - - // Create a timer that invokes CheckStatus after one second, - // and every 1/4 second thereafter. - Console::WriteLine("{0:h:mm:ss.fff} Creating timer.\n", - DateTime::Now); - Timer^ stateTimer = gcnew Timer(tcb, autoEvent, 1000, 250); - - // When autoEvent signals, change the period to every half second. - autoEvent->WaitOne(5000, false); - stateTimer->Change(0, 500); - Console::WriteLine("\nChanging period to .5 seconds.\n"); - - // When autoEvent signals the second time, dispose of the timer. - autoEvent->WaitOne(5000, false); - stateTimer->~Timer(); - Console::WriteLine("\nDestroying timer."); - } -}; - -int main() -{ - TimerExample::Main(); -} -// The example displays output like the following: -// 11:59:54.202 Creating timer. -// -// 11:59:55.217 Checking status 1. -// 11:59:55.466 Checking status 2. -// 11:59:55.716 Checking status 3. -// 11:59:55.968 Checking status 4. -// 11:59:56.218 Checking status 5. -// 11:59:56.470 Checking status 6. -// 11:59:56.722 Checking status 7. -// 11:59:56.972 Checking status 8. -// 11:59:57.223 Checking status 9. -// 11:59:57.473 Checking status 10. -// -// Changing period to .5 seconds. -// -// 11:59:57.474 Checking status 1. -// 11:59:57.976 Checking status 2. -// 11:59:58.476 Checking status 3. -// 11:59:58.977 Checking status 4. -// 11:59:59.477 Checking status 5. -// 11:59:59.977 Checking status 6. -// 12:00:00.478 Checking status 7. -// 12:00:00.980 Checking status 8. -// 12:00:01.481 Checking status 9. -// 12:00:01.981 Checking status 10. -// -// Destroying timer. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer2/CPP/source2.cpp deleted file mode 100644 index ec633fe45b1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer2/CPP/source2.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class StatusChecker -{ -private: - int invokeCount; - int maxCount; - -public: - StatusChecker( int count ) - : invokeCount( 0 ), maxCount( count ) - {} - - - // This method is called by the timer delegate. - void CheckStatus( Object^ stateInfo ) - { - AutoResetEvent^ autoEvent = dynamic_cast(stateInfo); - Console::WriteLine( "{0} Checking status {1,2}.", DateTime::Now.ToString( "h:mm:ss.fff" ), (++invokeCount).ToString() ); - if ( invokeCount == maxCount ) - { - - // Reset the counter and signal main. - invokeCount = 0; - autoEvent->Set(); - } - } - -}; - -int main() -{ - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - StatusChecker^ statusChecker = gcnew StatusChecker( 10 ); - - // Create the delegate that invokes methods for the timer. - TimerCallback^ timerDelegate = gcnew TimerCallback( statusChecker, &StatusChecker::CheckStatus ); - TimeSpan delayTime = TimeSpan(0,0,1); - TimeSpan intervalTime = TimeSpan(0,0,0,0,250); - - // Create a timer that signals the delegate to invoke CheckStatus - // after one second, and every 1/4 second thereafter. - Console::WriteLine( "{0} Creating timer.\n", DateTime::Now.ToString( "h:mm:ss.fff" ) ); - Timer^ stateTimer = gcnew Timer( timerDelegate,autoEvent,delayTime,intervalTime ); - - // When autoEvent signals, change the period to every 1/2 second. - autoEvent->WaitOne( 5000, false ); - stateTimer->Change( TimeSpan(0), intervalTime + intervalTime ); - Console::WriteLine( "\nChanging period.\n" ); - - // When autoEvent signals the second time, dispose of the timer. - autoEvent->WaitOne( 5000, false ); - stateTimer->~Timer(); - Console::WriteLine( "\nDestroying timer." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp deleted file mode 100644 index 2de583f098d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// -using namespace System; -using namespace System::Threading; - -public ref class Example -{ -private: - // The EventWaitHandle used to demonstrate the difference - // between AutoReset and ManualReset synchronization events. - // - static EventWaitHandle^ ewh; - - // A counter to make sure all threads are started and - // blocked before any are released. A Long is used to show - // the use of the 64-bit Interlocked methods. - // - static __int64 threadCount = 0; - - // An AutoReset event that allows the main thread to block - // until an exiting thread has decremented the count. - // - static EventWaitHandle^ clearCount = - gcnew EventWaitHandle( false,EventResetMode::AutoReset ); - -public: - [MTAThread] - static void main() - { - // Create an AutoReset EventWaitHandle. - // - ewh = gcnew EventWaitHandle( false,EventResetMode::AutoReset ); - - // Create and start five numbered threads. Use the - // ParameterizedThreadStart delegate, so the thread - // number can be passed as an argument to the Start - // method. - for ( int i = 0; i <= 4; i++ ) - { - Thread^ t = gcnew Thread( - gcnew ParameterizedThreadStart( ThreadProc ) ); - t->Start( i ); - } - - // Wait until all the threads have started and blocked. - // When multiple threads use a 64-bit value on a 32-bit - // system, you must access the value through the - // Interlocked class to guarantee thread safety. - // - while ( Interlocked::Read( threadCount ) < 5 ) - { - Thread::Sleep( 500 ); - } - - // Release one thread each time the user presses ENTER, - // until all threads have been released. - // - while ( Interlocked::Read( threadCount ) > 0 ) - { - Console::WriteLine( L"Press ENTER to release a waiting thread." ); - Console::ReadLine(); - - // SignalAndWait signals the EventWaitHandle, which - // releases exactly one thread before resetting, - // because it was created with AutoReset mode. - // SignalAndWait then blocks on clearCount, to - // allow the signaled thread to decrement the count - // before looping again. - // - WaitHandle::SignalAndWait( ewh, clearCount ); - } - Console::WriteLine(); - - // Create a ManualReset EventWaitHandle. - // - ewh = gcnew EventWaitHandle( false,EventResetMode::ManualReset ); - - // Create and start five more numbered threads. - // - for ( int i = 0; i <= 4; i++ ) - { - Thread^ t = gcnew Thread( - gcnew ParameterizedThreadStart( ThreadProc ) ); - t->Start( i ); - } - - // Wait until all the threads have started and blocked. - // - while ( Interlocked::Read( threadCount ) < 5 ) - { - Thread::Sleep( 500 ); - } - - // Because the EventWaitHandle was created with - // ManualReset mode, signaling it releases all the - // waiting threads. - // - Console::WriteLine( L"Press ENTER to release the waiting threads." ); - Console::ReadLine(); - ewh->Set(); - - } - - static void ThreadProc( Object^ data ) - { - int index = static_cast(data); - - Console::WriteLine( L"Thread {0} blocks.", data ); - // Increment the count of blocked threads. - Interlocked::Increment( threadCount ); - - // Wait on the EventWaitHandle. - ewh->WaitOne(); - - Console::WriteLine( L"Thread {0} exits.", data ); - // Decrement the count of blocked threads. - Interlocked::Decrement( threadCount ); - - // After signaling ewh, the main thread blocks on - // clearCount until the signaled thread has - // decremented the count. Signal it now. - // - clearCount->Set(); - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll1/CPP/source1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll1/CPP/source1.cpp deleted file mode 100644 index 77becf280e4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll1/CPP/source1.cpp +++ /dev/null @@ -1,93 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Permissions; -using namespace System::Threading; - -ref class State -{ -public: - String^ fileName; - array^byteArray; - ManualResetEvent^ manualEvent; - State( String^ fileName, array^byteArray, ManualResetEvent^ manualEvent ) - : fileName( fileName ), byteArray( byteArray ), manualEvent( manualEvent ) - {} - -}; - -ref class Writer -{ -private: - static int workItemCount = 0; - Writer(){} - - -public: - static void WriteToFile( Object^ state ) - { - int workItemNumber = workItemCount; - Interlocked::Increment( workItemCount ); - Console::WriteLine( "Starting work item {0}.", workItemNumber.ToString() ); - State^ stateInfo = dynamic_cast(state); - FileStream^ fileWriter; - - // Create and write to the file. - try - { - fileWriter = gcnew FileStream( stateInfo->fileName,FileMode::Create ); - fileWriter->Write( stateInfo->byteArray, 0, stateInfo->byteArray->Length ); - } - finally - { - if ( fileWriter != nullptr ) - { - fileWriter->Close(); - } - - // Signal main() that the work item has finished. - Console::WriteLine( "Ending work item {0}.", workItemNumber.ToString() ); - stateInfo->manualEvent->Set(); - } - - } - -}; - -void main() -{ - const int numberOfFiles = 5; - String^ dirName = "C:\\TestTest"; - String^ fileName; - array^byteArray; - Random^ randomGenerator = gcnew Random; - array^manualEvents = gcnew array(numberOfFiles); - State^ stateInfo; - if ( !Directory::Exists( dirName ) ) - { - Directory::CreateDirectory( dirName ); - } - - - // Queue the work items that create and write to the files. - for ( int i = 0; i < numberOfFiles; i++ ) - { - fileName = String::Concat( dirName, "\\Test", ((i)).ToString(), ".dat" ); - - // Create random data to write to the file. - byteArray = gcnew array(1000000); - randomGenerator->NextBytes( byteArray ); - manualEvents[ i ] = gcnew ManualResetEvent( false ); - stateInfo = gcnew State( fileName,byteArray,manualEvents[ i ] ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &Writer::WriteToFile ), stateInfo ); - - } - - // Since ThreadPool threads are background threads, - // wait for the work items to signal before exiting. - WaitHandle::WaitAll( manualEvents ); - Console::WriteLine( "Files written - main exiting." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll2/CPP/source2.cpp deleted file mode 100644 index 8cad6cf4acd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll2/CPP/source2.cpp +++ /dev/null @@ -1,102 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Permissions; -using namespace System::Threading; - -// Maintain state to pass to WriteToFile. -ref class State -{ -public: - String^ fileName; - array^byteArray; - ManualResetEvent^ manualEvent; - State( String^ fileName, array^byteArray, ManualResetEvent^ manualEvent ) - : fileName( fileName ), byteArray( byteArray ), manualEvent( manualEvent ) - {} - -}; - -ref class Writer -{ -private: - static int workItemCount = 0; - Writer(){} - - -public: - static void WriteToFile( Object^ state ) - { - int workItemNumber = workItemCount; - Interlocked::Increment( workItemCount ); - Console::WriteLine( "Starting work item {0}.", workItemNumber.ToString() ); - State^ stateInfo = dynamic_cast(state); - FileStream^ fileWriter; - - // Create and write to the file. - try - { - fileWriter = gcnew FileStream( stateInfo->fileName,FileMode::Create ); - fileWriter->Write( stateInfo->byteArray, 0, stateInfo->byteArray->Length ); - } - finally - { - if ( fileWriter != nullptr ) - { - fileWriter->Close(); - } - - // Signal main() that the work item has finished. - Console::WriteLine( "Ending work item {0}.", workItemNumber.ToString() ); - stateInfo->manualEvent->Set(); - } - - } - -}; - -int main() -{ - const int numberOfFiles = 5; - String^ dirName = "C:\\TestTest"; - String^ fileName; - array^byteArray; - Random^ randomGenerator = gcnew Random; - array^manualEvents = gcnew array(numberOfFiles); - State^ stateInfo; - if ( !Directory::Exists( dirName ) ) - { - Directory::CreateDirectory( dirName ); - } - - - // Queue the work items that create and write to the files. - for ( int i = 0; i < numberOfFiles; i++ ) - { - fileName = String::Concat( dirName, "\\Test", ((i)).ToString(), ".dat" ); - - // Create random data to write to the file. - byteArray = gcnew array(1000000); - randomGenerator->NextBytes( byteArray ); - manualEvents[ i ] = gcnew ManualResetEvent( false ); - stateInfo = gcnew State( fileName,byteArray,manualEvents[ i ] ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &Writer::WriteToFile ), stateInfo ); - - } - - // Since ThreadPool threads are background threads, - // wait for the work items to signal before exiting. - if ( WaitHandle::WaitAll( manualEvents, 5000, false ) ) - { - Console::WriteLine( "Files written - main exiting." ); - } - else - { - - // The wait operation times out. - Console::WriteLine( "Error writing files - main exiting." ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll3/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll3/CPP/source3.cpp deleted file mode 100644 index 6044e88bdcc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll3/CPP/source3.cpp +++ /dev/null @@ -1,102 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Permissions; -using namespace System::Threading; - -// Maintain state to pass to WriteToFile. -ref class State -{ -public: - String^ fileName; - array^byteArray; - ManualResetEvent^ manualEvent; - State( String^ fileName, array^byteArray, ManualResetEvent^ manualEvent ) - : fileName( fileName ), byteArray( byteArray ), manualEvent( manualEvent ) - {} - -}; - -ref class Writer -{ -private: - static int workItemCount = 0; - Writer(){} - - -public: - static void WriteToFile( Object^ state ) - { - int workItemNumber = workItemCount; - Interlocked::Increment( workItemCount ); - Console::WriteLine( "Starting work item {0}.", workItemNumber.ToString() ); - State^ stateInfo = dynamic_cast(state); - FileStream^ fileWriter; - - // Create and write to the file. - try - { - fileWriter = gcnew FileStream( stateInfo->fileName,FileMode::Create ); - fileWriter->Write( stateInfo->byteArray, 0, stateInfo->byteArray->Length ); - } - finally - { - if ( fileWriter != nullptr ) - { - fileWriter->Close(); - } - - // Signal main() that the work item has finished. - Console::WriteLine( "Ending work item {0}.", workItemNumber.ToString() ); - stateInfo->manualEvent->Set(); - } - - } - -}; - -int main() -{ - const int numberOfFiles = 5; - String^ dirName = "C:\\TestTest"; - String^ fileName; - array^byteArray; - Random^ randomGenerator = gcnew Random; - array^manualEvents = gcnew array(numberOfFiles); - State^ stateInfo; - if ( !Directory::Exists( dirName ) ) - { - Directory::CreateDirectory( dirName ); - } - - - // Queue the work items that create and write to the files. - for ( int i = 0; i < numberOfFiles; i++ ) - { - fileName = String::Concat( dirName, "\\Test", ((i)).ToString(), ".dat" ); - - // Create random data to write to the file. - byteArray = gcnew array(1000000); - randomGenerator->NextBytes( byteArray ); - manualEvents[ i ] = gcnew ManualResetEvent( false ); - stateInfo = gcnew State( fileName,byteArray,manualEvents[ i ] ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &Writer::WriteToFile ), stateInfo ); - - } - - // Since ThreadPool threads are background threads, - // wait for the work items to signal before exiting. - if ( WaitHandle::WaitAll( manualEvents, TimeSpan(0,0,5), false ) ) - { - Console::WriteLine( "Files written - main exiting." ); - } - else - { - - // The wait operation times out. - Console::WriteLine( "Error writing files - main exiting." ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny2/CPP/source2.cpp deleted file mode 100644 index 5873df3b3ad..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny2/CPP/source2.cpp +++ /dev/null @@ -1,83 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Threading; -ref class Search -{ -private: - - // Maintain state information to pass to FindCallback. - ref class State - { - public: - AutoResetEvent^ autoEvent; - String^ fileName; - State( AutoResetEvent^ autoEvent, String^ fileName ) - : autoEvent( autoEvent ), fileName( fileName ) - {} - - }; - - -public: - array^autoEvents; - array^diskLetters; - - // Search for stateInfo->fileName. - void FindCallback( Object^ state ) - { - State^ stateInfo = dynamic_cast(state); - - // Signal if the file is found. - if ( File::Exists( stateInfo->fileName ) ) - { - stateInfo->autoEvent->Set(); - } - } - - Search() - { - - // Retrieve an array of disk letters. - diskLetters = Environment::GetLogicalDrives(); - autoEvents = gcnew array(diskLetters->Length); - for ( int i = 0; i < diskLetters->Length; i++ ) - { - autoEvents[ i ] = gcnew AutoResetEvent( false ); - - } - } - - - // Search for fileName in the root directory of all disks. - void FindFile( String^ fileName ) - { - for ( int i = 0; i < diskLetters->Length; i++ ) - { - Console::WriteLine( "Searching for {0} on {1}.", fileName, diskLetters[ i ] ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( this, &Search::FindCallback ), gcnew State( autoEvents[ i ],String::Concat( diskLetters[ i ], fileName ) ) ); - - } - - // Wait for the first instance of the file to be found. - int index = WaitHandle::WaitAny( autoEvents, 3000, false ); - if ( index == WaitHandle::WaitTimeout ) - { - Console::WriteLine( "\n{0} not found.", fileName ); - } - else - { - Console::WriteLine( "\n{0} found on {1}.", fileName, diskLetters[ index ] ); - } - } - -}; - -int main() -{ - Search^ search = gcnew Search; - search->FindFile( "SomeFile.dat" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny3/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny3/CPP/source3.cpp deleted file mode 100644 index c8fbef542b7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny3/CPP/source3.cpp +++ /dev/null @@ -1,83 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Threading; -ref class Search -{ -private: - - // Maintain state information to pass to FindCallback. - ref class State - { - public: - AutoResetEvent^ autoEvent; - String^ fileName; - State( AutoResetEvent^ autoEvent, String^ fileName ) - : autoEvent( autoEvent ), fileName( fileName ) - {} - - }; - - -public: - array^autoEvents; - array^diskLetters; - - // Search for stateInfo->fileName. - void FindCallback( Object^ state ) - { - State^ stateInfo = dynamic_cast(state); - - // Signal if the file is found. - if ( File::Exists( stateInfo->fileName ) ) - { - stateInfo->autoEvent->Set(); - } - } - - Search() - { - - // Retrieve an array of disk letters. - diskLetters = Environment::GetLogicalDrives(); - autoEvents = gcnew array(diskLetters->Length); - for ( int i = 0; i < diskLetters->Length; i++ ) - { - autoEvents[ i ] = gcnew AutoResetEvent( false ); - - } - } - - - // Search for fileName in the root directory of all disks. - void FindFile( String^ fileName ) - { - for ( int i = 0; i < diskLetters->Length; i++ ) - { - Console::WriteLine( "Searching for {0} on {1}.", fileName, diskLetters[ i ] ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( this, &Search::FindCallback ), gcnew State( autoEvents[ i ],String::Concat( diskLetters[ i ], fileName ) ) ); - - } - - // Wait for the first instance of the file to be found. - int index = WaitHandle::WaitAny( autoEvents, TimeSpan(0,0,3), false ); - if ( index == WaitHandle::WaitTimeout ) - { - Console::WriteLine( "\n{0} not found.", fileName ); - } - else - { - Console::WriteLine( "\n{0} found on {1}.", fileName, diskLetters[ index ] ); - } - } - -}; - -int main() -{ - Search^ search = gcnew Search; - search->FindFile( "SomeFile.dat" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne1/CPP/source1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne1/CPP/source1.cpp deleted file mode 100644 index 1e895c2aace..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne1/CPP/source1.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class WaitOne -{ -private: - WaitOne(){} - - -public: - static void WorkMethod( Object^ stateInfo ) - { - Console::WriteLine( "Work starting." ); - - // Simulate time spent working. - Thread::Sleep( (gcnew Random)->Next( 100, 2000 ) ); - - // Signal that work is finished. - Console::WriteLine( "Work ending." ); - dynamic_cast(stateInfo)->Set(); - } - -}; - -int main() -{ - Console::WriteLine( "Main starting." ); - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &WaitOne::WorkMethod ), autoEvent ); - - // Wait for work method to signal. - autoEvent->WaitOne( ); - Console::WriteLine( "Work method signaled.\nMain ending." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne2/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne2/CPP/source2.cpp deleted file mode 100644 index 2d2d9d3a98f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne2/CPP/source2.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class WaitOne -{ -private: - WaitOne(){} - - -public: - static void WorkMethod( Object^ stateInfo ) - { - Console::WriteLine( "Work starting." ); - - // Simulate time spent working. - Thread::Sleep( (gcnew Random)->Next( 100, 2000 ) ); - - // Signal that work is finished. - Console::WriteLine( "Work ending." ); - dynamic_cast(stateInfo)->Set(); - } - -}; - -int main() -{ - Console::WriteLine( "Main starting." ); - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &WaitOne::WorkMethod ), autoEvent ); - - // Wait for work method to signal. - if ( autoEvent->WaitOne( 1000 ) ) - { - Console::WriteLine( "Work method signaled." ); - } - else - { - Console::WriteLine( "Timed out waiting for work " - "method to signal." ); - } - - Console::WriteLine( "Main ending." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne3/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne3/CPP/source3.cpp deleted file mode 100644 index d43bd113677..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitOne3/CPP/source3.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -ref class WaitOne -{ -private: - WaitOne(){} - - -public: - static void WorkMethod( Object^ stateInfo ) - { - Console::WriteLine( "Work starting." ); - - // Simulate time spent working. - Thread::Sleep( (gcnew Random)->Next( 100, 2000 ) ); - - // Signal that work is finished. - Console::WriteLine( "Work ending." ); - dynamic_cast(stateInfo)->Set(); - } - -}; - -int main() -{ - Console::WriteLine( "Main starting." ); - AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); - ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &WaitOne::WorkMethod ), autoEvent ); - - // Wait for work method to signal. - if ( autoEvent->WaitOne( TimeSpan(0,0,1), false ) ) - { - Console::WriteLine( "Work method signaled." ); - } - else - { - Console::WriteLine( "Timed out waiting for work " - "method to signal." ); - } - - Console::WriteLine( "Main ending." ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.collections.specialized.collectionsutil/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.collections.specialized.collectionsutil/cpp/source.cpp deleted file mode 100644 index 95fbc966ac0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.collections.specialized.collectionsutil/cpp/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; - -ref class TestCollectionsUtils -{ -public: - static void Main() - { - Hashtable^ population1 = CollectionsUtil::CreateCaseInsensitiveHashtable(); - - population1["Trapperville"] = 15; - population1["Doggerton"] = 230; - population1["New Hollow"] = 1234; - population1["McHenry"] = 185; - - // Select cities from the table using mixed case. - Console::WriteLine("Case insensitive hashtable results:\n"); - Console::WriteLine("{0}'s population is: {1}", "Trapperville", population1["trapperville"]); - Console::WriteLine("{0}'s population is: {1}", "Doggerton", population1["DOGGERTON"]); - Console::WriteLine("{0}'s population is: {1}", "New Hollow", population1["New hoLLow"]); - Console::WriteLine("{0}'s population is: {1}", "McHenry", population1["MchenrY"]); - - SortedList^ population2 = CollectionsUtil::CreateCaseInsensitiveSortedList(); - - for each (String^ city in population1->Keys) - { - population2->Add(city, population1[city]); - } - - // Select cities from the sorted list using mixed case. - Console::WriteLine("\nCase insensitive sorted list results:\n"); - Console::WriteLine("{0}'s population is: {1}", "Trapperville", population2["trapPeRVille"]); - Console::WriteLine("{0}'s population is: {1}", "Doggerton", population2["dOGGeRtON"]); - Console::WriteLine("{0}'s population is: {1}", "New Hollow", population2["nEW hOLLOW"]); - Console::WriteLine("{0}'s population is: {1}", "McHenry", population2["MchEnrY"]); - } -}; - -int main() -{ - TestCollectionsUtils::Main(); -} - -// This program displays the following output to the console -// -// Case insensitive hashtable results: -// -// Trapperville's population is: 15 -// Doggerton's population is: 230 -// New Hollow's population is: 1234 -// McHenry's population is: 185 -// -// Case insensitive sorted list results: -// -// Trapperville's population is: 15 -// Doggerton's population is: 230 -// New Hollow's population is: 1234 -// McHenry's population is: 185 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.collections.specialized.nameobjectcollectionbase.keyscollection/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.collections.specialized.nameobjectcollectionbase.keyscollection/cpp/source.cpp deleted file mode 100644 index 9fef255cba7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.collections.specialized.nameobjectcollectionbase.keyscollection/cpp/source.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Specialized; -using namespace System::Threading; - -public ref class DerivedCollection : public NameObjectCollectionBase { - -private: - DictionaryEntry^ _de; - - // Creates an empty collection. -public: - DerivedCollection() { - _de = gcnew DictionaryEntry(); - } - - // Adds elements from an IDictionary into the new collection. - DerivedCollection( IDictionary^ d, Boolean bReadOnly ) { - - _de = gcnew DictionaryEntry(); - - for each ( DictionaryEntry^ de in d ) { - this->BaseAdd( (String^) de->Key, de->Value ); - } - this->IsReadOnly = bReadOnly; - } - - // Gets a key-and-value pair (DictionaryEntry) using an index. - property DictionaryEntry^ default[ int ] { - DictionaryEntry^ get(int index) { - _de->Key = this->BaseGetKey(index); - _de->Value = this->BaseGet(index); - return( _de ); - } - } - - // Gets or sets the value associated with the specified key. - property Object^ default[ String^ ] { - Object^ get(String^ key) { - return( this->BaseGet( key ) ); - } - void set( String^ key, Object^ value ) { - this->BaseSet( key, value ); - } - } - - // Gets a String array that contains all the keys in the collection. - property array^ AllKeys { - array^ get() { - return( (array^)this->BaseGetAllKeys() ); - } - } - - // Gets an Object array that contains all the values in the collection. - property Array^ AllValues { - Array^ get() { - return( this->BaseGetAllValues() ); - } - } - - // Gets a String array that contains all the values in the collection. - property array^ AllStringValues { - array^ get() { - return( (array^) this->BaseGetAllValues( String ::typeid )); - } - } - - // Gets a value indicating if the collection contains keys that are not null. - property Boolean HasKeys { - Boolean get() { - return( this->BaseHasKeys() ); - } - } - - // Adds an entry to the collection. - void Add( String^ key, Object^ value ) { - this->BaseAdd( key, value ); - } - - // Removes an entry with the specified key from the collection. - void Remove( String^ key ) { - this->BaseRemove( key ); - } - - // Removes an entry in the specified index from the collection. - void Remove( int index ) { - this->BaseRemoveAt( index ); - } - - // Clears all the elements in the collection. - void Clear() { - this->BaseClear(); - } -}; - -public ref class SamplesNameObjectCollectionBaseKeys -{ -public: - static void Main() - { - // - // Create a collection derived from NameObjectCollectionBase - NameObjectCollectionBase^ myBaseCollection = gcnew DerivedCollection(); - // Get the ICollection from NameObjectCollectionBase.KeysCollection - ICollection^ myKeysCollection = myBaseCollection->Keys; - bool lockTaken = false; - try - { - Monitor::Enter(myKeysCollection->SyncRoot, lockTaken); - for each (Object^ item in myKeysCollection) - { - // Insert your code here. - } - } - finally - { - if (lockTaken) - { - Monitor::Exit(myKeysCollection->SyncRoot); - } - } - // - } -}; - -int main() -{ - SamplesNameObjectCollectionBaseKeys::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.diagnostics.tracefilter/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.diagnostics.tracefilter/cpp/source.cpp deleted file mode 100644 index 2e0fc257300..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.diagnostics.tracefilter/cpp/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -#define TRACE - -#using - -using namespace System; -using namespace System::Diagnostics; - -namespace TestingTracing -{ - // - public ref class ErrorFilter : TraceFilter - { - public: - virtual bool ShouldTrace(TraceEventCache^ cache, String^ source, - TraceEventType eventType, int id, String^ formatOrMessage, - array^ args, Object^ data, array^ dataArray) override - { - return eventType == TraceEventType::Error; - } - }; - // - - ref class TraceTest - { - public: - static void Main() - { - TraceSource^ ts = gcnew TraceSource("TraceTest"); - SourceSwitch^ sourceSwitch = gcnew SourceSwitch("SourceSwitch", "Verbose"); - ts->Switch = sourceSwitch; - ConsoleTraceListener^ ctl = gcnew ConsoleTraceListener(); - ctl->Name = "console"; - ctl->TraceOutputOptions = TraceOptions::DateTime; - ctl->Filter = gcnew ErrorFilter(); - ts->Listeners->Add(ctl); - - ts->TraceEvent(TraceEventType::Warning, 1, "*** This event will be filtered out ***"); - // this event will be get displayed - ts->TraceEvent(TraceEventType::Error, 2, "*** This event will be be displayed ***"); - - ts->Flush(); - ts->Close(); - } - }; -} - -int main() -{ - TestingTracing::TraceTest::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.io.pipes.pipestream/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.io.pipes.pipestream/cpp/sample.cpp deleted file mode 100644 index 40f37b3e60b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.io.pipes.pipestream/cpp/sample.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::IO::Pipes; -using namespace System::Diagnostics; - -ref class PipeStreamExample -{ -private: - static array^ matchSign = {9, 0, 9, 0}; - -public: - static void Main() - { - array^ args = Environment::GetCommandLineArgs(); - if (args->Length < 2) - { - Process^ clientProcess = gcnew Process(); - - clientProcess->StartInfo->FileName = Environment::CommandLine; - - AnonymousPipeServerStream^ pipeServer = - gcnew AnonymousPipeServerStream(PipeDirection::In, - HandleInheritability::Inheritable); - // Pass the client process a handle to the server. - clientProcess->StartInfo->Arguments = pipeServer->GetClientHandleAsString(); - clientProcess->StartInfo->UseShellExecute = false; - Console::WriteLine("[SERVER] Starting client process..."); - clientProcess->Start(); - - pipeServer->DisposeLocalCopyOfClientHandle(); - - try - { - if (WaitForClientSign(pipeServer)) - { - Console::WriteLine("[SERVER] Valid sign code received!"); - } - else - { - Console::WriteLine("[SERVER] Invalid sign code received!"); - } - } - catch (IOException^ e) - { - Console::WriteLine("[SERVER] Error: {0}", e->Message); - } - clientProcess->WaitForExit(); - clientProcess->Close(); - Console::WriteLine("[SERVER] Client quit. Server terminating."); - } - else - { - PipeStream^ pipeClient = - gcnew AnonymousPipeClientStream(PipeDirection::Out, args[1]); - try - { - Console::WriteLine("[CLIENT] Sending sign code..."); - SendClientSign(pipeClient); - } - catch (IOException^ e) - { - Console::WriteLine("[CLIENT] Error: {0}", e->Message); - } - Console::WriteLine("[CLIENT] Terminating."); - } - } - - // -private: - static bool WaitForClientSign(PipeStream^ inStream) - { - array^ inSign = gcnew array(matchSign->Length); - int len = inStream->Read(inSign, 0, matchSign->Length); - bool valid = len == matchSign->Length; - - while (valid && len-- > 0) - { - valid = valid && (matchSign[len] == inSign[len]); - } - return valid; - } - // - - static void SendClientSign(PipeStream^ outStream) - { - outStream->Write(matchSign, 0, matchSign->Length); - } -}; - -int main() -{ - PipeStreamExample::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend1.cpp deleted file mode 100644 index 64c01acb0e7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend1.cpp +++ /dev/null @@ -1,39 +0,0 @@ -using namespace System; - -ref class FileUtilities -{ - public: - static String^ AppendDirectorySeparator(String^ dir) - { - if (!dir->Trim()->EndsWith(System::IO::Path::DirectorySeparatorChar.ToString())) - return dir->Trim() + System::IO::Path::DirectorySeparatorChar; - else - return dir; - } -}; - - -// -// -// The assembly that exposes its internal types to this assembly should be -// named Assembly1.dll. -// -// The public key of this assembly should correspond to the public key -// specified in the class constructor of the InternalsVisibleTo attribute in the -// Assembly1 assembly. -// -#using as_friend - -using namespace System; - -void main() -{ - String^ dir = L"C:\\Program Files"; - dir = FileUtilities::AppendDirectorySeparator(dir); - Console::WriteLine(dir); -} -// The example displays the following output: -// C:\Program Files\ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend2.cpp deleted file mode 100644 index d98516de040..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend2.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// -#using as_friend - -using namespace System; -using namespace Utilities::StringUtilities; - -void main() -{ - String^ s = "The Sign of the Four"; - Console::WriteLine(StringLib::IsFirstLetterUpperCase(s)); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/cpp/encryptor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/cpp/encryptor.cpp deleted file mode 100644 index 9bb50f4bd80..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/cpp/encryptor.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; - -class EncryptorExample -{ -public: - static void Main() - { - TripleDESCryptoServiceProvider^ tdesCSP = gcnew TripleDESCryptoServiceProvider(); - - tdesCSP->GenerateKey(); - tdesCSP->GenerateIV(); - String^ quote = - "Things may come to those who wait, but only the " + - "things left by those who hustle. -- Abraham Lincoln"; - array^ encQuote = EncryptString(tdesCSP, quote); - - Console::WriteLine("Encrypted Quote:\n"); - Console::WriteLine(Convert::ToBase64String(encQuote)); - - Console::WriteLine("\nDecrypted Quote:\n"); - Console::WriteLine(DecryptBytes(tdesCSP, encQuote)); - } - - // -public: - static array^ EncryptString(SymmetricAlgorithm^ symAlg, String^ inString) - { - array^ inBlock = UnicodeEncoding::Unicode->GetBytes(inString); - ICryptoTransform^ xfrm = symAlg->CreateEncryptor(); - array^ outBlock = xfrm->TransformFinalBlock(inBlock, 0, inBlock->Length); - - return outBlock; - } - // - - // - static String^ DecryptBytes(SymmetricAlgorithm^ symAlg, array^ inBytes) - { - ICryptoTransform^ xfrm = symAlg->CreateDecryptor(); - array^ outBlock = xfrm->TransformFinalBlock(inBytes, 0, inBytes->Length); - - return UnicodeEncoding::Unicode->GetString(outBlock); - } - // -}; - -int main() -{ - EncryptorExample::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.security.securestring.ctor2/cpp/ctor1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.security.securestring.ctor2/cpp/ctor1.cpp deleted file mode 100644 index 80d78080d26..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.security.securestring.ctor2/cpp/ctor1.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; -using namespace System::Security; - -int main(array ^args) -{ - SecureString^ testString; - // Define the string value to assign to a new secure string. - Char chars[4] = { 't', 'e', 's', 't' }; - // Instantiate a new secure string. - Char* pChars = &chars[0]; - - testString = gcnew SecureString(pChars, sizeof(chars)/sizeof(chars[0])); - - // Display secure string length. - Console::WriteLine("The length of the string is {0} characters.", - testString->Length); - delete testString; - return 0; -} -// The example displays the following output: -// The length of the string is 4 characters. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.security.securityelement/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.security.securityelement/cpp/remarks.cpp deleted file mode 100644 index 7ff6cd67159..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.security.securityelement/cpp/remarks.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -using namespace System; -using namespace System::Security; - - -public ref class SecurityElementTest -{ -private: - SecurityElement^ xmlRootElement; - -public: - SecurityElementTest() - { - xmlRootElement = gcnew SecurityElement("thetag", " "); - - xmlRootElement->AddAttribute("a", "123"); - xmlRootElement->AddAttribute("b", "456"); - xmlRootElement->AddAttribute("c", "789"); - - xmlRootElement->AddChild(gcnew SecurityElement("first", "text1")); - xmlRootElement->AddChild(gcnew SecurityElement("second", "text2")); - } - - // - String^ SearchForTextOfTag(String^ tag) - { - SecurityElement^ element = this->SearchForChildByTag(tag); - return element->Text; - } - // - -private: - SecurityElement^ SearchForChildByTag(String^ tag) - { - return xmlRootElement->SearchForChildByTag(tag); - } -}; - -int main() -{ - SecurityElementTest^ seTest = gcnew SecurityElementTest(); - - Console::WriteLine("Found the text for : " + seTest->SearchForTextOfTag("second")); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.text.regularexpressions.MatchEvaluator/CPP/regexreplace.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.text.regularexpressions.MatchEvaluator/CPP/regexreplace.cpp deleted file mode 100644 index e378abfd947..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.text.regularexpressions.MatchEvaluator/CPP/regexreplace.cpp +++ /dev/null @@ -1,49 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Text::RegularExpressions; -ref class MyClass -{ -public: - static int i = 0; - static String^ ReplaceCC( Match^ m ) - { - - // Replace each Regex cc match with the number of the occurrence. - i++; - return i.ToString(); - } - -}; - -int main() -{ - String^ sInput; - String^ sRegex; - - // The string to search. - sInput = "aabbccddeeffcccgghhcccciijjcccckkcc"; - - // A very simple regular expression. - sRegex = "cc"; - Regex^ r = gcnew Regex( sRegex ); - - // Assign the replace method to the MatchEvaluator delegate. - MatchEvaluator^ myEvaluator = gcnew MatchEvaluator( &MyClass::ReplaceCC ); - - // Write out the original string. - Console::WriteLine( sInput ); - - // Replace matched characters using the delegate method. - sInput = r->Replace( sInput, myEvaluator ); - - // Write out the modified string. - Console::WriteLine( sInput ); -} -// The example displays the following output: -// aabbccddeeffcccgghhcccciijjcccckkcc -// aabb11ddeeff22cgghh3344iijj5566kk77 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.threading.thread.threadstate/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.threading.thread.threadstate/cpp/source.cpp deleted file mode 100644 index 8cee8672a42..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.threading.thread.threadstate/cpp/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; - -// ref class ApartmentTest -// { -// public: - static void ThreadMethod() - { - Thread::Sleep( 1000 ); -// } - -}; - -int main() -{ -// Thread^ newThread = gcnew Thread( gcnew ThreadStart( &ApartmentTest::ThreadMethod ) ); - Thread^ newThread = gcnew Thread( gcnew ThreadStart( &ThreadMethod ) ); - - Console::WriteLine("ThreadState: {0}", newThread->ThreadState); - newThread->Start(); - - // Wait for newThread to start and go to sleep. - Thread::Sleep(300); - Console::WriteLine("ThreadState: {0}", newThread->ThreadState); - - // Wait for newThread to restart. - Thread::Sleep(1000); - Console::WriteLine("ThreadState: {0}", newThread->ThreadState); -} -// The example displays the following output: -// ThreadState: Unstarted -// ThreadState: WaitSleepJoin -// ThreadState: Stopped -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.threading.waithandle.waitone4/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.threading.waithandle.waitone4/cpp/source.cpp deleted file mode 100644 index 857931694b0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.threading.waithandle.waitone4/cpp/source.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// -using namespace System; -using namespace System::Threading; -using namespace System::Runtime::Remoting::Contexts; - -[Synchronization(true)] -public ref class SyncingClass : ContextBoundObject -{ -private: - EventWaitHandle^ waitHandle; - -public: - SyncingClass() - { - waitHandle = - gcnew EventWaitHandle(false, EventResetMode::ManualReset); - } - - void Signal() - { - Console::WriteLine("Thread[{0:d4}]: Signalling...", Thread::CurrentThread->GetHashCode()); - waitHandle->Set(); - } - - void DoWait(bool leaveContext) - { - bool signalled; - - waitHandle->Reset(); - Console::WriteLine("Thread[{0:d4}]: Waiting...", Thread::CurrentThread->GetHashCode()); - signalled = waitHandle->WaitOne(3000, leaveContext); - if (signalled) - { - Console::WriteLine("Thread[{0:d4}]: Wait released!!!", Thread::CurrentThread->GetHashCode()); - } - else - { - Console::WriteLine("Thread[{0:d4}]: Wait timeout!!!", Thread::CurrentThread->GetHashCode()); - } - } -}; - -public ref class TestSyncDomainWait -{ -public: - static void Main() - { - SyncingClass^ syncClass = gcnew SyncingClass(); - - Thread^ runWaiter; - - Console::WriteLine("\nWait and signal INSIDE synchronization domain:\n"); - runWaiter = gcnew Thread(gcnew ParameterizedThreadStart(&TestSyncDomainWait::RunWaitKeepContext)); - runWaiter->Start(syncClass); - Thread::Sleep(1000); - Console::WriteLine("Thread[{0:d4}]: Signal...", Thread::CurrentThread->GetHashCode()); - // This call to Signal will block until the timeout in DoWait expires. - syncClass->Signal(); - runWaiter->Join(); - - Console::WriteLine("\nWait and signal OUTSIDE synchronization domain:\n"); - runWaiter = gcnew Thread(gcnew ParameterizedThreadStart(&TestSyncDomainWait::RunWaitLeaveContext)); - runWaiter->Start(syncClass); - Thread::Sleep(1000); - Console::WriteLine("Thread[{0:d4}]: Signal...", Thread::CurrentThread->GetHashCode()); - // This call to Signal is unblocked and will set the wait handle to - // release the waiting thread. - syncClass->Signal(); - runWaiter->Join(); - } - - static void RunWaitKeepContext(Object^ parm) - { - ((SyncingClass^)parm)->DoWait(false); - } - - static void RunWaitLeaveContext(Object^ parm) - { - ((SyncingClass^)parm)->DoWait(true); - } -}; - -int main() -{ - TestSyncDomainWait::Main(); -} -// The output for the example program will be similar to the following: -// -// Wait and signal INSIDE synchronization domain: -// -// Thread[0004]: Waiting... -// Thread[0001]: Signal... -// Thread[0004]: Wait timeout!!! -// Thread[0001]: Signalling... -// -// Wait and signal OUTSIDE synchronization domain: -// -// Thread[0006]: Waiting... -// Thread[0001]: Signal... -// Thread[0001]: Signalling... -// Thread[0006]: Wait released!!! -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp deleted file mode 100644 index 84663c2d1bc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -using namespace System; -using namespace System::Timers; - -public ref class Example -{ -private: - static System::Timers::Timer^ aTimer; - -public: - static void Demo() - { - // Create a timer and set a two second interval. - aTimer = gcnew System::Timers::Timer(); - aTimer->Interval = 2000; - - // Hook up the Elapsed event for the timer. - aTimer->Elapsed += gcnew System::Timers::ElapsedEventHandler(Example::OnTimedEvent); - - // Have the timer fire repeated events (true is the default) - aTimer->AutoReset = true; - - // Start the timer - aTimer->Enabled = true; - - Console::WriteLine("Press the Enter key to exit the program at any time... "); - Console::ReadLine(); - } - -private: - static void OnTimedEvent(Object^ source, System::Timers::ElapsedEventArgs^ e) - { - Console::WriteLine("The Elapsed event was raised at {0}", e->SignalTime); - } -}; - -int main() -{ - Example::Demo(); -} -// The example displays output like the following: -// Press the Enter key to exit the program at any time... -// The Elapsed event was raised at 5/20/2015 8:48:58 PM -// The Elapsed event was raised at 5/20/2015 8:49:00 PM -// The Elapsed event was raised at 5/20/2015 8:49:02 PM -// The Elapsed event was raised at 5/20/2015 8:49:04 PM -// The Elapsed event was raised at 5/20/2015 8:49:06 PM - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/CPP/source.cpp deleted file mode 100644 index 248a1274b23..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "http://localhost/baseuri.xml" ); - - //Display information on the attribute node. The value - //returned for BaseURI is 'http://localhost/baseuri.xml'. - XmlAttribute^ attr = doc->DocumentElement->Attributes[ 0 ]; - Console::WriteLine( "Name of the attribute: {0}", attr->Name ); - Console::WriteLine( "Base URI of the attribute: {0}", attr->BaseURI ); - Console::WriteLine( "The value of the attribute: {0}", attr->InnerText ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/CPP/source.cpp deleted file mode 100644 index 7da06cb2507..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create an XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "2elems.xml" ); - - //Create an attribute. - XmlAttribute^ attr; - attr = doc->CreateAttribute( "bk", "genre", "urn:samples" ); - attr->Value = "novel"; - - //Add the attribute to the first book. - XmlElement^ currNode = dynamic_cast(doc->DocumentElement->FirstChild); - currNode->SetAttributeNode( attr ); - - //An attribute cannot be added to two different elements. - //You must clone the attribute and add it to the second book. - XmlAttribute^ attr2; - attr2 = dynamic_cast(attr->CloneNode( true )); - currNode = dynamic_cast(doc->DocumentElement->LastChild); - currNode->SetAttributeNode( attr2 ); - Console::WriteLine( "Display the modified XML...\r\n" ); - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - doc->WriteContentTo( writer ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.Name Example/CPP/source.cpp deleted file mode 100644 index e610435a6f1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.Name Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - Console::WriteLine( "Display information on each of the attributes... \r\n" ); - System::Collections::IEnumerator^ myEnum = attrColl->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlAttribute^ attr = safe_cast(myEnum->Current); - Console::Write( "{0} = {1}", attr->Name, attr->Value ); - Console::WriteLine( "\t namespaceURI={0}", attr->NamespaceURI ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/CPP/source.cpp deleted file mode 100644 index d5ae5b95da8..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - Console::WriteLine( "Display information on each of the attributes... \r\n" ); - System::Collections::IEnumerator^ myEnum = attrColl->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlAttribute^ attr = safe_cast(myEnum->Current); - Console::Write( "{0}:{1} = {2}", attr->Prefix, attr->LocalName, attr->Value ); - Console::WriteLine( "\t namespaceURI={0}", attr->NamespaceURI ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerDocument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerDocument Example/CPP/source.cpp deleted file mode 100644 index ab859d7c703..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerDocument Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute. - XmlAttribute^ attr; - attr = doc->CreateAttribute( "bk", "genre", "urn:samples" ); - attr->Value = "novel"; - - //Display the attribute's owner document. Note - //that although the attribute has not been inserted - //into the document, it still has an owner document. - Console::WriteLine( attr->OwnerDocument->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerElement Example/CPP/source.cpp deleted file mode 100644 index dcbf0298041..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.OwnerElement Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute. - XmlAttribute^ attr; - attr = doc->CreateAttribute( "bk", "genre", "urn:samples" ); - attr->Value = "novel"; - - //Try to display the attribute's owner element. - if ( attr->OwnerElement == nullptr ) - Console::WriteLine( "The attribute has not been added to an element\r\n" ); - else - Console::WriteLine( attr->OwnerElement->OuterXml ); - - - //Add the attribute to an element. - doc->DocumentElement->SetAttributeNode( attr ); - - //Display the attribute's owner element. - Console::WriteLine( "Display the owner element..." ); - Console::WriteLine( attr->OwnerElement->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Append Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Append Example/CPP/source.cpp deleted file mode 100644 index 3adf20c7f03..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Append Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create a new attribute. - XmlAttribute^ newAttr = doc->CreateAttribute( "genre" ); - newAttr->Value = "novel"; - - //Create an attribute collection and add the new attribute - //to the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->Append( newAttr ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.CopyTo Example/CPP/source.cpp deleted file mode 100644 index ac6d9660ec5..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - - //Declare the array. - array^arr = gcnew array(2); - int index = 0; - - //Copy all the attributes into the array. - attrColl->CopyTo( arr, index ); - Console::WriteLine( "Display all the attributes in the array.." ); - System::Collections::IEnumerator^ myEnum = arr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlAttribute^ attr = safe_cast(myEnum->Current); - Console::WriteLine( "{0} = {1}", attr->Name, attr->Value ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertAfter Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertAfter Example/CPP/source.cpp deleted file mode 100644 index cef8075ba6b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertAfter Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create a new attribute. - XmlAttribute^ newAttr = doc->CreateAttribute( "genre" ); - newAttr->Value = "novel"; - - //Create an attribute collection and add the new attribute - //to the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->InsertAfter( newAttr, attrColl[ 0 ] ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertBefore Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertBefore Example/CPP/source.cpp deleted file mode 100644 index e83046a63b2..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.InsertBefore Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create a new attribute. - XmlAttribute^ newAttr = doc->CreateAttribute( "genre" ); - newAttr->Value = "novel"; - - //Create an attribute collection and add the new attribute - //to the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->InsertBefore( newAttr, attrColl[ 0 ] ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Prepend Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Prepend Example/CPP/source.cpp deleted file mode 100644 index 58098e9636e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Prepend Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create a new attribute. - XmlAttribute^ newAttr = doc->CreateAttribute( "genre" ); - newAttr->Value = "novel"; - - //Create an attribute collection and add the new attribute - //to the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->Prepend( newAttr ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/CPP/source.cpp deleted file mode 100644 index 462904f2588..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection and remove an attribute - //from the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->Remove( attrColl[ "genre" ] ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAll Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAll Example/CPP/source.cpp deleted file mode 100644 index 6b44e2cdb0b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAll Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection and remove all attributes - //from the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->RemoveAll(); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAt Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAt Example/CPP/source.cpp deleted file mode 100644 index 852996d7f61..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.RemoveAt Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection and remove an attribute - //from the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->RemoveAt( 0 ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.SetNamedItem Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.SetNamedItem Example/CPP/source.cpp deleted file mode 100644 index 1eeb8a09d55..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.SetNamedItem Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create a new attribute. - XmlAttribute^ newAttr = doc->CreateAttribute( "genre" ); - newAttr->Value = "novel"; - - //Create an attribute collection and add the new attribute - //to the collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - attrColl->SetNamedItem( newAttr ); - Console::WriteLine( "Display the modified XML...\r\n" ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/CPP/source.cpp deleted file mode 100644 index d05785cb9df..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - //Create an attribute collection. - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - Console::WriteLine( "Display all the attributes in the collection...\r\n" ); - for ( int i = 0; i < attrColl->Count; i++ ) - { - Console::Write( "{0} = ", attrColl[ i ]->Name ); - Console::Write( "{0}", attrColl[ i ]->Value ); - Console::WriteLine(); - - } -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp deleted file mode 100644 index 65290b3374d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Define the order data. They will be converted to string - //before being written out. - Int16 custID = 32632; - String^ orderID = "367A54"; - DateTime orderDate = DateTime::Now; - Double price = 19.95; - - //Create a writer that outputs to the console. - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - - //Write an element (this one is the root) - writer->WriteStartElement( "order" ); - - //Write the order date. - writer->WriteAttributeString( "date", XmlConvert::ToString( orderDate, "yyyy-MM-dd" ) ); - - //Write the order time. - writer->WriteAttributeString( "time", XmlConvert::ToString( orderDate, "HH:mm:ss" ) ); - - //Write the order data. - writer->WriteElementString( "orderID", orderID ); - writer->WriteElementString( "custID", XmlConvert::ToString( custID ) ); - writer->WriteElementString( "price", XmlConvert::ToString( price ) ); - - //Write the close tag for the root element - writer->WriteEndElement(); - - //Write the XML and close the writer - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/CPP/source.cpp deleted file mode 100644 index e37f5167c22..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/CPP/source.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; -using namespace System::Data::SqlClient; -int main() -{ - DataSet^ dsNorthwind = gcnew DataSet; - - //Create the connection string. - String^ sConnect; - sConnect = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind"; - - //Create a connection object to connect to the northwind db. - SqlConnection^ nwconnect = gcnew SqlConnection( sConnect ); - - //Create a command string to select all the customers in the WA region. - String^ sCommand = "Select * from Customers where Region='WA'"; - - //Create an adapter to load the DataSet. - SqlDataAdapter^ myDataAdapter = gcnew SqlDataAdapter( sCommand,nwconnect ); - - //Fill the DataSet with the selected records. - myDataAdapter->Fill( dsNorthwind, "Customers" ); - - //Load the document with the DataSet. - XmlDataDocument^ doc = gcnew XmlDataDocument( dsNorthwind ); - - //Create a shallow clone of the XmlDataDocument. Note that although - //none of the child nodes were copied over, the cloned node does - //have the schema information. - XmlDataDocument^ clone = dynamic_cast(doc->CloneNode( false )); - Console::WriteLine( "Child count: {0}", clone->ChildNodes->Count ); - Console::WriteLine( clone->DataSet->GetXmlSchema() ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/CPP/source.cpp deleted file mode 100644 index 8ef5454e02d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.DataSet Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; - -int main() -{ - - //Create an XmlDataDocument. - XmlDataDocument^ doc = gcnew XmlDataDocument; - - //Load the schema file. - doc->DataSet->ReadXmlSchema( "store.xsd" ); - - //Load the XML data. - doc->Load( "2books.xml" ); - - //Update the price on the first book using the DataSet methods. - DataTable^ books = doc->DataSet->Tables[ "book" ]; - books->Rows[ 0 ][ "price" ] = "12.95"; - Console::WriteLine( "Display the modified XML data..." ); - doc->Save( Console::Out ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.GetElementFromRow Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.GetElementFromRow Example/CPP/source.cpp deleted file mode 100644 index 9ee8eb597d8..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.GetElementFromRow Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; -using namespace System::Data::SqlClient; - -int main() -{ - DataSet^ dsNorthwind = gcnew DataSet; - - //Create the connection string - String^ sConnect; - sConnect = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind"; - - //Create a connection object to connect to the northwind db. - SqlConnection^ nwconnect = gcnew SqlConnection( sConnect ); - - //Create a command string to select all the customers in the WA region. - String^ sCommand = "Select * from Customers where Region='WA'"; - - //Create an adapter to load the DataSet. - SqlDataAdapter^ myDataAdapter = gcnew SqlDataAdapter( sCommand,nwconnect ); - - //Fill the DataSet with the selected records. - myDataAdapter->Fill( dsNorthwind, "Customers" ); - - //Load the document with the DataSet. - XmlDataDocument^ doc = gcnew XmlDataDocument( dsNorthwind ); - - //Create an element representing the first customer record. - DataRow^ row = doc->DataSet->Tables[ 0 ]->Rows[ 0 ]; - XmlElement^ elem = doc->GetElementFromRow( row ); - Console::WriteLine( elem->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/CPP/source.cpp deleted file mode 100644 index efc4bd880c6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.XmlDataDocument1 Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; -using namespace System::Data::SqlClient; -int main() -{ - DataSet^ dsNorthwind = gcnew DataSet; - - //Create the connection string. - String^ sConnect; - sConnect = "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind"; - - //Create a connection object to connect to the northwind db. - SqlConnection^ nwconnect = gcnew SqlConnection( sConnect ); - - //Create a command string to select all the customers in the WA region. - String^ sCommand = "Select * from Customers where Region='WA'"; - - //Create an adapter to load the DataSet. - SqlDataAdapter^ myDataAdapter = gcnew SqlDataAdapter( sCommand,nwconnect ); - - //Fill the DataSet with the selected records. - myDataAdapter->Fill( dsNorthwind, "Customers" ); - - //Load the document with the DataSet. - XmlDataDocument^ doc = gcnew XmlDataDocument( dsNorthwind ); - - //Display the XmlDataDocument. - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Encoding Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Encoding Example/CPP/source.cpp deleted file mode 100644 index cf3fc8cd852..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Encoding Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - String^ xmlString = "Oberon's Legacy"; - doc->Load( gcnew StringReader( xmlString ) ); - - // Create an XML declaration. - XmlDeclaration^ xmldecl; - xmldecl = doc->CreateXmlDeclaration( "1.0", nullptr, nullptr ); - xmldecl->Encoding = "UTF-8"; - xmldecl->Standalone = "yes"; - - // Add the new node to the document. - XmlElement^ root = doc->DocumentElement; - doc->InsertBefore( xmldecl, root ); - - // Display the modified XML document - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Standalone Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Standalone Example/CPP/source.cpp deleted file mode 100644 index cf3fc8cd852..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDeclaration.Standalone Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - String^ xmlString = "Oberon's Legacy"; - doc->Load( gcnew StringReader( xmlString ) ); - - // Create an XML declaration. - XmlDeclaration^ xmldecl; - xmldecl = doc->CreateXmlDeclaration( "1.0", nullptr, nullptr ); - xmldecl->Encoding = "UTF-8"; - xmldecl->Standalone = "yes"; - - // Add the new node to the document. - XmlElement^ root = doc->DocumentElement; - doc->InsertBefore( xmldecl, root ); - - // Display the modified XML document - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/CPP/source.cpp deleted file mode 100644 index f4464977f99..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" ); - - // Create a document fragment. - XmlDocumentFragment^ docFrag = doc->CreateDocumentFragment(); - - // Set the contents of the document fragment. - docFrag->InnerXml = "widget"; - - // Create a deep clone. The cloned node - // includes child nodes. - XmlNode^ deep = docFrag->CloneNode( true ); - Console::WriteLine( "Name: {0}", deep->Name ); - Console::WriteLine( "OuterXml: {0}", deep->OuterXml ); - - // Create a shallow clone. The cloned node does - // not include any child nodes. - XmlNode^ shallow = docFrag->CloneNode( false ); - Console::WriteLine( "Name: {0}", shallow->Name ); - Console::WriteLine( "OuterXml: {0}", shallow->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.InnerXml Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.InnerXml Example/CPP/source.cpp deleted file mode 100644 index 28e3cfe2a6e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.InnerXml Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - - // Create a document fragment. - XmlDocumentFragment^ docFrag = doc->CreateDocumentFragment(); - - // Set the contents of the document fragment. - docFrag->InnerXml = "widget"; - - // Display the document fragment. - Console::WriteLine( docFrag->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.OwnerDocument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.OwnerDocument Example/CPP/source.cpp deleted file mode 100644 index 8c15797d0b5..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.OwnerDocument Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" ); - - // Create a document fragment. - XmlDocumentFragment^ docFrag = doc->CreateDocumentFragment(); - - // Display the owner document of the document fragment. - Console::WriteLine( docFrag->OwnerDocument->OuterXml ); - - // Add nodes to the document fragment. Notice that the - // new element is created using the owner document of - // the document fragment. - XmlElement^ elem = doc->CreateElement( "item" ); - elem->InnerText = "widget"; - docFrag->AppendChild( elem ); - Console::WriteLine( "Display the document fragment..." ); - Console::WriteLine( docFrag->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.IsReadOnly Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.IsReadOnly Example/CPP/source.cpp deleted file mode 100644 index 6c4328103ed..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.IsReadOnly Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "Pride And Prejudice" - "" - "" ); - - // Check if the node is read-only. - if ( doc->DocumentType->IsReadOnly ) - Console::WriteLine( "Document type nodes are always read-only" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.Name Example/CPP/source.cpp deleted file mode 100644 index 7c1b61160cd..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentType.Name Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "Pride And Prejudice" - "" - "" ); - - // Display information on the DocumentType node. - XmlDocumentType^ doctype = doc->DocumentType; - Console::WriteLine( "Name of the document type: {0}", doctype->Name ); - Console::WriteLine( "The internal subset of the document type: {0}", doctype->InternalSubset ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Attributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Attributes Example/CPP/source.cpp deleted file mode 100644 index 0b8dd71f455..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Attributes Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Change the value of the first attribute. - root->Attributes[ 0 ]->Value = "fiction"; - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/CPP/source.cpp deleted file mode 100644 index b75667b60fc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "2books.xml" ); - - // Create a new element. - XmlElement^ elem = doc->CreateElement( "misc" ); - elem->InnerText = "hardcover"; - elem->SetAttribute( "publisher", "WorldWide Publishing" ); - - // Clone the element so we can add one to each of the book nodes. - XmlNode^ elem2 = elem->CloneNode( true ); - - // Add the new elements. - doc->DocumentElement->FirstChild->AppendChild( elem ); - doc->DocumentElement->LastChild->AppendChild( elem2 ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetAttributeNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetAttributeNode Example/CPP/source.cpp deleted file mode 100644 index fc626a6df19..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetAttributeNode Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Check to see if the element has a genre attribute. - if ( root->HasAttribute( "genre" ) ) - { - XmlAttribute^ attr = root->GetAttributeNode( "genre" ); - Console::WriteLine( attr->Value ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp deleted file mode 100644 index 43426ae0dd2..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "2books.xml" ); - - // Get and display all the book titles. - XmlElement^ root = doc->DocumentElement; - XmlNodeList^ elemList = root->GetElementsByTagName( "title" ); - for ( int i = 0; i < elemList->Count; i++ ) - { - Console::WriteLine( elemList[ i ]->InnerXml ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttribute Example/CPP/source.cpp deleted file mode 100644 index ab87fd72095..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Check to see if the element has a genre attribute. - if ( root->HasAttribute( "genre" ) ) - { - String^ genre = root->GetAttribute( "genre" ); - Console::WriteLine( genre ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttributes Example/CPP/source.cpp deleted file mode 100644 index b0288ee6c7e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.HasAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove all attributes from the root element. - if ( root->HasAttributes ) - root->RemoveAllAttributes(); - - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/CPP/source.cpp deleted file mode 100644 index 1c76c3bca01..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/CPP/source.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "some textmore text" ); - XmlElement^ elem = dynamic_cast(doc->DocumentElement->FirstChild); - - // Note that InnerText does not include the markup. - Console::WriteLine( "Display the InnerText of the element..." ); - Console::WriteLine( elem->InnerText ); - - // InnerXml includes the markup of the element. - Console::WriteLine( "Display the InnerXml of the element..." ); - Console::WriteLine( elem->InnerXml ); - - // Set InnerText to a string that includes markup. - // The markup is escaped. - elem->InnerText = "Text containing will have char(<) and char(>) escaped."; - Console::WriteLine( elem->OuterXml ); - - // Set InnerXml to a string that includes markup. - // The markup is not escaped. - elem->InnerXml = "Text containing ."; - Console::WriteLine( elem->OuterXml ); -} -// This example produces the following results: -// -// Display the InnerText of the element... -// some textmore text -// Display the InnerXml of the element... -// some textmore text -// Text containing <markup/> will have char(<) and char(>) escaped. -// Text containing . -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.IsEmpty Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.IsEmpty Example/CPP/source.cpp deleted file mode 100644 index 32d168f69fc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.IsEmpty Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " Pride And Prejudice " ); - XmlElement^ currNode = dynamic_cast(doc->DocumentElement->LastChild); - if ( currNode->IsEmpty ) - currNode->InnerXml = "19.95"; - - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->OuterXml ); -} - -// 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 deleted file mode 100644 index 79d6693b5c4..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "1-861001-57-5" - "Pride And Prejudice" - "" ); - - // Display information on the ISBN element. - XmlElement^ elem = dynamic_cast(doc->DocumentElement->FirstChild); - Console::Write( "{0}:{1} = {2}", elem->Prefix, elem->LocalName, elem->InnerText ); - 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 deleted file mode 100644 index 0523cdebda0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.Name Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "1-861001-57-5" - "Pride And Prejudice" - "" ); - - // Display information on the ISBN element. - XmlElement^ elem = dynamic_cast(doc->DocumentElement->FirstChild); - Console::Write( "{0} = {1}", elem->Name, elem->InnerText ); - 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.OwnerDocument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.OwnerDocument Example/CPP/source.cpp deleted file mode 100644 index 61bff069bb3..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.OwnerDocument Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Create a new element. - XmlElement^ elem = doc->CreateElement( "price" ); - elem->InnerText = "19.95"; - - // Display the new element's owner document. Note - // that although the element has not been inserted - // into the document, it still has an owner document. - Console::WriteLine( elem->OwnerDocument->OuterXml ); - - // Add the new element into the document. - root->AppendChild( elem ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAll Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAll Example/CPP/source.cpp deleted file mode 100644 index 55d58e8f4df..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAll Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - - // Remove all attributes and child nodes from the book element. - XmlElement^ root = doc->DocumentElement; - root->RemoveAll(); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAllAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAllAttributes Example/CPP/source.cpp deleted file mode 100644 index b35acf816b6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAllAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove all attributes from the root element. - root->RemoveAllAttributes(); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute Example/CPP/source.cpp deleted file mode 100644 index b0464c9da27..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove the genre attribute. - root->RemoveAttribute( "genre" ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute1 Example/CPP/source.cpp deleted file mode 100644 index f16ed9f8182..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove the ISBN attribute. - root->RemoveAttribute( "ISBN", "urn:samples" ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeAt Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeAt Example/CPP/source.cpp deleted file mode 100644 index d65bd739012..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeAt Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove the genre attribute. - root->RemoveAttributeAt( 0 ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeNode1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeNode1 Example/CPP/source.cpp deleted file mode 100644 index 85f87dd21d6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.RemoveAttributeNode1 Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Remove the ISBN attribute. - root->RemoveAttributeNode( "ISBN", "urn:samples" ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/CPP/source.cpp deleted file mode 100644 index 495d6d0bedd..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Add a new attribute. - XmlAttribute^ attr = root->SetAttributeNode( "genre", "urn:samples" ); - attr->Value = "novel"; - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteContentTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteContentTo Example/CPP/source.cpp deleted file mode 100644 index 577c59e10dc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteContentTo Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Note that because WriteContentTo saves only the children of the element - // to the writer none of the attributes are displayed. - Console::WriteLine( "Display the contents of the element..." ); - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - root->WriteContentTo( writer ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteTo Example/CPP/source.cpp deleted file mode 100644 index dc693bbe781..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.WriteTo Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "Pride And Prejudice" ); - XmlElement^ root = doc->DocumentElement; - - // Add a new attribute. - root->SetAttribute( "genre", "urn:samples", "novel" ); - Console::WriteLine( "Display the modified XML..." ); - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - root->WriteTo( writer ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/CPP/source.cpp deleted file mode 100644 index 557e86ed61a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "http://localhost/uri.xml" ); - - //Display information on the entity reference node. - XmlEntityReference^ entref = dynamic_cast(doc->DocumentElement->LastChild->FirstChild); - Console::WriteLine( "Name of the entity reference: {0}", entref->Name ); - Console::WriteLine( "Base URI of the entity reference: {0}", entref->BaseURI ); - Console::WriteLine( "The entity replacement text: {0}", entref->InnerText ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.IsReadOnly Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.IsReadOnly Example/CPP/source.cpp deleted file mode 100644 index 5df1512470f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.IsReadOnly Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "Pride And Prejudice" - "" - "" ); - - // Check if the node is read-only. - XmlEntityReference^ entref = dynamic_cast(doc->DocumentElement->LastChild->FirstChild); - if ( entref->IsReadOnly ) - Console::WriteLine( "Entity reference nodes are always read-only" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.Name Example/CPP/source.cpp deleted file mode 100644 index 0635eed93bf..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.Name Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "Pride And Prejudice" - "" - "" ); - - // Display information on the entity reference node. - XmlEntityReference^ entref = dynamic_cast(doc->DocumentElement->LastChild->FirstChild); - Console::WriteLine( "Name of the entity reference: {0}", entref->Name ); - Console::WriteLine( "The entity replacement text: {0}", entref->InnerText ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/CPP/source.cpp deleted file mode 100644 index 80c8c8c001b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Data; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - DataSet^ dataset; - -public: - void Method() - { -// - XmlImplementation^ imp = gcnew XmlImplementation; - XmlDocument^ doc1 = imp->CreateDocument(); - XmlDocument^ doc2 = imp->CreateDocument(); -// - } -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.NextSibling Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.NextSibling Example/CPP/source.cpp deleted file mode 100644 index da00cfebf0a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.NextSibling Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - - // Display the first two book nodes. - XmlNode^ book = doc->DocumentElement->FirstChild; - Console::WriteLine( book->OuterXml ); - Console::WriteLine(); - Console::WriteLine( book->NextSibling->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.PreviousSibling Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.PreviousSibling Example/CPP/source.cpp deleted file mode 100644 index 6b73208b236..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlLinkedNode.PreviousSibling Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - XmlNode^ lastNode = doc->DocumentElement->LastChild; - Console::WriteLine( "Last book..." ); - Console::WriteLine( lastNode->OuterXml ); - XmlNode^ prevNode = lastNode->PreviousSibling; - Console::WriteLine( "\r\nPrevious book..." ); - Console::WriteLine( prevNode->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/CPP/source.cpp deleted file mode 100644 index 284b8359eb1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " Pride And Prejudice" ); - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - Console::WriteLine( "Display all the attributes for this book..." ); - for ( int i = 0; i < attrColl->Count; i++ ) - { - Console::WriteLine( "{0} = {1}", attrColl->Item( i )->Name, attrColl->Item( i )->Value ); - - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetEnumerator Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetEnumerator Example/CPP/source.cpp deleted file mode 100644 index 4d3bd90411a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetEnumerator Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Collections; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - " Pride And Prejudice" - "" ); - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - Console::WriteLine( "Display all the attributes for this book..." ); - IEnumerator^ ienum = attrColl->GetEnumerator(); - while ( ienum->MoveNext() ) - { - XmlAttribute^ attr = dynamic_cast(ienum->Current); - Console::WriteLine( "{0} = {1}", attr->Name, attr->Value ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/CPP/source.cpp deleted file mode 100644 index 0f47e848c12..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " Pride And Prejudice" ); - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - - // Change the value for the genre attribute. - XmlAttribute^ attr = dynamic_cast(attrColl->GetNamedItem( "genre" )); - attr->Value = "fiction"; - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/CPP/source.cpp deleted file mode 100644 index 8850c3b5bc0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " Pride And Prejudice" ); - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - - // Remove the publicationdate attribute. - attrColl->RemoveNamedItem( "publicationdate" ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/CPP/source.cpp deleted file mode 100644 index 6dda24559d4..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " Pride And Prejudice" ); - XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes; - - // Add a new attribute to the collection. - XmlAttribute^ attr = doc->CreateAttribute( "style" ); - attr->Value = "hardcover"; - attrColl->SetNamedItem( attr ); - Console::WriteLine( "Display the modified XML..." ); - Console::WriteLine( doc->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/CPP/source.cpp deleted file mode 100644 index e1cf039093e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Data; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - DataSet^ dataset; - -public: - void Method( XmlNamespaceManager^ nsmgr ) - { -// - if ( nsmgr->HasNamespace( String::Empty ) ) - { - Console::WriteLine( nsmgr->DefaultNamespace ); - } -// - } -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp deleted file mode 100644 index 38bee9fe649..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -public: - Sample() - { - - // Create the XmlNamespaceManager. - NameTable^ nt = gcnew NameTable; - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt ); - - // Add prefix/namespace pairs to the XmlNamespaceManager. - nsmgr->AddNamespace( "", "www.wideworldimporters.com" ); //Adds a default namespace. - nsmgr->AddNamespace( "europe", "www.wideworldimporters.com/europe" ); - nsmgr->PushScope(); //Pushes a namespace scope on the stack. - nsmgr->AddNamespace( "", "www.lucernepublishing.com" ); //Adds another default namespace. - nsmgr->AddNamespace( "partners", "www.lucernepublishing.com/partners" ); - Console::WriteLine( "Show all the prefix/namespace pairs in the XmlNamespaceManager..." ); - ShowAllNamespaces( nsmgr ); - } - - -private: - void ShowAllNamespaces( XmlNamespaceManager^ nsmgr ) - { - do - { - System::Collections::IEnumerator^ myEnum = nsmgr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ prefix = safe_cast(myEnum->Current); - Console::WriteLine( "Prefix={0}, Namespace={1}", prefix, nsmgr->LookupNamespace( prefix ) ); - } - } - while ( nsmgr->PopScope() ); - } - -}; - -int main() -{ - gcnew Sample; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.XmlNamespaceManager Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.XmlNamespaceManager Example/CPP/source.cpp deleted file mode 100644 index 7e0abed5a53..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.XmlNamespaceManager Example/CPP/source.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; -using namespace System::Xml::Schema; -public ref class Class1 -{ -public: - void Method1() - { - - // - XmlTextReader^ reader = gcnew XmlTextReader( "myfile.xml" ); - XmlNamespaceManager^ nsmanager = gcnew XmlNamespaceManager( reader->NameTable ); - nsmanager->AddNamespace( "msbooks", "www.microsoft.com/books" ); - nsmanager->PushScope(); - nsmanager->AddNamespace( "msstore", "www.microsoft.com/store" ); - while ( reader->Read() ) - { - Console::WriteLine( "Reader Prefix:{0}", reader->Prefix ); - Console::WriteLine( "XmlNamespaceManager Prefix:{0}", nsmanager->LookupPrefix( nsmanager->NameTable->Get( reader->NamespaceURI ) ) ); - } - } - -}; - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.AppendChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.AppendChild Example/CPP/source.cpp deleted file mode 100644 index cc33f1ca5ec..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.AppendChild Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Create a new node. - XmlElement^ elem = doc->CreateElement( "price" ); - elem->InnerText = "19.95"; - - //Add the node to the document. - root->AppendChild( elem ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.Clone Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.Clone Example/CPP/source.cpp deleted file mode 100644 index 0e20454fc0c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.Clone Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - - //Clone the root node. The cloned node includes - //child nodes. This is similar to calling CloneNode(true). - XmlNode^ clone = root->Clone(); - Console::WriteLine( clone->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.CloneNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.CloneNode Example/CPP/source.cpp deleted file mode 100644 index 5d3608a3e74..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.CloneNode Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - - //Create a deep clone. The cloned node - //includes the child nodes. - XmlNode^ deep = root->CloneNode( true ); - Console::WriteLine( deep->OuterXml ); - - //Create a shallow clone. The cloned node does not - //include the child nodes, but does include its attribute. - XmlNode^ shallow = root->CloneNode( false ); - Console::WriteLine( shallow->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.FirstChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.FirstChild Example/CPP/source.cpp deleted file mode 100644 index 8c9bb154ef8..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.FirstChild Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - Console::WriteLine( "Display the title element..." ); - Console::WriteLine( root->FirstChild->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetEnumerator Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetEnumerator Example/CPP/source.cpp deleted file mode 100644 index b7fb2e4d051..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetEnumerator Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - Console::WriteLine( "Display all the books..." ); - XmlNode^ root = doc->DocumentElement; - IEnumerator^ ienum = root->GetEnumerator(); - XmlNode^ book; - while ( ienum->MoveNext() ) - { - book = dynamic_cast(ienum->Current); - Console::WriteLine( book->OuterXml ); - Console::WriteLine(); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp deleted file mode 100644 index 7f8efa23a79..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->FirstChild; - - //Create a new attribute. - String^ ns = root->GetNamespaceOfPrefix( "bk" ); - XmlNode^ attr = doc->CreateNode( XmlNodeType::Attribute, "genre", ns ); - attr->Value = "novel"; - - //Add the attribute to the document. - root->Attributes->SetNamedItem( attr ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetPrefixOfNamespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetPrefixOfNamespace Example/CPP/source.cpp deleted file mode 100644 index 24c5ad1996b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetPrefixOfNamespace Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->FirstChild; - - //Create a new node. - String^ prefix = root->GetPrefixOfNamespace( "urn:samples" ); - XmlElement^ elem = doc->CreateElement( prefix, "style", "urn:samples" ); - elem->InnerText = "hardcover"; - - //Add the node to the document. - root->AppendChild( elem ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/CPP/source.cpp deleted file mode 100644 index ff8ddddef56..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - - //Display the contents of the child nodes. - if ( root->HasChildNodes ) - { - for ( int i = 0; i < root->ChildNodes->Count; i++ ) - { - Console::WriteLine( root->ChildNodes[ i ]->InnerText ); - } - } -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/CPP/source.cpp deleted file mode 100644 index afa0e8a8997..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "some textmore text" - "" ); - XmlNode^ elem = doc->DocumentElement->FirstChild; - - // Note that InnerText does not include the markup. - Console::WriteLine( "Display the InnerText of the element..." ); - Console::WriteLine( elem->InnerText ); - - // InnerXml includes the markup of the element. - Console::WriteLine( "Display the InnerXml of the element..." ); - Console::WriteLine( elem->InnerXml ); - - // Set InnerText to a string that includes markup. - // The markup is escaped. - elem->InnerText = "Text containing will have char(<) and char(>) escaped."; - Console::WriteLine( elem->OuterXml ); - - // Set InnerXml to a string that includes markup. - // The markup is not escaped. - elem->InnerXml = "Text containing ."; - Console::WriteLine( elem->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertAfter Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertAfter Example/CPP/source.cpp deleted file mode 100644 index bbc72ef7e69..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertAfter Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Create a new node. - XmlElement^ elem = doc->CreateElement( "price" ); - elem->InnerText = "19.95"; - - //Add the node to the document. - root->InsertAfter( elem, root->FirstChild ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertBefore Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertBefore Example/CPP/source.cpp deleted file mode 100644 index 3ebee800a51..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertBefore Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Create a new node. - XmlElement^ elem = doc->CreateElement( "price" ); - elem->InnerText = "19.95"; - - //Add the node to the document. - root->InsertBefore( elem, root->FirstChild ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.LastChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.LastChild Example/CPP/source.cpp deleted file mode 100644 index 9514236fc62..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.LastChild Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - Console::WriteLine( "Display the price element..." ); - Console::WriteLine( root->LastChild->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.NextSibling Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.NextSibling Example/CPP/source.cpp deleted file mode 100644 index c78113a0dab..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.NextSibling Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - XmlNode^ currNode = doc->DocumentElement->FirstChild; - Console::WriteLine( "First book..." ); - Console::WriteLine( currNode->OuterXml ); - XmlNode^ nextNode = currNode->NextSibling; - Console::WriteLine( "\r\nSecond book..." ); - Console::WriteLine( nextNode->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.OuterXml Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.OuterXml Example/CPP/source.cpp deleted file mode 100644 index 9465dbc7815..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.OuterXml Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - // OuterXml includes the markup of current node. - Console::WriteLine( "Display the OuterXml property..." ); - Console::WriteLine( root->OuterXml ); - - // InnerXml does not include the markup of the current node. - // As a result, the attributes are not displayed. - Console::WriteLine(); - Console::WriteLine( "Display the InnerXml property..." ); - Console::WriteLine( root->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PrependChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PrependChild Example/CPP/source.cpp deleted file mode 100644 index 63c23bf93d4..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PrependChild Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Create a new node. - XmlElement^ elem = doc->CreateElement( "price" ); - elem->InnerText = "19.95"; - - //Add the node to the document. - root->PrependChild( elem ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PreviousSibling Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PreviousSibling Example/CPP/source.cpp deleted file mode 100644 index 6b73208b236..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PreviousSibling Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - XmlNode^ lastNode = doc->DocumentElement->LastChild; - Console::WriteLine( "Last book..." ); - Console::WriteLine( lastNode->OuterXml ); - XmlNode^ prevNode = lastNode->PreviousSibling; - Console::WriteLine( "\r\nPrevious book..." ); - Console::WriteLine( prevNode->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveAll Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveAll Example/CPP/source.cpp deleted file mode 100644 index 5d7402c67e9..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveAll Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Remove all attribute and child nodes. - root->RemoveAll(); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveChild Example/CPP/source.cpp deleted file mode 100644 index 3eeeb8ee336..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveChild Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Remove the title element. - root->RemoveChild( root->FirstChild ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.ReplaceChild Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.ReplaceChild Example/CPP/source.cpp deleted file mode 100644 index 8b2b88dc130..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.ReplaceChild Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->DocumentElement; - - //Create a new title element. - XmlElement^ elem = doc->CreateElement( "title" ); - elem->InnerText = "The Handmaid's Tale"; - - //Replace the title element. - root->ReplaceChild( elem, root->FirstChild ); - Console::WriteLine( "Display the modified XML..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectNodes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectNodes Example/CPP/source.cpp deleted file mode 100644 index fa145876295..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectNodes Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "booksort.xml" ); - XmlNodeList^ nodeList; - XmlNode^ root = doc->DocumentElement; - nodeList = root->SelectNodes( "descendant::book[author/last-name='Austen']" ); - - //Change the price on the books. - System::Collections::IEnumerator^ myEnum = nodeList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlNode^ book = safe_cast(myEnum->Current); - book->LastChild->InnerText = "15.95"; - } - - Console::WriteLine( "Display the modified XML document...." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectSingleNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectSingleNode Example/CPP/source.cpp deleted file mode 100644 index 7ef2af1b754..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectSingleNode Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "booksort.xml" ); - XmlNode^ book; - XmlNode^ root = doc->DocumentElement; - book = root->SelectSingleNode( "descendant::book[author/last-name='Austen']" ); - - //Change the price on the book. - book->LastChild->InnerText = "15.95"; - Console::WriteLine( "Display the modified XML document...." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteContentTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteContentTo Example/CPP/source.cpp deleted file mode 100644 index 109df9f1d9a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteContentTo Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->FirstChild; - - // Because WriteContentTo saves only the child nodes of the node - // to the writer none of the attributes are displayed. - Console::WriteLine( "Display the contents of the node..." ); - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - root->WriteContentTo( writer ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteTo Example/CPP/source.cpp deleted file mode 100644 index 7a871794b8e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteTo Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "" ); - XmlNode^ root = doc->FirstChild; - Console::WriteLine( "Display the root node..." ); - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - root->WriteTo( writer ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.this Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.this Example/CPP/source.cpp deleted file mode 100644 index d308ff6a9b0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.this Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" ); - XmlNode^ root = doc->FirstChild; - Console::WriteLine( "Display the title element..." ); - Console::WriteLine( root[ "title" ]->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.GetEnumerator Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.GetEnumerator Example/CPP/source.cpp deleted file mode 100644 index 931cd16856c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.GetEnumerator Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Collections; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "2books.xml" ); - - //Get and display all the book titles. - XmlElement^ root = doc->DocumentElement; - XmlNodeList^ elemList = root->GetElementsByTagName( "title" ); - IEnumerator^ ienum = elemList->GetEnumerator(); - while ( ienum->MoveNext() ) - { - XmlNode^ title = dynamic_cast(ienum->Current); - Console::WriteLine( title->InnerText ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.Item Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.Item Example/CPP/source.cpp deleted file mode 100644 index 8fcc0d2c019..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeList.Item Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - " First item" - " Second item" - "" ); - - //Get and display the last item node. - XmlElement^ root = doc->DocumentElement; - XmlNodeList^ nodeList = root->GetElementsByTagName( "item" ); - Console::WriteLine( nodeList->Item( 1 )->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp deleted file mode 100644 index 91353be15eb..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp +++ /dev/null @@ -1,44 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " " - "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Read the attributes on the root element. - reader->MoveToContent(); - if ( reader->HasAttributes ) - { - for ( int i = 0; i < reader->AttributeCount; i++ ) - { - reader->MoveToAttribute( i ); - Console::WriteLine( "{0} = {1}", reader->Name, reader->Value ); - - } - reader->MoveToElement(); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.BaseURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.BaseURI Example/CPP/source.cpp deleted file mode 100644 index d3287716081..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.BaseURI Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load an XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "http://localhost/uri.xml" ); - reader = gcnew XmlNodeReader( doc ); - - //Parse the file and display the base URI for each node. - while ( reader->Read() ) - { - Console::WriteLine( "({0}) {1}", reader->NodeType, reader->BaseURI ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.GetAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.GetAttribute Example/CPP/source.cpp deleted file mode 100644 index 5b0e8725b23..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.GetAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " " - "" ); - - // Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Read the ISBN attribute. - reader->MoveToContent(); - String^ isbn = reader->GetAttribute( "ISBN" ); - Console::WriteLine( "The ISBN value: {0}", isbn ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.HasValue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.HasValue Example/CPP/source.cpp deleted file mode 100644 index 009705ea4c1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.HasValue Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - // Create and load an XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "]>" - "" - "Pride And Prejudice" - "&h;" - "" ); - reader = gcnew XmlNodeReader( doc ); - - // Parse the file and display each node. - while ( reader->Read() ) - { - if ( reader->HasValue ) - Console::WriteLine( "({0}) {1}={2}", reader->NodeType, reader->Name, reader->Value ); - else - Console::WriteLine( "({0}) {1}", reader->NodeType, reader->Name ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/CPP/source.cpp deleted file mode 100644 index a63f00d1f68..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Pride And Prejudice" - "19.95" - "" - "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Parse the XML and display the text content of each of the elements. - while ( reader->Read() ) - { - if ( reader->IsStartElement() ) - { - if ( reader->IsEmptyElement ) - Console::WriteLine( "<{0}/>", reader->Name ); - else - { - Console::Write( "<{0}> ", reader->Name ); - reader->Read(); //Read the start tag. - if ( reader->IsStartElement() ) - - //Handle nested elements. - Console::Write( "\r\n<{0}>", reader->Name ); - Console::WriteLine( reader->ReadString() ); //Read the text content of the element. - } - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToFirstAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToFirstAttribute Example/CPP/source.cpp deleted file mode 100644 index 255f2c6a1da..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToFirstAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Read the genre attribute. - reader->MoveToContent(); - reader->MoveToFirstAttribute(); - String^ genre = reader->Value; - Console::WriteLine( "The genre value: {0}", genre ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToNextAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToNextAttribute Example/CPP/source.cpp deleted file mode 100644 index 2d6857ce16e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToNextAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " " - "Pride And Prejudice" - "19.95" - "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Read the attributes on the book element. - reader->MoveToContent(); - while ( reader->MoveToNextAttribute() ) - { - Console::WriteLine( "{0} = {1}", reader->Name, reader->Value ); - } - - //Move the reader to the title element. - reader->Read(); - - //Read the title and price elements. - Console::WriteLine( reader->ReadElementString() ); - Console::WriteLine( reader->ReadElementString() ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp deleted file mode 100644 index b596f0cbf8c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - String^ filename = "items.xml"; - XmlNodeReader^ reader = nullptr; - try - { - - //Create an XmlNodeReader to read the XmlDocument. - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( filename ); - reader = gcnew XmlNodeReader( doc ); - - //Parse the file and display each of the nodes. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( "<{0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( reader->Value ); - break; - - case XmlNodeType::CDATA: - Console::Write( reader->Value ); - break; - - case XmlNodeType::ProcessingInstruction: - Console::Write( "", reader->Name, reader->Value ); - break; - - case XmlNodeType::Comment: - Console::Write( "", reader->Value ); - break; - - case XmlNodeType::XmlDeclaration: - Console::Write( "" ); - break; - - case XmlNodeType::Document: - break; - - case XmlNodeType::EndElement: - Console::Write( "", reader->Name ); - break; - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp deleted file mode 100644 index 209660c6243..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp +++ /dev/null @@ -1,49 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( " " - "Pride And Prejudice" - "novel" - "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - - //Parse the XML. If they exist, display the prefix and - //namespace URI of each node. - while ( reader->Read() ) - { - if ( reader->IsStartElement() ) - { - if ( reader->Prefix == String::Empty ) - Console::WriteLine( "<{0}>", reader->LocalName ); - else - { - Console::Write( "<{0}:{1}>", reader->Prefix, reader->LocalName ); - Console::WriteLine( " The namespace URI is {0}", reader->NamespaceURI ); - } - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ReadAttributeValue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ReadAttributeValue Example/CPP/source.cpp deleted file mode 100644 index fa8f90ee268..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ReadAttributeValue Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load an XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "" ); - - //Create the reader. - reader = gcnew XmlNodeReader( doc ); - - //Read the misc attribute. The attribute is parsed into multiple - //text and entity reference nodes. - reader->MoveToContent(); - reader->MoveToAttribute( "misc" ); - while ( reader->ReadAttributeValue() ) - { - if ( reader->NodeType == XmlNodeType::EntityReference ) - - //To expand the entity, call ResolveEntity. - Console::WriteLine( "{0} {1}", reader->NodeType, reader->Name ); - else - Console::WriteLine( "{0} {1}", reader->NodeType, reader->Value ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ResolveEntity Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ResolveEntity Example/CPP/source.cpp deleted file mode 100644 index a980ac2665e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ResolveEntity Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load an XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "]>" - "" - "Pride And Prejudice" - "&h;" - "" ); - - //Create the reader. - reader = gcnew XmlNodeReader( doc ); - reader->MoveToContent(); //Move to the root element. - reader->Read(); //Move to title start tag. - reader->Skip(); //Skip the title element. - - //Read the misc start tag. The reader is now positioned on - //the entity reference node. - reader->ReadStartElement(); - - //You must call ResolveEntity to expand the entity reference. - //The entity replacement text is then parsed and returned as a child node. - Console::WriteLine( "Expand the entity..." ); - reader->ResolveEntity(); - Console::WriteLine( "The entity replacement text is returned as a text node." ); - reader->Read(); - Console::WriteLine( "NodeType: {0} Value: {1}", reader->NodeType, reader->Value ); - Console::WriteLine( "An EndEntity node closes the entity reference scope." ); - reader->Read(); - Console::WriteLine( "NodeType: {0} Name: {1}", reader->NodeType, reader->Name ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Skip Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Skip Example/CPP/source.cpp deleted file mode 100644 index cb90b873442..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Skip Example/CPP/source.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlNodeReader^ reader = nullptr; - try - { - - //Create and load the XML document. - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "" - "Pride And Prejudice" - "19.95" - "" ); - - //Load the XmlNodeReader - reader = gcnew XmlNodeReader( doc ); - reader->MoveToContent(); //Move to the book node. - reader->Read(); //Read the book start tag. - reader->Skip(); //Skip the title element. - Console::WriteLine( reader->ReadOuterXml() ); //Read the price element. - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.HasAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.HasAttributes Example/CPP/source.cpp deleted file mode 100644 index 7658108b64d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.HasAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; -using namespace System::Xml::Schema; - -public ref class Class1 -{ -// -public: - void DisplayAttributes( XmlReader^ reader ) - { - if ( reader->HasAttributes ) - { - Console::WriteLine( "Attributes of <{0}>", reader->Name ); - while ( reader->MoveToNextAttribute() ) - { - Console::WriteLine( " {0}={1}", reader->Name, reader->Value ); - } - } - } -// -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/CPP/source.cpp deleted file mode 100644 index 4d1aa635c0e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - //Load the reader with the XML file. - reader = gcnew XmlTextReader( "elems.xml" ); - - //Parse the XML and display the text content of each of the elements. - while ( reader->Read() ) - { - if ( reader->IsStartElement() ) - { - if ( reader->IsEmptyElement ) - Console::WriteLine( "<{0}/>", reader->Name ); - else - { - Console::Write( "<{0}> ", reader->Name ); - reader->Read(); //Read the start tag. - if ( reader->IsStartElement() ) - - //Handle nested elements. - Console::Write( "\r\n<{0}>", reader->Name ); - Console::WriteLine( reader->ReadString() ); //Read the text content of the element. - } - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.MoveToContent Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.MoveToContent Example/CPP/source.cpp deleted file mode 100644 index 05bb06db971..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.MoveToContent Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Data; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -protected: - String^ _price; - -public: - void Method( XmlReader^ reader ) - { -// - if ( reader->MoveToContent() == XmlNodeType::Element && - reader->Name->Equals( "price" ) ) - { - _price = reader->ReadString(); - } -// - } -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchema Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchema Example/CPP/source.cpp deleted file mode 100644 index 2ecb603c997..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchema Example/CPP/source.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - static void Main() - { - - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ elementCat = gcnew XmlSchemaElement(); - schema->Items->Add(elementCat); - elementCat->Name = "cat"; - elementCat->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementDog); - elementDog->Name = "dog"; - elementDog->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementRedDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementRedDog); - elementRedDog->Name = "redDog"; - elementRedDog->SubstitutionGroup = gcnew XmlQualifiedName("dog"); - - // - XmlSchemaElement^ elementBrownDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementBrownDog); - elementBrownDog->Name = "brownDog"; - elementBrownDog->SubstitutionGroup = gcnew XmlQualifiedName("dog"); - - - // - XmlSchemaElement^ elementPets = gcnew XmlSchemaElement(); - schema->Items->Add(elementPets); - elementPets->Name = "pets"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - elementPets->SchemaType = complexType; - - // - XmlSchemaChoice^ choice = gcnew XmlSchemaChoice(); - complexType->Particle = choice; - choice->MinOccurs = 0; - choice->MaxOccursString = "unbounded"; - - // - XmlSchemaElement^ catRef = gcnew XmlSchemaElement(); - choice->Items->Add(catRef); - catRef->RefName = gcnew XmlQualifiedName("cat"); - - // - XmlSchemaElement^ dogRef = gcnew XmlSchemaElement(); - choice->Items->Add(dogRef); - dogRef->RefName = gcnew XmlQualifiedName("dog"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// - - diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/CPP/source.cpp deleted file mode 100644 index d410a9785b7..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/CPP/source.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - XmlSchemaElement^ thing1 = gcnew XmlSchemaElement(); - thing1->Name = "thing1"; - thing1->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - schema->Items->Add(thing1); - - XmlSchemaElement^ thing2 = gcnew XmlSchemaElement(); - thing2->Name = "thing2"; - thing2->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - schema->Items->Add(thing2); - - XmlSchemaElement^ thing3 = gcnew XmlSchemaElement(); - thing3->Name = "thing3"; - thing3->SchemaTypeName = - gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - schema->Items->Add(thing3); - - XmlSchemaElement^ thing4 = gcnew XmlSchemaElement(); - thing4->Name = "thing4"; - thing4->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - schema->Items->Add(thing4); - - XmlSchemaAttribute^ myAttribute = gcnew XmlSchemaAttribute(); - myAttribute->Name = "myAttribute"; - myAttribute->SchemaTypeName = gcnew XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema"); - schema->Items->Add(myAttribute); - - XmlSchemaComplexType^ myComplexType = gcnew XmlSchemaComplexType(); - myComplexType->Name = "myComplexType"; - - XmlSchemaAll^ complexType_all = gcnew XmlSchemaAll(); - - XmlSchemaElement^ complexType_all_thing1 = gcnew XmlSchemaElement(); - complexType_all_thing1->RefName = gcnew XmlQualifiedName("thing1", ""); - complexType_all->Items->Add(complexType_all_thing1); - - XmlSchemaElement^ complexType_all_thing2 = gcnew XmlSchemaElement(); - complexType_all_thing2->RefName = gcnew XmlQualifiedName("thing2", ""); - complexType_all->Items->Add(complexType_all_thing2); - - XmlSchemaElement^ complexType_all_thing3 = gcnew XmlSchemaElement(); - complexType_all_thing3->RefName = gcnew XmlQualifiedName("thing3", ""); - complexType_all->Items->Add(complexType_all_thing3); - - XmlSchemaElement^ complexType_all_thing4 = gcnew XmlSchemaElement(); - complexType_all_thing4->RefName = gcnew XmlQualifiedName("thing4", ""); - complexType_all->Items->Add(complexType_all_thing4); - - myComplexType->Particle = complexType_all; - - XmlSchemaAttribute^ complexType_myAttribute = gcnew XmlSchemaAttribute(); - complexType_myAttribute->RefName = gcnew XmlQualifiedName("myAttribute", ""); - myComplexType->Attributes->Add(complexType_myAttribute); - - schema->Items->Add(myComplexType); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/CPP/source.cpp deleted file mode 100644 index 0da1a34fd86..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/CPP/source.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - static void Main() - { - - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ simpleType = gcnew XmlSchemaSimpleType(); - simpleType->Name = "northwestStates"; - schema->Items->Add(simpleType); - - // - XmlSchemaAnnotation^ annNorthwestStates = gcnew XmlSchemaAnnotation(); - simpleType->Annotation = annNorthwestStates; - - // States in the Pacific Northwest of US - XmlSchemaDocumentation^ docNorthwestStates = gcnew XmlSchemaDocumentation(); - annNorthwestStates->Items->Add(docNorthwestStates); - docNorthwestStates->Markup = TextToNodeArray("States in the Pacific Northwest of US"); - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - simpleType->Content = restriction; - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaEnumerationFacet^ enumerationWA = gcnew XmlSchemaEnumerationFacet(); - restriction->Facets->Add(enumerationWA); - enumerationWA->Value = "WA"; - - // - XmlSchemaAnnotation^ annWA = gcnew XmlSchemaAnnotation(); - enumerationWA->Annotation = annWA; - - // Washington - XmlSchemaDocumentation^ docWA = gcnew XmlSchemaDocumentation(); - annWA->Items->Add(docWA); - docWA->Markup = TextToNodeArray("Washington"); - - // - XmlSchemaEnumerationFacet^ enumerationOR = gcnew XmlSchemaEnumerationFacet(); - restriction->Facets->Add(enumerationOR); - enumerationOR->Value = "OR"; - - // - XmlSchemaAnnotation^ annOR = gcnew XmlSchemaAnnotation(); - enumerationOR->Annotation = annOR; - - // Oregon - XmlSchemaDocumentation^ docOR = gcnew XmlSchemaDocumentation(); - annOR->Items->Add(docOR); - docOR->Markup = TextToNodeArray("Oregon"); - - // - XmlSchemaEnumerationFacet^ enumerationID = gcnew XmlSchemaEnumerationFacet(); - - restriction->Facets->Add(enumerationID); - enumerationID->Value = "ID"; - - // - XmlSchemaAnnotation^ annID = gcnew XmlSchemaAnnotation(); - enumerationID->Annotation = annID; - - // Idaho - XmlSchemaDocumentation^ docID = gcnew XmlSchemaDocumentation(); - annID->Items->Add(docID); - docID->Markup = TextToNodeArray("Idaho"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - - static array^ TextToNodeArray(String^ text) - { - XmlDocument^ doc = gcnew XmlDocument(); - array^ temp = {doc->CreateTextNode(text)}; - return temp; - } - -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAny Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAny Example/CPP/source.cpp deleted file mode 100644 index de4222ca95d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAny Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ xeHtmlText = gcnew XmlSchemaElement(); - xeHtmlText->Name = "htmlText"; - - // - XmlSchemaComplexType^ ct = gcnew XmlSchemaComplexType(); - - // - XmlSchemaSequence^ sequence = gcnew XmlSchemaSequence(); - - // - XmlSchemaAny^ any = gcnew XmlSchemaAny(); - any->MinOccurs = 1; - any->MaxOccursString = "unbounded"; - any->Namespace = "http://www.w3.org/1999/xhtml"; - any->ProcessContents = XmlSchemaContentProcessing::Lax; - sequence->Items->Add(any); - - ct->Particle = sequence; - xeHtmlText->SchemaType = ct; - - schema->Items->Add(xeHtmlText); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - schema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnyAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnyAttribute Example/CPP/source.cpp deleted file mode 100644 index 17a9abb810d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnyAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - schema->Items->Add(element); - element->Name = "stringElementWithAnyAttribute"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - element->SchemaType = complexType; - - // - XmlSchemaSimpleContent^ simpleContent = gcnew XmlSchemaSimpleContent(); - complexType->ContentModel = simpleContent; - - // - XmlSchemaSimpleContentExtension^ extension = gcnew XmlSchemaSimpleContentExtension(); - simpleContent->Content = extension; - extension->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAnyAttribute^ anyAttribute = gcnew XmlSchemaAnyAttribute(); - extension->AnyAttribute = anyAttribute; - anyAttribute->Namespace = "##targetNamespace"; - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAppInfo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAppInfo Example/CPP/source.cpp deleted file mode 100644 index cb4bdbb1014..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAppInfo Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - schema->Items->Add(element); - element->Name = "State"; - - // - XmlSchemaAnnotation^ annNorthwestStates = gcnew XmlSchemaAnnotation(); - element->Annotation = annNorthwestStates; - - // State Name - XmlSchemaDocumentation^ docNorthwestStates = gcnew XmlSchemaDocumentation(); - annNorthwestStates->Items->Add(docNorthwestStates); - docNorthwestStates->Markup = TextToNodeArray("State Name"); - - // Application Information - XmlSchemaAppInfo^ appInfo = gcnew XmlSchemaAppInfo(); - annNorthwestStates->Items->Add(appInfo); - appInfo->Markup = TextToNodeArray("Application Information"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - - Console::WriteLine(args->Message); - } - - static array^ TextToNodeArray(String^ text) - { - XmlDocument^ doc = gcnew XmlDocument(); - array^ nodes = {doc->CreateTextNode(text)}; - return nodes; - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttribute Example/CPP/source.cpp deleted file mode 100644 index 083c98e686d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaAttribute^ attributeBase = gcnew XmlSchemaAttribute(); - schema->Items->Add(attributeBase); - attributeBase->Name = "mybaseattribute"; - - // - XmlSchemaSimpleType^ simpleType = gcnew XmlSchemaSimpleType(); - attributeBase->SchemaType = simpleType; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - simpleType->Content = restriction; - restriction->BaseTypeName = gcnew XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMaxInclusiveFacet^ maxInclusive = gcnew XmlSchemaMaxInclusiveFacet(); - restriction->Facets->Add(maxInclusive); - maxInclusive->Value = "1000"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - schema->Items->Add(complexType); - complexType->Name = "myComplexType"; - - // - XmlSchemaAttribute^ attributeBaseRef = gcnew XmlSchemaAttribute(); - complexType->Attributes->Add(attributeBaseRef); - attributeBaseRef->RefName = gcnew XmlQualifiedName("mybaseattribute"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttributeGroup Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttributeGroup Example/CPP/source.cpp deleted file mode 100644 index 465d8de18d4..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAttributeGroup Example/CPP/source.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaAttributeGroup^ myAttributeGroup = gcnew XmlSchemaAttributeGroup(); - schema->Items->Add(myAttributeGroup); - myAttributeGroup->Name = "myAttributeGroup"; - - // - XmlSchemaAttribute^ someattribute1 = gcnew XmlSchemaAttribute(); - myAttributeGroup->Attributes->Add(someattribute1); - someattribute1->Name = "someattribute1"; - someattribute1->SchemaTypeName = gcnew XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema"); - - - // - XmlSchemaAttribute^ someattribute2 = gcnew XmlSchemaAttribute(); - myAttributeGroup->Attributes->Add(someattribute2); - someattribute2->Name = "someattribute2"; - someattribute2->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaComplexType^ myElementType = gcnew XmlSchemaComplexType(); - schema->Items->Add(myElementType); - myElementType->Name = "myElementType"; - - // - XmlSchemaAttributeGroupRef^ myAttributeGroupRef = gcnew XmlSchemaAttributeGroupRef(); - myElementType->Attributes->Add(myAttributeGroupRef); - myAttributeGroupRef->RefName = gcnew XmlQualifiedName("myAttributeGroup"); - - // - XmlSchemaAttributeGroup^ myAttributeGroupA = gcnew XmlSchemaAttributeGroup(); - schema->Items->Add(myAttributeGroupA); - myAttributeGroupA->Name = "myAttributeGroupA"; - - // - XmlSchemaAttribute^ someattribute10 = gcnew XmlSchemaAttribute(); - myAttributeGroupA->Attributes->Add(someattribute10); - someattribute10->Name = "someattribute10"; - someattribute10->SchemaTypeName = gcnew XmlQualifiedName("integer", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAttribute^ someattribute11 = gcnew XmlSchemaAttribute(); - myAttributeGroupA->Attributes->Add(someattribute11); - someattribute11->Name = "someattribute11"; - someattribute11->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAttributeGroup^ myAttributeGroupB = gcnew XmlSchemaAttributeGroup(); - schema->Items->Add(myAttributeGroupB); - myAttributeGroupB->Name = "myAttributeGroupB"; - - // - XmlSchemaAttribute^ someattribute20 = gcnew XmlSchemaAttribute(); - myAttributeGroupB->Attributes->Add(someattribute20); - someattribute20->Name = "someattribute20"; - someattribute20->SchemaTypeName = gcnew XmlQualifiedName("date", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAttributeGroupRef^ myAttributeGroupRefA = gcnew XmlSchemaAttributeGroupRef(); - myAttributeGroupB->Attributes->Add(myAttributeGroupRefA); - myAttributeGroupRefA->RefName = gcnew XmlQualifiedName("myAttributeGroupA"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaChoice Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaChoice Example/CPP/source.cpp deleted file mode 100644 index d73de8b2cf6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaChoice Example/CPP/source.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ xeSelected = gcnew XmlSchemaElement(); - xeSelected->Name = "selected"; - schema->Items->Add(xeSelected); - - // - XmlSchemaElement^ xeUnselected = gcnew XmlSchemaElement(); - xeUnselected->Name = "unselected"; - schema->Items->Add(xeUnselected); - - // - XmlSchemaElement^ xeDimpled = gcnew XmlSchemaElement(); - xeDimpled->Name = "dimpled"; - schema->Items->Add(xeDimpled); - - // - XmlSchemaElement^ xePerforated = gcnew XmlSchemaElement(); - xePerforated->Name = "perforated"; - schema->Items->Add(xePerforated); - - // - XmlSchemaComplexType^ chadState = gcnew XmlSchemaComplexType(); - schema->Items->Add(chadState); - chadState->Name = "chadState"; - - // - XmlSchemaChoice^ choice = gcnew XmlSchemaChoice(); - chadState->Particle = choice; - choice->MinOccurs = 1; - choice->MaxOccurs = 1; - - // - XmlSchemaElement^ elementSelected = gcnew XmlSchemaElement(); - choice->Items->Add(elementSelected); - elementSelected->RefName = gcnew XmlQualifiedName("selected"); - - // - XmlSchemaElement^ elementUnselected = gcnew XmlSchemaElement(); - choice->Items->Add(elementUnselected); - elementUnselected->RefName = gcnew XmlQualifiedName("unselected"); - - // - XmlSchemaElement^ elementDimpled = gcnew XmlSchemaElement(); - choice->Items->Add(elementDimpled); - elementDimpled->RefName = gcnew XmlQualifiedName("dimpled"); - - // - XmlSchemaElement^ elementPerforated = gcnew XmlSchemaElement(); - choice->Items->Add(elementPerforated); - elementPerforated->RefName = gcnew XmlQualifiedName("perforated"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/CPP/source.cpp deleted file mode 100644 index b9bf69edc70..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; -using namespace System::Xml::Schema; - -public ref class Class1 -{ - // -public: - void DisplaySchemas( XmlSchemaCollection^ xsc ) - { - XmlSchemaCollectionEnumerator^ ienum = xsc->GetEnumerator(); - while ( ienum->MoveNext() ) - { - XmlSchema^ schema = ienum->Current; - StringWriter^ sw = gcnew StringWriter; - XmlTextWriter^ writer = gcnew XmlTextWriter( sw ); - writer->Formatting = Formatting::Indented; - writer->Indentation = 2; - schema->Write( writer ); - Console::WriteLine( sw ); - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/CPP/source.cpp deleted file mode 100644 index 9dfc421ef93..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#using -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::IO; -using namespace System::Windows::Forms; - -public ref class Form1: public Form -{ -public: - void Method( XmlSchemaCollection^ xsc ) - { - // - if ( xsc->Contains( "urn:bookstore-schema" ) ) - { - XmlSchema^ schema = xsc[ "urn:bookstore-schema" ]; - StringWriter^ sw = gcnew StringWriter; - XmlTextWriter^ xmlWriter = gcnew XmlTextWriter( sw ); - xmlWriter->Formatting = Formatting::Indented; - xmlWriter->Indentation = 2; - schema->Write( xmlWriter ); - Console::WriteLine( sw ); - } - // - } -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContent Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContent Example/CPP/source.cpp deleted file mode 100644 index 65680c23fba..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContent Example/CPP/source.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaComplexType^ address = gcnew XmlSchemaComplexType(); - schema->Items->Add(address); - address->Name = "address"; - - // - XmlSchemaSequence^ sequence = gcnew XmlSchemaSequence(); - address->Particle = sequence; - - // - XmlSchemaElement^ elementName = gcnew XmlSchemaElement(); - sequence->Items->Add(elementName); - elementName->Name = "name"; - elementName->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementStreet = gcnew XmlSchemaElement(); - sequence->Items->Add(elementStreet); - elementStreet->Name = "street"; - elementStreet->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementCity = gcnew XmlSchemaElement(); - sequence->Items->Add(elementCity); - elementCity->Name = "city"; - elementCity->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaComplexType^ USAddress = gcnew XmlSchemaComplexType(); - schema->Items->Add(USAddress); - USAddress->Name = "USAddress"; - - // - XmlSchemaComplexContent^ complexContent = gcnew XmlSchemaComplexContent(); - USAddress->ContentModel = complexContent; - - // - XmlSchemaComplexContentExtension^ extensionAddress = gcnew XmlSchemaComplexContentExtension(); - complexContent->Content = extensionAddress; - extensionAddress->BaseTypeName = gcnew XmlQualifiedName("address"); - - // - XmlSchemaSequence^ sequence2 = gcnew XmlSchemaSequence(); - extensionAddress->Particle = sequence2; - - // - XmlSchemaElement^ elementUSState = gcnew XmlSchemaElement(); - sequence2->Items->Add(elementUSState); - elementUSState->Name = "state"; - elementUSState->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - - // - XmlSchemaElement^ elementZipcode = gcnew XmlSchemaElement(); - sequence2->Items->Add(elementZipcode); - elementZipcode->Name = "zipcode"; - elementZipcode->SchemaTypeName = gcnew XmlQualifiedName("positiveInteger", "http://www.w3.org/2001/XMLSchema"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContentRestriction Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContentRestriction Example/CPP/source.cpp deleted file mode 100644 index 8c05936319d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaComplexContentRestriction Example/CPP/source.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaComplexType^ phoneNumber = gcnew XmlSchemaComplexType(); - phoneNumber->Name = "phoneNumber"; - - // - XmlSchemaSequence^ phoneNumberSequence = gcnew XmlSchemaSequence(); - - // - XmlSchemaElement^ areaCode1 = gcnew XmlSchemaElement(); - areaCode1->MinOccurs = 0; - areaCode1->MaxOccursString = "1"; - areaCode1->Name = "areaCode"; - phoneNumberSequence->Items->Add(areaCode1); - - // - XmlSchemaElement^ prefix1 = gcnew XmlSchemaElement(); - prefix1->MinOccurs = 1; - prefix1->MaxOccursString = "1"; - prefix1->Name = "prefix"; - phoneNumberSequence->Items->Add(prefix1); - - // - XmlSchemaElement^ number1 = gcnew XmlSchemaElement(); - number1->MinOccurs = 1; - number1->MaxOccursString = "1"; - number1->Name = "number"; - phoneNumberSequence->Items->Add(number1); - - phoneNumber->Particle = phoneNumberSequence; - - schema->Items->Add(phoneNumber); - - // - XmlSchemaComplexType^ localPhoneNumber = gcnew XmlSchemaComplexType(); - localPhoneNumber->Name = "localPhoneNumber"; - - // - XmlSchemaComplexContent^ complexContent = gcnew XmlSchemaComplexContent(); - - // - XmlSchemaComplexContentRestriction^ restriction = gcnew XmlSchemaComplexContentRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("phoneNumber", ""); - - // - XmlSchemaSequence^ sequence2 = gcnew XmlSchemaSequence(); - - // - XmlSchemaElement^ areaCode2 = gcnew XmlSchemaElement(); - areaCode2->MinOccurs = 0; - areaCode2->MaxOccursString = "1"; - areaCode2->Name = "areaCode"; - sequence2->Items->Add(areaCode2); - - // - XmlSchemaElement^ prefix2 = gcnew XmlSchemaElement(); - prefix2->MinOccurs = 1; - prefix2->MaxOccursString = "1"; - prefix2->Name = "prefix"; - sequence2->Items->Add(prefix2); - - // - XmlSchemaElement^ number2 = gcnew XmlSchemaElement(); - number2->MinOccurs = 1; - number2->MaxOccursString = "1"; - number2->Name = "number"; - sequence2->Items->Add(number2); - - restriction->Particle = sequence2; - complexContent->Content = restriction; - localPhoneNumber->ContentModel = complexContent; - - schema->Items->Add(localPhoneNumber); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaEnumerationFacet Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaEnumerationFacet Example/CPP/source.cpp deleted file mode 100644 index 6381b6b7526..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaEnumerationFacet Example/CPP/source.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ SizeType = gcnew XmlSchemaSimpleType(); - SizeType->Name = "SizeType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaEnumerationFacet^ enumerationSmall = gcnew XmlSchemaEnumerationFacet(); - enumerationSmall->Value = "Small"; - restriction->Facets->Add(enumerationSmall); - - // - XmlSchemaEnumerationFacet^ enumerationMedium = gcnew XmlSchemaEnumerationFacet(); - enumerationMedium->Value = "Medium"; - restriction->Facets->Add(enumerationMedium); - - // - XmlSchemaEnumerationFacet^ enumerationLarge = gcnew XmlSchemaEnumerationFacet(); - enumerationLarge->Value = "Large"; - restriction->Facets->Add(enumerationLarge); - - SizeType->Content = restriction; - - schema->Items->Add(SizeType); - - // - XmlSchemaElement^ elementItem = gcnew XmlSchemaElement(); - elementItem->Name = "Item"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ attributeSize = gcnew XmlSchemaAttribute(); - attributeSize->Name = "Size"; - attributeSize->SchemaTypeName = gcnew XmlQualifiedName("SizeType", ""); - complexType->Attributes->Add(attributeSize); - - elementItem->SchemaType = complexType; - - schema->Items->Add(elementItem); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaException Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaException Example/CPP/source.cpp deleted file mode 100644 index b7af3eb044a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaException Example/CPP/source.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class ValidXsd -{ -public: - - static void Main() - { - FileStream^ fs; - XmlSchema^ schema; - - try - { - fs = gcnew FileStream("example.xsd", FileMode::Open); - schema = XmlSchema::Read(fs, gcnew ValidationEventHandler(ShowCompileError)); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ShowCompileError); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - schema = compiledSchema; - - if (schema->IsCompiled) - { - // Schema is successfully compiled. - // Do something with it here. - - } - } - catch (XmlSchemaException^ e) - { - Console::WriteLine("LineNumber = {0}", e->LineNumber); - Console::WriteLine("LinePosition = {0}", e->LinePosition); - Console::WriteLine("Message = {0}", e->Message); - } - - } - - static void ShowCompileError(Object^ sender, ValidationEventArgs^ e) - { - Console::WriteLine("Validation Error: {0}", e->Message); - } -}; - -int main() -{ - ValidXsd::Main(); - Console::ReadLine(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaGroup Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaGroup Example/CPP/source.cpp deleted file mode 100644 index 308c590aadf..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaGroup Example/CPP/source.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ elementThing1 = gcnew XmlSchemaElement(); - schema->Items->Add(elementThing1); - elementThing1->Name = "thing1"; - elementThing1->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementThing2 = gcnew XmlSchemaElement(); - schema->Items->Add(elementThing2); - elementThing2->Name = "thing2"; - elementThing2->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementThing3 = gcnew XmlSchemaElement(); - schema->Items->Add(elementThing3); - elementThing3->Name = "thing3"; - elementThing3->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAttribute^ myAttribute = gcnew XmlSchemaAttribute(); - schema->Items->Add(myAttribute); - myAttribute->Name = "myAttribute"; - myAttribute->SchemaTypeName = gcnew XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaGroup^ myGroupOfThings = gcnew XmlSchemaGroup(); - schema->Items->Add(myGroupOfThings); - myGroupOfThings->Name = "myGroupOfThings"; - - // - XmlSchemaSequence^ sequence = gcnew XmlSchemaSequence(); - myGroupOfThings->Particle = sequence; - - // - XmlSchemaElement^ elementThing1Ref = gcnew XmlSchemaElement(); - sequence->Items->Add(elementThing1Ref); - elementThing1Ref->RefName = gcnew XmlQualifiedName("thing1"); - - // - XmlSchemaElement^ elementThing2Ref = gcnew XmlSchemaElement(); - sequence->Items->Add(elementThing2Ref); - elementThing2Ref->RefName = gcnew XmlQualifiedName("thing2"); - - // - XmlSchemaElement^ elementThing3Ref = gcnew XmlSchemaElement(); - sequence->Items->Add(elementThing3Ref); - elementThing3Ref->RefName = gcnew XmlQualifiedName("thing3"); - - // - XmlSchemaComplexType^ myComplexType = gcnew XmlSchemaComplexType(); - schema->Items->Add(myComplexType); - myComplexType->Name = "myComplexType"; - - // - XmlSchemaGroupRef^ myGroupOfThingsRef = gcnew XmlSchemaGroupRef(); - myComplexType->Particle = myGroupOfThingsRef; - myGroupOfThingsRef->RefName = gcnew XmlQualifiedName("myGroupOfThings"); - - // - XmlSchemaAttribute^ myAttributeRef = gcnew XmlSchemaAttribute(); - myComplexType->Attributes->Add(myAttributeRef); - myAttributeRef->RefName = gcnew XmlQualifiedName("myAttribute"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaNotation Example/CPP/notation.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaNotation Example/CPP/notation.cpp deleted file mode 100644 index 4f5ccb60525..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaNotation Example/CPP/notation.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaNotation^ notation = gcnew XmlSchemaNotation(); - notation->Name = "jpeg"; - notation->Public = "image/jpeg"; - notation->System = "viewer.exe"; - - schema->Items->Add(notation); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject Example/CPP/source.cpp deleted file mode 100644 index 320ba3c48fc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject Example/CPP/source.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Reflection; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class ValidXSD -{ -private: - static void DisplayObjects(Object^ o) - { - DisplayObjects(o, ""); - } - - static void DisplayObjects(Object^ o, String^ indent) - { - Console::WriteLine("{0}{1}", indent, o); - - for each (PropertyInfo^ property1 in o->GetType()->GetProperties()) - { - if (property1->PropertyType->FullName == "System.Xml.Schema.XmlSchemaObjectCollection") - { - XmlSchemaObjectCollection^ childObjectCollection = dynamic_cast(property1->GetValue(o, nullptr)); - - for each (XmlSchemaObject^ schemaObject in childObjectCollection) - { - DisplayObjects(schemaObject, indent + "\t"); - } - } - } - } - - static void ShowCompileError(Object^ sender, ValidationEventArgs^ e) - { - Console::WriteLine("Validation Error: {0}", e->Message); - } - -public: - static int Main() - { - String^ xsd = "example.xsd"; - - FileStream^ fs; - XmlSchema^ schema; - try - { - fs = gcnew FileStream(xsd, FileMode::Open); - schema = XmlSchema::Read(fs, gcnew ValidationEventHandler(ShowCompileError)); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ShowCompileError); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - schema = compiledSchema; - - if (schema->IsCompiled) - { - DisplayObjects(schema); - } - return 0; - } - catch (XmlSchemaException^ e) - { - Console::WriteLine("LineNumber = {0}", e->LineNumber); - Console::WriteLine("LinePosition = {0}", e->LinePosition); - Console::WriteLine("Message = {0}", e->Message); - Console::WriteLine("Source = {0}", e->Source); - return -1; - } - } -}; - -int main() -{ - ValidXSD::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/CPP/namespaces.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/CPP/namespaces.cpp deleted file mode 100644 index f4e63a564af..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/CPP/namespaces.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -int main() -{ - XmlSchema^ s = gcnew XmlSchema; - s->TargetNamespace = "myNamespace"; - s->Namespaces->Add( "myImpPrefix", "myImportNamespace" ); - - // Create the element. - XmlSchemaImport^ import = gcnew XmlSchemaImport; - import->Namespace = "myImportNamespace"; - import->SchemaLocation = "http://www.example.com/myImportNamespace"; - s->Includes->Add( import ); - - // Create an element and assign a type from imported schema. - XmlSchemaElement^ elem = gcnew XmlSchemaElement; - elem->SchemaTypeName = gcnew XmlQualifiedName( "importType","myImportNamespace" ); - elem->Name = "element1"; - s->Items->Add( elem ); - s->Write( Console::Out ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/CPP/source.cpp deleted file mode 100644 index 4c7edb2f322..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XMLSchemaExamples -{ - -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ generalPrice = gcnew XmlSchemaElement(); - generalPrice->Name = "generalPrice"; - - // - XmlSchemaComplexType^ ct = gcnew XmlSchemaComplexType(); - - // - XmlSchemaSimpleContent^ simpleContent = gcnew XmlSchemaSimpleContent(); - - // - XmlSchemaSimpleContentExtension^ simpleContent_extension = gcnew XmlSchemaSimpleContentExtension(); - simpleContent_extension->BaseTypeName = gcnew XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAttribute^ currency = gcnew XmlSchemaAttribute(); - currency->Name = "currency"; - currency->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - simpleContent_extension->Attributes->Add(currency); - - simpleContent->Content = simpleContent_extension; - ct->ContentModel = simpleContent; - generalPrice->SchemaType = ct; - - schema->Items->Add(generalPrice); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleType Example/CPP/source.cpp deleted file mode 100644 index 35a881cdd78..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleType Example/CPP/source.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ LotteryNumberType = gcnew XmlSchemaSimpleType(); - LotteryNumberType->Name = "LotteryNumber"; - - // - XmlSchemaSimpleTypeRestriction^ LotteryNumberRestriction = gcnew XmlSchemaSimpleTypeRestriction(); - LotteryNumberRestriction->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMinInclusiveFacet^ minInclusive = gcnew XmlSchemaMinInclusiveFacet(); - minInclusive->Value = "1"; - LotteryNumberRestriction->Facets->Add(minInclusive); - - // - XmlSchemaMaxInclusiveFacet^ maxInclusive = gcnew XmlSchemaMaxInclusiveFacet(); - maxInclusive->Value = "99"; - LotteryNumberRestriction->Facets->Add(maxInclusive); - - LotteryNumberType->Content = LotteryNumberRestriction; - schema->Items->Add(LotteryNumberType); - - // - XmlSchemaSimpleType^ LotteryNumberListType = gcnew XmlSchemaSimpleType(); - LotteryNumberListType->Name = "LotteryNumberList"; - - // - XmlSchemaSimpleTypeList^ list = gcnew XmlSchemaSimpleTypeList(); - list->ItemTypeName = gcnew XmlQualifiedName("LotteryNumber", ""); - LotteryNumberListType->Content = list; - - schema->Items->Add(LotteryNumberListType); - - // - XmlSchemaSimpleType^ LotteryNumbersType = gcnew XmlSchemaSimpleType(); - LotteryNumbersType->Name = "LotteryNumbers"; - - // - XmlSchemaSimpleTypeRestriction^ LotteryNumbersRestriction = gcnew XmlSchemaSimpleTypeRestriction(); - LotteryNumbersRestriction->BaseTypeName = gcnew XmlQualifiedName("LotteryNumberList", ""); - - // - XmlSchemaLengthFacet^ length = gcnew XmlSchemaLengthFacet(); - length->Value = "5"; - LotteryNumbersRestriction->Facets->Add(length); - - LotteryNumbersType->Content = LotteryNumbersRestriction; - - schema->Items->Add(LotteryNumbersType); - - // - XmlSchemaElement^ TodaysLottery = gcnew XmlSchemaElement(); - TodaysLottery->Name = "TodaysLottery"; - TodaysLottery->SchemaTypeName = gcnew XmlQualifiedName("LotteryNumbers", ""); - - schema->Items->Add(TodaysLottery); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSignificantWhitespace.NodeType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSignificantWhitespace.NodeType Example/CPP/source.cpp deleted file mode 100644 index 78ec91dd354..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSignificantWhitespace.NodeType Example/CPP/source.cpp +++ /dev/null @@ -1,119 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -private: - XmlNode^ currNode; - XmlTextReader^ reader; - -public: - Sample() - { - reader = nullptr; - String^ filename = "space.xml"; - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "" - "Eva" - "Corets" - "" ); - Console::WriteLine( "InnerText before..." ); - Console::WriteLine( doc->DocumentElement->InnerText ); - - // Add white space. - currNode = doc->DocumentElement; - XmlSignificantWhitespace^ sigws = doc->CreateSignificantWhitespace( "\t" ); - currNode->InsertAfter( sigws, currNode->FirstChild ); - Console::WriteLine(); - Console::WriteLine( "InnerText after..." ); - Console::WriteLine( doc->DocumentElement->InnerText ); - - // Save and then display the file. - doc->Save( filename ); - Console::WriteLine(); - Console::WriteLine( "Reading file..." ); - ReadFile( filename ); - } - - - // Parse the file and print out each node. - void ReadFile( String^ filename ) - { - try - { - reader = gcnew XmlTextReader( filename ); - String^ sNodeType = nullptr; - while ( reader->Read() ) - { - sNodeType = NodeTypeToString( reader->NodeType ); - - // Print the node type, name, and value. - Console::WriteLine( "{0}<{1}> {2}", sNodeType, reader->Name, reader->Value ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - - } - - static String^ NodeTypeToString( XmlNodeType nodetype ) - { - String^ sNodeType = nullptr; - switch ( nodetype ) - { - case XmlNodeType::None: - sNodeType = "None"; - break; - - case XmlNodeType::Element: - sNodeType = "Element"; - break; - - case XmlNodeType::Attribute: - sNodeType = "Attribute"; - break; - - case XmlNodeType::Text: - sNodeType = "Text"; - break; - - case XmlNodeType::Comment: - sNodeType = "Comment"; - break; - - case XmlNodeType::Document: - sNodeType = "Document"; - break; - - case XmlNodeType::Whitespace: - sNodeType = "Whitespace"; - break; - - case XmlNodeType::SignificantWhitespace: - sNodeType = "SignificantWhitespace"; - break; - - case XmlNodeType::EndElement: - sNodeType = "EndElement"; - break; - } - return sNodeType; - } - -}; - -int main() -{ - gcnew Sample; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.BaseURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.BaseURI Example/CPP/source.cpp deleted file mode 100644 index 47a0236b987..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.BaseURI Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - //Load the reader with the XML file. - reader = gcnew XmlTextReader( "http://localhost/baseuri.xml" ); - - //Parse the file and display the base URI for each node. - while ( reader->Read() ) - { - Console::WriteLine( "({0}) {1}", reader->NodeType, reader->BaseURI ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetAttribute1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetAttribute1 Example/CPP/source.cpp deleted file mode 100644 index e63d63dc208..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - //Load the reader with the XML file. - reader = gcnew XmlTextReader( "attrs.xml" ); - - //Read the ISBN attribute. - reader->MoveToContent(); - String^ isbn = reader->GetAttribute( "ISBN" ); - Console::WriteLine( "The ISBN value: {0}", isbn ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetRemainder Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetRemainder Example/CPP/source.cpp deleted file mode 100644 index f61a0885d7c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetRemainder Example/CPP/source.cpp +++ /dev/null @@ -1,82 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - String^ filename = "tworeads.xml"; - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Read the first part of the XML document - while ( reader->Read() ) - { - - // Display the elements and stop reading on the book endelement tag - // then go to ReadPart2 to start another reader to read the rest of the file. - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::WriteLine( "Name: {0}", reader->Name ); - break; - - case XmlNodeType::Text: - Console::WriteLine( " Element Text: {0}", reader->Value ); - break; - - case XmlNodeType::EndElement: - - // Stop reading when the reader gets to the end element of the book node. - if ( "book" == reader->LocalName ) - { - Console::WriteLine( "End reading first book..." ); - Console::WriteLine(); - goto ReadPart2; - } - break; - } - } - - - // Read the rest of the XML document - -ReadPart2: - Console::WriteLine( "Begin reading second book..." ); - - // Create a new reader to read the rest of the document. - XmlTextReader^ reader2 = gcnew XmlTextReader( reader->GetRemainder() ); - while ( reader2->Read() ) - { - switch ( reader2->NodeType ) - { - case XmlNodeType::Element: - Console::WriteLine( "Name: {0}", reader2->Name ); - break; - - case XmlNodeType::Text: - Console::WriteLine( " Element Text: {0}", reader2->Value ); - break; - - case XmlNodeType::EndElement: - - // Stop reading when the reader gets to the end element of the book node. - if ( "book" == reader2->LocalName ) - { - Console::WriteLine( "End reading second book..." ); - goto Done; - } - break; - } - } - - -Done: - Console::WriteLine( "Done." ); - reader->Close(); - reader2->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.HasValue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.HasValue Example/CPP/source.cpp deleted file mode 100644 index 96ecc78d7af..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.HasValue Example/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - //Load the reader with the XML file. - reader = gcnew XmlTextReader( "book1.xml" ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - //Parse the file and display each node. - while ( reader->Read() ) - { - if ( reader->HasValue ) - Console::WriteLine( "({0}) {1}={2}", reader->NodeType, reader->Name, reader->Value ); - else - Console::WriteLine( "({0}) {1}", reader->NodeType, reader->Name ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp deleted file mode 100644 index a5d564f75ff..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - // Load the reader with the XML file. - reader = gcnew XmlTextReader( "book2.xml" ); - - // Parse the file. If they exist, display the prefix and - // namespace URI of each node. - while ( reader->Read() ) - { - if ( reader->IsStartElement() ) - { - if ( reader->Prefix == String::Empty ) - Console::WriteLine( "<{0}>", reader->LocalName ); - else - { - Console::Write( "<{0}:{1}>", reader->Prefix, reader->LocalName ); - Console::WriteLine( " The namespace URI is {0}", reader->NamespaceURI ); - } - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp deleted file mode 100644 index 21a005822c1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; - -public ref class Class1 -{ - // -public: - void DisplayAttributes( XmlReader^ reader ) - { - if ( reader->HasAttributes ) - { - Console::WriteLine( "Attributes of <{0}>", reader->Name ); - for ( int i = 0; i < reader->AttributeCount; i++ ) - { - reader->MoveToAttribute( i ); - Console::Write( " {0}={1}", reader->Name, reader->Value ); - - } - reader->MoveToElement(); //Moves the reader back to the element node. - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToFirstAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToFirstAttribute Example/CPP/source.cpp deleted file mode 100644 index b5a9bd22ca6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToFirstAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - try - { - - //Load the reader with the XML file. - reader = gcnew XmlTextReader( "attrs.xml" ); - - //Read the genre attribute. - reader->MoveToContent(); - reader->MoveToFirstAttribute(); - String^ genre = reader->Value; - Console::WriteLine( "The genre value: {0}", genre ); - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp deleted file mode 100644 index e6fe1c8a26a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp +++ /dev/null @@ -1,74 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - String^ filename = "items.xml"; - try - { - - // Load the reader with the data file and ignore all white space nodes. - reader = gcnew XmlTextReader( filename ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Parse the file and display each of the nodes. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( "<{0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( reader->Value ); - break; - - case XmlNodeType::CDATA: - Console::Write( "", reader->Value ); - break; - - case XmlNodeType::ProcessingInstruction: - Console::Write( "", reader->Name, reader->Value ); - break; - - case XmlNodeType::Comment: - Console::Write( "", reader->Value ); - break; - - case XmlNodeType::XmlDeclaration: - Console::Write( "" ); - break; - - case XmlNodeType::Document: - break; - - case XmlNodeType::DocumentType: - Console::Write( "Name, reader->Value ); - break; - - case XmlNodeType::EntityReference: - Console::Write( reader->Name ); - break; - - case XmlNodeType::EndElement: - Console::Write( "", reader->Name ); - break; - } - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/CPP/source.cpp deleted file mode 100644 index e47fe405c6d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - String^ filename = "binary.xml"; - try - { - reader = gcnew XmlTextReader( filename ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Read the file. Stop at the Base64 element. - while ( reader->Read() ) - { - if ( "Base64" == reader->Name ) - break; - } - - // Read the Base64 data. Write the decoded - // bytes to the console. - Console::WriteLine( "Reading Base64... " ); - int base64len = 0; - array^base64 = gcnew array(1000); - do - { - base64len = reader->ReadBase64( base64, 0, 50 ); - for ( int i = 0; i < base64len; i++ ) - Console::Write( base64[ i ] ); - } - while ( reader->Name->Equals( "Base64" ) ); - - // Read the BinHex data. Write the decoded - // bytes to the console. - Console::WriteLine( "\r\nReading BinHex..." ); - int binhexlen = 0; - array^binhex = gcnew array(1000); - do - { - binhexlen = reader->ReadBinHex( binhex, 0, 50 ); - for ( int i = 0; i < binhexlen; i++ ) - Console::Write( binhex[ i ] ); - } - while ( reader->Name->Equals( "BinHex" ) ); - } - finally - { - Console::WriteLine(); - Console::WriteLine( "Processing of the file {0} complete.", filename ); - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadChars Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadChars Example/CPP/source.cpp deleted file mode 100644 index f4197a14142..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadChars Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; - -// Reads an XML document using ReadChars -int main() -{ - XmlTextReader^ reader = nullptr; - String^ filename = "items.xml"; - try - { - - // Declare variables used by ReadChars - array^buffer; - int iCnt = 0; - int charbuffersize; - - // Load the reader with the data file. Ignore white space. - reader = gcnew XmlTextReader( filename ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Set variables used by ReadChars. - charbuffersize = 10; - buffer = gcnew array(charbuffersize); - - // Parse the file. Read the element content - // using the ReadChars method. - reader->MoveToContent(); - while ( (iCnt = reader->ReadChars( buffer, 0, charbuffersize )) > 0 ) - { - - // Print out chars read and the buffer contents. - Console::WriteLine( " Chars read to buffer:{0}", iCnt ); - Console::WriteLine( " Buffer: [{0}]", gcnew String( buffer,0,iCnt ) ); - - // Clear the buffer. - Array::Clear( buffer, 0, charbuffersize ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.WhitespaceHandling Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.WhitespaceHandling Example/CPP/source.cpp deleted file mode 100644 index f64733ec447..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.WhitespaceHandling Example/CPP/source.cpp +++ /dev/null @@ -1,69 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -void ReadXML( XmlParserContext^ context, String^ xmlFrag, WhitespaceHandling ws ) -{ - - //Create the reader and specify the WhitespaceHandling setting. - XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - reader->WhitespaceHandling = ws; - - //Parse the XML and display each of the nodes. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::WriteLine( "{0}: <{1}>", reader->NodeType, reader->Name ); - break; - - case XmlNodeType::Text: - Console::WriteLine( "{0}: {1}", reader->NodeType, reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::WriteLine( "{0}: ", reader->NodeType, reader->Name ); - break; - - case XmlNodeType::Whitespace: - Console::WriteLine( "{0}:", reader->NodeType ); - break; - - case XmlNodeType::SignificantWhitespace: - Console::WriteLine( "{0}:", reader->NodeType ); - break; - } - } - - - //Close the reader. - reader->Close(); -} - -int main() -{ - - //Create the XML fragment to be parsed. - String^ xmlFrag = " " - " Pride And Prejudice" - " novel" - ""; - - //Create the XmlNamespaceManager. - NameTable^ nt = gcnew NameTable; - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt ); - - //Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::Default ); - Console::WriteLine( "Read the XML and ignore all white space..." ); - ReadXML( context, xmlFrag, WhitespaceHandling::None ); - Console::WriteLine( "\r\nRead the XML including white space nodes..." ); - ReadXML( context, xmlFrag, WhitespaceHandling::All ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp deleted file mode 100644 index fb1cc689964..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create a writer to write XML to the console. - XmlTextWriter^ writer = nullptr; - writer = gcnew XmlTextWriter( Console::Out ); - - //Use indentation for readability. - writer->Formatting = Formatting::Indented; - writer->Indentation = 4; - - //Write an element (this one is the root). - writer->WriteStartElement( "book" ); - - //Write the title element. - writer->WriteStartElement( "title" ); - writer->WriteString( "Pride And Prejudice" ); - writer->WriteEndElement(); - - //Write the close tag for the root element. - writer->WriteEndElement(); - - //Write the XML to file and close the writer. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteEndElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteEndElement Example/CPP/source.cpp deleted file mode 100644 index f9eaffb0162..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteEndElement Example/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = nullptr; - String^ filename = "sampledata.xml"; - writer = gcnew XmlTextWriter( filename, nullptr ); - - //Use indenting for readability. - writer->Formatting = Formatting::Indented; - - //Write the XML delcaration - writer->WriteStartDocument(); - - //Write the ProcessingInstruction node. - String^ PItext = "type=\"text/xsl\" href=\"book.xsl\""; - writer->WriteProcessingInstruction( "xml-stylesheet", PItext ); - - //Write the DocumentType node. - writer->WriteDocType( "book", nullptr, nullptr, "" ); - - //Write a Comment node. - writer->WriteComment( "sample XML" ); - - //Write the root element. - writer->WriteStartElement( "book" ); - - //Write the genre attribute. - writer->WriteAttributeString( "genre", "novel" ); - - //Write the ISBN attribute. - writer->WriteAttributeString( "ISBN", "1-8630-014" ); - - //Write the title. - writer->WriteElementString( "title", "The Handmaid's Tale" ); - - //Write the style element. - writer->WriteStartElement( "style" ); - writer->WriteEntityRef( "h" ); - writer->WriteEndElement(); - - //Write the price. - writer->WriteElementString( "price", "19.95" ); - - //Write CDATA. - writer->WriteCData( "Prices 15% off!!" ); - - //Write the close tag for the root element. - writer->WriteEndElement(); - writer->WriteEndDocument(); - - //Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); - - //Load the file into an XmlDocument to ensure well formed XML. - XmlDocument^ doc = gcnew XmlDocument; - - //Preserve white space for readability. - doc->PreserveWhitespace = true; - - //Load the file. - doc->Load( filename ); - - //Display the XML content to the console. - Console::Write( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteFullEndElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteFullEndElement Example/CPP/source.cpp deleted file mode 100644 index 51d524810dc..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteFullEndElement Example/CPP/source.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - //Create a writer to write XML to the console. - XmlTextWriter^ writer = nullptr; - writer = gcnew XmlTextWriter( Console::Out ); - - //Use indentation for readability. - writer->Formatting = Formatting::Indented; - - //Write an element (this one is the root). - writer->WriteStartElement( "order" ); - - //Write some attributes. - writer->WriteAttributeString( "date", "2/19/01" ); - writer->WriteAttributeString( "orderID", "136A5" ); - - //Write a full end element. Because this element has no - //content, calling WriteEndElement would have written a - //short end tag '/>'. - writer->WriteFullEndElement(); - - //Write the XML to file and close the writer - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteQualifiedName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteQualifiedName Example/CPP/source.cpp deleted file mode 100644 index 2adeaa8ff54..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteQualifiedName Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = nullptr; - String^ filename = "sampledata.xml"; - writer = gcnew XmlTextWriter( filename, nullptr ); - - // Use indenting for readability. - writer->Formatting = Formatting::Indented; - - // Write the root element. - writer->WriteStartElement( "schema" ); - - // Write the namespace declarations. - writer->WriteAttributeString( "xmlns", nullptr, "http://www.w3.org/2001/XMLSchema" ); - writer->WriteAttributeString( "xmlns", "po", nullptr, "http://contoso.com/po" ); - writer->WriteStartElement( "element" ); - writer->WriteAttributeString( "name", "purchaseOrder" ); - - // Write the type attribute. - writer->WriteStartAttribute( nullptr, "type", nullptr ); - writer->WriteQualifiedName( "PurchaseOrder", "http://contoso.com/po" ); - writer->WriteEndAttribute(); - writer->WriteEndElement(); - - // Write the close tag for the root element. - writer->WriteEndElement(); - - // Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); - - // Read the file back in and parse to ensure well formed XML. - XmlDocument^ doc = gcnew XmlDocument; - - // Preserve white space for readability. - doc->PreserveWhitespace = true; - - // Load the file. - doc->Load( filename ); - - // Write the XML content to the console. - Console::Write( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteRaw1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteRaw1 Example/CPP/source.cpp deleted file mode 100644 index 147d3385162..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteRaw1 Example/CPP/source.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create a writer that outputs to the console. - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - - // Write the root element. - writer->WriteStartElement( "Items" ); - - // Write a string using WriteRaw. Note that the special - // characters are not escaped. - writer->WriteStartElement( "Item" ); - writer->WriteString( "Write unescaped text: " ); - writer->WriteRaw( "this & that" ); - writer->WriteEndElement(); - - // Write the same string using WriteString. Note that the - // special characters are escaped. - writer->WriteStartElement( "Item" ); - writer->WriteString( "Write the same string using WriteString: " ); - writer->WriteString( "this & that" ); - writer->WriteEndElement(); - - // Write the close tag for the root element. - writer->WriteEndElement(); - - // Write the XML to file and close the writer. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp deleted file mode 100644 index 7ebefe6b4d0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = nullptr; - String^ filename = "sampledata.xml"; - writer = gcnew XmlTextWriter( filename, nullptr ); - - //Use indenting for readability. - writer->Formatting = Formatting::Indented; - - //Write the XML delcaration. - writer->WriteStartDocument(); - - //Write the ProcessingInstruction node. - String^ PItext = "type='text/xsl' href='book.xsl'"; - writer->WriteProcessingInstruction( "xml-stylesheet", PItext ); - - //Write the DocumentType node. - writer->WriteDocType( "book", nullptr, nullptr, "" ); - - //Write a Comment node. - writer->WriteComment( "sample XML" ); - - //Write a root element. - writer->WriteStartElement( "book" ); - - //Write the genre attribute. - writer->WriteAttributeString( "genre", "novel" ); - - //Write the ISBN attribute. - writer->WriteAttributeString( "ISBN", "1-8630-014" ); - - //Write the title. - writer->WriteElementString( "title", "The Handmaid's Tale" ); - - //Write the style element. - writer->WriteStartElement( "style" ); - writer->WriteEntityRef( "h" ); - writer->WriteEndElement(); - - //Write the price. - writer->WriteElementString( "price", "19.95" ); - - //Write CDATA. - writer->WriteCData( "Prices 15% off!!" ); - - //Write the close tag for the root element. - writer->WriteEndElement(); - writer->WriteEndDocument(); - - //Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); - - //Load the file into an XmlDocument to ensure well formed XML. - XmlDocument^ doc = gcnew XmlDocument; - - //Preserve white space for readability. - doc->PreserveWhitespace = true; - - //Load the file. - doc->Load( filename ); - - //Display the XML content to the console. - Console::Write( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp deleted file mode 100644 index d18c68662b6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - String^ filename = "sampledata.xml"; - XmlTextWriter^ writer = gcnew XmlTextWriter( filename, nullptr ); - - //Use indenting for readability. - writer->Formatting = Formatting::Indented; - writer->WriteComment( "sample XML fragment" ); - - //Write an element (this one is the root). - writer->WriteStartElement( "bookstore" ); - - //Write the namespace declaration. - writer->WriteAttributeString( "xmlns", "bk", nullptr, "urn:samples" ); - writer->WriteStartElement( "book" ); - - //Lookup the prefix and then write the ISBN attribute. - String^ prefix = writer->LookupPrefix( "urn:samples" ); - writer->WriteStartAttribute( prefix, "ISBN", "urn:samples" ); - writer->WriteString( "1-861003-78" ); - writer->WriteEndAttribute(); - - //Write the title. - writer->WriteStartElement( "title" ); - writer->WriteString( "The Handmaid's Tale" ); - writer->WriteEndElement(); - - //Write the price. - writer->WriteElementString( "price", "19.95" ); - - //Write the style element. - writer->WriteStartElement( prefix, "style", "urn:samples" ); - writer->WriteString( "hardcover" ); - writer->WriteEndElement(); - - //Write the end tag for the book element. - writer->WriteEndElement(); - - //Write the close tag for the root element. - writer->WriteEndElement(); - - //Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); - - //Read the file back in and parse to ensure well formed XML. - XmlDocument^ doc = gcnew XmlDocument; - - //Preserve white space for readability. - doc->PreserveWhitespace = true; - - //Load the file - doc->Load( filename ); - - //Write the XML content to the console. - Console::Write( doc->InnerXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteTimeSpan Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteTimeSpan Example/CPP/source.cpp deleted file mode 100644 index ef94526fc30..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteTimeSpan Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = nullptr; - try - { - writer = gcnew XmlTextWriter( Console::Out ); - - // Write an element. - writer->WriteStartElement( "address" ); - - // Write an email address using entities - // for the @ and . characters. - writer->WriteString( "someone" ); - writer->WriteCharEntity( '@' ); - writer->WriteString( "example" ); - writer->WriteCharEntity( '.' ); - writer->WriteString( "com" ); - writer->WriteEndElement(); - } - finally - { - - // Close the writer. - if ( writer != nullptr ) - writer->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/CPP/source.cpp deleted file mode 100644 index e5fd8acae1e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the writer. - XmlTextWriter^ writer = nullptr; - writer = gcnew XmlTextWriter( "ws.html", nullptr ); - - // Write an element (this one is the root). - writer->WriteStartElement( "p" ); - - // Write the xml:space attribute. - writer->WriteAttributeString( "xml", "space", nullptr, "preserve" ); - - // Verify that xml:space is set properly. - if ( writer->XmlSpace == XmlSpace::Preserve ) - Console::WriteLine( "xmlspace is correct!" ); - - - // Write out the HTML elements. Insert white space - // between 'something' and 'Big' - writer->WriteString( "something" ); - writer->WriteWhitespace( " " ); - writer->WriteElementString( "b", "B" ); - writer->WriteString( "ig" ); - - // Write the root end element. - writer->WriteEndElement(); - - // Write the XML to file and close the writer. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/CPP/source.cpp deleted file mode 100644 index be6e39b350c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/CPP/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; - -int main() -{ - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - Uri^ baseUri = gcnew Uri( "http://servername/tmp/test.xsl" ); - Uri^ fulluri = resolver->ResolveUri( baseUri, "includefile.xsl" ); - - // Get a stream object containing the XSL file - Stream^ s = dynamic_cast(resolver->GetEntity( fulluri, nullptr, Stream::typeid )); - - // Read the stream object displaying the contents of the XSL file - XmlTextReader^ reader = gcnew XmlTextReader( s ); - while ( reader->Read() ) - { - Console::WriteLine( reader->ReadOuterXml() ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlWhitespace.NodeType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XmlWhitespace.NodeType Example/CPP/source.cpp deleted file mode 100644 index 15790751077..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XmlWhitespace.NodeType Example/CPP/source.cpp +++ /dev/null @@ -1,117 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -private: - XmlNode^ currNode; - XmlTextReader^ reader; - -public: - Sample() - { - String^ filename = "space.xml"; - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( "" - "Eva" - "Corets" - "" ); - Console::WriteLine( "InnerText before..." ); - Console::WriteLine( doc->DocumentElement->InnerText ); - - // Add white space. - currNode = doc->DocumentElement; - XmlWhitespace^ ws = doc->CreateWhitespace( "\r\n" ); - currNode->InsertAfter( ws, currNode->FirstChild ); - Console::WriteLine(); - Console::WriteLine( "InnerText after..." ); - Console::WriteLine( doc->DocumentElement->InnerText ); - - // Save and then display the file. - doc->Save( filename ); - Console::WriteLine(); - Console::WriteLine( "Reading file..." ); - ReadFile( filename ); - } - - - // Parse the file and display each node. - void ReadFile( String^ filename ) - { - try - { - reader = gcnew XmlTextReader( filename ); - String^ sNodeType = nullptr; - while ( reader->Read() ) - { - sNodeType = NodeTypeToString( reader->NodeType ); - - // Print the node type, name, and value. - Console::WriteLine( "{0}<{1}> {2}", sNodeType, reader->Name, reader->Value ); - } - } - finally - { - if ( reader != nullptr ) - reader->Close(); - } - - } - - static String^ NodeTypeToString( XmlNodeType nodetype ) - { - String^ sNodeType = nullptr; - switch ( nodetype ) - { - case XmlNodeType::None: - sNodeType = "None"; - break; - - case XmlNodeType::Element: - sNodeType = "Element"; - break; - - case XmlNodeType::Attribute: - sNodeType = "Attribute"; - break; - - case XmlNodeType::Text: - sNodeType = "Text"; - break; - - case XmlNodeType::Comment: - sNodeType = "Comment"; - break; - - case XmlNodeType::Document: - sNodeType = "Document"; - break; - - case XmlNodeType::Whitespace: - sNodeType = "Whitespace"; - break; - - case XmlNodeType::SignificantWhitespace: - sNodeType = "SignificantWhitespace"; - break; - - case XmlNodeType::EndElement: - sNodeType = "EndElement"; - break; - } - return sNodeType; - } - -}; - -int main() -{ - gcnew Sample; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/CPP/source.cpp deleted file mode 100644 index fed23d6f782..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; - -int main() -{ - String^ filename = "books.xml"; - String^ stylesheet = "output.xsl"; - - //Load the stylesheet. - XslTransform^ xslt = gcnew XslTransform; - xslt->Load( stylesheet ); - - //Load the file to transform. - XPathDocument^ doc = gcnew XPathDocument( filename ); - - //Create an XmlTextWriter which outputs to the console. - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - - //Transform the file and send the output to the console. - xslt->Transform(doc,nullptr,writer,nullptr); - writer->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaComplexType Example/CPP/complextype.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaComplexType Example/CPP/complextype.cpp deleted file mode 100644 index 3c119776397..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaComplexType Example/CPP/complextype.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - schema->Items->Add(element); - element->Name = "stringElementWithAnyAttribute"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - element->SchemaType = complexType; - - // - XmlSchemaSimpleContent^ simpleContent = gcnew XmlSchemaSimpleContent(); - complexType->ContentModel = simpleContent; - - // - XmlSchemaSimpleContentExtension^ extension = gcnew XmlSchemaSimpleContentExtension(); - simpleContent->Content = extension; - extension->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaAnyAttribute^ anyAttribute = gcnew XmlSchemaAnyAttribute(); - extension->AnyAttribute = anyAttribute; - anyAttribute->Namespace = "##targetNamespace"; - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/CPP/datatype.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/CPP/datatype.cpp deleted file mode 100644 index 92d06d54db3..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/CPP/datatype.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlTextReader^ xtr = gcnew XmlTextReader("example.xsd"); - XmlSchema^ schema = XmlSchema::Read(xtr, gcnew ValidationEventHandler(ValidationCallbackOne)); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - for each (XmlSchemaObject^ schemaObject in compiledSchema->Items) - { - if (schemaObject->GetType() == XmlSchemaSimpleType::typeid) - { - XmlSchemaSimpleType^ simpleType = dynamic_cast(schemaObject); - Console::WriteLine("{0} {1}", simpleType->Name, simpleType->Datatype->ValueType); - } - if (schemaObject->GetType() == XmlSchemaComplexType::typeid) - { - XmlSchemaComplexType^ complexType = dynamic_cast(schemaObject); - Console::WriteLine("{0} {1}", complexType->Name, complexType->Datatype->ValueType); - } - } - xtr->Close(); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDocumentation Example/CPP/documentation.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDocumentation Example/CPP/documentation.cpp deleted file mode 100644 index 78ca73c17ae..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDocumentation Example/CPP/documentation.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ simpleType = gcnew XmlSchemaSimpleType(); - simpleType->Name = "northwestStates"; - schema->Items->Add(simpleType); - - // - XmlSchemaAnnotation^ annNorthwestStates = gcnew XmlSchemaAnnotation(); - simpleType->Annotation = annNorthwestStates; - - // States in the Pacific Northwest of US - XmlSchemaDocumentation^ docNorthwestStates = gcnew XmlSchemaDocumentation(); - annNorthwestStates->Items->Add(docNorthwestStates); - docNorthwestStates->Markup = TextToNodeArray("States in the Pacific Northwest of US"); - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - simpleType->Content = restriction; - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaEnumerationFacet^ enumerationWA = gcnew XmlSchemaEnumerationFacet(); - restriction->Facets->Add(enumerationWA); - enumerationWA->Value = "WA"; - - // - XmlSchemaAnnotation^ annWA = gcnew XmlSchemaAnnotation(); - enumerationWA->Annotation = annWA; - - // Washington - XmlSchemaDocumentation^ docWA = gcnew XmlSchemaDocumentation(); - annWA->Items->Add(docWA); - docWA->Markup = TextToNodeArray("Washington"); - - // - XmlSchemaEnumerationFacet^ enumerationOR = gcnew XmlSchemaEnumerationFacet(); - restriction->Facets->Add(enumerationOR); - enumerationOR->Value = "OR"; - - // - XmlSchemaAnnotation^ annOR = gcnew XmlSchemaAnnotation(); - enumerationOR->Annotation = annOR; - - // Oregon - XmlSchemaDocumentation^ docOR = gcnew XmlSchemaDocumentation(); - annOR->Items->Add(docOR); - docOR->Markup = TextToNodeArray("Oregon"); - - // - XmlSchemaEnumerationFacet^ enumerationID = gcnew XmlSchemaEnumerationFacet(); - restriction->Facets->Add(enumerationID); - enumerationID->Value = "ID"; - - // - XmlSchemaAnnotation^ annID = gcnew XmlSchemaAnnotation(); - enumerationID->Annotation = annID; - - // Idaho - XmlSchemaDocumentation^ docID = gcnew XmlSchemaDocumentation(); - annID->Items->Add(docID); - docID->Markup = TextToNodeArray("Idaho"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - - static array^ TextToNodeArray(String^ text) - { - XmlDocument^ doc = gcnew XmlDocument(); - array^ nodes = gcnew array {doc->CreateTextNode(text)}; - return nodes; - } - -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/CPP/element.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/CPP/element.cpp deleted file mode 100644 index cb71c94ba29..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/CPP/element.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaElement^ elementCat = gcnew XmlSchemaElement(); - schema->Items->Add(elementCat); - elementCat->Name = "cat"; - elementCat->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementDog); - elementDog->Name = "dog"; - elementDog->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaElement^ elementRedDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementRedDog); - elementRedDog->Name = "redDog"; - elementRedDog->SubstitutionGroup = gcnew XmlQualifiedName("dog"); - - // - XmlSchemaElement^ elementBrownDog = gcnew XmlSchemaElement(); - schema->Items->Add(elementBrownDog); - elementBrownDog->Name = "brownDog"; - elementBrownDog->SubstitutionGroup = gcnew XmlQualifiedName("dog"); - - // - XmlSchemaElement^ elementPets = gcnew XmlSchemaElement(); - schema->Items->Add(elementPets); - elementPets->Name = "pets"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - elementPets->SchemaType = complexType; - - // - XmlSchemaChoice^ choice = gcnew XmlSchemaChoice(); - complexType->Particle = choice; - choice->MinOccurs = 0; - choice->MaxOccursString = "unbounded"; - - // - XmlSchemaElement^ catRef = gcnew XmlSchemaElement(); - choice->Items->Add(catRef); - catRef->RefName = gcnew XmlQualifiedName("cat"); - - // - XmlSchemaElement^ dogRef = gcnew XmlSchemaElement(); - choice->Items->Add(dogRef); - dogRef->RefName = gcnew XmlQualifiedName("dog"); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaFractionDigitsFacet Example/CPP/fractiondigitsfacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaFractionDigitsFacet Example/CPP/fractiondigitsfacet.cpp deleted file mode 100644 index acf2f9e018f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaFractionDigitsFacet Example/CPP/fractiondigitsfacet.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -class XmlSchemaExamples -{ -public: - - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ RatingType = gcnew XmlSchemaSimpleType(); - RatingType->Name = "RatingType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaTotalDigitsFacet^ totalDigits = gcnew XmlSchemaTotalDigitsFacet(); - totalDigits->Value = "2"; - restriction->Facets->Add(totalDigits); - - // - XmlSchemaFractionDigitsFacet^ fractionDigits = gcnew XmlSchemaFractionDigitsFacet(); - fractionDigits->Value = "1"; - restriction->Facets->Add(fractionDigits); - - RatingType->Content = restriction; - - schema->Items->Add(RatingType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "movie"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ ratingAttribute = gcnew XmlSchemaAttribute(); - ratingAttribute->Name = "rating"; - ratingAttribute->SchemaTypeName = gcnew XmlQualifiedName("RatingType", ""); - complexType->Attributes->Add(ratingAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } -}; - -int main() -{ - XmlSchemaExamples::Main(); - return 0; -}; -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaInclude Example/CPP/import_include_sample.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaInclude Example/CPP/import_include_sample.cpp deleted file mode 100644 index 777c38d292a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaInclude Example/CPP/import_include_sample.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class ImportIncludeSample -{ -private: - static void ValidationCallBack(Object^ sender, ValidationEventArgs^ args) - { - - if (args->Severity == XmlSeverityType::Warning) - Console::Write("WARNING: "); - else if (args->Severity == XmlSeverityType::Error) - Console::Write("ERROR: "); - - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - schema->ElementFormDefault = XmlSchemaForm::Qualified; - schema->TargetNamespace = "http://www.w3.org/2001/05/XMLInfoset"; - - // - XmlSchemaImport^ import = gcnew XmlSchemaImport(); - import->Namespace = "http://www.example.com/IPO"; - schema->Includes->Add(import); - - // - XmlSchemaInclude^ include = gcnew XmlSchemaInclude(); - include->SchemaLocation = "example.xsd"; - schema->Includes->Add(include); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallBack); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } - -}; - -int main() -{ - ImportIncludeSample::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaKeyRef Example/CPP/key_sample.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaKeyRef Example/CPP/key_sample.cpp deleted file mode 100644 index 89d0bf0c37b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaKeyRef Example/CPP/key_sample.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Xml::Schema; -public ref class XmlSchemaObjectGenerator -{ -private: - static void ValidationCallback( Object^ /*sender*/, ValidationEventArgs^ args ) - { - if ( args->Severity == XmlSeverityType::Warning ) - Console::Write( "WARNING: " ); - else - if ( args->Severity == XmlSeverityType::Error ) - Console::Write( "ERROR: " ); - - Console::WriteLine( args->Message ); - } - - // XmlSchemaObjectGenerator - int main() - { - XmlTextReader^ tr = gcnew XmlTextReader( "empty.xsd" ); - XmlSchema^ schema = XmlSchema::Read( tr, gcnew ValidationEventHandler( XmlSchemaObjectGenerator::ValidationCallback ) ); - schema->ElementFormDefault = XmlSchemaForm::Qualified; - schema->TargetNamespace = "http://www.example.com/Report"; - { - XmlSchemaElement^ element = gcnew XmlSchemaElement; - element->Name = "purchaseReport"; - XmlSchemaComplexType^ element_complexType = gcnew XmlSchemaComplexType; - XmlSchemaSequence^ element_complexType_sequence = gcnew XmlSchemaSequence; - { - XmlSchemaElement^ element_complexType_sequence_element = gcnew XmlSchemaElement; - element_complexType_sequence_element->Name = "region"; - element_complexType_sequence_element->SchemaTypeName = gcnew XmlQualifiedName( "String*","http://www.w3.org/2001/XMLSchema" ); - { - XmlSchemaKeyref^ element_complexType_sequence_element_keyref = gcnew XmlSchemaKeyref; - element_complexType_sequence_element_keyref->Name = "dummy2"; - element_complexType_sequence_element_keyref->Selector = gcnew XmlSchemaXPath; - element_complexType_sequence_element_keyref->Selector->XPath = "r:zip/r:part"; - { - XmlSchemaXPath^ field = gcnew XmlSchemaXPath; - field->XPath = "@number"; - element_complexType_sequence_element_keyref->Fields->Add( field ); - } - element_complexType_sequence_element_keyref->Refer = gcnew XmlQualifiedName( "pNumKey","http://www.example.com/Report" ); - element_complexType_sequence_element->Constraints->Add( element_complexType_sequence_element_keyref ); - } - element_complexType_sequence->Items->Add( element_complexType_sequence_element ); - } - element_complexType->Particle = element_complexType_sequence; - { - XmlSchemaAttribute^ element_complexType_attribute = gcnew XmlSchemaAttribute; - element_complexType_attribute->Name = "periodEnding"; - element_complexType_attribute->SchemaTypeName = gcnew XmlQualifiedName( "date","http://www.w3.org/2001/XMLSchema" ); - element_complexType->Attributes->Add( element_complexType_attribute ); - } - element->SchemaType = element_complexType; - { - XmlSchemaKey^ element_key = gcnew XmlSchemaKey; - element_key->Name = "pNumKey"; - element_key->Selector = gcnew XmlSchemaXPath; - element_key->Selector->XPath = "r:parts/r:part"; - { - XmlSchemaXPath^ field = gcnew XmlSchemaXPath; - field->XPath = "@number"; - element_key->Fields->Add( field ); - } - element->Constraints->Add( element_key ); - } - schema->Items->Add( element ); - } - schema->Write( Console::Out ); - - return 0; - } // main -}; -// diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaLengthFacet Example/CPP/lengthfacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaLengthFacet Example/CPP/lengthfacet.cpp deleted file mode 100644 index 47765242264..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaLengthFacet Example/CPP/lengthfacet.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ ZipCodeType = gcnew XmlSchemaSimpleType(); - ZipCodeType->Name = "ZipCodeType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaLengthFacet^ length = gcnew XmlSchemaLengthFacet(); - length->Value = "5"; - restriction->Facets->Add(length); - - ZipCodeType->Content = restriction; - - schema->Items->Add(ZipCodeType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Address"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ ZipCodeAttribute = gcnew XmlSchemaAttribute(); - ZipCodeAttribute->Name = "ZipCode"; - ZipCodeAttribute->SchemaTypeName = gcnew XmlQualifiedName("ZipCodeType", ""); - complexType->Attributes->Add(ZipCodeAttribute); - - element->SchemaType = complexType; - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxExclusiveFacet Example/CPP/maxexclusivefacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxExclusiveFacet Example/CPP/maxexclusivefacet.cpp deleted file mode 100644 index a66dd7e2553..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxExclusiveFacet Example/CPP/maxexclusivefacet.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ WaitQueueLengthType = gcnew XmlSchemaSimpleType(); - WaitQueueLengthType->Name = "WaitQueueLengthType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMaxExclusiveFacet^ maxExclusive = gcnew XmlSchemaMaxExclusiveFacet(); - maxExclusive->Value = "5"; - restriction->Facets->Add(maxExclusive); - - WaitQueueLengthType->Content = restriction; - - schema->Items->Add(WaitQueueLengthType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Lobby"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ WaitQueueLengthAttribute = gcnew XmlSchemaAttribute(); - WaitQueueLengthAttribute->Name = "WaitQueueLength"; - WaitQueueLengthAttribute->SchemaTypeName = gcnew XmlQualifiedName("WaitQueueLengthType", ""); - complexType->Attributes->Add(WaitQueueLengthAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxInclusiveFacet Example/CPP/maxinclusivefacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxInclusiveFacet Example/CPP/maxinclusivefacet.cpp deleted file mode 100644 index f27f5519922..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxInclusiveFacet Example/CPP/maxinclusivefacet.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ WaitQueueLengthType = gcnew XmlSchemaSimpleType(); - WaitQueueLengthType->Name = "WaitQueueLengthType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMaxInclusiveFacet^ maxInclusive = gcnew XmlSchemaMaxInclusiveFacet(); - maxInclusive->Value = "5"; - restriction->Facets->Add(maxInclusive); - - WaitQueueLengthType->Content = restriction; - - schema->Items->Add(WaitQueueLengthType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Lobby"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ WaitQueueLengthAttribute = gcnew XmlSchemaAttribute(); - WaitQueueLengthAttribute->Name = "WaitQueueLength"; - WaitQueueLengthAttribute->SchemaTypeName = gcnew XmlQualifiedName("WaitQueueLengthType", ""); - complexType->Attributes->Add(WaitQueueLengthAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxLengthFacet Example/CPP/maxlengthfacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxLengthFacet Example/CPP/maxlengthfacet.cpp deleted file mode 100644 index b50d96ac18d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMaxLengthFacet Example/CPP/maxlengthfacet.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ ZipCodeType = gcnew XmlSchemaSimpleType(); - ZipCodeType->Name = "ZipCodeType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMaxLengthFacet^ maxLength = gcnew XmlSchemaMaxLengthFacet(); - maxLength->Value = "10"; - restriction->Facets->Add(maxLength); - - ZipCodeType->Content = restriction; - - schema->Items->Add(ZipCodeType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Address"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ ZipCodeAttribute = gcnew XmlSchemaAttribute(); - ZipCodeAttribute->Name = "ZipCode"; - ZipCodeAttribute->SchemaTypeName = gcnew XmlQualifiedName("ZipCodeType", ""); - - complexType->Attributes->Add(ZipCodeAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinExclusiveFacet Example/CPP/minexclusivefacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinExclusiveFacet Example/CPP/minexclusivefacet.cpp deleted file mode 100644 index 34816fb1131..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinExclusiveFacet Example/CPP/minexclusivefacet.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ OrderQuantityType = gcnew XmlSchemaSimpleType(); - OrderQuantityType->Name = "OrderQuantityType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMinExclusiveFacet^ MinExclusive = gcnew XmlSchemaMinExclusiveFacet(); - MinExclusive->Value = "5"; - restriction->Facets->Add(MinExclusive); - - OrderQuantityType->Content = restriction; - - schema->Items->Add(OrderQuantityType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "item"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ OrderQuantityAttribute = gcnew XmlSchemaAttribute(); - OrderQuantityAttribute->Name = "OrderQuantity"; - OrderQuantityAttribute->SchemaTypeName = gcnew XmlQualifiedName("OrderQuantityType", ""); - complexType->Attributes->Add(OrderQuantityAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinInclusiveFacet Example/CPP/mininclusivefacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinInclusiveFacet Example/CPP/mininclusivefacet.cpp deleted file mode 100644 index 8b460bf9a13..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinInclusiveFacet Example/CPP/mininclusivefacet.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ OrderQuantityType = gcnew XmlSchemaSimpleType(); - OrderQuantityType->Name = "OrderQuantityType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMinInclusiveFacet^ minInclusive = gcnew XmlSchemaMinInclusiveFacet(); - minInclusive->Value = "5"; - restriction->Facets->Add(minInclusive); - - OrderQuantityType->Content = restriction; - - schema->Items->Add(OrderQuantityType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "item"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ OrderQuantityAttribute = gcnew XmlSchemaAttribute(); - OrderQuantityAttribute->Name = "OrderQuantity"; - OrderQuantityAttribute->SchemaTypeName = gcnew XmlQualifiedName("OrderQuantityType", ""); - complexType->Attributes->Add(OrderQuantityAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinLengthFacet Example/CPP/minlengthfacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinLengthFacet Example/CPP/minlengthfacet.cpp deleted file mode 100644 index 7bc0e93f86c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaMinLengthFacet Example/CPP/minlengthfacet.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ ZipCodeType = gcnew XmlSchemaSimpleType(); - ZipCodeType->Name = "ZipCodeType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaMinLengthFacet^ minLength = gcnew XmlSchemaMinLengthFacet(); - minLength->Value = "5"; - restriction->Facets->Add(minLength); - - ZipCodeType->Content = restriction; - - schema->Items->Add(ZipCodeType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Address"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ ZipCodeAttribute = gcnew XmlSchemaAttribute(); - ZipCodeAttribute->Name = "ZipCode"; - ZipCodeAttribute->SchemaTypeName = gcnew XmlQualifiedName("ZipCodeType", ""); - complexType->Attributes->Add(ZipCodeAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaPatternFacet Example/CPP/patternfacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaPatternFacet Example/CPP/patternfacet.cpp deleted file mode 100644 index c21f9400afa..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaPatternFacet Example/CPP/patternfacet.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ ZipCodeType = gcnew XmlSchemaSimpleType(); - ZipCodeType->Name = "ZipCodeType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaPatternFacet^ pattern = gcnew XmlSchemaPatternFacet(); - pattern->Value = "[0-9]{5}(-[0-9]{4})?"; - restriction->Facets->Add(pattern); - - ZipCodeType->Content = restriction; - - schema->Items->Add(ZipCodeType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "Address"; - - // - XmlSchemaComplexType^ complexType = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ ZipCodeAttribute = gcnew XmlSchemaAttribute(); - ZipCodeAttribute->Name = "ZipCode"; - ZipCodeAttribute->SchemaTypeName = gcnew XmlQualifiedName("ZipCodeType", ""); - complexType->Attributes->Add(ZipCodeAttribute); - - element->SchemaType = complexType; - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaSimpleTypeUnion Example/CPP/simpletypeunion.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaSimpleTypeUnion Example/CPP/simpletypeunion.cpp deleted file mode 100644 index 2f67440b88f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaSimpleTypeUnion Example/CPP/simpletypeunion.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ StringOrIntType = gcnew XmlSchemaSimpleType(); - StringOrIntType->Name = "StringOrIntType"; - schema->Items->Add(StringOrIntType); - - // - XmlSchemaSimpleTypeUnion^ union1 = gcnew XmlSchemaSimpleTypeUnion(); - StringOrIntType->Content = union1; - - // - XmlSchemaSimpleType^ simpleType1 = gcnew XmlSchemaSimpleType(); - union1->BaseTypes->Add(simpleType1); - - // - XmlSchemaSimpleTypeRestriction^ restriction1 = gcnew XmlSchemaSimpleTypeRestriction(); - restriction1->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - simpleType1->Content = restriction1; - - // - XmlSchemaSimpleType^ simpleType2 = gcnew XmlSchemaSimpleType(); - union1->BaseTypes->Add(simpleType2); - - // - XmlSchemaSimpleTypeRestriction^ restriction2 = gcnew XmlSchemaSimpleTypeRestriction(); - restriction2->BaseTypeName = gcnew XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema"); - simpleType2->Content = restriction2; - - - // - XmlSchemaElement^ elementSize = gcnew XmlSchemaElement(); - elementSize->Name = "size"; - elementSize->SchemaTypeName = gcnew XmlQualifiedName("StringOrIntType"); - schema->Items->Add(elementSize); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaUnique Example/CPP/unique.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaUnique Example/CPP/unique.cpp deleted file mode 100644 index 27611f0c5e7..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaUnique Example/CPP/unique.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaComplexType^ customerOrderType = gcnew XmlSchemaComplexType(); - customerOrderType->Name = "customerOrderType"; - - // - XmlSchemaSequence^ sequence1 = gcnew XmlSchemaSequence(); - - // - XmlSchemaElement^ item = gcnew XmlSchemaElement(); - item->MinOccurs = 0; - item->MaxOccursString = "unbounded"; - item->Name = "item"; - - // - XmlSchemaComplexType^ ct1 = gcnew XmlSchemaComplexType(); - - // - XmlSchemaAttribute^ itemID = gcnew XmlSchemaAttribute(); - itemID->Name = "itemID"; - itemID->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - ct1->Attributes->Add(itemID); - - // - item->SchemaType = ct1; - - // - sequence1->Items->Add(item); - customerOrderType->Particle = sequence1; - - // - XmlSchemaAttribute^ CustomerID = gcnew XmlSchemaAttribute(); - CustomerID->Name = "CustomerID"; - CustomerID->SchemaTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - customerOrderType->Attributes->Add(CustomerID); - - // - schema->Items->Add(customerOrderType); - - // - XmlSchemaElement^ ordersByCustomer = gcnew XmlSchemaElement(); - ordersByCustomer->Name = "ordersByCustomer"; - - // - XmlSchemaComplexType^ ct2 = gcnew XmlSchemaComplexType(); - - // - XmlSchemaSequence^ sequence2 = gcnew XmlSchemaSequence(); - - // - XmlSchemaElement^ customerOrders = gcnew XmlSchemaElement(); - customerOrders->MinOccurs = 0; - customerOrders->MaxOccursString = "unbounded"; - customerOrders->Name = "customerOrders"; - customerOrders->SchemaTypeName = gcnew XmlQualifiedName("customerOrderType", ""); - - // - sequence2->Items->Add(customerOrders); - - // - ct2->Particle = sequence2; - ordersByCustomer->SchemaType = ct2; - - // - XmlSchemaUnique^ element_unique = gcnew XmlSchemaUnique(); - element_unique->Name = "oneCustomerOrdersforEachCustomerID"; - - // - element_unique->Selector = gcnew XmlSchemaXPath(); - element_unique->Selector->XPath = "customerOrders"; - - // - XmlSchemaXPath^ field = gcnew XmlSchemaXPath(); - field->XPath = "@customerID"; - - // - element_unique->Fields->Add(field); - ordersByCustomer->Constraints->Add(element_unique); - - // - schema->Items->Add(ordersByCustomer); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/CPP/whitespacefacet.cpp b/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/CPP/whitespacefacet.cpp deleted file mode 100644 index 82b40e0837b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/CPP/whitespacefacet.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XMLSchemaExamples -{ -private: - static void ValidationCallbackOne(Object^ sender, ValidationEventArgs^ args) - { - Console::WriteLine(args->Message); - } - -public: - static void Main() - { - XmlSchema^ schema = gcnew XmlSchema(); - - // - XmlSchemaSimpleType^ NameType = gcnew XmlSchemaSimpleType(); - NameType->Name = "NameType"; - - // - XmlSchemaSimpleTypeRestriction^ restriction = gcnew XmlSchemaSimpleTypeRestriction(); - restriction->BaseTypeName = gcnew XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); - - // - XmlSchemaWhiteSpaceFacet^ whiteSpace = gcnew XmlSchemaWhiteSpaceFacet(); - whiteSpace->Value = "collapse"; - restriction->Facets->Add(whiteSpace); - - NameType->Content = restriction; - - schema->Items->Add(NameType); - - // - XmlSchemaElement^ element = gcnew XmlSchemaElement(); - element->Name = "LastName"; - element->SchemaTypeName = gcnew XmlQualifiedName("NameType", ""); - - schema->Items->Add(element); - - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallbackOne); - schemaSet->Add(schema); - schemaSet->Compile(); - - XmlSchema^ compiledSchema = nullptr; - - for each (XmlSchema^ schema1 in schemaSet->Schemas()) - { - compiledSchema = schema1; - } - - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager(gcnew NameTable()); - nsmgr->AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); - compiledSchema->Write(Console::Out, nsmgr); - } -}; - -int main() -{ - XMLSchemaExamples::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/IHasXmlNode.GetNode/CPP/hasxmlnode.cpp b/snippets/cpp/VS_Snippets_Data/IHasXmlNode.GetNode/CPP/hasxmlnode.cpp deleted file mode 100644 index 31d19ed131b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/IHasXmlNode.GetNode/CPP/hasxmlnode.cpp +++ /dev/null @@ -1,26 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::XPath; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - - // Create an XPathNavigator and select all books by Plato. - XPathNavigator^ nav = doc->CreateNavigator(); - XPathNodeIterator^ ni = nav->Select("descendant::book[author/name='Plato']"); - ni->MoveNext(); - - // Get the first matching node and change the book price. - XmlNode^ book = dynamic_cast(ni->Current)->GetNode(); - book->LastChild->InnerText = "12.95"; - Console::WriteLine( book->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/IXmlLineInfo/CPP/lineinfo.cpp b/snippets/cpp/VS_Snippets_Data/IXmlLineInfo/CPP/lineinfo.cpp deleted file mode 100644 index 8bc4192df74..00000000000 --- a/snippets/cpp/VS_Snippets_Data/IXmlLineInfo/CPP/lineinfo.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XML fragment to be parsed. - String^ xmlFrag = "\n" - "\n" - "\n" - "240\n" - "\n" - "\n"; - - // Create the XmlNamespaceManager. - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( gcnew NameTable ); - - // Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::None ); - - // Create the reader. - XmlValidatingReader^ reader = gcnew XmlValidatingReader( xmlFrag,XmlNodeType::Element,context ); - IXmlLineInfo^ lineInfo = (dynamic_cast(reader)); - if ( lineInfo->HasLineInfo() ) - { - - // Parse the XML and display each node. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( " {0} {1}, {2} ", reader->Depth, lineInfo->LineNumber, lineInfo->LinePosition ); - Console::WriteLine( "< {0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( " {0} {1}, {2} ", reader->Depth, lineInfo->LineNumber, lineInfo->LinePosition ); - Console::WriteLine( " {0}", reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::Write( " {0} {1}, {2} ", reader->Depth, lineInfo->LineNumber, lineInfo->LinePosition ); - Console::WriteLine( "", reader->Name ); - break; - } - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/NameTable/CPP/nametable.cpp b/snippets/cpp/VS_Snippets_Data/NameTable/CPP/nametable.cpp deleted file mode 100644 index 27ae8903478..00000000000 --- a/snippets/cpp/VS_Snippets_Data/NameTable/CPP/nametable.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - - // - NameTable^ nt = gcnew NameTable; - Object^ book = nt->Add( "book" ); - Object^ price = nt->Add( "price" ); - - // Create the reader. - XmlReaderSettings ^ settings = gcnew XmlReaderSettings; - settings->NameTable = nt; - XmlReader^ reader = XmlReader::Create( (String^)"books.xml", settings ); - reader->MoveToContent(); - reader->ReadToDescendant( "book" ); - if ( System::Object::ReferenceEquals( book, reader->Name ) ) - { - - // Do additional processing. - } - // - //Close the reader. - reader->Close(); -} - diff --git a/snippets/cpp/VS_Snippets_Data/ValidationEventArgs.Severity/CPP/severity.cpp b/snippets/cpp/VS_Snippets_Data/ValidationEventArgs.Severity/CPP/severity.cpp deleted file mode 100644 index 711f1bfbba1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/ValidationEventArgs.Severity/CPP/severity.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class Sample -{ -private: - static void Validate(String^ filename, XmlSchemaSet^ schemaSet) - { - Console::WriteLine(); - Console::WriteLine("\r\nValidating XML file {0}...", filename->ToString()); - - XmlSchema^ compiledSchema; - - for each (XmlSchema^ schema in schemaSet->Schemas()) - { - compiledSchema = schema; - } - - XmlReaderSettings^ settings = gcnew XmlReaderSettings(); - settings->Schemas->Add(compiledSchema); - settings->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallBack); - settings->ValidationType = ValidationType::Schema; - - //Create the schema validating reader. - XmlReader^ vreader = XmlReader::Create(filename, settings); - - while (vreader->Read()) { } - - //Close the reader. - vreader->Close(); - } - - //Display any warnings or errors. - static void ValidationCallBack(Object^ sender, ValidationEventArgs^ args) - { - if (args->Severity == XmlSeverityType::Warning) - Console::WriteLine("\tWarning: Matching schema not found. No validation occurred." + args->Message); - else - Console::WriteLine("\tValidation error: " + args->Message); - } - -public: - static void Main() - { - //Load the XmlSchemaSet. - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - schemaSet->Add("urn:bookstore-schema", "books.xsd"); - - //Validate the file using the schema stored in the schema set. - //Any elements belonging to the namespace "urn:cd-schema" generate - //a warning because there is no schema matching that namespace. - Validate("store.xml", schemaSet); - Console::ReadLine(); - } -}; - -int main() -{ - Sample::Main(); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp b/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp deleted file mode 100644 index beabf44763b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp +++ /dev/null @@ -1,1166 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::XPath; -using namespace System::Collections; - -ref class XPathNavigatorMethods -{ -public: - - static String^ contosobooks = "C:\\Documents and Settings\\dylanm\\My Documents\\contosoBooks.xml"; - - static void XPathNavigatorMethods_AppendChild1() - { - // XPathNavigator->AppendChild() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlWriter^ pages = navigator->AppendChild(); - pages->WriteElementString("pages", "100"); - pages->Close(); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_AppendChild2() - { - // XPathNavigator->AppendChild(string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - navigator->AppendChild("100"); - - Console::WriteLine(navigator->OuterXml); - // - } - - - static void XPathNavigatorMethods_AppendChild3() - { - // XPathNavigator->AppendChile(XmlReader^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlReader^ pages = XmlReader::Create(gcnew StringReader("100")); - - navigator->AppendChild(pages); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_AppendChild4() - { - // XPathNavigator->AppendChild(XPathNavigator^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlDocument^ childNodes = gcnew XmlDocument(); - childNodes->Load(gcnew StringReader("100")); - XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator(); - - - if (childNodesNavigator->MoveToChild("pages", "http://www.contoso.com/books")) - { - navigator->AppendChild(childNodesNavigator); - } - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_AppendChildElement() - { - // XPathNavigator->AppendChildElement(string, string, string, string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - navigator->AppendChildElement(navigator->Prefix, "pages", navigator->LookupNamespace(navigator->Prefix), "100"); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_Clone() - { - // XPathNavigator->Clone() - - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - // Select all books authored by Melville. - XPathNodeIterator^ nodes = navigator->Select("descendant::book[author/last-name='Melville']"); - - while (nodes->MoveNext()) - { - // Clone the navigator returned by the Current property. - // Use the cloned navigator to get the title element. - XPathNavigator^ clone = nodes->Current->Clone(); - clone->MoveToFirstChild(); - Console::WriteLine("Book title: {0}", clone->Value); - } - // - } - - static void XPathNavigatorMethods_CreateAttribute() - { - // XPathNavigator->CreateAttribute(string, string, string, string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->CreateAttribute("", "discount", "", "1.00"); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_CreateAttributes() - { - // XPathNavigator->CreateAttributes() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlWriter^ attributes = navigator->CreateAttributes(); - - attributes->WriteAttributeString("discount", "1.00"); - attributes->WriteAttributeString("currency", "USD"); - attributes->Close(); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_DeleteSelf() - { - // XPathNavigator->DeleteSelf() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->DeleteSelf(); - - Console::WriteLine("Position after delete: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_DeleteRange() - { - // XPathNavigator->DeleteRange() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(document->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - XPathNavigator^ first = navigator->SelectSingleNode("/bk:bookstore/bk:book[1]", manager); - XPathNavigator^ last = navigator->SelectSingleNode("/bk:bookstore/bk:book[2]", manager); - - navigator->MoveTo(first); - navigator->DeleteRange(last); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_Evaluate1() - { - // XPathNavigator->Evaluate(string) - - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - Double total = (double)navigator->Evaluate("sum(descendant::book/price)"); - Console::WriteLine("Total price for all books: {0}", total.ToString()); - // - } - - static void XPathNavigatorMethods_Evaluate2() - { - // XPathNavigator->Evaluate(XPathExpression) - - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathExpression^ query = navigator->Compile("sum(descendant::book/price)"); - - Double total = (double)navigator->Evaluate(query); - Console::WriteLine("Total price for all books: {0}", total.ToString()); - // - } - - static void XPathNavigatorMethods_Evaluate3() - { - // XPathNavigator->Evaluate(string, IXmlNamespaceResolver) - - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(navigator->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - Double total = (double)navigator->Evaluate("sum(descendant::bk:book/bk:price)", manager); - Console::WriteLine("Total price for all books: {0}", total.ToString()); - // - } - - static void XPathNavigatorMethods_Evaluate4() - { - // XPathNavigator->Evaluate(XPathExpression, XPathNodeIterator^) - - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathNodeIterator^ nodes = navigator->Select("//book"); - XPathExpression^ query = nodes->Current->Compile("sum(descendant::price)"); - - Double total = (double)navigator->Evaluate(query, nodes); - Console::WriteLine("Total price for all books: {0}", total.ToString()); - // - } - - static void XPathNavigatorMethods_InsertAfter1() - { - // XPathNavigator->InsertAfter() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlWriter^ pages = navigator->InsertAfter(); - pages->WriteElementString("pages", "100"); - pages->Close(); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertAfter2() - { - // XPathNavigator->InsertAfter(string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->InsertAfter("100"); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertAfter3() - { - // XPathNavigator->InsertAfter(XmlReader^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlReader^ pages = XmlReader::Create(gcnew StringReader("100")); - - navigator->InsertAfter(pages); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertAfter4() - { - // XPathNavigator->InsertAfter(XPathNavigator^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlDocument^ childNodes = gcnew XmlDocument(); - childNodes->Load(gcnew StringReader("100")); - XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator(); - - navigator->InsertAfter(childNodesNavigator); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertBefore1() - { - // XPathNavigator->InsertBefore() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlWriter^ pages = navigator->InsertBefore(); - pages->WriteElementString("pages", "100"); - pages->Close(); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertBefore2() - { - // XPathNavigator->InsertBefore(string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->InsertBefore("100"); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertBefore3() - { - // XPathNavigator->InsertBefore(XmlReader^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlReader^ pages = XmlReader::Create(gcnew StringReader("100")); - - navigator->InsertBefore(pages); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertBefore4() - { - // XPathNavigator->InsertBefore(XPathNavigator^) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlDocument^ childNodes = gcnew XmlDocument(); - childNodes->Load(gcnew StringReader("100")); - XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator(); - - navigator->InsertBefore(childNodesNavigator); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertElementAfter() - { - // XPathNavigator->InsertElementAfter(string, string, string, string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->InsertElementAfter(navigator->Prefix, "pages", navigator->LookupNamespace(navigator->Prefix), "100"); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_InsertElementBefore() - { - // XPathNavigator->InsertElementBefore(string, string, string, string) - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->InsertElementBefore(navigator->Prefix, "pages", navigator->LookupNamespace(navigator->Prefix), "100"); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_Matches() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - // Select all book nodes. - XPathNodeIterator^ nodes = navigator->SelectDescendants("book", "", false); - - // Select all book nodes that have the matching attribute value. - XPathExpression^ expr = navigator->Compile("book[@genre='novel']"); - while (nodes->MoveNext()) - { - XPathNavigator^ navigator2 = nodes->Current->Clone(); - if (navigator2->Matches(expr)) - { - navigator2->MoveToFirstChild(); - Console::WriteLine("Book title: {0}", navigator2->Value); - } - } - // - } - - static void XPathNavigatorMethods_MoveToFollowing1() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToFollowing(XPathNodeType::Element); - - Console::WriteLine("Position: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_MoveToFollowing2() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToFollowing("price", "http://www.contoso.com/books"); - - Console::WriteLine("Position: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_MoveToFollowing3() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToFollowing("price", "http://www.contoso.com/books"); - XPathNavigator^ boundary = navigator->Clone(); - - navigator->MoveToRoot(); - - while (navigator->MoveToFollowing(XPathNodeType::Text, boundary)) - { - Console::WriteLine(navigator->OuterXml); - } - // - } - - static void XPathNavigatorMethods_MoveToFollowing4() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToFollowing("book", "http://www.contoso.com/books"); - XPathNavigator^ boundary = navigator->Clone(); - boundary->MoveToFollowing("first-name", "http://www.contoso.com/books"); - - navigator->MoveToFollowing("price", "http://www.contoso.com/books", boundary); - - Console::WriteLine("Position (after boundary): {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - - navigator->MoveToFollowing("title", "http://www.contoso.com/books", boundary); - - Console::WriteLine("Position (before boundary): {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - // - static void XPathNavigatorMethods_MoveToNext() - { - - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - XPathNodeIterator^ nodeset = navigator->Select("descendant::book[author/last-name='Melville']"); - - while (nodeset->MoveNext()) - { - // Clone iterator here when working with it. - RecursiveWalk(nodeset->Current->Clone()); - } - } - - static void RecursiveWalk(XPathNavigator^ navigator) - { - switch (navigator->NodeType) - { - case XPathNodeType::Element: - if (navigator->Prefix == String::Empty) - Console::WriteLine("<{0}>", navigator->LocalName); - else - Console::Write("<{0}:{1}>", navigator->Prefix, navigator->LocalName); - Console::WriteLine("\t" + navigator->NamespaceURI); - break; - case XPathNodeType::Text: - Console::WriteLine("\t" + navigator->Value); - break; - } - - if (navigator->MoveToFirstChild()) - { - do - { - RecursiveWalk(navigator); - } while (navigator->MoveToNext()); - - navigator->MoveToParent(); - if (navigator->NodeType == XPathNodeType::Element) - Console::WriteLine("", navigator->Name); - } - else - { - if (navigator->NodeType == XPathNodeType::Element) - { - Console::WriteLine("", navigator->Name); - } - } - } - // - - static void XPathNavigatorMethods_PrependChild1() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlWriter^ pages = navigator->PrependChild(); - pages->WriteElementString("pages", "100"); - pages->Close(); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_PrependChild2() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - navigator->PrependChild("100"); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_PrependChild3() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlReader^ pages = XmlReader::Create(gcnew StringReader("100")); - - navigator->PrependChild(pages); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_PrependChild4() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlDocument^ childNodes = gcnew XmlDocument(); - childNodes->Load(gcnew StringReader("100")); - XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator(); - - navigator->PrependChild(childNodesNavigator); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_PrependChildElement() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - navigator->PrependChildElement(navigator->Prefix, "pages", navigator->LookupNamespace(navigator->Prefix), "100"); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_ReadSubtree() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlReader^ reader = navigator->ReadSubtree(); - - while (reader->Read()) - { - Console::WriteLine(reader->ReadInnerXml()); - } - - reader->Close(); - // - } - - static void XPathNavigatorMethods_ReplaceRange() - { - // XPathNavigator->ReplaceRange() - - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(document->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - XPathNavigator^ first = navigator->SelectSingleNode("/bk:bookstore/bk:book[1]", manager); - XPathNavigator^ last = navigator->SelectSingleNode("/bk:bookstore/bk:book[2]", manager); - - navigator->MoveTo(first); - XmlWriter^ newRange = navigator->ReplaceRange(last); - newRange->WriteStartElement("book"); - newRange->WriteAttributeString("genre", ""); - newRange->WriteAttributeString("publicationdate", "2005-04-07"); - newRange->WriteAttributeString("ISBN", "0"); - newRange->WriteStartElement("title"); - newRange->WriteString("New Book"); - newRange->WriteEndElement(); - newRange->WriteStartElement("author"); - newRange->WriteStartElement("first-name"); - newRange->WriteString("First Name"); - newRange->WriteEndElement(); - newRange->WriteStartElement("last-name"); - newRange->WriteString("Last Name"); - newRange->WriteEndElement(); - newRange->WriteEndElement(); - newRange->WriteElementString("price", "$0.00"); - newRange->WriteEndElement(); - newRange->Close(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_ReplaceSelf1() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - navigator->ReplaceSelf("100"); - - Console::WriteLine("Position after delete: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_ReplaceSelf2() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlReader^ pages = XmlReader::Create(gcnew StringReader("100")); - - navigator->ReplaceSelf(pages); - - Console::WriteLine("Position after delete: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_ReplaceSelf3() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - XmlDocument^ childNodes = gcnew XmlDocument(); - childNodes->Load(gcnew StringReader("100")); - XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator(); - - navigator->ReplaceSelf(childNodesNavigator); - - Console::WriteLine("Position after delete: {0}", navigator->Name); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_Select1() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathNodeIterator^ nodes = navigator->Select("/bookstore/book"); - nodes->MoveNext(); - XPathNavigator^ nodesNavigator = nodes->Current; - - XPathNodeIterator^ nodesText = nodesNavigator->SelectDescendants(XPathNodeType::Text, false); - - while (nodesText->MoveNext()) - Console::WriteLine(nodesText->Current->Value); - // - } - - static void XPathNavigatorMethods_Select2() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathExpression^ query = navigator->Compile("/bookstore/book"); - XPathNodeIterator^ nodes = navigator->Select(query); - XPathNavigator^ nodesNavigator = nodes->Current; - - XPathNodeIterator^ nodesText = nodesNavigator->SelectDescendants(XPathNodeType::Text, false); - - while (nodesText->MoveNext()) - { - Console::WriteLine(nodesText->Current->Value); - } - // - } - - static void XPathNavigatorMethods_Select3() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(navigator->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - XPathNodeIterator^ nodes = navigator->Select("/bk:bookstore/bk:book/bk:price", manager); - // Move to the first node bk:price node. - if(nodes->MoveNext()) - { - // Now nodes.Current points to the first selected node. - XPathNavigator^ nodesNavigator = nodes->Current; - - // Select all the descendants of the current price node. - XPathNodeIterator^ nodesText = nodesNavigator->SelectDescendants(XPathNodeType::Text, false); - - while(nodesText->MoveNext()) - { - Console::WriteLine(nodesText->Current->Value); - } - } - // - } - - static void XPathNavigatorMethods_SelectAncestorsChildrenDescendants() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - // Select all the descendant nodes of the book node. - XPathNodeIterator^ bookDescendants = navigator->SelectDescendants("", "http://www.contoso.com/books", false); - - // Display the LocalName of each descendant node. - Console::WriteLine("Descendant nodes of the book node:"); - while (bookDescendants->MoveNext()) - { - Console::WriteLine(bookDescendants->Current->Name); - } - - // Select all the child nodes of the book node. - XPathNodeIterator^ bookChildren = navigator->SelectChildren("", "http://www.contoso.com/books"); - - // Display the LocalName of each child node. - Console::WriteLine("\nChild nodes of the book node:"); - while (bookChildren->MoveNext()) - { - Console::WriteLine(bookChildren->Current->Name); - } - - // Select all the ancestor nodes of the title node. - navigator->MoveToChild("title", "http://www.contoso.com/books"); - - XPathNodeIterator^ bookAncestors = navigator->SelectAncestors("", "http://www.contoso.com/books", false); - - // Display the LocalName of each ancestor node. - Console::WriteLine("\nAncestor nodes of the title node:"); - - while (bookAncestors->MoveNext()) - { - Console::WriteLine(bookAncestors->Current->Name); - } - // - } - - static void XPathNavigatorMethods_SelectSingleNode1() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathNavigator^ node = navigator->SelectSingleNode("//title"); - Console::WriteLine(node->InnerXml); - // - } - - static void XPathNavigatorMethods_SelectSingleNode2() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XPathExpression^ query = navigator->Compile("//title"); - - XPathNavigator^ node = navigator->SelectSingleNode(query); - Console::WriteLine(node->InnerXml); - // - } - - static void XPathNavigatorMethods_SelectSingleNode3() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(navigator->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - XPathNavigator^ node = navigator->SelectSingleNode("//bk:title", manager); - Console::WriteLine(node->InnerXml); - // - } - - static void XPathNavigatorMethods_SetTypedValue() - { - // - XmlReaderSettings^ settings = gcnew XmlReaderSettings(); - settings->Schemas->Add("http://www.contoso.com/books", "contosoBooks.xsd"); - settings->ValidationType = ValidationType::Schema; - - XmlReader^ reader = XmlReader::Create("contosoBooks.xml", settings); - XmlDocument^ document = gcnew XmlDocument(); - document->Load(reader); - - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - Decimal^ price = gcnew Decimal(19.99); - navigator->SetTypedValue(price); - - navigator->MoveToParent(); - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_SetValue() - { - // - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(navigator->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - for each (XPathNavigator^ nav in navigator->Select("//bk:price", manager)) - { - if(nav->Value == "11.99") - { - nav->SetValue("12.99"); - } - } - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorMethods_WriteSubtree() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - XmlWriter^ writer = XmlWriter::Create("contosoBook.xml"); - navigator->WriteSubtree(writer); - - writer->Close(); - // - } - - static void XPathNavigatorMethods_MoveToNextAttribute() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - // Select all book nodes and display all attributes on each book. - XPathNodeIterator^ nodes = navigator->SelectDescendants("book", "", false); - while (nodes->MoveNext()) - { - XPathNavigator^ navigator2 = nodes->Current->Clone(); - navigator2->MoveToFirstAttribute(); - Console::WriteLine("{0} = {1}", navigator2->Name, navigator2->Value); - - while (navigator2->MoveToNextAttribute()) - { - Console::WriteLine("{0} = {1}", navigator2->Name, navigator2->Value); - } - - Console::WriteLine(); - } - // - } - - static void XPathNavigatorMethods_BasicMoveTos() - { - // - // Load the XML document. - XmlDocument^ document = gcnew XmlDocument(); - document->Load("contosoBooks.xml"); - - // Create the XPathNavigator. - XPathNavigator^ navigator = document->CreateNavigator(); - - // Create an XmlNamespaceManager used to handle namespaces - // found in the XML document. - XmlNamespaceManager^ manager = gcnew XmlNamespaceManager(document->NameTable); - manager->AddNamespace("bk", "http://www.contoso.com/books"); - - // Move to the last book node using the SelectSingleNode method. - navigator = navigator->SelectSingleNode("//bk:book[last()]", manager); - Console::WriteLine("Last book node: \n===============\n{0}", navigator->OuterXml); - - // Move to the previous book node and write it to the console - // if the move was successful. - if (navigator->MoveToPrevious()) - { - Console::WriteLine("\nSecond book node: \n=================\n{0}", - navigator->OuterXml); - } - - // Move to the first book node and write it to the console - // if the move was successful. - if (navigator->MoveToFirst()) - { - Console::WriteLine("\nFirst book node: \n================\n{0}", - navigator->OuterXml); - } - - // Move to the parent bookstore node and write it to the console - // if the move was successful. - if (navigator->MoveToParent()) - { - Console::WriteLine("\nParent bookstore node: \n======================\n{0}", - navigator->OuterXml); - } - - // Move to the first child node of the bookstore node and write - // it to the console if the move was successful. - if (navigator->MoveToFirstChild()) - { - Console::WriteLine("\nFirst book node: \n================\n{0}", - navigator->OuterXml); - } - - // Move to the root node and write it to the console. - navigator->MoveToRoot(); - Console::WriteLine("\nRoot node: \n==========\n{0}", - navigator->OuterXml); - // - } - static void XPathNavigatorMethods_TwoWaysToIterateOverXPathNavigator() - { - XPathDocument^ doc = gcnew XPathDocument(gcnew StringReader("")); - XPathNavigator^ nav = doc->CreateNavigator(); - XPathNodeIterator^ nodeIterator = nav->SelectDescendants("", "", false); - - // - while (nodeIterator->MoveNext()) - { - XPathNavigator^ n = nodeIterator->Current; - Console::WriteLine(n->LocalName); - } - // - - // - for each (XPathNavigator^ n in nodeIterator) - Console::WriteLine(n->LocalName); - // - } - - -}; - -int main() -{ - return 0; -}; \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp b/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp deleted file mode 100644 index 98a87366e0c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::XPath; -using namespace System::Collections; - -class XPathNavigatorProperties -{ -public: - - static void XPathNavigatorProperties_CanEdit() - { - // - XPathDocument^ readOnlyDocument = gcnew XPathDocument("books.xml"); - XPathNavigator^ readOnlyNavigator = readOnlyDocument->CreateNavigator(); - - XmlDocument^ editableDocument = gcnew XmlDocument(); - editableDocument->Load("books.xml"); - XPathNavigator^ editableNavigator = editableDocument->CreateNavigator(); - - Console::WriteLine("XPathNavigator.CanEdit from XPathDocument: {0}", readOnlyNavigator->CanEdit); - Console::WriteLine("XPathNavigator.CanEdit from XmlDocument: {0}", editableNavigator->CanEdit); - // - } - - static void XPathNavigatorProperties_InnerXml() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - Console::WriteLine(navigator->InnerXml); - // - } - - static void XPathNavigatorProperties_NavigatorComparer() - { - // - XPathDocument^ document = gcnew XPathDocument("books.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - Hashtable^ table = gcnew Hashtable(XPathNavigator::NavigatorComparer); - - // Add nodes to the Hashtable. - for each (XPathNavigator^ navigator2 in navigator->Select("//book")) - { - Object^ value = navigator2->Evaluate("string(./title)"); - table->Add(navigator2->Clone(), value); - Console::WriteLine("Added book with title {0}", value); - } - - Console::WriteLine(table->Count); - Console::WriteLine("Does the Hashtable have the book \"The Confidence Man\"?"); - Console::WriteLine(table->Contains(navigator->SelectSingleNode("//book[title='The Confidence Man']"))); - // - } - - static void XPathNavigatorProperties_OuterXml() - { - // - XPathDocument^ document = gcnew XPathDocument("contosoBooks.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - - Console::WriteLine(navigator->OuterXml); - // - } - - static void XPathNavigatorProperties_ValueAs() - { - // - XPathDocument^ document = gcnew XPathDocument("valueas.xml"); - XPathNavigator^ navigator = document->CreateNavigator(); - - // ValueAsBoolean - navigator->MoveToChild("root", ""); - navigator->MoveToChild("booleanElement", ""); - bool^ booleanValue = navigator->ValueAsBoolean; - Console::WriteLine(navigator->LocalName + ": " + booleanValue); - - // ValueAsDateTime - navigator->MoveToNext("dateTimeElement", ""); - DateTime^ dateTimeValue = navigator->ValueAsDateTime; - Console::WriteLine(navigator->LocalName + ": " + dateTimeValue); - - // ValueAsDouble, ValueAsInt32, ValueAsInt64, ValueAsSingle - navigator->MoveToNext("numberElement", ""); - Double doubleValue = navigator->ValueAsDouble; - Int32 int32Value = navigator->ValueAsInt; - Int64 int64Value = navigator->ValueAsLong; - Console::WriteLine(navigator->LocalName + ": " + doubleValue); - Console::WriteLine(navigator->LocalName + ": " + int32Value); - Console::WriteLine(navigator->LocalName + ": " + int64Value); - // - } - - static void XPathNavigatorProperties_ValueType() - { - // - // Create an XmlReaderSettings object with the contosoBooks.xsd schema. - XmlReaderSettings^ settings = gcnew XmlReaderSettings(); - settings->Schemas->Add("http://www.contoso.com/books", "contosoBooks.xsd"); - settings->ValidationType = ValidationType::Schema; - - // Create an XmlReader object with the contosoBooks.xml file and its schema. - XmlReader^ reader = XmlReader::Create("contosoBooks.xml", settings); - - XPathDocument^ document = gcnew XPathDocument(reader); - XPathNavigator^ navigator = document->CreateNavigator(); - - navigator->MoveToChild("bookstore", "http://www.contoso.com/books"); - navigator->MoveToChild("book", "http://www.contoso.com/books"); - navigator->MoveToChild("price", "http://www.contoso.com/books"); - - // Display the current type of the price element. - Console::WriteLine(navigator->ValueType); - - // Get the value of the price element as a string and display it. - String^ price = dynamic_cast(navigator->ValueAs(String::typeid)); - Console::WriteLine(price); - // - } -}; - -int main() -{ - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp b/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp deleted file mode 100644 index 47d9622fae0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Encode and decode a name with spaces. - String^ name1 = XmlConvert::EncodeName( "Order Detail" ); - Console::WriteLine( "Encoded name: {0}", name1 ); - Console::WriteLine( "Decoded name: {0}", XmlConvert::DecodeName( name1 ) ); - - // Encode and decode a local name. - String^ name2 = XmlConvert::EncodeLocalName( "a:book" ); - Console::WriteLine( "Encoded local name: {0}", name2 ); - Console::WriteLine( "Decoded local name: {0}", XmlConvert::DecodeName( name2 ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlConvert.ToDouble/CPP/readData.cpp b/snippets/cpp/VS_Snippets_Data/XmlConvert.ToDouble/CPP/readData.cpp deleted file mode 100644 index c3d8da70f59..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlConvert.ToDouble/CPP/readData.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = gcnew XmlTextReader( "orderData.xml" ); - - //Parse the file and pull out the order date and price. - while ( reader->Read() ) - { - if ( reader->NodeType == XmlNodeType::Element ) - { - if ( reader->Name->Equals( "order" ) ) - { - DateTime orderDate = XmlConvert::ToDateTime( reader->GetAttribute( "date" ) ); - Console::WriteLine( "order date: {0}", orderDate.ToString() ); - } - else - if ( reader->Name->Equals( "price" ) ) - { - Double price = XmlConvert::ToDouble( reader->ReadInnerXml() ); - Console::WriteLine( "price: {0}", price ); - } - } - } - - - //Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlConvert.VerifyName/CPP/verifyname.cpp b/snippets/cpp/VS_Snippets_Data/XmlConvert.VerifyName/CPP/verifyname.cpp deleted file mode 100644 index a3e011767f0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlConvert.VerifyName/CPP/verifyname.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = gcnew XmlTextWriter( "out.xml", nullptr ); - String^ tag = "item name"; - try - { - - // Write the root element. - writer->WriteStartElement( "root" ); - writer->WriteStartElement( XmlConvert::VerifyName( tag ) ); - } - catch ( XmlException^ e ) - { - Console::WriteLine( e->Message ); - Console::WriteLine( "Convert to a valid name..." ); - writer->WriteStartElement( XmlConvert::EncodeName( tag ) ); - } - - writer->WriteString( "hammer" ); - writer->WriteEndElement(); - - // Write the end tag for the root element. - writer->WriteEndElement(); - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlDataDocument.GetRowFromElement/CPP/getrow.cpp b/snippets/cpp/VS_Snippets_Data/XmlDataDocument.GetRowFromElement/CPP/getrow.cpp deleted file mode 100644 index f69ebbfb60c..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlDataDocument.GetRowFromElement/CPP/getrow.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; - -int main() -{ - // Create an XmlDataDocument. - XmlDataDocument^ doc = gcnew XmlDataDocument; - - // Load the schema file. - doc->DataSet->ReadXmlSchema( "store.xsd" ); - - // Load the XML data. - doc->Load( "2books.xml" ); - - //Change the price on the first book. - XmlElement^ root = doc->DocumentElement; - DataRow^ row = doc->GetRowFromElement( safe_cast(root->FirstChild) ); - row["price"] = "12.95"; - Console::WriteLine( "Display the modified XML data..." ); - Console::WriteLine( doc->DocumentElement->OuterXml ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlDataDocument.Load/CPP/loadrdr.cpp b/snippets/cpp/VS_Snippets_Data/XmlDataDocument.Load/CPP/loadrdr.cpp deleted file mode 100644 index 631d04fa9a1..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlDataDocument.Load/CPP/loadrdr.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Data; -using namespace System::Xml; -int main() -{ - // Create an XmlDataDocument. - XmlDataDocument^ doc = gcnew XmlDataDocument; - - // Load the schema file. - doc->DataSet->ReadXmlSchema( "store.xsd" ); - - // Load the XML data. - XmlTextReader^ reader = gcnew XmlTextReader( "2books.xml" ); - reader->MoveToContent(); // Moves the reader to the root node. - doc->Load( reader ); - - // Update the price on the first book using the DataSet methods. - DataTable^ books = doc->DataSet->Tables["book"]; - books->Rows[0]["price"] = "12.95"; - Console::WriteLine( "Display the modified XML data..." ); - doc->Save( Console::Out ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlEntity/CPP/entities.cpp b/snippets/cpp/VS_Snippets_Data/XmlEntity/CPP/entities.cpp deleted file mode 100644 index 85250f42094..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlEntity/CPP/entities.cpp +++ /dev/null @@ -1,39 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -public: - static void DisplayEntities( XmlNamedNodeMap^ nMap ) - { - for ( int i = 0; i < nMap->Count; i++ ) - { - XmlEntity^ ent = dynamic_cast(nMap->Item( i )); - Console::Write( " {0} ", ent->NodeType ); - Console::Write( " {0} ", ent->Name ); - Console::Write( " {0} ", ent->NotationName ); - Console::Write( " {0} ", ent->PublicId ); - Console::Write( " {0} ", ent->SystemId ); - Console::WriteLine(); - - } - } - -}; - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "doment.xml" ); - Console::WriteLine( "Display information on all entities..." ); - XmlNamedNodeMap^ nMap = doc->DocumentType->Entities; - Sample^ MySample = gcnew Sample; - MySample->DisplayEntities( nMap ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectNodes1/CPP/selectnodes1.cpp b/snippets/cpp/VS_Snippets_Data/XmlNode.SelectNodes1/CPP/selectnodes1.cpp deleted file mode 100644 index 3424276fabf..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectNodes1/CPP/selectnodes1.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Collections; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "booksort.xml" ); - - // Create an XmlNamespaceManager for resolving namespaces. - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( doc->NameTable ); - nsmgr->AddNamespace( "bk", "urn:samples" ); - - // Select and display the value of all the ISBN attributes. - XmlNodeList^ nodeList; - XmlElement^ root = doc->DocumentElement; - nodeList = root->SelectNodes( "/bookstore/book/@bk:ISBN", nsmgr ); - IEnumerator^ myEnum = nodeList->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlNode^ isbn = safe_cast(myEnum->Current); - Console::WriteLine( isbn->Value ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode1/CPP/selectsingnode.cpp b/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode1/CPP/selectsingnode.cpp deleted file mode 100644 index 3cc1ad791d3..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode1/CPP/selectsingnode.cpp +++ /dev/null @@ -1,25 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "booksort.xml" ); - - //Create an XmlNamespaceManager for resolving namespaces. - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( doc->NameTable ); - nsmgr->AddNamespace( "bk", "urn:samples" ); - - //Select the book node with the matching attribute value. - XmlNode^ book; - XmlElement^ root = doc->DocumentElement; - book = root->SelectSingleNode( "descendant::book->Item[@bk:ISBN='1-861001-57-6']", nsmgr ); - Console::WriteLine( book->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode2/CPP/XmlNode.SelectSingleNode2.cpp b/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode2/CPP/XmlNode.SelectSingleNode2.cpp deleted file mode 100644 index f460ecd9f3d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode2/CPP/XmlNode.SelectSingleNode2.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( L"newbooks.xml" ); - - // Create an XmlNamespaceManager to resolve the default namespace. - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( doc->NameTable ); - nsmgr->AddNamespace( L"bk", L"urn:newbooks-schema" ); - - // Select the first book written by an author whose last name is Atwood. - XmlNode^ book; - XmlElement^ root = doc->DocumentElement; - book = root->SelectSingleNode( L"descendant::bk:book[bk:author/bk:last-name='Atwood']", nsmgr ); - Console::WriteLine( book->OuterXml ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlNodeChangedEventHandler/CPP/nodeevent.cpp b/snippets/cpp/VS_Snippets_Data/XmlNodeChangedEventHandler/CPP/nodeevent.cpp deleted file mode 100644 index ab467b652be..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlNodeChangedEventHandler/CPP/nodeevent.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -public: - void Run( String^ args ) - { - // Create and load the XML document. - Console::WriteLine( "Loading file {0} ...", args ); - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( args ); - - //Create the event handlers. - doc->NodeChanged += gcnew XmlNodeChangedEventHandler( this, &Sample::MyNodeChangedEvent ); - doc->NodeInserted += gcnew XmlNodeChangedEventHandler( this, &Sample::MyNodeInsertedEvent ); - - // Change the book price. - doc->DocumentElement->LastChild->InnerText = "5.95"; - - // Add a new element. - XmlElement^ newElem = doc->CreateElement( "style" ); - newElem->InnerText = "hardcover"; - doc->DocumentElement->AppendChild( newElem ); - Console::WriteLine( "\r\nDisplay the modified XML..." ); - Console::WriteLine( doc->OuterXml ); - } - - // Handle the NodeChanged event. -private: - void MyNodeChangedEvent( Object^ /*src*/, XmlNodeChangedEventArgs^ args ) - { - Console::Write( "Node Changed Event: <{0}> changed", args->Node->Name ); - if ( args->Node->Value != nullptr ) - { - Console::WriteLine( " with value {0}", args->Node->Value ); - } - else - Console::WriteLine( "" ); - } - - // Handle the NodeInserted event. - void MyNodeInsertedEvent( Object^ /*src*/, XmlNodeChangedEventArgs^ args ) - { - Console::Write( "Node Inserted Event: <{0}> inserted", args->Node->Name ); - if ( args->Node->Value != nullptr ) - { - Console::WriteLine( " with value {0}", args->Node->Value ); - } - else - Console::WriteLine( "" ); - } -}; -// End class - -int main() -{ - Sample^ mySample = gcnew Sample; - mySample->Run( "book.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlNotation/CPP/notation.cpp b/snippets/cpp/VS_Snippets_Data/XmlNotation/CPP/notation.cpp deleted file mode 100644 index 5e7a6c8360b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlNotation/CPP/notation.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -void DisplayNotations( XmlNamedNodeMap^ nMap ) -{ - for ( int i = 0; i < nMap->Count; i++ ) - { - XmlNotation^ note = dynamic_cast(nMap->Item( i )); - Console::Write( " {0} ", note->NodeType ); - Console::Write( " {0} ", note->Name ); - Console::Write( " {0} ", note->PublicId ); - Console::Write( " {0} ", note->SystemId ); - Console::WriteLine(); - - } -} - -int main() -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "doment.xml" ); - Console::WriteLine( "Display information on all notations..." ); - XmlNamedNodeMap^ nMap = doc->DocumentType->Notations; - DisplayNotations( nMap ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.DtdValidate/CPP/XmlReaderSettings.DtdValidate.cpp b/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.DtdValidate/CPP/XmlReaderSettings.DtdValidate.cpp deleted file mode 100644 index a3f97a98a5a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.DtdValidate/CPP/XmlReaderSettings.DtdValidate.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::IO; - -// Display any validation errors. -static void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ e ) -{ - Console::WriteLine( L"Validation Error: {0}", e->Message ); -} - -int main() -{ - // Set the validation settings. - XmlReaderSettings^ settings = gcnew XmlReaderSettings; - settings->DtdProcessing = DtdProcessing::Parse; - settings->ValidationType = ValidationType::DTD; - settings->ValidationEventHandler += gcnew ValidationEventHandler( ValidationCallBack ); - - // Create the XmlReader object. - XmlReader^ reader = XmlReader::Create( L"itemDTD.xml", settings ); - - // Parse the file. - while ( reader->Read() ) - ; - - return 1; -} -// - diff --git a/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.cctor/CPP/XmlReaderSettings.cctor.cpp b/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.cctor/CPP/XmlReaderSettings.cctor.cpp deleted file mode 100644 index 2c42e5cc4eb..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlReaderSettings.cctor/CPP/XmlReaderSettings.cctor.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::IO; -int main() -{ - - // - // Set the reader settings. - XmlReaderSettings^ settings = gcnew XmlReaderSettings; - settings->IgnoreComments = true; - settings->IgnoreProcessingInstructions = true; - settings->IgnoreWhitespace = true; - - // - // - // Create a resolver with default credentials. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - resolver->Credentials = System::Net::CredentialCache::DefaultCredentials; - - // Set the reader settings object to use the resolver. - settings->XmlResolver = resolver; - - // Create the XmlReader object. - XmlReader^ reader = XmlReader::Create( L"http://ServerName/data/books.xml", settings ); - - // - // Parse the file. - while ( reader->Read() ) - ; - - return 1; -} - diff --git a/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp b/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp deleted file mode 100644 index f202c678601..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::IO; - -// Display any validation errors. -static void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ e ) -{ - Console::WriteLine( L"Validation Error:\n {0}", e->Message ); - Console::WriteLine(); -} - -int main() -{ - // Create the XmlSchemaSet class. - XmlSchemaSet^ sc = gcnew XmlSchemaSet; - - // Add the schema to the collection. - sc->Add( L"urn:bookstore-schema", L"books.xsd" ); - - // Set the validation settings. - XmlReaderSettings^ settings = gcnew XmlReaderSettings; - settings->ValidationType = ValidationType::Schema; - settings->Schemas = sc; - settings->ValidationEventHandler += gcnew ValidationEventHandler(ValidationCallBack); - - // Create the XmlReader object. - XmlReader^ reader = XmlReader::Create( L"booksSchemaFail.xml", settings ); - - // Parse the file. - while ( reader->Read() ) - ; - - return 1; -} -// The example displays output like the following: -// Validation Error: -// The element 'book' in namespace 'urn:bookstore-schema' has invalid child element 'author' -// in namespace 'urn:bookstore-schema'. List of possible elements expected: 'title' in -// namespace 'urn:bookstore-schema'. -// -// Validation Error: -// The element 'author' in namespace 'urn:bookstore-schema' has invalid child element 'name' -// in namespace 'urn:bookstore-schema'. List of possible elements expected: 'first-name' in -// namespace 'urn:bookstore-schema'. -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlSchema.ValidationEventHandler/CPP/schemaevent.cpp b/snippets/cpp/VS_Snippets_Data/XmlSchema.ValidationEventHandler/CPP/schemaevent.cpp deleted file mode 100644 index 8ad92c04292..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSchema.ValidationEventHandler/CPP/schemaevent.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Sample -{ -private: - //Display the schema error information. - static void ValidationCallBack( Object^ sender, ValidationEventArgs^ args ) - { - Console::WriteLine( "Invalid XSD schema: {0}", args->Exception->Message ); - } - -public: - static void main() - { - // Create the schema collection. - XmlSchemaCollection^ xsc = gcnew XmlSchemaCollection; - - //Set an event handler to manage invalid schemas. - xsc->ValidationEventHandler += gcnew ValidationEventHandler( Sample::ValidationCallBack ); - - //Add the schema to the collection. - xsc->Add( nullptr, "invalid.xsd" ); - } -}; - -int main() -{ - Sample::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Add/CPP/schemacolladd.cpp b/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Add/CPP/schemacolladd.cpp deleted file mode 100644 index d496898fad0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Add/CPP/schemacolladd.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Sample -{ -private: - // Display any errors. - static void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ e ) - { - Console::WriteLine( "Validation Error: {0}", e->Message ); - } - -public: - static void main() - { - array^ args = Environment::GetCommandLineArgs(); - String^ UserName = args[ 1 ]; - String^ SecurelyStoredPassword = args[ 2 ]; - String^ Domain = args[ 3 ]; - - // - XmlSchemaCollection^ sc = gcnew XmlSchemaCollection; - sc->ValidationEventHandler += gcnew ValidationEventHandler( Sample::ValidationCallBack ); - - // Create a resolver with the necessary credentials. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - System::Net::NetworkCredential^ nc; - nc = gcnew System::Net::NetworkCredential( UserName,SecurelyStoredPassword,Domain ); - resolver->Credentials = nc; - - // Add the new schema to the collection. - sc->Add( nullptr, gcnew XmlTextReader( "sample.xsd" ), resolver ); - // - - if ( sc->Count > 0 ) - { - XmlTextReader^ tr = gcnew XmlTextReader( "notValidXSD.xml" ); - XmlValidatingReader^ rdr = gcnew XmlValidatingReader( tr ); - - rdr->ValidationType = ValidationType::Schema; - rdr->Schemas->Add( sc ); - rdr->ValidationEventHandler += gcnew ValidationEventHandler( Sample::ValidationCallBack ); - while ( rdr->Read() ); - } - } -}; - -int main() -{ - Sample::main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Basic/CPP/aa.cpp b/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Basic/CPP/aa.cpp deleted file mode 100644 index 16126254e5a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Basic/CPP/aa.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::IO; -public ref class ValidXSD -{ -public: - static void main() - { - XmlSchemaCollection^ sc = gcnew XmlSchemaCollection; - sc->ValidationEventHandler += gcnew ValidationEventHandler( ValidationCallBack ); - sc->Add( nullptr, "books.xsd" ); - if ( sc->Count > 0 ) - { - XmlTextReader^ tr = gcnew XmlTextReader( "notValidXSD.xml" ); - XmlValidatingReader^ rdr = gcnew XmlValidatingReader( tr ); - rdr->ValidationType = ValidationType::Schema; - rdr->Schemas->Add( sc ); - rdr->ValidationEventHandler += gcnew ValidationEventHandler( ValidationCallBack ); - while ( rdr->Read() ) - ; - } - } - - -private: - static void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ e ) - { - Console::WriteLine( "Validation Error: {0}", e->Message ); - } - -}; - -int main() -{ - ValidXSD::main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp b/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp deleted file mode 100644 index 0d338c1f4c0..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -ref class XmlSchemaInferenceExamples -{ -public: - - static void Main() - { - - } - - static void XmlSchemaInference_OverallExample() - { - // - XmlReader^ reader = XmlReader::Create("contosoBooks.xml"); - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - XmlSchemaInference^ schema = gcnew XmlSchemaInference(); - - schemaSet = schema->InferSchema(reader); - - for each (XmlSchema^ s in schemaSet->Schemas()) - { - s->Write(Console::Out); - } - // - } - - static void XmlSchemaInference_Occurrence() - { - // - XmlReader^ reader = XmlReader::Create("input.xml"); - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - XmlSchemaInference^ schema = gcnew XmlSchemaInference(); - - schema->Occurrence = XmlSchemaInference::InferenceOption::Relaxed; - - schemaSet = schema->InferSchema(reader); - - for each (XmlSchema^ s in schemaSet->Schemas()) - { - s->Write(Console::Out); - } - // - } - - static void XmlSchemaInference_TypeInference() - { - // - XmlReader^ reader = XmlReader::Create("input.xml"); - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - XmlSchemaInference^ schema = gcnew XmlSchemaInference(); - - schema->TypeInference = XmlSchemaInference::InferenceOption::Relaxed; - - schemaSet = schema->InferSchema(reader); - - for each (XmlSchema^ s in schemaSet->Schemas()) - { - s->Write(Console::Out); - } - // - } - - static void XmlSchemaInference_RefinementProcess() - { - // - XmlReader^ reader = XmlReader::Create("item1.xml"); - XmlReader^ reader1 = XmlReader::Create("item2.xml"); - XmlSchemaSet^ schemaSet = gcnew XmlSchemaSet(); - XmlSchemaInference^ inference = gcnew XmlSchemaInference(); - schemaSet = inference->InferSchema(reader); - - // Display the inferred schema. - Console::WriteLine("Original schema:\n"); - for each (XmlSchema^ schema in schemaSet->Schemas("http://www.contoso.com/items")) - { - schema->Write(Console::Out); - } - - // Use the additional data in item2.xml to refine the original schema. - schemaSet = inference->InferSchema(reader1, schemaSet); - - // Display the refined schema. - Console::WriteLine("\n\nRefined schema:\n"); - for each (XmlSchema^ schema in schemaSet->Schemas("http://www.contoso.com/items")) - { - schema->Write(Console::Out); - } - // - } -}; - -int main() -{ - XmlSchemaInferenceExamples::Main(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_Data/XmlSchemaSetOverall Example/CPP/xmlschemasetexample.cpp b/snippets/cpp/VS_Snippets_Data/XmlSchemaSetOverall Example/CPP/xmlschemasetexample.cpp deleted file mode 100644 index 1f3adf25c44..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSchemaSetOverall Example/CPP/xmlschemasetexample.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; - -static void booksSettingsValidationEventHandler( Object^ /*sender*/, ValidationEventArgs^ e ) -{ - if ( e->Severity == XmlSeverityType::Warning ) - { - Console::Write( L"WARNING: " ); - Console::WriteLine( e->Message ); - } - else - if ( e->Severity == XmlSeverityType::Error ) - { - Console::Write( L"ERROR: " ); - Console::WriteLine( e->Message ); - } -} - -int main() -{ - XmlReaderSettings^ booksSettings = gcnew XmlReaderSettings; - booksSettings->Schemas->Add( L"http://www.contoso.com/books", L"books.xsd" ); - booksSettings->ValidationType = ValidationType::Schema; - booksSettings->ValidationEventHandler += gcnew ValidationEventHandler( booksSettingsValidationEventHandler ); - XmlReader^ books = XmlReader::Create( L"books.xml", booksSettings ); - while ( books->Read() ) - {} - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.Credentials/CPP/secresolver2.cpp b/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.Credentials/CPP/secresolver2.cpp deleted file mode 100644 index ccf73e57aee..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.Credentials/CPP/secresolver2.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Net; -int main() -{ - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( "http://myServer/data/books.xml" ); - - // Create a secure resolver with default credentials. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - XmlSecureResolver^ sResolver = gcnew XmlSecureResolver( resolver,"http://myServer/data/" ); - sResolver->Credentials = CredentialCache::DefaultCredentials; - - // Use the secure resolver to resolve resources. - reader->XmlResolver = sResolver; - - // Parse the file. - while ( reader->Read() ) - { - - // Do any additional processing here. - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.cctor/CPP/secresolver.cpp b/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.cctor/CPP/secresolver.cpp deleted file mode 100644 index 3da4b5ed406..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.cctor/CPP/secresolver.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Security; -using namespace System::Security::Policy; -using namespace System::Net; - -// NOTE: To test, replace www.contoso.com w/ the local string - -// -Object^ GetFile( String^ fileURL, XmlResolver^ resolver ) -{ - // Generate the default PermissionSet using the file URL. - Evidence^ evidence = XmlSecureResolver::CreateEvidenceForUrl( fileURL ); - PermissionSet^ myPermissions = SecurityManager::ResolvePolicy( evidence ); - - // Modify the PermissionSet to only allow access to http://www.contoso.com. - // Create a WebPermission which only allows access to http://www.contoso.com. - WebPermission^ myWebPermission = gcnew WebPermission( - NetworkAccess::Connect,"http://www.contoso.com" ); - // Replace the existing WebPermission in myPermissions with the updated WebPermission. - myPermissions->SetPermission( myWebPermission ); - - // Use the modified PermissionSet to construct the XmlSecureResolver. - XmlSecureResolver^ sResolver = gcnew XmlSecureResolver( resolver,myPermissions ); - - // Get the object. - Uri^ fullUri = sResolver->ResolveUri( nullptr, fileURL ); - return sResolver->GetEntity( fullUri, nullptr, nullptr ); -} -// - -int main() -{ - Stream^ s = (Stream^)(GetFile( "http://localhost/data/books.xml", - gcnew XmlUrlResolver )); - XmlTextReader^ reader = gcnew XmlTextReader( s ); -} diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.Cctor/CPP/readfrag.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.Cctor/CPP/readfrag.cpp deleted file mode 100644 index 91be2b8ba6b..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.Cctor/CPP/readfrag.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XML fragment to be parsed. - String^ xmlFrag = " Pride And Prejudice novel "; - - // Create the XmlNamespaceManager. - NameTable^ nt = gcnew NameTable; - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt ); - nsmgr->AddNamespace( "bk", "urn:sample" ); - - // Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::None ); - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - - // Parse the XML. If they exist, display the prefix and - // namespace URI of each element. - while ( reader->Read() ) - { - if ( reader->IsStartElement() ) - { - if ( reader->Prefix == String::Empty ) - Console::WriteLine( "< {0}>", reader->LocalName ); - else - { - Console::Write( "< {0}: {1}>", reader->Prefix, reader->LocalName ); - Console::WriteLine( " The namespace URI is {0}", reader->NamespaceURI ); - } - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp deleted file mode 100644 index 5ef9f82c8ce..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XML fragment to be parsed. - String^ xmlFrag = "\n" - "\n" - "\n" - "240\n" - "\n" - "\n"; - - // Create the XmlNamespaceManager. - NameTable^ nt = gcnew NameTable; - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt ); - - // Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::None ); - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - - // Parse the XML and display each node. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( " {0} {1}, {2} ", reader->Depth, reader->LineNumber, reader->LinePosition ); - Console::WriteLine( "< {0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( " {0} {1}, {2} ", reader->Depth, reader->LineNumber, reader->LinePosition ); - Console::WriteLine( " {0}", reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::Write( " {0} {1}, {2} ", reader->Depth, reader->LineNumber, reader->LinePosition ); - Console::WriteLine( "", reader->Name ); - break; - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.Normalization/CPP/readnormal.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.Normalization/CPP/readnormal.cpp deleted file mode 100644 index d7a782ca81e..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.Normalization/CPP/readnormal.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XML fragment to be parsed. - String^ xmlFrag = "\n" - "\n"; - - // Create the XmlNamespaceManager. - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( gcnew NameTable ); - - // Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::Preserve ); - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - - // Show attribute value normalization. - reader->Read(); - reader->Normalization = false; - Console::WriteLine( "Attribute value: {0}", reader->GetAttribute( "attr1" ) ); - reader->Normalization = true; - Console::WriteLine( "Attribute value: {0}", reader->GetAttribute( "attr1" ) ); - - // Set Normalization back to false. This allows the reader to accept - // character entities in the � to  range. If Normalization had - // been set to true, character entities in this range throw an exception. - reader->Normalization = false; - reader->Read(); - reader->MoveToContent(); - Console::WriteLine( "Attribute value: {0}", reader->GetAttribute( "attr2" ) ); - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.ReadAttributeValue/CPP/readattrval.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.ReadAttributeValue/CPP/readattrval.cpp deleted file mode 100644 index 67a11857486..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.ReadAttributeValue/CPP/readattrval.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = nullptr; - __try - { - - // Create the XML fragment to be parsed. - String^ xmlFrag = ""; - - // Create the XmlParserContext. - XmlParserContext^ context; - String^ subset = ""; - context = gcnew XmlParserContext( nullptr,nullptr,"book",nullptr,nullptr,subset,"","",XmlSpace::None ); - - // Create the reader. - reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - - // Read the misc attribute. The attribute is parsed - // into multiple text and entity reference nodes. - reader->MoveToContent(); - reader->MoveToAttribute( "misc" ); - while ( reader->ReadAttributeValue() ) - { - if ( reader->NodeType == XmlNodeType::EntityReference ) - Console::WriteLine( " {0} {1}", reader->NodeType, reader->Name ); - else - Console::WriteLine( " {0} {1}", reader->NodeType, reader->Value ); - } - } - __finally - { - if ( reader != nullptr ) - reader->Close(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.ResetState/CPP/resetstate.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.ResetState/CPP/resetstate.cpp deleted file mode 100644 index 43944b7d4c9..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.ResetState/CPP/resetstate.cpp +++ /dev/null @@ -1,31 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -int main() -{ - Encoding^ enc = gcnew UTF8Encoding; - array^utf8Buffer = enc->GetBytes( " 12345 " ); - enc = gcnew UnicodeEncoding; - array^unicodeBuffer = enc->GetBytes( " root " ); - MemoryStream^ memStrm = gcnew MemoryStream; - memStrm->Write( unicodeBuffer, 0, unicodeBuffer->Length ); - memStrm->Write( utf8Buffer, 0, utf8Buffer->Length ); - memStrm->Position = 0; - XmlTextReader^ reader = gcnew XmlTextReader( memStrm ); - while ( reader->Read() ) - { - Console::WriteLine( "NodeType: {0}", reader->NodeType ); - if ( XmlNodeType::EndElement == reader->NodeType && "root" == reader->Name ) - break; - if ( XmlNodeType::EndElement == reader->NodeType ) - reader->ResetState(); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlLang/CPP/readlang.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlLang/CPP/readlang.cpp deleted file mode 100644 index baa5d62f323..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlLang/CPP/readlang.cpp +++ /dev/null @@ -1,50 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create the XML fragment to be parsed. - String^ xmlFrag = " Colour Analysis Color Analysis "; - - // Create the XmlNamespaceManager. - NameTable^ nt = gcnew NameTable; - XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt ); - - // Create the XmlParserContext. - XmlParserContext^ context = gcnew XmlParserContext( nullptr,nsmgr,nullptr,XmlSpace::None ); - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( xmlFrag,XmlNodeType::Element,context ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Parse the XML and display each of the nodes, including the xml:lang setting. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::WriteLine( "{0}: < {1}>", reader->XmlLang, reader->Name ); - break; - - case XmlNodeType::Text: - Console::WriteLine( "{0}: {1}", reader->XmlLang, reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::WriteLine( "{0}: ", reader->XmlLang, reader->Name ); - break; - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlResolver/CPP/rdr_resolver.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlResolver/CPP/rdr_resolver.cpp deleted file mode 100644 index dcc839cdab3..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlResolver/CPP/rdr_resolver.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Net; -int main() -{ - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( "http://myServer/data/books.xml" ); - - // Supply the credentials necessary to access the Web server. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - resolver->Credentials = CredentialCache::DefaultCredentials; - reader->XmlResolver = resolver; - - // Parse the file. - while ( reader->Read() ) - { - - // Do any additional processing here. - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlSpace/CPP/readspace.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlSpace/CPP/readspace.cpp deleted file mode 100644 index ae4be95667f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlSpace/CPP/readspace.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = gcnew XmlTextReader( "authors.xml" ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Parse the file. Return white space only if an - // xml:space='preserve' attribute is found. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( "<{0}>", reader->Name ); - if ( reader->XmlSpace == XmlSpace::Preserve ) - reader->WhitespaceHandling = WhitespaceHandling::Significant; - break; - - case XmlNodeType::Text: - Console::Write( reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::Write( "", reader->Name ); - break; - - case XmlNodeType::SignificantWhitespace: - Console::Write( reader->Value ); - break; - } - } -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextReader.cctor1/CPP/rdrcctor1.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextReader.cctor1/CPP/rdrcctor1.cpp deleted file mode 100644 index 32f5080e71f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextReader.cctor1/CPP/rdrcctor1.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - String^ xmlData = "\r\n Oberon's Legacy\r\n 5.95\r\n "; - - // Create the reader. - XmlTextReader^ reader = gcnew XmlTextReader( gcnew StringReader( xmlData ) ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Display each element node. - while ( reader->Read() ) - { - switch ( reader->NodeType ) - { - case XmlNodeType::Element: - Console::Write( "<{0}>", reader->Name ); - break; - - case XmlNodeType::Text: - Console::Write( reader->Value ); - break; - - case XmlNodeType::EndElement: - Console::Write( "", reader->Name ); - break; - } - } - - - // Close the reader. - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlTextWriter.Flush/CPP/write2docs.cpp b/snippets/cpp/VS_Snippets_Data/XmlTextWriter.Flush/CPP/write2docs.cpp deleted file mode 100644 index 7457e02c9e8..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlTextWriter.Flush/CPP/write2docs.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - - // Use indenting for readability - writer->Formatting = Formatting::Indented; - - // Write an XML fragment. - writer->WriteStartElement( "book" ); - writer->WriteElementString( "title", "Pride And Prejudice" ); - writer->WriteEndElement(); - writer->Flush(); - - // Write another XML fragment. - writer->WriteStartElement( "cd" ); - writer->WriteElementString( "title", "Americana" ); - writer->WriteEndElement(); - writer->Flush(); - - // Close the writer. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp deleted file mode 100644 index ff9fd542be2..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - - // Create a writer to write XML to the console. - XmlWriterSettings^ settings = gcnew XmlWriterSettings; - settings->Indent = true; - settings->OmitXmlDeclaration = true; - XmlWriter^ writer = XmlWriter::Create( Console::Out, settings ); - - // Write the book element. - writer->WriteStartElement( L"book" ); - - // Write the title element. - writer->WriteStartElement( L"title" ); - writer->WriteString( L"Pride And Prejudice" ); - writer->WriteEndElement(); - - // Write the close tag for the root element. - writer->WriteEndElement(); - - // Write the XML and close the writer. - writer->Close(); - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.Flush/CPP/write2docs_v2.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.Flush/CPP/write2docs_v2.cpp deleted file mode 100644 index ca3bcbf4373..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.Flush/CPP/write2docs_v2.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -void main() -{ - - // Create an XmlWriter to write XML fragments. - XmlWriterSettings^ settings = gcnew XmlWriterSettings; - settings->ConformanceLevel = ConformanceLevel::Fragment; - settings->Indent = true; - XmlWriter^ writer = XmlWriter::Create( Console::Out, settings ); - - // Write an XML fragment. - writer->WriteStartElement( L"book" ); - writer->WriteElementString( L"title", L"Pride And Prejudice" ); - writer->WriteEndElement(); - writer->Flush(); - - // Write another XML fragment. - writer->WriteStartElement( L"cd" ); - writer->WriteElementString( L"title", L"Americana" ); - writer->WriteEndElement(); - writer->Flush(); - - // Close the writer. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributeString/CPP/writeattrstring.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributeString/CPP/writeattrstring.cpp deleted file mode 100644 index 59b7bac475a..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributeString/CPP/writeattrstring.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -void main() -{ - XmlWriter^ writer = nullptr; - writer = XmlWriter::Create( L"sampledata.xml" ); - - // Write the root element. - writer->WriteStartElement( L"book" ); - - // Write the xmlns:bk="urn:book" namespace declaration. - writer->WriteAttributeString( L"xmlns", L"bk", nullptr, L"urn:book" ); - - // Write the bk:ISBN="1-800-925" attribute. - writer->WriteAttributeString( L"ISBN", L"urn:book", L"1-800-925" ); - writer->WriteElementString( L"price", L"19.95" ); - - // Write the close tag for the root element. - writer->WriteEndElement(); - - // Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributes/CPP/writeattrs_v2.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributes/CPP/writeattrs_v2.cpp deleted file mode 100644 index cd4481a5f86..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributes/CPP/writeattrs_v2.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -void main() -{ - XmlReader^ reader = XmlReader::Create( L"test1.xml" ); - XmlWriterSettings^ settings = gcnew XmlWriterSettings; - settings->Indent = true; - XmlWriter^ writer = XmlWriter::Create( Console::Out ); - while ( reader->Read() ) - { - if ( reader->NodeType == XmlNodeType::Element ) - { - writer->WriteStartElement( reader->Name->ToUpper() ); - writer->WriteAttributes( reader, false ); - if ( reader->IsEmptyElement ) - writer->WriteEndElement(); - } - else - if ( reader->NodeType == XmlNodeType::EndElement ) - { - writer->WriteEndElement(); - } - } - - writer->Close(); - reader->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteBase64/CPP/writebase64.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteBase64/CPP/writebase64.cpp deleted file mode 100644 index af773508941..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteBase64/CPP/writebase64.cpp +++ /dev/null @@ -1,143 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Text; -ref class TestBase64 -{ -private: - static int bufferSize = 4096; - -public: - - // Use the WriteBase64 method to create an XML document. The object - // passed by the user is encoded and included in the document. - void EncodeXmlFile( String^ xmlFileName, FileStream^ fileOld ) - { - array^buffer = gcnew array(bufferSize); - int readByte = 0; - XmlTextWriter^ xw = gcnew XmlTextWriter( xmlFileName,Encoding::UTF8 ); - xw->WriteStartDocument(); - xw->WriteStartElement( "root" ); - - // Create a Char writer. - BinaryReader^ br = gcnew BinaryReader( fileOld ); - - // Set the file pointer to the end. - try - { - do - { - readByte = br->Read( buffer, 0, bufferSize ); - xw->WriteBase64( buffer, 0, readByte ); - } - while ( bufferSize <= readByte ); - } - catch ( Exception^ ex ) - { - EndOfStreamException^ ex1 = gcnew EndOfStreamException; - if ( ex1->Equals( ex ) ) - Console::WriteLine( "We are at end of file" ); - else - Console::WriteLine( ex ); - } - - xw->WriteEndElement(); - xw->WriteEndDocument(); - xw->Flush(); - xw->Close(); - } - - // Use the ReadBase64 method to decode the new XML document - // and generate the original object. - void DecodeOrignalObject( String^ xmlFileName, FileStream^ fileNew ) - { - array^buffer = gcnew array(bufferSize); - int readByte = 0; - - // Create a file to write the bmp back. - BinaryWriter^ bw = gcnew BinaryWriter( fileNew ); - XmlTextReader^ tr = gcnew XmlTextReader( xmlFileName ); - tr->MoveToContent(); - Console::WriteLine( tr->Name ); - do - { - readByte = tr->ReadBase64( buffer, 0, bufferSize ); - bw->Write( buffer, 0, readByte ); - } - while ( readByte >= bufferSize ); - - bw->Flush(); - } - - // Compare the two files. - bool CompareResult( FileStream^ fileOld, FileStream^ fileNew ) - { - int readByteOld = 0; - int readByteNew = 0; - int count; - int readByte = 0; - array^bufferOld = gcnew array(bufferSize); - array^bufferNew = gcnew array(bufferSize); - BinaryReader^ binaryReaderOld = gcnew BinaryReader( fileOld ); - BinaryReader^ binaryReaderNew = gcnew BinaryReader( fileNew ); - binaryReaderOld->BaseStream->Seek( 0, SeekOrigin::Begin ); - binaryReaderNew->BaseStream->Seek( 0, SeekOrigin::Begin ); - do - { - readByteOld = binaryReaderOld->Read( bufferOld, 0, bufferSize ); - readByteNew = binaryReaderNew->Read( bufferNew, 0, bufferSize ); - if ( readByteOld != readByteNew ) - return false; - - for ( count = 0; count < bufferSize; ++count ) - if ( bufferOld[ count ] != bufferNew[ count ] ) - return false; - } - while ( count < readByte ); - - return true; - } - - // Display the usage statement. - void Usage() - { - Console::WriteLine( "TestBase64 sourceFile, targetFile \n" ); - Console::WriteLine( "For example: TestBase64 winlogon.bmp, target.bmp\n" ); - } -}; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - TestBase64^ testBase64 = gcnew TestBase64; - - // Check that the usage is correct. - if ( args->Length < 3 ) - { - testBase64->Usage(); - return 1; - } - - FileStream^ fileOld = gcnew FileStream( args[ 1 ],FileMode::OpenOrCreate,FileAccess::Read,FileShare::Read ); - testBase64->EncodeXmlFile( "temp.xml", fileOld ); - FileStream^ fileNew = gcnew FileStream( args[ 2 ],FileMode::Create,FileAccess::ReadWrite,FileShare::ReadWrite ); - testBase64->DecodeOrignalObject( "temp.xml", fileNew ); - - // Compare the two files. - if ( testBase64->CompareResult( fileOld, fileNew ) ) - Console::WriteLine( "The recreated binary file {0} is the same as {1}", args[ 2 ], args[ 1 ] ); - else - Console::WriteLine( "The recreated binary file {0} is not the same as {1}", args[ 2 ], args[ 1 ] ); - - fileOld->Flush(); - fileNew->Flush(); - fileOld->Close(); - fileNew->Close(); - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp deleted file mode 100644 index 1b8726a4f19..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -public ref class Sample -{ -private: - static String^ m_Document = L"sampledata.xml"; - -public: - static void Main() - { - XmlWriter^ writer = nullptr; - try - { - XmlWriterSettings^ settings = gcnew XmlWriterSettings; - settings->Indent = true; - writer = XmlWriter::Create( m_Document,settings ); - writer->WriteComment( L"sample XML fragment" ); - - // Write an element (this one is the root). - writer->WriteStartElement( L"book" ); - - // Write the namespace declaration. - writer->WriteAttributeString( L"xmlns", L"bk", nullptr, L"urn:samples" ); - - // Write the genre attribute. - writer->WriteAttributeString( L"genre", L"novel" ); - - // Write the title. - writer->WriteStartElement( L"title" ); - writer->WriteString( L"The Handmaid's Tale" ); - writer->WriteEndElement(); - - // Write the price. - writer->WriteElementString( L"price", L"19.95" ); - - // Lookup the prefix and write the ISBN element. - String^ prefix = writer->LookupPrefix( L"urn:samples" ); - writer->WriteStartElement( prefix, L"ISBN", L"urn:samples" ); - writer->WriteString( L"1-861003-78" ); - writer->WriteEndElement(); - - // Write the style element (shows a different way to handle prefixes). - writer->WriteElementString( L"style", L"urn:samples", L"hardcover" ); - - // Write the close tag for the root element. - writer->WriteEndElement(); - - // Write the XML to file and close the writer. - writer->Flush(); - writer->Close(); - } - finally - { - if ( writer != nullptr ) - writer->Close(); - } - - } - -}; - -void main() -{ - Sample::Main(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteNode/CPP/writenode.cpp b/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteNode/CPP/writenode.cpp deleted file mode 100644 index a34c595c6da..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteNode/CPP/writenode.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - XmlTextReader^ reader = gcnew XmlTextReader( "books.xml" ); - reader->WhitespaceHandling = WhitespaceHandling::None; - - // Move the reader to the first book element. - reader->MoveToContent(); - reader->Read(); - - // Create a writer that outputs to the console. - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - writer->Formatting = Formatting::Indented; - - // Write the start tag. - writer->WriteStartElement( "myBooks" ); - - // Write the first book. - writer->WriteNode( reader, false ); - - // Skip the second book. - reader->Skip(); - - // Write the last book. - writer->WriteNode( reader, false ); - writer->WriteEndElement(); - - // Close the writer and the reader. - writer->Close(); - reader->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XslTRansform.Transform7/CPP/trans_snip4.cpp b/snippets/cpp/VS_Snippets_Data/XslTRansform.Transform7/CPP/trans_snip4.cpp deleted file mode 100644 index c26844cce27..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XslTRansform.Transform7/CPP/trans_snip4.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; - -int main() -{ - // - // Create a resolver with default credentials. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - resolver->Credentials = System::Net::CredentialCache::DefaultCredentials; - - // Create the XslTransform object. - XslTransform^ xslt = gcnew XslTransform; - - // Load the stylesheet. - xslt->Load( "http://myServer/data/authors.xsl", resolver ); - - // Transform the file. - xslt->Transform( "books.xml", "books.html", resolver ); - // -} diff --git a/snippets/cpp/VS_Snippets_Data/XslTransform.Load3/CPP/trans3.cpp b/snippets/cpp/VS_Snippets_Data/XslTransform.Load3/CPP/trans3.cpp deleted file mode 100644 index c1c69b21c5d..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XslTransform.Load3/CPP/trans3.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; -int main() -{ - String^ filename = "books.xml"; - String^ stylesheet = "titles.xsl"; - - // Create the reader to load the stylesheet. - // Move the reader to the xsl:stylesheet node. - XmlTextReader^ reader = gcnew XmlTextReader( stylesheet ); - reader->Read(); - reader->Read(); - - // Create the XslTransform object and load the stylesheet. - XslTransform^ xslt = gcnew XslTransform; - xslt->Load( reader ); - - // Load the file to transform. - XPathDocument^ doc = gcnew XPathDocument( filename ); - - // Create an XmlTextWriter which outputs to the console. - XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out ); - - // Transform the file and send the output to the console. - xslt->Transform(doc,nullptr,writer); - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XslTransform.Load4/CPP/trans_ev.cpp b/snippets/cpp/VS_Snippets_Data/XslTransform.Load4/CPP/trans_ev.cpp deleted file mode 100644 index 589fa928b67..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XslTransform.Load4/CPP/trans_ev.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; -void TransformFile( XmlReader^ xsltReader, String^ secureURL ); -int main() -{ - String^ stylesheet = "c:\\tmp\\output.xsl"; - String^ myURL = "http://localhost/data"; - XmlTextReader^ reader = gcnew XmlTextReader( stylesheet ); - TransformFile( reader, myURL ); -} - - -// Perform an XSLT transformation where xsltReader is an XmlReader containing -// a stylesheet and secureURI is a trusted URI that can be used to create Evidence. -// -void TransformFile( XmlReader^ xsltReader, String^ secureURL ) -{ - - // Load the stylesheet using a default XmlUrlResolver and Evidence - // created using the trusted URL. - XslTransform^ xslt = gcnew XslTransform; - xslt->Load( xsltReader, gcnew XmlUrlResolver, XmlSecureResolver::CreateEvidenceForUrl( secureURL ) ); - - // Transform the file. - xslt->Transform("books.xml","books.html",gcnew XmlUrlResolver); -} - -// diff --git a/snippets/cpp/VS_Snippets_Data/XslTransform.Transform2/CPP/trans_snip.cpp b/snippets/cpp/VS_Snippets_Data/XslTransform.Transform2/CPP/trans_snip.cpp deleted file mode 100644 index 4b4ca81384f..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XslTransform.Transform2/CPP/trans_snip.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; - -int main() -{ -// - XmlDocument^ doc = gcnew XmlDocument; - doc->Load( "books.xml" ); - - // Modify the XML file. - XmlElement^ root = doc->DocumentElement; - root->FirstChild->LastChild->InnerText = "12.95"; - - // Create an XPathNavigator to use for the transform. - XPathNavigator^ nav = root->CreateNavigator(); - - // Transform the file. - XslTransform^ xslt = gcnew XslTransform; - xslt->Load( "output.xsl" ); - XmlTextWriter^ writer = gcnew XmlTextWriter( "books.html", nullptr ); - xslt->Transform( nav, nullptr, writer, nullptr); -// -} diff --git a/snippets/cpp/VS_Snippets_Data/XslTransform.Transform4/CPP/trans_snip3.cpp b/snippets/cpp/VS_Snippets_Data/XslTransform.Transform4/CPP/trans_snip3.cpp deleted file mode 100644 index 93872c9a3c6..00000000000 --- a/snippets/cpp/VS_Snippets_Data/XslTransform.Transform4/CPP/trans_snip3.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; -using namespace System::Xml::XPath; - -int main() -{ - array^ args = Environment::GetCommandLineArgs(); - String^ UserName = args[ 1 ]; - String^ SecurelyStoredPassword = args[ 2 ]; - String^ Domain = args[ 3 ]; - - // - // Create the XslTransform object. - XslTransform^ xslt = gcnew XslTransform; - - // Load the stylesheet. - xslt->Load( "titles.xsl" ); - - // Create a resolver and specify the necessary credentials. - XmlUrlResolver^ resolver = gcnew XmlUrlResolver; - System::Net::NetworkCredential^ myCred; - myCred = gcnew System::Net::NetworkCredential( UserName, SecurelyStoredPassword, Domain ); - resolver->Credentials = myCred; - - // Transform the file using the resolver. The resolver is used - // to process the XSLT document() function. - XPathDocument^ doc = gcnew XPathDocument( "books.xml" ); - XmlReader^ reader = xslt->Transform( doc, nullptr, resolver ); - - // Load the reader into a new document for more processing. - XmlDocument^ xmldoc = gcnew XmlDocument; - xmldoc->Load( reader ); - // - - Console::WriteLine( xmldoc->OuterXml ); -} diff --git a/snippets/cpp/VS_Snippets_Data/xsltransform.transform3/CPP/trans_snip2.cpp b/snippets/cpp/VS_Snippets_Data/xsltransform.transform3/CPP/trans_snip2.cpp deleted file mode 100644 index 326d279b9ae..00000000000 --- a/snippets/cpp/VS_Snippets_Data/xsltransform.transform3/CPP/trans_snip2.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Xsl; - -int main() -{ - // - // Create the XslTransform object. - XslTransform^ xslt = gcnew XslTransform; - - // Load the stylesheet. - xslt->Load( "output.xsl" ); - - // Transform the file. - xslt->Transform("books.xml","books.html"); - // -} diff --git a/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange/cpp/source.cpp b/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange/cpp/source.cpp deleted file mode 100644 index df2c6373e93..00000000000 --- a/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange/cpp/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*System::Net::HttpWebRequest->AddRange(int, int) -This program demonstrates 'AddRange(int, int)' method of 'HttpWebRequest class. -A new 'HttpWebRequest' Object* is created. The number of characters of the response to be received can be -restricted by the 'AddRange' method.By calling 'AddRange(50, 150)' on the 'HttpWebRequest' Object* the content -of the response page is restricted from the 50th character to 150th charater. The response of the request is -obtained and displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -int main() -{ - try - { -// - // Create a New 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest1 = - (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest1->AddRange( 1000); - Console::WriteLine("Call AddRange(1000)"); - Console::Write("Resulting Headers: "); - Console::WriteLine(myHttpWebRequest1->Headers); - - HttpWebRequest^ myHttpWebRequest2 = - (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest2->AddRange(-1000); - Console::WriteLine("Call AddRange(-1000)"); - Console::Write("Resulting Headers: "); - Console::WriteLine(myHttpWebRequest2->Headers); - -// - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/cpp/source.cpp b/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/cpp/source.cpp deleted file mode 100644 index 68d09127497..00000000000 --- a/snippets/cpp/VS_Snippets_Misc/system.net.httpwebrequest.addrange2/cpp/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*System::Net::HttpWebRequest->AddRange(int, int) -This program demonstrates 'AddRange(int, int)' method of 'HttpWebRequest class. -A new 'HttpWebRequest' Object* is created. The number of characters of the response to be received can be -restricted by the 'AddRange' method.By calling 'AddRange(50, 150)' on the 'HttpWebRequest' Object* the content -of the response page is restricted from the 50th character to 150th charater. The response of the request is -obtained and displayed to the console. -*/ - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Net; - -int main() -{ - try - { -// - // Create a New 'HttpWebRequest' object. - HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) ); - myHttpWebRequest->AddRange( 50, 150 ); - Console::WriteLine("Call AddRange(50, 150)"); - Console::Write("Resulting Request Headers: "); - Console::WriteLine(myHttpWebRequest->Headers); - - // Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable. - HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() ); - - // Displays the headers in the response received - Console::Write("Resulting Response Headers: "); - Console::WriteLine(myHttpWebResponse->Headers); - - // Display the contents of the page to the console. - Stream^ streamResponse = myHttpWebResponse->GetResponseStream(); - StreamReader^ streamRead = gcnew StreamReader( streamResponse ); - array^ readBuffer = gcnew array(256); - int count = streamRead->Read( readBuffer, 0, 256 ); - Console::WriteLine( "\nThe HTML contents of the page from 50th to 150 charaters are :\n " ); - while ( count > 0 ) - { - String^ outputData = gcnew String( readBuffer,0,count ); - Console::WriteLine( outputData ); - count = streamRead->Read( readBuffer, 0, 256 ); - } - streamRead->Close(); - streamResponse->Close(); - myHttpWebResponse->Close(); -// - Console::WriteLine( "\nPress 'Enter' Key to Continue..........." ); - Console::Read(); - } - catch ( WebException^ e ) - { - Console::WriteLine( "\nWebException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nException Caught!" ); - Console::WriteLine( "Message : {0} ", e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp deleted file mode 100644 index 557ea7d00c8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class XClass -{ -public: - - /* Apply the XmlAnyElementAttribute to a field returning an array - of XmlElement objects. */ - - [XmlAnyElement] - array^AllElements; -}; - -public ref class Test -{ -public: - void DeserializeObject( String^ filename ) - { - // Create an XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( XClass::typeid ); - - // To read a file, a FileStream is needed. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Deserialize the class. - XClass^ x = dynamic_cast(mySerializer->Deserialize( fs )); - - // Read the element names and values. - System::Collections::IEnumerator^ myEnum = x->AllElements->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - XmlElement^ xel = safe_cast(myEnum->Current); - Console::WriteLine( "{0}: {1}", xel->LocalName, xel->Value ); - } - } -}; - -int main() -{ - Test^ t = gcnew Test; - t->DeserializeObject( "XFile.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp deleted file mode 100644 index 7824f3ba5cb..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,132 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -public ref class Item -{ -public: - - [XmlElement(ElementName="OrderItem")] - String^ ItemName; - String^ ItemCode; - Decimal ItemPrice; - int ItemQuantity; -}; - -public ref class BookItem: public Item -{ -public: - String^ Title; - String^ Author; - String^ ISBN; -}; - -// This is the class that will be serialized. -public ref class MyRootClass -{ -private: - array^items; - -public: - - /* Here is a simple way to serialize the array as XML. Using the - XmlArrayAttribute, assign an element name and namespace. The - IsNullable property determines whether the element will be - generated if the field is set to a null value. If set to true, - the default, setting it to a null value will cause the XML - xsi:null attribute to be generated. */ - - [XmlArray(ElementName="MyStrings", - Namespace="http://www.cpandl.com",IsNullable=true)] - array^MyStringArray; - - /* Here is a more complex example of applying an - XmlArrayAttribute. The Items property can contain both Item - and BookItem objects. Use the XmlArrayItemAttribute to specify - that both types can be inserted into the array. */ - [XmlArrayItem(ElementName="Item", - IsNullable=true, - Type=Item::typeid, - Namespace="http://www.cpandl.com"), - XmlArrayItem(ElementName="BookItem", - IsNullable=true, - Type=BookItem::typeid, - Namespace="http://www.cohowinery.com")] - [XmlArray] - property array^ Items - { - array^ get() - { - return items; - } - - void set( array^value ) - { - items = value; - } - } -}; - -public ref class Run -{ -public: - void SerializeDocument( String^ filename ) - { - // Creates a new XmlSerializer. - XmlSerializer^ s = gcnew XmlSerializer( MyRootClass::typeid ); - - // Writing the file requires a StreamWriter. - TextWriter^ myWriter = gcnew StreamWriter( filename ); - - // Creates an instance of the class to serialize. - MyRootClass^ myRootClass = gcnew MyRootClass; - - /* Uses a basic method of creating an XML array: Create and - populate a string array, and assign it to the - MyStringArray property. */ - array^myString = {"Hello","world","!"}; - myRootClass->MyStringArray = myString; - - /* Uses a more advanced method of creating an array: - create instances of the Item and BookItem, where BookItem - is derived from Item. */ - Item^ item1 = gcnew Item; - BookItem^ item2 = gcnew BookItem; - - // Sets the objects' properties. - item1->ItemName = "Widget1"; - item1->ItemCode = "w1"; - item1->ItemPrice = 231; - item1->ItemQuantity = 3; - item2->ItemCode = "w2"; - item2->ItemPrice = 123; - item2->ItemQuantity = 7; - item2->ISBN = "34982333"; - item2->Title = "Book of Widgets"; - item2->Author = "John Smith"; - - // Fills the array with the items. - array^myItems = {item1,item2}; - - // Sets the class's Items property to the array. - myRootClass->Items = myItems; - - /* Serializes the class, writes it to disk, and closes - the TextWriter. */ - s->Serialize( myWriter, myRootClass ); - myWriter->Close(); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeDocument( "books.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp deleted file mode 100644 index dc6cfc478ab..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Book -{ -public: - String^ Title; - String^ Author; - String^ ISBN; -}; - -public ref class Library -{ -private: - array^books; - -public: - - [XmlArray(ElementName="My_Books")] - property array^ Books - { - array^ get() - { - return books; - } - - void set( array^value ) - { - books = value; - } - } -}; - -int main() -{ - String^ filename = "ArrayExample.xml"; - XmlSerializer^ mySerializer = gcnew XmlSerializer( Library::typeid ); - TextWriter^ t = gcnew StreamWriter( filename ); - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - ns->Add( "bk", "http://wwww.contoso.com" ); - Book^ b1 = gcnew Book; - b1->Title = "MyBook Title"; - b1->Author = "An Author"; - b1->ISBN = "00000000"; - Book^ b2 = gcnew Book; - b2->Title = "Another Title"; - b2->Author = "Another Author"; - b2->ISBN = "0000000"; - Library^ myLibrary = gcnew Library; - array^myBooks = {b1,b2}; - myLibrary->Books = myBooks; - mySerializer->Serialize( t, myLibrary, ns ); - t->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 84965bcbf7a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,111 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; -public ref class Winery -{ -public: - String^ Name; -}; - -public ref class VacationCompany -{ -public: - String^ Name; -}; - -public ref class Enterprises -{ -private: - array^wineries; - array^companies; - -public: - - // Sets the Form property to qualified, and specifies the namespace. - [XmlArray(Form=XmlSchemaForm::Qualified,ElementName="Company", - Namespace="http://www.cohowinery.com")] - property array^ Wineries - { - array^ get() - { - return wineries; - } - void set( array^value ) - { - wineries = value; - } - } - - [XmlArray(Form=XmlSchemaForm::Qualified,ElementName="Company", - Namespace="http://www.treyresearch.com")] - property array^ Companies - { - array^ get() - { - return companies; - } - void set( array^value ) - { - companies = value; - } - } -}; - -int main() -{ - String^ filename = "MyEnterprises.xml"; - - // Creates an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Enterprises::typeid ); - - // Writing file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Creates an instance of the XmlSerializerNamespaces class. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Adds namespaces and prefixes for the XML document instance. - ns->Add( "winery", "http://www.cohowinery.com" ); - ns->Add( "vacationCompany", "http://www.treyresearch.com" ); - - // Creates an instance of the class that will be serialized. - Enterprises^ myEnterprises = gcnew Enterprises; - - // Creates objects and adds to the array. - Winery^ w1 = gcnew Winery; - w1->Name = "cohowinery"; - array^myWinery = {w1}; - myEnterprises->Wineries = myWinery; - VacationCompany^ com1 = gcnew VacationCompany; - com1->Name = "adventure-works"; - array^myCompany = {com1}; - myEnterprises->Companies = myCompany; - - // Serializes the class, and closes the TextWriter. - mySerializer->Serialize( writer, myEnterprises, ns ); - writer->Close(); -} - -void ReadEnterprises( String^ filename ) -{ - XmlSerializer^ mySerializer = gcnew XmlSerializer( Enterprises::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Enterprises^ myEnterprises = dynamic_cast(mySerializer->Deserialize( fs )); - for ( int i = 0; i < myEnterprises->Wineries->Length; i++ ) - { - Console::WriteLine( myEnterprises->Wineries[ i ]->Name ); - } - for ( int i = 0; i < myEnterprises->Companies->Length; i++ ) - { - Console::WriteLine( myEnterprises->Companies[ i ]->Name ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index b04f9de845e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlArray(IsNullable=true)] - array^IsNullableIsTrueArray; - - [XmlArray(IsNullable=false)] - array^IsNullableIsFalseArray; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index ffc20656b48..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,162 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Book -{ -public: - String^ Title; - String^ Author; - String^ ISBN; - - [XmlAttributeAttribute] - String^ Publisher; -}; - -public ref class Periodical -{ -private: - String^ title; - -public: - - property String^ Title - { - String^ get() - { - return title; - } - void set( String^ value ) - { - title = value; - } - } -}; - -public ref class Library -{ -private: - array^books; - array^periodicals; - -public: - - /* This element will be qualified with the prefix - that is associated with the namespace http://wwww.cpandl.com. */ - [XmlArray(ElementName="Titles", - Namespace="http://wwww.cpandl.com")] - property array^ Books - { - array^ get() - { - return books; - } - void set( array^value ) - { - books = value; - } - } - - /* This element will be qualified with the prefix that is - associated with the namespace http://www.proseware.com. */ - [XmlArray(ElementName="Titles",Namespace= - "http://www.proseware.com")] - property array^ Periodicals - { - array^ get() - { - return periodicals; - } - void set( array^value ) - { - periodicals = value; - } - } -}; - -void WriteBook( String^ filename ) -{ - // Creates a new XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Library::typeid ); - - // Writing the file requires a StreamWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - /* Creates an XmlSerializerNamespaces and adds prefixes and - namespaces to be used. */ - XmlSerializerNamespaces^ myNamespaces = gcnew XmlSerializerNamespaces; - myNamespaces->Add( "books", "http://wwww.cpandl.com" ); - myNamespaces->Add( "magazines", "http://www.proseware.com" ); - - // Creates an instance of the class to be serialized. - Library^ myLibrary = gcnew Library; - - // Creates two book objects. - Book^ b1 = gcnew Book; - b1->Title = "My Book Title"; - b1->Author = "An Author"; - b1->ISBN = "000000000"; - b1->Publisher = "Microsoft Press"; - Book^ b2 = gcnew Book; - b2->Title = "Another Book Title"; - b2->Author = "Another Author"; - b2->ISBN = "00000001"; - b2->Publisher = "Another Press"; - - /* Creates an array using the objects, and sets the Books property - to the array. */ - array^myBooks = {b1,b2}; - myLibrary->Books = myBooks; - - // Creates two Periodical objects. - Periodical^ per1 = gcnew Periodical; - per1->Title = "My Magazine Title"; - Periodical^ per2 = gcnew Periodical; - per2->Title = "Another Magazine Title"; - - // Sets the Periodicals property to the array. - array^myPeridocials = {per1,per2}; - myLibrary->Periodicals = myPeridocials; - - // Serializes the myLibrary object. - mySerializer->Serialize( myStreamWriter, myLibrary, myNamespaces ); - myStreamWriter->Close(); -} - -void ReadBook( String^ filename ) -{ - /* Creates an instance of an XmlSerializer - with the class used to read the document. */ - XmlSerializer^ mySerializer = gcnew XmlSerializer( Library::typeid ); - - // A FileStream is needed to read the file. - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Library^ myLibrary = dynamic_cast(mySerializer->Deserialize( myFileStream )); - - // Reads each book in the array returned by the Books property. - for ( int i = 0; i < myLibrary->Books->Length; i++ ) - { - Console::WriteLine( myLibrary->Books[ i ]->Title ); - Console::WriteLine( myLibrary->Books[ i ]->Author ); - Console::WriteLine( myLibrary->Books[ i ]->ISBN ); - Console::WriteLine( myLibrary->Books[ i ]->Publisher ); - Console::WriteLine(); - } - for ( int i = 0; i < myLibrary->Periodicals->Length; i++ ) - { - Console::WriteLine( myLibrary->Periodicals[ i ]->Title ); - } -} - -int main() -{ - WriteBook( "MyLibrary.xml" ); - ReadBook( "MyLibrary.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp deleted file mode 100644 index 78a6040f3fa..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlArrayAttribute] - array^MyStringArray; - - [XmlArrayAttribute] - array^MyIntegerArray; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp deleted file mode 100644 index 9b68919eff8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class MyClass -{ -public: - - [XmlArrayAttribute("MyStrings")] - array^MyStringArray; - - [XmlArrayAttribute(ElementName="MyIntegers")] - array^MyIntegerArray; -}; - -int main() -{ - String^ filename = "MyClass.xml"; - - // Creates a new instance of the XmlSerializer class. - XmlSerializer^ s = gcnew XmlSerializer( MyClass::typeid ); - - // Needs a StreamWriter to write the file. - TextWriter^ myWriter = gcnew StreamWriter( filename ); - MyClass^ myClass = gcnew MyClass; - - // Creates and populates a string array, then assigns - // it to the MyStringArray property. - array^myStrings = {"Hello","World","!"}; - myClass->MyStringArray = myStrings; - - /* Creates and populates an integer array, and assigns - it to the MyIntegerArray property. */ - array^myIntegers = {1,2,3}; - myClass->MyIntegerArray = myIntegers; - - // Serializes the class, and writes it to disk. - s->Serialize( myWriter, myClass ); - myWriter->Close(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp deleted file mode 100644 index 7504aad63a3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,93 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - /* The XmlArrayItemAttribute allows the XmlSerializer to insert - both the base type (Employee) and derived type (Manager) - into serialized arrays. */ - - [XmlArrayItem(Manager::typeid), - XmlArrayItem(Employee::typeid)] - array^Employees; - - /* Use the XmlArrayItemAttribute to specify types allowed - in an array of Object items. */ - - [XmlArray] - [XmlArrayItem(Int32::typeid, - ElementName="MyNumber"), - XmlArrayItem(String::typeid, - ElementName="MyString"), - XmlArrayItem(Manager::typeid)] - array^ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // Creates a new XmlSerializer. - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - Group^ group = gcnew Group; - Manager^ manager = gcnew Manager; - Employee^ emp1 = gcnew Employee; - Employee^ emp2 = gcnew Employee; - manager->Name = "Consuela"; - manager->Level = 3; - emp1->Name = "Seiko"; - emp2->Name = "Martina"; - array^emps = {manager,emp1,emp2}; - group->Employees = emps; - - // Creates an int and a string and assigns to ExtraInfo. - array^temp = {43,"Extra",manager}; - group->ExtraInfo = temp; - - // Serializes the object, and closes the StreamWriter. - s->Serialize( writer, group ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlSerializer^ x = gcnew XmlSerializer( Group::typeid ); - Group^ g = dynamic_cast(x->Deserialize( fs )); - Console::WriteLine( "Members:" ); - System::Collections::IEnumerator^ myEnum = g->Employees->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Employee^ e = safe_cast(myEnum->Current); - Console::WriteLine( "\t{0}", e->Name ); - } -} - -int main() -{ - SerializeObject( "TypeDoc.xml" ); - DeserializeObject( "TypeDoc.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp deleted file mode 100644 index 1ad1f494f35..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// By default, this class results in XML elements named "Vehicle". -public ref class Vehicle -{ -public: - String^ id; -}; - -// By default, this class results in XML elements named "Car". -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - /* Specifies acceptable types and the ElementName generated - for each object type. */ - - [XmlArray("Vehicles")] - [XmlArrayItem(Vehicle::typeid,ElementName="Transport"), - XmlArrayItem(Car::typeid,ElementName="Automobile")] - array^MyVehicles; -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 6f0101ea001..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -// -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - // Specifies the Form property value. - - [XmlArray("Vehicles")] - [XmlArrayItem(Vehicle::typeid, - Form=XmlSchemaForm::Unqualified), - XmlArrayItem(Car::typeid, - Form=XmlSchemaForm::Qualified)] - array^MyVehicles; -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index 10b3c35b2f1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - [XmlArray(IsNullable=true)] - [XmlArrayItem(Manager::typeid,IsNullable=false), - XmlArrayItem(Employee::typeid,IsNullable=false)] - array^Employees; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Creates the object to serialize. - Group^ group = gcnew Group; - - // Creates a null Manager object. - Manager^ mgr = nullptr; - - // Creates a null Employee object. - Employee^ y = nullptr; - array^temp = {mgr,y}; - group->Employees = temp; - - // Serializes the object and closes the TextWriter. - s->Serialize( writer, group ); - writer->Close(); -} - -int main() -{ - SerializeObject( "TypeDoc.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 41cc05bd344..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Vehicle{}; - -public ref class Car: public Vehicle{}; - -// -public ref class Transportation -{ -public: - - // Sets the Namespace property. - - [XmlArrayItem(Car::typeid,Namespace="http://www.cpandl.com")] - array^MyVehicles; -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp deleted file mode 100644 index b249fa9707c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Person -{ -public: - String^ Name; -}; - -public ref class Manager: public Person -{ -public: - int Rank; -}; - -public ref class Group -{ -public: - - /* The Type property instructs the XmlSerializer to accept both - the Person and Manager types in the array. */ - - [XmlArrayItem(Type=Manager::typeid), - XmlArrayItem(Type=Person::typeid)] - array^Staff; -}; - -void SerializeOrder( String^ filename ) -{ - // Creates an XmlSerializer. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid ); - - // Creates the Group object, and two array items. - Group^ myGroup = gcnew Group; - Person^ p1 = gcnew Person; - p1->Name = "Jacki"; - Manager^ p2 = gcnew Manager; - p2->Name = "Megan"; - p2->Rank = 2; - array^myStaff = {p1,p2}; - myGroup->Staff = myStaff; - - // Serializes the object, and closes the StreamWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myGroup ); -} - -int main() -{ - SerializeOrder( "TypeEx.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp deleted file mode 100644 index 153e7b6e3d2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,75 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArrayItem, - XmlArrayItem(Car::typeid,ElementName="Automobile")] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer for the Transportation class. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - - // Creates the object to serialize. - Transportation^ myTransportation = gcnew Transportation; - - // Creates objects to add to the array. - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^temp = {myVehicle,myCar}; - myTransportation->MyVehicles = temp; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates an XmlSerializer instance. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem1.xml" ); - DeserializeObject( "XmlArrayItem1.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp deleted file mode 100644 index 27560a12758..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArrayItem(ElementName="Transportation"), - XmlArrayItem(Car::typeid,ElementName="Automobile")] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer for the Transportation class. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - Transportation^ myTransportation = gcnew Transportation; - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^myVehicles = {myVehicle,myCar}; - myTransportation->MyVehicles = myVehicles; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates the serializer with the type to deserialize. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem2.xml" ); - DeserializeObject( "XmlArrayItem2.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp deleted file mode 100644 index 8809b40c0af..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArrayItem(Vehicle::typeid), - XmlArrayItem(Car::typeid)] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - Transportation^ myTransportation = gcnew Transportation; - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^myVehicles = {myVehicle,myCar}; - myTransportation->MyVehicles = myVehicles; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates the serializer with the type to deserialize. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem3.xml" ); - DeserializeObject( "XmlArrayItem3.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp deleted file mode 100644 index 6886a80fe91..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Vehicle -{ -public: - String^ id; -}; - -public ref class Car: public Vehicle -{ -public: - String^ Maker; -}; - -public ref class Transportation -{ -public: - - [XmlArray] - [XmlArrayItem("Transport",Vehicle::typeid), - XmlArrayItem("Automobile",Car::typeid)] - array^MyVehicles; -}; - -void SerializeObject( String^ filename ) -{ - // Creates an XmlSerializer for the Transportation class. - XmlSerializer^ MySerializer = gcnew XmlSerializer( Transportation::typeid ); - - // Writing the XML file to disk requires a TextWriter. - TextWriter^ myTextWriter = gcnew StreamWriter( filename ); - Transportation^ myTransportation = gcnew Transportation; - Vehicle^ myVehicle = gcnew Vehicle; - myVehicle->id = "A12345"; - Car^ myCar = gcnew Car; - myCar->id = "Car 34"; - myCar->Maker = "FamousCarMaker"; - array^myVehicles = {myVehicle,myCar}; - myTransportation->MyVehicles = myVehicles; - - // Serializes the object, and closes the StreamWriter. - MySerializer->Serialize( myTextWriter, myTransportation ); - myTextWriter->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Creates an XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Transportation::typeid ); - FileStream^ myFileStream = gcnew FileStream( filename,FileMode::Open ); - Transportation^ myTransportation = dynamic_cast(mySerializer->Deserialize( myFileStream )); - for ( int i = 0; i < myTransportation->MyVehicles->Length; i++ ) - { - Console::WriteLine( myTransportation->MyVehicles[ i ]->id ); - } -} - -int main() -{ - SerializeObject( "XmlArrayItem4.xml" ); - DeserializeObject( "XmlArrayItem4.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp deleted file mode 100644 index ded3d3f240a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,54 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - - [XmlAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; - - [XmlAttributeAttribute(DataType="base64Binary")] - array^GroupNumber; - - [XmlAttributeAttribute(DataType="date",AttributeName="CreationDate")] - DateTime Today; -}; - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - array^hexByte = {Convert::ToByte( 100 ),Convert::ToByte( 50 )}; - myGroup->GroupNumber = hexByte; - DateTime myDate = DateTime(2001,1,10); - myGroup->Today = myDate; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "Attributes.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp deleted file mode 100644 index bf8889f6772..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Group -{ -public: - - // Change the XML attribute name. - - [XmlAttributeAttribute(AttributeName="MgrName")] - String^ Name; - /* Use the AttributeName to collect all the XML attributes - in the XML-document instance. */ -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Serializing" ); - - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - /* Set the Name property, which will be generated - as an XML attribute. */ - myGroup->Name = "Wallace"; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Deserializing" ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myGroup->Name ); -} - -int main() -{ - /* To use the AttributeName to collect all the - XML attributes. Call SerializeObject to generate - an XML document and alter the document by adding - new XML attributes to it. Then comment out the SerializeObject - method, and call DeserializeObject. */ - SerializeObject( "MyAtts.xml" ); - DeserializeObject( "MyAtts.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp deleted file mode 100644 index dbc9a73c48f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Group -{ -public: - - [XmlAttributeAttribute(DataType="string")] - String^ Name; - - [XmlAttributeAttribute(DataType="base64Binary")] - array^Hex64Code; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 37de504e9b7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,23 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -// -public ref class Vehicle -{ -public: - - [XmlAttributeAttribute(Form=XmlSchemaForm::Qualified)] - String^ Maker; - - [XmlAttributeAttribute(Form=XmlSchemaForm::Unqualified)] - String^ ModelID; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 8cd4fd710f3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Car -{ -public: - - [XmlAttributeAttribute(Namespace="Make")] - String^ MakerName; - - [XmlAttributeAttribute(Namespace="Model")] - String^ ModelName; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp deleted file mode 100644 index 4dc40d33dd2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownAttribute( Object^ /*sender*/, XmlAttributeEventArgs^ e ) - { - System::Xml::XmlAttribute^ attr = e->Attr; - Console::WriteLine( "Unknown Attribute Name and Value: {0} = '{1}'", - attr->Name, attr->Value ); - Object^ x = e->ObjectBeingDeserialized; - Console::WriteLine( "ObjectBeingDeserialized: {0}", x ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp deleted file mode 100644 index 5d23724e8ea..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp +++ /dev/null @@ -1,113 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -public ref class Instrument -{ -public: - String^ Name; -}; - -public ref class Brass: public Instrument -{ -public: - bool IsValved; -}; - -public ref class Orchestra -{ -public: - array^Instruments; -}; - -void SerializeObject( String^ filename ) -{ - /* Each overridden field, property, or type requires - an XmlAttributes object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Create an XmlElementAttribute to override the - field that returns Instrument objects. The overridden field - returns Brass objects instead. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the element to the collection of elements. - attrs->XmlElements->Add( attr ); - - // Create the XmlAttributeOverrides object. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - /* Add the type of the class that contains the overridden - member and the XmlAttributes to override it with to the - XmlAttributeOverrides object. */ - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object that will be serialized. - Orchestra^ band = gcnew Orchestra; - - // Create an object of the derived type. - Brass^ i = gcnew Brass; - i->Name = "Trumpet"; - i->IsValved = true; - array^myInstruments = {i}; - band->Instruments = myInstruments; - - // Serialize the object. - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Create an XmlElementAttribute to override the Instrument. - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the XmlElementAttribute to the collection of objects. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Orchestra^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - - /* The difference between deserializing the overridden - XML document and serializing it is this: To read the derived - object values, you must declare an object of the derived type - (Brass), and cast the Instrument instance to it. */ - Brass^ b; - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - b = dynamic_cast(i); - Console::WriteLine( "{0}\n{1}", b->Name, b->IsValved ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp deleted file mode 100644 index e474a5694c3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp +++ /dev/null @@ -1,102 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -ref class Band; -ref class Instrument; - -/* This is the class that will be overridden. The XmlIncludeAttribute -tells the XmlSerializer that the overriding type exists. */ - -[XmlInclude(Band::typeid)] -public ref class Orchestra -{ -public: - array^Instruments; -}; - -// This is the overriding class. -public ref class Band: public Orchestra -{ -public: - String^ BandName; -}; - -public ref class Instrument -{ -public: - String^ Name; -}; - -void SerializeObject( String^ filename ) -{ - /* Each object that is being overridden requires - an XmlAttributes object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - - // An XmlRootAttribute allows overriding the Orchestra class. - XmlRootAttribute^ xmlRoot = gcnew XmlRootAttribute; - - // Set the object to the XmlAttribute.XmlRoot property. - attrs->XmlRoot = xmlRoot; - - // Create an XmlAttributeOverrides object. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - // Add the XmlAttributes to the XmlAttributeOverrrides. - attrOverrides->Add( Orchestra::typeid, attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object using the derived class. - Band^ band = gcnew Band; - band->BandName = "NewBand"; - - // Create an Instrument. - Instrument^ i = gcnew Instrument; - i->Name = "Trumpet"; - array^myInstruments = {i}; - band->Instruments = myInstruments; - - // Serialize the object. - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlRootAttribute^ attr = gcnew XmlRootAttribute; - attrs->XmlRoot = attr; - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Deserialize the Band object. - Band^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - Console::WriteLine( i->Name ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp deleted file mode 100644 index ae9b594d0f2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -public ref class Sample -{ -public: - XmlSerializer^ CreateOverrider() - { - // Create an XmlAttributeOverrides object. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlAttributeAttribute to override the base class - object's XmlAttributeAttribute object. Give the overriding object - a new attribute name ("Code"). */ - XmlAttributeAttribute^ xAtt = gcnew XmlAttributeAttribute; - xAtt->AttributeName = "Code"; - - /* Create an instance of the XmlAttributes class and set the - XmlAttribute property to the XmlAttributeAttribute object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - attrs->XmlAttribute = xAtt; - - /* Add the XmlAttributes object to the XmlAttributeOverrides - and specify the type and member name to override. */ - xOver->Add( Group::typeid, "GroupCode", attrs ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp deleted file mode 100644 index d9d43cdf6b3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -public ref class Sample -{ -public: - XmlSerializer^ CreateOverrider() - { - // Create an XmlSerializer with overriding attributes. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - - // Set a new Namespace and ElementName for the root element. - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->ElementName = "NewGroup"; - attrs->XmlRoot = xRoot; - xOver->Add( Group::typeid, attrs ); - - // Get the XmlAttributes object, based on the type. - XmlAttributes^ tempAttrs; - tempAttrs = xOver[ Group::typeid ]; - - // Print the Namespace and ElementName of the root. - Console::WriteLine( tempAttrs->XmlRoot->Namespace ); - Console::WriteLine( tempAttrs->XmlRoot->ElementName ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp deleted file mode 100644 index 099c81b6664..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -public ref class Sample -{ -public: - XmlSerializer^ CreateOverrider() - { - // Create an XmlSerializer with overriding attributes. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlAttributeAttribute object and set the - AttributeName property. */ - XmlAttributeAttribute^ xAtt = gcnew XmlAttributeAttribute; - xAtt->AttributeName = "Code"; - - /* Create a new XmlAttributes object and set the - XmlAttributeAttribute object to the XmlAttribute property. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - attrs->XmlAttribute = xAtt; - - /* Add the XmlAttributes to the XmlAttributeOverrides object. The - name of the overridden attribute must be specified. */ - xOver->Add( Group::typeid, "GroupCode", attrs ); - - // Get the XmlAttributes object for the type and member. - XmlAttributes^ tempAttrs; - tempAttrs = xOver[Group::typeid, "GroupCode"]; - Console::WriteLine( tempAttrs->XmlAttribute->AttributeName ); - - // Create the XmlSerializer instance and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp deleted file mode 100644 index c0960e934fc..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp +++ /dev/null @@ -1,85 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Member -{ -public: - String^ MemberName; -}; - - -// This is the class that will be serialized. -public ref class Group -{ -public: - - // This field will be overridden. - array^Members; -}; - - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Creating XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an override for the XmlArray. - XmlArrayAttribute^ xArray = gcnew XmlArrayAttribute( "Staff" ); - xArray->Namespace = "http://www.cpandl.com"; - xAttrs->XmlArray = xArray; - xOver->Add( Group::typeid, "Members", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - Member^ m = gcnew Member; - m->MemberName = "Paul"; - array^temp = {m}; - myGroup->Members = temp; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - System::Collections::IEnumerator^ myEnum = myGroup->Members->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Member^ m = safe_cast(myEnum->Current); - Console::WriteLine( m->MemberName ); - } -} - -int main() -{ - SerializeObject( "OverrideArray.xml" ); - DeserializeObject( "OverrideArray.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp deleted file mode 100644 index d2aff93a0ce..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp +++ /dev/null @@ -1,107 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Member -{ -public: - String^ MemberName; -}; - -// This is the class that will be serialized. -public ref class Group -{ -public: - array^Members; -}; - -public ref class NewMember: public Member -{ -public: - int MemberID; -}; - -public ref class RetiredMember: public NewMember -{ -public: - DateTime RetireDate; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an override for the XmlArrayItem. - XmlArrayItemAttribute^ xArrayItem = gcnew XmlArrayItemAttribute( NewMember::typeid ); - xArrayItem->Namespace = "http://www.cpandl.com"; - xAttrs->XmlArrayItems->Add( xArrayItem ); - - // Add a second override. - XmlArrayItemAttribute^ xArrayItem2 = gcnew XmlArrayItemAttribute( RetiredMember::typeid ); - xArrayItem2->Namespace = "http://www.cpandl.com"; - xAttrs->XmlArrayItems->Add( xArrayItem2 ); - - // Add all overrides to XmlAttribueOverrides object. - xOver->Add( Group::typeid, "Members", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - NewMember^ m = gcnew NewMember; - m->MemberName = "Paul"; - m->MemberID = 2; - - // Create a second member. - RetiredMember^ m2 = gcnew RetiredMember; - m2->MemberName = "Renaldo"; - m2->MemberID = 23; - m2->RetireDate = DateTime(2000,10,10); - array^temp = {m,m2}; - myGroup->Members = temp; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - System::Collections::IEnumerator^ myEnum = myGroup->Members->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Member^ m = safe_cast(myEnum->Current); - Console::WriteLine( m->MemberName ); - } -} - -int main() -{ - SerializeObject( "OverrideArrayItem.xml" ); - DeserializeObject( "OverrideArrayItem.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp deleted file mode 100644 index 080d02f704e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,78 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - - // This is the attribute that will be overridden. - - [XmlAttributeAttribute] - String^ GroupName; - int GroupNumber; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - /* Create an overriding XmlAttributeAttribute set it to - the XmlAttribute property of the XmlAttributes object.*/ - XmlAttributeAttribute^ xAttribute = gcnew XmlAttributeAttribute( "SplinterName" ); - xAttrs->XmlAttribute = xAttribute; - - // Add to the XmlAttributeOverrides. Specify the member name. - xOver->Add( Group::typeid, "GroupName", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - /* Set the Name property, which will be generated - as an XML attribute. */ - myGroup->GroupName = ".NET"; - myGroup->GroupNumber = 1; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( myGroup->GroupNumber ); -} - -int main() -{ - SerializeObject( "OverrideAttribute.xml" ); - DeserializeObject( "OverrideAttribute.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp deleted file mode 100644 index 79e6e301177..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,112 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Instrument -{ -public: - String^ Name; -}; - -public ref class Brass: public Instrument -{ -public: - bool IsValved; -}; - -public ref class Orchestra -{ -public: - array^Instruments; -}; - -void SerializeObject( String^ filename ) -{ - /* Each overridden field, property, or type requires - an XmlAttributes object. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Create an XmlElementAttribute to override the - field that returns Instrument objects. The overridden field - returns Brass objects instead. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the element to the collection of elements. - attrs->XmlElements->Add( attr ); - - // Create the XmlAttributeOverrides object. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - /* Add the type of the class that contains the overridden - member and the XmlAttributes to override it with to the - XmlAttributeOverrides object. */ - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object that will be serialized. - Orchestra^ band = gcnew Orchestra; - - // Create an object of the derived type. - Brass^ i = gcnew Brass; - i->Name = "Trumpet"; - i->IsValved = true; - array^myInstruments = {i}; - band->Instruments = myInstruments; - - // Serialize the object. - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Create an XmlElementAttribute to override the Instrument. - XmlElementAttribute^ attr = gcnew XmlElementAttribute; - attr->ElementName = "Brass"; - attr->Type = Brass::typeid; - - // Add the element to the collection of elements. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Orchestra^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - - /* The difference between deserializing the overridden - XML document and serializing it is this: To read the derived - object values, you must declare an object of the derived type - (Brass), and cast the Instrument instance to it. */ - Brass^ b; - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - b = dynamic_cast(i); - Console::WriteLine( "{0}\n{1}", b->Name, b->IsValved ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp deleted file mode 100644 index 40f6a96deb7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp +++ /dev/null @@ -1,88 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::ComponentModel; - -// This is the class that will be serialized. -public ref class Pet -{ -public: - - // The default value for the Animal field is "Dog". - - [DefaultValueAttribute("Dog")] - String^ Animal; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an override for the default value of the GroupName. - Object^ defaultAnimal = "Cat"; - xAttrs->XmlDefaultValue = defaultAnimal; - - // Add all the XmlAttributes to the XmlAttributeOverrides object. - xOver->Add( Pet::typeid, "Animal", xAttrs ); - - // Create the XmlSerializer and return it. - return gcnew XmlSerializer( Pet::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Pet^ myPet = gcnew Pet; - - /* Set the Animal property. If you set it to the default value, - which is "Cat" (the value assigned to the XmlDefaultValue - of the XmlAttributes object), no value will be serialized. - If you change the value to any other value (including "Dog"), - the value will be serialized. - */ - // The default value "Cat" will be assigned (nothing serialized). - myPet->Animal = ""; - - // Uncommenting the next line also results in the default - // value because Cat is the default value (not serialized). - // myPet.Animal = "Cat"; - // Uncomment the next line to see the value serialized: - // myPet.Animal = "fish"; - // This will also be serialized because Dog is not the - // default anymore. - // myPet.Animal = "Dog"; - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myPet ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Pet^ myPet = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myPet->Animal ); -} - -int main() -{ - SerializeObject( "OverrideDefaultValue.xml" ); - DeserializeObject( "OverrideDefaultValue.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp deleted file mode 100644 index dc3a90e6177..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp +++ /dev/null @@ -1,101 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; - -public ref class Car -{ -public: - String^ Name; -}; - -public ref class Plane -{ -public: - String^ Name; -}; - -public ref class Truck -{ -public: - String^ Name; -}; - -public ref class Train -{ -public: - String^ Name; -}; - -public ref class Transportation -{ -public: - - // Subsequent code overrides these two XmlElementAttributes. - - [XmlElement(Car::typeid), - XmlElement(Plane::typeid)] - ArrayList^ Vehicles; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributes and XmlAttributeOverrides objects. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlElementAttribute to override - the Vehicles property. */ - XmlElementAttribute^ xElement1 = gcnew XmlElementAttribute( Truck::typeid ); - - // Add the XmlElementAttribute to the collection. - attrs->XmlElements->Add( xElement1 ); - - /* Create a second XmlElementAttribute, and - add it to the collection. */ - XmlElementAttribute^ xElement2 = gcnew XmlElementAttribute( Train::typeid ); - attrs->XmlElements->Add( xElement2 ); - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Transportation::typeid, "Vehicles", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Transportation::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object and serialize it. - Transportation^ myTransportation = gcnew Transportation; - - /* Create two new override objects that can be - inserted into the array. */ - myTransportation->Vehicles = gcnew ArrayList; - Truck^ myTruck = gcnew Truck; - myTruck->Name = "MyTruck"; - Train^ myTrain = gcnew Train; - myTrain->Name = "MyTrain"; - myTransportation->Vehicles->Add( myTruck ); - myTransportation->Vehicles->Add( myTrain ); - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myTransportation ); -} - -int main() -{ - SerializeObject( "OverrideElement.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp deleted file mode 100644 index 9b65599120b..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public enum class FoodType -{ - // Subsequent code overrides these enumerations. - Low, High -}; - -// This is the class that will be serialized. -public ref class Food -{ -public: - FoodType Type; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an XmlEnumAttribute for the FoodType.Low enumeration. - XmlEnumAttribute^ xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Cold"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "Low", xAttrs ); - - // Add an XmlEnumAttribute for the FoodType.High enumeration. - xAttrs = gcnew XmlAttributes; - xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Hot"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "High", xAttrs ); - - // Create the XmlSerializer, and return it. - return gcnew XmlSerializer( Food::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Food^ myFood = gcnew Food; - - // Set the object properties. - myFood->Type = FoodType::High; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myFood ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Food^ myFood = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myFood->Type ); -} - -int main() -{ - SerializeObject( "OverrideEnum.xml" ); - DeserializeObject( "OverrideEnum.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp deleted file mode 100644 index 1f586f80547..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - - // The GroupName value will be serialized--unless it's overridden. - String^ GroupName; - - /* This field will be ignored when serialized-- - unless it's overridden. */ - - [XmlIgnoreAttribute] - String^ Comment; -}; - - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Setting XmlIgnore to false overrides the XmlIgnoreAttribute - applied to the Comment field. Thus it will be serialized.*/ - attrs->XmlIgnore = false; - xOver->Add( Group::typeid, "Comment", attrs ); - - /* Use the XmlIgnore to instruct the XmlSerializer to ignore - the GroupName instead. */ - attrs = gcnew XmlAttributes; - attrs->XmlIgnore = true; - xOver->Add( Group::typeid, "GroupName", attrs ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object to serialize and set its properties. - Group^ myGroup = gcnew Group; - myGroup->GroupName = ".NET"; - myGroup->Comment = "My Comment..."; - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Serialize the object and close the TextWriter. - xSer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "IgnoreXml.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp deleted file mode 100644 index 42c1f3a3503..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - [XmlAttributeAttribute] - int GroupCode; -}; - -// Return an XmlSerializer for overriding attributes. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributes and XmlAttributeOverrides objects. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - - // Set a new Namespace and ElementName for the root element. - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->ElementName = "NewGroup"; - attrs->XmlRoot = xRoot; - - /* Add the XmlAttributes object to the XmlAttributeOverrides. - No member name is needed because the whole class is - overridden. */ - xOver->Add( Group::typeid, attrs ); - - // Get the XmlAttributes object, based on the type. - XmlAttributes^ tempAttrs; - tempAttrs = xOver[ Group::typeid ]; - - // Print the Namespace and ElementName of the root. - Console::WriteLine( tempAttrs->XmlRoot->Namespace ); - Console::WriteLine( tempAttrs->XmlRoot->ElementName ); - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create the XmlSerializer using the CreateOverrider method. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object to serialize. - Group^ myGroup = gcnew Group; - myGroup->GroupName = ".NET"; - myGroup->GroupCode = 123; - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Serialize the object and close the TextWriter. - xSer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "OverrideRoot.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp deleted file mode 100644 index e2732ed2c57..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp +++ /dev/null @@ -1,74 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Group -{ -public: - String^ GroupName; - - // This field will be serialized as XML text. - String^ Comment; -}; - -// Return an XmlSerializer to be used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - /* Create an XmlTextAttribute and assign it to the XmlText - property. This instructs the XmlSerializer to treat the - Comment field as XML text. */ - XmlTextAttribute^ xText = gcnew XmlTextAttribute; - xAttrs->XmlText = xText; - xOver->Add( Group::typeid, "Comment", xAttrs ); - - // Create the XmlSerializer, and return it. - return gcnew XmlSerializer( Group::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - myGroup->Comment = "Great Stuff!"; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( myGroup->Comment ); -} - -int main() -{ - SerializeObject( "OverrideText.xml" ); - DeserializeObject( "OverrideText.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp deleted file mode 100644 index d2cccc13596..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp +++ /dev/null @@ -1,69 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Car -{ -public: - int ID; -}; - -public ref class Transportation -{ -public: - array^Cars; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlAttributes and XmlAttributeOverrides objects. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlTypeAttribute and change the name of the - XML type. */ - XmlTypeAttribute^ xType = gcnew XmlTypeAttribute; - xType->TypeName = "Autos"; - - // Set the XmlTypeAttribute to the XmlType property. - attrs->XmlType = xType; - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Car::typeid, attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Transportation::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create object and serialize it. - Transportation^ myTransportation = gcnew Transportation; - Car^ c1 = gcnew Car; - c1->ID = 12; - Car^ c2 = gcnew Car; - c2->ID = 44; - array^temp0 = {c1,c2}; - myTransportation->Cars = temp0; - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myTransportation ); -} - -int main() -{ - SerializeObject( "XmlType.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp deleted file mode 100644 index eea4fa29c6d..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,115 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - /* Set the element name and namespace of the XML element. - By applying an XmlElementAttribute to an array, you instruct - the XmlSerializer to serialize the array as a series of XML - elements, instead of a nested set of elements. */ - - [XmlElement( - ElementName="Members", - Namespace="http://www.cpandl.com")] - array^Employees; - - [XmlElement(DataType="snippet1>", - ElementName="Building")] - double GroupID; - - [XmlElement(DataType="hexBinary")] - array^HexBytes; - - [XmlElement(DataType="boolean")] - bool IsActive; - - [XmlElement(Type=::Manager::typeid)] - Employee^ Manager; - - [XmlElement(Int32::typeid, - ElementName="ObjectNumber"), - XmlElement(String::typeid, - ElementName="ObjectString")] - ArrayList^ ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // Create the XmlSerializer. - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - - /* Create an instance of the group to serialize, and set - its properties. */ - Group^ group = gcnew Group; - group->GroupID = 10.089f; - group->IsActive = false; - array^temp0 = {Convert::ToByte( 100 )}; - group->HexBytes = temp0; - Employee^ x = gcnew Employee; - Employee^ y = gcnew Employee; - x->Name = "Jack"; - y->Name = "Jill"; - array^temp1 = {x,y}; - group->Employees = temp1; - Manager^ mgr = gcnew Manager; - mgr->Name = "Sara"; - mgr->Level = 4; - group->Manager = mgr; - - /* Add a number and a string to the - ArrayList returned by the ExtraInfo property. */ - group->ExtraInfo = gcnew ArrayList; - group->ExtraInfo->Add( 42 ); - group->ExtraInfo->Add( "Answer" ); - - // Serialize the object, and close the TextWriter. - s->Serialize( writer, group ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlSerializer^ x = gcnew XmlSerializer( Group::typeid ); - Group^ g = dynamic_cast(x->Deserialize( fs )); - Console::WriteLine( g->Manager->Name ); - Console::WriteLine( g->GroupID ); - Console::WriteLine( g->HexBytes[ 0 ] ); - IEnumerator^ myEnum = g->Employees->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Employee^ e = safe_cast(myEnum->Current); - Console::WriteLine( e->Name ); - } -} - -int main() -{ - SerializeObject( "FirstDoc.xml" ); - DeserializeObject( "FirstDoc.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp deleted file mode 100644 index dac3339b9d7..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Group -{ -public: - - /* Apply two XmlElementAttributes to the field. Set the DataType - to string an int to allow the ArrayList to accept - both types. The Namespace is also set to different values - for each type. */ - - [XmlElement(DataType="string", - Type=String::typeid, - Namespace="http://www.cpandl.com"), - XmlElement(DataType="snippet1>", - Namespace="http://www.cohowinery.com", - Type=Int32::typeid)] - ArrayList^ ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // A TextWriter is needed to write the file. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // Create the object to serialize. - Group^ myGroup = gcnew Group; - - /* Add a string and an integer to the ArrayList returned - by the ExtraInfo field. */ - myGroup->ExtraInfo = gcnew ArrayList; - myGroup->ExtraInfo->Add( "hello" ); - myGroup->ExtraInfo->Add( 100 ); - - // Serialize the object and close the TextWriter. - s->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "ElementTypes.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp deleted file mode 100644 index c73eab60f3b..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#using - -using namespace System; -using namespace System::Xml; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// -// This is the class that will be serialized. -public ref class XClass -{ -public: - /* The XML element name will be XName - instead of the default ClassName. */ - [XmlElement(ElementName="XName")] - String^ ClassName; -}; -// - -int main(){} diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp deleted file mode 100644 index 323a5e3febf..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp +++ /dev/null @@ -1,20 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlElement(Form=XmlSchemaForm::Unqualified)] - String^ ClassName; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index 496244672df..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlElement(IsNullable=false)] - String^ Group; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp deleted file mode 100644 index 217959b7fad..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp +++ /dev/null @@ -1,64 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -public ref class Group -{ -public: - - [XmlElement(Manager::typeid)] - array^Staff; - - [XmlElement(Int32::typeid), - XmlElement(String::typeid), - XmlElement(DateTime::typeid)] - ArrayList^ ExtraInfo; -}; - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid ); - - // Create object and serialize it. - Group^ myGroup = gcnew Group; - Manager^ e1 = gcnew Manager; - e1->Name = "Manager1"; - Manager^ m1 = gcnew Manager; - m1->Name = "Manager2"; - m1->Level = 4; - array^emps = {e1,m1}; - myGroup->Staff = emps; - myGroup->ExtraInfo = gcnew ArrayList; - myGroup->ExtraInfo->Add( ".NET" ); - myGroup->ExtraInfo->Add( 42 ); - myGroup->ExtraInfo->Add( DateTime(2001,1,1) ); - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myGroup ); - writer->Close(); -} - -int main() -{ - SerializeObject( "TypeEx.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp deleted file mode 100644 index f06647e1954..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class MyClass -{ -public: - - [XmlElement] - String^ TeacherName; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp deleted file mode 100644 index a92464e29dc..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Transportation -{ -public: - - [XmlElement("Cars")] - String^ Vehicles; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp deleted file mode 100644 index 701b642c490..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp +++ /dev/null @@ -1,96 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Instrument -{ -public: - String^ Name; -}; - -public ref class Brass: public Instrument -{ -public: - bool IsValved; -}; - -public ref class Orchestra -{ -public: - array^Instruments; -}; - -void SerializeObject( String^ filename ) -{ - // To write the file, a TextWriter is required. - TextWriter^ writer = gcnew StreamWriter( filename ); - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Creates an XmlElementAttribute that overrides the Instrument type. - XmlElementAttribute^ attr = gcnew XmlElementAttribute( Brass::typeid ); - attr->ElementName = "Brass"; - - // Adds the element to the collection of elements. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Creates the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - - // Creates the object to serialize. - Orchestra^ band = gcnew Orchestra; - - // Creates an object of the derived type. - Brass^ i = gcnew Brass; - i->Name = "Trumpet"; - i->IsValved = true; - array^myInstruments = {i}; - band->Instruments = myInstruments; - s->Serialize( writer, band ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Creates an XmlElementAttribute that override the Instrument type. - XmlElementAttribute^ attr = gcnew XmlElementAttribute( Brass::typeid ); - attr->ElementName = "Brass"; - - // Adds the element to the collection of elements. - attrs->XmlElements->Add( attr ); - attrOverrides->Add( Orchestra::typeid, "Instruments", attrs ); - - // Creates the XmlSerializer using the XmlAttributeOverrides. - XmlSerializer^ s = gcnew XmlSerializer( Orchestra::typeid,attrOverrides ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Orchestra^ band = dynamic_cast(s->Deserialize( fs )); - Console::WriteLine( "Brass:" ); - - /* Deserializing differs from serializing. To read the - derived-object values, declare an object of the derived - type (Brass) and cast the Instrument instance to it. */ - Brass^ b; - System::Collections::IEnumerator^ myEnum = band->Instruments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Instrument^ i = safe_cast(myEnum->Current); - b = dynamic_cast(i); - Console::WriteLine( "{0}\n{1}", b->Name, b->IsValved ); - } -} - -int main() -{ - SerializeObject( "Override.xml" ); - DeserializeObject( "Override.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp deleted file mode 100644 index 000e548b46f..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp +++ /dev/null @@ -1,100 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; - -public ref class Car -{ -public: - String^ Name; -}; - -public ref class Plane -{ -public: - String^ Name; -}; - -public ref class Truck -{ -public: - String^ Name; -}; - -public ref class Train -{ -public: - String^ Name; -}; - -public ref class Transportation -{ -public: - - // Override these two XmlElementAttributes. - - [XmlElement(Car::typeid), - XmlElement(Plane::typeid)] - ArrayList^ Vehicles; -}; - -XmlSerializer^ CreateOverrider() -{ - // Create XmlAtrributes and XmlAttributeOverrides instances. - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlElementAttributes object to override - one of the attributes applied to the Vehicles property. */ - XmlElementAttribute^ xElement1 = gcnew XmlElementAttribute( Truck::typeid ); - - // Add the XmlElementAttribute to the collection. - attrs->XmlElements->Add( xElement1 ); - - /* Create a second XmlElementAttribute and - add it to the collection. */ - XmlElementAttribute^ xElement2 = gcnew XmlElementAttribute( Train::typeid ); - attrs->XmlElements->Add( xElement2 ); - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Transportation::typeid, "Vehicles", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Transportation::typeid,xOver ); - return xSer; -} - -void SerializeObject( String^ filename ) -{ - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object. - Transportation^ myTransportation = gcnew Transportation; - - /* Create two new, overriding objects that can be - inserted into the Vehicles array. */ - myTransportation->Vehicles = gcnew ArrayList; - Truck^ myTruck = gcnew Truck; - myTruck->Name = "MyTruck"; - Train^ myTrain = gcnew Train; - myTrain->Name = "MyTrain"; - myTransportation->Vehicles->Add( myTruck ); - myTransportation->Vehicles->Add( myTrain ); - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myTransportation ); -} - -int main() -{ - SerializeObject( "OverrideElement.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp deleted file mode 100644 index 3933ca7d495..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Truck{ - // Class added so sample will compile -}; - -public ref class Train{ - // Class added so sample will compile -}; - -public ref class Transportation{ - // Class added so sample will compile -}; - -public ref class Sample -{ - // -public: - XmlSerializer^ CreateOverrider() - { - // Create XmlAttributes and XmlAttributeOverrides instances. - - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = - gcnew XmlAttributeOverrides; - - /* Create an XmlElementAttributes to override - the Vehicles property. */ - XmlElementAttribute^ xElement1 = - gcnew XmlElementAttribute( Truck::typeid ); - // Add the XmlElementAttribute to the collection. - attrs->XmlElements->Add( xElement1 ); - - /* Create a second XmlElementAttribute, and - add to the collection. */ - XmlElementAttribute^ xElement2 = - gcnew XmlElementAttribute( Train::typeid ); - attrs->XmlElements->Add( xElement2 ); - - /* Add the XmlAttributes to the XmlAttributeOverrides, - specifying the member to override. */ - xOver->Add( Transportation::typeid, "Vehicles", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( - Transportation::typeid,xOver ); - return xSer; - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp deleted file mode 100644 index b82f373dbe0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public enum class EmployeeStatus -{ - [XmlEnum(Name = "Single")] - One, - [XmlEnum(Name = "Double")] - Two, - [XmlEnum(Name = "Triple")] - Three -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp deleted file mode 100644 index d494e993e3e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp +++ /dev/null @@ -1,21 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public enum class EmployeeStatus -{ - [XmlEnum("Single")] - One, - [XmlEnum("Double")] - Two, - [XmlEnum("Triple")] - Three -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp deleted file mode 100644 index d7f0debeaec..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public enum class FoodType -{ - // Subsequent code overrides these enumerations. - Low, High -}; - -// This is the class that will be serialized. -public ref class Food -{ -public: - FoodType Type; -}; - -// Return an XmlSerializer used for overriding. -XmlSerializer^ CreateOverrider() -{ - // Create the XmlOverrides and XmlAttributes objects. - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - XmlAttributes^ xAttrs = gcnew XmlAttributes; - - // Add an XmlEnumAttribute for the FoodType.Low enumeration. - XmlEnumAttribute^ xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Cold"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "Low", xAttrs ); - - // Add an XmlEnumAttribute for the FoodType.High enumeration. - xAttrs = gcnew XmlAttributes; - xEnum = gcnew XmlEnumAttribute; - xEnum->Name = "Hot"; - xAttrs->XmlEnum = xEnum; - xOver->Add( FoodType::typeid, "High", xAttrs ); - - // Create the XmlSerializer, and return it. - return gcnew XmlSerializer( Food::typeid,xOver ); -} - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrider(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Food^ myFood = gcnew Food; - - // Set the object properties. - myFood->Type = FoodType::High; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myFood ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = CreateOverrider(); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Food^ myFood = dynamic_cast(mySerializer->Deserialize( fs )); - Console::WriteLine( myFood->Type ); -} - -int main() -{ - SerializeObject( "OverrideEnum.xml" ); - DeserializeObject( "OverrideEnum.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp deleted file mode 100644 index 7298f812c7a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Group -{ -public: - - // The XmlSerializer ignores this field. - - [XmlIgnore] - String^ Comment; - - // The XmlSerializer serializes this field. - String^ GroupName; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp deleted file mode 100644 index cbfdda004f2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -ref class Employee; - -ref class Manager; - -ref class Group -{ -public: - array^Employees; -}; - -// Instruct the XmlSerializer to accept Manager types as well. -[XmlInclude(Manager::typeid)] -public ref class Employee -{ -public: - String^ Name; -}; - -public ref class Manager: public Employee -{ -public: - int Level; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - Group^ group = gcnew Group; - Manager^ manager = gcnew Manager; - Employee^ emp1 = gcnew Employee; - Employee^ emp2 = gcnew Employee; - manager->Name = "Zeus"; - manager->Level = 2; - emp1->Name = "Ares"; - emp2->Name = "Artemis"; - array^emps = {manager,emp1,emp2}; - group->Employees = emps; - s->Serialize( writer, group ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlSerializer^ x = gcnew XmlSerializer( Group::typeid ); - Group^ g = dynamic_cast(x->Deserialize( fs )); - Console::Write( "Members:" ); - System::Collections::IEnumerator^ myEnum = g->Employees->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Employee^ e = safe_cast(myEnum->Current); - Console::WriteLine( "\t{0}", e->Name ); - } -} - -int main() -{ - SerializeObject( "IncludeExample.xml" ); - DeserializeObject( "IncludeExample.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp deleted file mode 100644 index 8ba6ec67f15..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,34 +0,0 @@ - - -#using -#using -#using - -using namespace System; -using namespace System::Web::Services; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -public ref class Vehicle{}; - -public ref class Car: public Vehicle{}; - -public ref class Truck: public Vehicle{}; - -public ref class Sample -{ -public: - - [WebMethodAttribute] - [XmlInclude(Car::typeid)] - [XmlInclude(Truck::typeid)] - Vehicle^ ReturnVehicle( int i ) - { - if ( i == 0 ) - return gcnew Car; - else - return gcnew Truck; - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp deleted file mode 100644 index 78b7ac99698..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode LocalName: {0}", e->LocalName ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp deleted file mode 100644 index de9d0304ae4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ -private: - // - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Name: {0}", e->Name ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp deleted file mode 100644 index 68985474069..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Namespace URI: {0}", e->NamespaceURI ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp deleted file mode 100644 index bd6a1e29d72..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - XmlNodeType myNodeType = e->NodeType; - Console::WriteLine( myNodeType ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp deleted file mode 100644 index 88a67fdab41..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Object^ o = e->ObjectBeingDeserialized; - Console::WriteLine( "Object being deserialized: {0}", o ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp deleted file mode 100644 index a4734b7e012..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Text: {0}", e->Text ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp deleted file mode 100644 index b4318feda2a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Class1 -{ - // -private: - void DeserializeItem( String^ filename ) - { - XmlSerializer^ mySerializer = gcnew XmlSerializer( ObjectToDeserialize::typeid ); - - // Add an instance of the delegate to the event. - mySerializer->UnknownNode += gcnew XmlNodeEventHandler( this, &Class1::Serializer_UnknownNode ); - - // A FileStream is needed to read the file to deserialize. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - ObjectToDeserialize^ o = dynamic_cast(mySerializer->Deserialize( fs )); - } - - void Serializer_UnknownNode( Object^ sender, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Name: {0}", e->Name ); - Console::WriteLine( "UnknownNode LocalName: {0}", e->LocalName ); - Console::WriteLine( "UnknownNode Namespace URI: {0}", e->NamespaceURI ); - Console::WriteLine( "UnknownNode Text: {0}", e->Text ); - Object^ o = e->ObjectBeingDeserialized; - Console::WriteLine( "Object being deserialized {0}", o ); - XmlNodeType myNodeType = e->NodeType; - Console::WriteLine( myNodeType ); - } - // - -public: - - ref class ObjectToDeserialize{}; -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp deleted file mode 100644 index 705ea6b1244..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; - -[XmlRoot(Namespace="www.contoso.com", -ElementName="MyGroupName", -DataType="string", -IsNullable=true)] -public ref class Group -{ -private: - String^ groupNameValue; - -public: - - // Insert code for the Group class. - Group(){} - - Group( String^ groupNameVal ) - { - groupNameValue = groupNameVal; - } - - property String^ GroupName - { - String^ get() - { - return groupNameValue; - } - void set( String^ value ) - { - groupNameValue = value; - } - - } - -}; - -void SerializeGroup() -{ - // Create an instance of the Group class, and an - // instance of the XmlSerializer to serialize it. - Group^ myGroup = gcnew Group( "Redmond" ); - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // A FileStream is used to write the file. - FileStream^ fs = gcnew FileStream( "group.xml",FileMode::Create ); - ser->Serialize( fs, myGroup ); - fs->Close(); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( "Done" ); - Console::ReadLine(); -} - -int main() -{ - SerializeGroup(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp deleted file mode 100644 index 9780f3bb003..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; - -// Apply the XmlRootAttribute and set the IsNullable property to false. - -[XmlRoot(IsNullable=false)] -public ref class Group -{ -public: - String^ Name; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ s = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create the object to serialize. - Group^ mygroup = nullptr; - - // Serialize the object, and close the TextWriter. - s->Serialize( writer, mygroup ); - writer->Close(); -} - -int main() -{ - Console::WriteLine( "Running" ); - SerializeObject( "NullDoc.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 4d0cd2a4a61..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlRoot(Namespace="http://www.cpandl.com")] -public ref class Group{}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp deleted file mode 100644 index ee176b3d4b4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,62 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that is the default root element. -public ref class MyClass -{ -public: - String^ Name; -}; - -XmlSerializer^ CreateOverrider(); -void SerializeOrder( String^ filename ) -{ - // Create an XmlSerializer instance using the method below. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object, and set its Name property. - MyClass^ myClass = gcnew MyClass; - myClass->Name = "New Class Name"; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myClass ); - writer->Close(); -} - -// Return an XmlSerializer to override the root serialization. -XmlSerializer^ CreateOverrider() -{ - // Create an XmlAttributes to override the default root element. - XmlAttributes^ attrs = gcnew XmlAttributes; - - // Create an XmlRootAttribute and set its element name and namespace. - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - xRoot->ElementName = "OverriddenRootElementName"; - xRoot->Namespace = "http://www.microsoft.com"; - - // Set the XmlRoot property to the XmlRoot object. - attrs->XmlRoot = xRoot; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Add the XmlAttributes object to the - XmlAttributeOverrides object. */ - xOver->Add( MyClass::typeid, attrs ); - - // Create the Serializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( MyClass::typeid,xOver ); - return xSer; -} - -int main() -{ - SerializeOrder( "OverrideAttribute.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer Example/CPP/source.cpp deleted file mode 100644 index 0bfeccd401c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer Example/CPP/source.cpp +++ /dev/null @@ -1,216 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; -ref class Address; -ref class OrderedItem; - -/* The XmlRootAttribute allows you to set an alternate name - (PurchaseOrder) of the XML element, the element namespace; by - default, the XmlSerializer uses the class name. The attribute - also allows you to set the XML namespace for the element. Lastly, - the attribute sets the IsNullable property, which specifies whether - the xsi:null attribute appears if the class instance is set to - a null reference. */ - -[XmlRootAttribute("PurchaseOrder",Namespace="http://www.cpandl.com", -IsNullable=false)] -public ref class PurchaseOrder -{ -public: - Address^ ShipTo; - String^ OrderDate; - - /* The XmlArrayAttribute changes the XML element name - from the default of "OrderedItems" to "Items". */ - - [XmlArrayAttribute("Items")] - array^OrderedItems; - Decimal SubTotal; - Decimal ShipCost; - Decimal TotalCost; -}; - -public ref class Address -{ -public: - - /* The XmlAttribute instructs the XmlSerializer to serialize the Name - field as an XML attribute instead of an XML element (the default - behavior). */ - - [XmlAttributeAttribute] - String^ Name; - String^ Line1; - - /* Setting the IsNullable property to false instructs the - XmlSerializer that the XML attribute will not appear if - the City field is set to a null reference. */ - - [XmlElementAttribute(IsNullable=false)] - String^ City; - String^ State; - String^ Zip; -}; - -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - /* Calculate is a custom method that calculates the price per item, - and stores the value in a field. */ - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } - -}; - -public ref class Test -{ -public: - static void main() - { - // Read and write purchase orders. - Test^ t = gcnew Test; - t->CreatePO( "po.xml" ); - t->ReadPO( "po.xml" ); - } - -private: - void CreatePO( String^ filename ) - { - // Create an instance of the XmlSerializer class; - // specify the type of object to serialize. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - PurchaseOrder^ po = gcnew PurchaseOrder; - - // Create an address to ship and bill to. - Address^ billAddress = gcnew Address; - billAddress->Name = "Teresa Atkinson"; - billAddress->Line1 = "1 Main St."; - billAddress->City = "AnyTown"; - billAddress->State = "WA"; - billAddress->Zip = "00000"; - - // Set ShipTo and BillTo to the same addressee. - po->ShipTo = billAddress; - po->OrderDate = System::DateTime::Now.ToLongDateString(); - - // Create an OrderedItem object. - OrderedItem^ i1 = gcnew OrderedItem; - i1->ItemName = "Widget S"; - i1->Description = "Small widget"; - i1->UnitPrice = (Decimal)5.23; - i1->Quantity = 3; - i1->Calculate(); - - // Insert the item into the array. - array^items = {i1}; - po->OrderedItems = items; - - // Calculate the total cost. - Decimal subTotal = Decimal(0); - System::Collections::IEnumerator^ myEnum = items->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - OrderedItem^ oi = safe_cast(myEnum->Current); - subTotal = subTotal + oi->LineTotal; - } - - po->SubTotal = subTotal; - po->ShipCost = (Decimal)12.51; - po->TotalCost = po->SubTotal + po->ShipCost; - - // Serialize the purchase order, and close the TextWriter. - serializer->Serialize( writer, po ); - writer->Close(); - } - -protected: - void ReadPO( String^ filename ) - { - // Create an instance of the XmlSerializer class; - // specify the type of object to be deserialized. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - - /* If the XML document has been altered with unknown - nodes or attributes, handle them with the - UnknownNode and UnknownAttribute events.*/ - serializer->UnknownNode += gcnew XmlNodeEventHandler( this, &Test::serializer_UnknownNode ); - serializer->UnknownAttribute += gcnew XmlAttributeEventHandler( this, &Test::serializer_UnknownAttribute ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - PurchaseOrder^ po; - - /* Use the Deserialize method to restore the object's state with - data from the XML document. */ - po = dynamic_cast(serializer->Deserialize( fs )); - - // Read the order date. - Console::WriteLine( "OrderDate: {0}", po->OrderDate ); - - // Read the shipping address. - Address^ shipTo = po->ShipTo; - ReadAddress( shipTo, "Ship To:" ); - - // Read the list of ordered items. - array^items = po->OrderedItems; - Console::WriteLine( "Items to be shipped:" ); - System::Collections::IEnumerator^ myEnum1 = items->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - OrderedItem^ oi = safe_cast(myEnum1->Current); - Console::WriteLine( "\t{0}\t{1}\t{2}\t{3}\t{4}", oi->ItemName, oi->Description, oi->UnitPrice, oi->Quantity, oi->LineTotal ); - } - - Console::WriteLine( "\t\t\t\t\t Subtotal\t{0}", po->SubTotal ); - Console::WriteLine( "\t\t\t\t\t Shipping\t{0}", po->ShipCost ); - Console::WriteLine( "\t\t\t\t\t Total\t\t{0}", po->TotalCost ); - } - - void ReadAddress( Address^ a, String^ label ) - { - // Read the fields of the Address object. - Console::WriteLine( label ); - Console::WriteLine( "\t{0}", a->Name ); - Console::WriteLine( "\t{0}", a->Line1 ); - Console::WriteLine( "\t{0}", a->City ); - Console::WriteLine( "\t{0}", a->State ); - Console::WriteLine( "\t{0}", a->Zip ); - Console::WriteLine(); - } - -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "Unknown Node:{0}\t{1}", e->Name, e->Text ); - } - - void serializer_UnknownAttribute( Object^ /*sender*/, XmlAttributeEventArgs^ e ) - { - System::Xml::XmlAttribute^ attr = e->Attr; - Console::WriteLine( "Unknown attribute {0}='{1}'", attr->Name, attr->Value ); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp deleted file mode 100644 index b488c27b932..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void TestDocument( String^ filename, Type^ objType ) - { - // Using a FileStream, create an XmlTextReader. - Stream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlReader^ reader = gcnew XmlTextReader( fs ); - XmlSerializer^ serializer = gcnew XmlSerializer( objType ); - if ( serializer->CanDeserialize( reader ) ) - { - Object^ o = serializer->Deserialize( reader ); - } - fs->Close(); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp deleted file mode 100644 index 542444fb61a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be deserialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void DeserializeObject(String^ filename) -{ - Console::WriteLine("Reading with Stream"); - - // Create an instance of the XmlSerializer. - XmlSerializer^ serializer = gcnew XmlSerializer(OrderedItem::typeid); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Reading the XML document requires a FileStream. - Stream^ reader = gcnew FileStream(filename, FileMode::Open); - - try - { - // Call the Deserialize method to restore the object's state. - i = dynamic_cast(serializer->Deserialize(reader)); - } - finally - { - delete reader; - } - - // Write out the properties of the object. - Console::Write("{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal); -} - -int main() -{ - // Read a purchase order. - DeserializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp deleted file mode 100644 index b803c3b61af..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml::Serialization; - -// This is the class that will be deserialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Reading with TextReader" ); - - // Create an instance of the XmlSerializer specifying type. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - - /* Create a TextReader to read the file. Specify an - Encoding to use. */ - TextReader^ reader = gcnew StreamReader( filename,Encoding::Unicode ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Use the Deserialize method to restore the object's state. - i = dynamic_cast(serializer->Deserialize( reader )); - - // Write out the properties of the object. - Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal ); -} - -int main() -{ - // Read a purchase order. - DeserializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp deleted file mode 100644 index 3b2738346ee..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be deserialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Reading with XmlReader" ); - - // Create an instance of the XmlSerializer specifying type and namespace. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - XmlReader^ reader = gcnew XmlTextReader( fs ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Use the Deserialize method to restore the object's state. - i = dynamic_cast(serializer->Deserialize( reader )); - - // Write out the properties of the object. - Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal ); -} - -int main() -{ - // Read a purchase order. - DeserializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp deleted file mode 100644 index a9b0d0bf54e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -/* Three classes are included here. Each one will -be used to create three XmlSerializer objects. */ -public ref class Instrument -{ -public: - String^ InstrumentName; -}; - -public ref class Player -{ -public: - String^ PlayerName; -}; - -public ref class Piece -{ -public: - String^ PieceName; -}; - -void GetSerializers() -{ - // Create an array of types. - array^types = gcnew array(3); - types[ 0 ] = Instrument::typeid; - types[ 1 ] = Player::typeid; - types[ 2 ] = Piece::typeid; - - // Create an array for XmlSerializer objects. - array^serializers = gcnew array(3); - serializers = XmlSerializer::FromTypes( types ); - - // Create one Instrument and serialize it. - Instrument^ i = gcnew Instrument; - i->InstrumentName = "Piano"; - - // Create a TextWriter to write with. - TextWriter^ writer = gcnew StreamWriter( "Inst.xml" ); - serializers[ 0 ]->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - GetSerializers(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp deleted file mode 100644 index deb65e2782e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With TextWriter" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - /* Create a StreamWriter to write with. First create a FileStream - object, and create the StreamWriter specifying an Encoding to use. */ - FileStream^ fs = gcnew FileStream( filename,FileMode::Create ); - TextWriter^ writer = gcnew StreamWriter( fs,gcnew UTF8Encoding ); - - // Serialize using the XmlTextWriter. - serializer->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp deleted file mode 100644 index c635e566468..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With TextWriter" ); - - // Create an XmlSerializer instance using the type. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlSerializerNamespaces object. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Add two namespaces with prefixes. - ns->Add( "inventory", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create a StreamWriter to write with. - TextWriter^ writer = gcnew StreamWriter( filename ); - - /* Serialize using the object using the TextWriter - and namespaces. */ - serializer->Serialize( writer, i, ns ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp deleted file mode 100644 index 053d871e78a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With Stream" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create a FileStream to write with. - Stream^ writer = gcnew FileStream( filename,FileMode::Create ); - - // Serialize the object, and close the TextWriter - serializer->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp deleted file mode 100644 index baf2cd1b7c8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp +++ /dev/null @@ -1,91 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With Stream" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlSerializerNamespaces object. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Add two prefix-namespace pairs. - ns->Add( "inventory", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create a FileStream to write with. - Stream^ writer = gcnew FileStream( filename,FileMode::Create ); - - // Serialize the object, and close the TextWriter - serializer->Serialize( writer, i, ns ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - Console::WriteLine( "Reading with Stream" ); - - // Create an instance of the XmlSerializer. - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - - // Writing the file requires a Stream. - Stream^ reader = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - /* Use the Deserialize method to restore the object's state - using data from the XML document. */ - i = dynamic_cast(serializer->Deserialize( reader )); - - // Write out the properties of the object. - Console::Write( "{0}\t{1}\t{2}\t{3}\t{4}", i->ItemName, i->Description, i->UnitPrice, i->Quantity, i->LineTotal ); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); - DeserializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp deleted file mode 100644 index 1774c451ee4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With XmlTextWriter" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlTextWriter using a FileStream. - Stream^ fs = gcnew FileStream( filename,FileMode::Create ); - XmlWriter^ writer = gcnew XmlTextWriter( fs,Encoding::Unicode ); - - // Serialize using the XmlTextWriter. - serializer->Serialize( writer, i ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp deleted file mode 100644 index 8a82ba5a382..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class OrderedItem -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ ItemName; - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ Description; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal UnitPrice; - - [XmlElement(Namespace="http://www.cpandl.com")] - int Quantity; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal LineTotal; - - // A custom method used to calculate price per item. - void Calculate() - { - LineTotal = UnitPrice * Quantity; - } -}; - -void SerializeObject( String^ filename ) -{ - Console::WriteLine( "Writing With XmlTextWriter" ); - XmlSerializer^ serializer = gcnew XmlSerializer( OrderedItem::typeid ); - OrderedItem^ i = gcnew OrderedItem; - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - i->Calculate(); - - // Create an XmlSerializerNamespaces object. - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - - // Add two namespaces with prefixes. - ns->Add( "inventory", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create an XmlTextWriter using a FileStream. - Stream^ fs = gcnew FileStream( filename,FileMode::Create ); - XmlWriter^ writer = gcnew XmlTextWriter( fs,gcnew UTF8Encoding ); - - // Serialize using the XmlTextWriter. - serializer->Serialize( writer, i, ns ); - writer->Close(); -} - -int main() -{ - // Write a purchase order. - SerializeObject( "simple.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp deleted file mode 100644 index cef506f6c43..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - String^ GroupName; -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - - // Deserialize the file containing unknown elements. - t->DeserializeObject( "UnknownAttributes.xml" ); - } - -private: - void Serializer_UnknownAttribute( Object^ sender, XmlAttributeEventArgs^ e ) - { - Console::WriteLine( "Unknown Attribute" ); - Console::WriteLine( "\t{0} {1}", e->Attr->Name, e->Attr->InnerXml ); - Console::WriteLine( "\t LineNumber: {0}", e->LineNumber ); - Console::WriteLine( "\t LinePosition: {0}", e->LinePosition ); - Group^ x = dynamic_cast(e->ObjectBeingDeserialized); - Console::WriteLine( x->GroupName ); - Console::WriteLine( sender ); - } - - void DeserializeObject( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // Add a delegate to handle unknown element events. - ser->UnknownAttribute += gcnew XmlAttributeEventHandler( this, &Test::Serializer_UnknownAttribute ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = dynamic_cast(ser->Deserialize( fs )); - fs->Close(); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp deleted file mode 100644 index 57d80144134..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp +++ /dev/null @@ -1,79 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Group -{ -public: - - // Only the GroupName field will be known. - String^ GroupName; -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - t->DeserializeObject( "UnknownNodes.xml" ); - } - -private: - void DeserializeObject( String^ filename ) - { - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - mySerializer->UnknownNode += gcnew XmlNodeEventHandler( this, &Test::serializer_UnknownNode ); - Group^ myGroup = dynamic_cast(mySerializer->Deserialize( fs )); - fs->Close(); - } - -private: - void serializer_UnknownNode( Object^ /*sender*/, XmlNodeEventArgs^ e ) - { - Console::WriteLine( "UnknownNode Name: {0}", e->Name ); - Console::WriteLine( "UnknownNode LocalName: {0}", e->LocalName ); - Console::WriteLine( "UnknownNode Namespace URI: {0}", e->NamespaceURI ); - Console::WriteLine( "UnknownNode Text: {0}", e->Text ); - XmlNodeType myNodeType = e->NodeType; - Console::WriteLine( "NodeType: {0}", myNodeType ); - Group^ myGroup = dynamic_cast(e->ObjectBeingDeserialized); - Console::WriteLine( "GroupName: {0}", myGroup->GroupName ); - Console::WriteLine(); - } -}; - -int main() -{ - Test::main(); -} - -/* Paste this XML into a file named UnknownNodes: - - - MyGroup - Large - 444 - West - - 1 - Thing1 - - element - - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp deleted file mode 100644 index 1df7c03435e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp +++ /dev/null @@ -1,181 +0,0 @@ - - -// -// Beginning of the HighSchool.dll -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -namespace HighSchool -{ - public ref class Student - { - public: - String^ Name; - int ID; - }; - - public ref class MyClass - { - public: - array^Students; - }; -} - -namespace College -{ - -using namespace HighSchool; - public ref class Graduate: public HighSchool::Student - { - public: - Graduate(){} - - // Add a new field named University. - String^ University; - - // Use extra types to use this field. - array^Info; - }; - - public ref class Address - { - public: - String^ City; - }; - - public ref class Phone - { - public: - String^ Number; - }; - - public ref class Run - { - public: - static void main() - { - Run^ test = gcnew Run; - test->WriteOverriddenAttributes( "College.xml" ); - test->ReadOverriddenAttributes( "College.xml" ); - } - - private: - void WriteOverriddenAttributes( String^ filename ) - { - // Writing the file requires a TextWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - // Create an XMLAttributeOverrides class. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - // Create the XmlAttributes class. - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Override the Student class. "Alumni" is the name - of the overriding element in the XML output. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - - /* Add the XmlElementAttribute to the collection of - elements in the XmlAttributes object. */ - attrs->XmlElements->Add( attr ); - - /* Add the XmlAttributes to the XmlAttributeOverrides. - "Students" is the name being overridden. */ - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - - // Create array of extra types. - array^extraTypes = gcnew array(2); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - - // Create an XmlRootAttribute. - XmlRootAttribute^ root = gcnew XmlRootAttribute( "Graduates" ); - - /* Create the XmlSerializer with the - XmlAttributeOverrides object. */ - XmlSerializer^ mySerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides,extraTypes,root,"http://www.microsoft.com" ); - MyClass ^ myClass = gcnew MyClass; - Graduate^ g1 = gcnew Graduate; - g1->Name = "Jacki"; - g1->ID = 1; - g1->University = "Alma"; - Graduate^ g2 = gcnew Graduate; - g2->Name = "Megan"; - g2->ID = 2; - g2->University = "CM"; - array^myArray = {g1,g2}; - myClass->Students = myArray; - - // Create extra information. - Address^ a1 = gcnew Address; - a1->City = "Ionia"; - Address^ a2 = gcnew Address; - a2->City = "Stamford"; - Phone^ p1 = gcnew Phone; - p1->Number = "555-0101"; - Phone^ p2 = gcnew Phone; - p2->Number = "555-0100"; - array^o1 = {a1,p1}; - array^o2 = {a2,p2}; - g1->Info = o1; - g2->Info = o2; - mySerializer->Serialize( myStreamWriter, myClass ); - myStreamWriter->Close(); - } - - void ReadOverriddenAttributes( String^ filename ) - { - /* The majority of the code here is the same as that in the - WriteOverriddenAttributes method. Because the XML being read - doesn't conform to the schema defined by the DLL, the - XMLAttributesOverrides must be used to create an - XmlSerializer instance to read the XML document.*/ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - attrs->XmlElements->Add( attr ); - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - array^extraTypes = gcnew array(2); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - XmlRootAttribute^ root = gcnew XmlRootAttribute( "Graduates" ); - XmlSerializer^ readSerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides,extraTypes,root,"http://www.microsoft.com" ); - - // A FileStream object is required to read the file. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - MyClass ^ myClass; - myClass = dynamic_cast(readSerializer->Deserialize( fs )); - - /* Here is the difference between reading and writing an - XML document: You must declare an object of the derived - type (Graduate) and cast the Student instance to it.*/ - Graduate^ g; - Address^ a; - Phone^ p; - System::Collections::IEnumerator^ myEnum = myClass->Students->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Graduate^ grad = safe_cast(myEnum->Current); - g = dynamic_cast(grad); - Console::Write( "{0}\t", g->Name ); - Console::Write( "{0}\t", g->ID ); - Console::Write( "{0}\n", g->University ); - a = dynamic_cast(g->Info[ 0 ]); - Console::WriteLine( a->City ); - p = dynamic_cast(g->Info[ 1 ]); - Console::WriteLine( p->Number ); - } - } - }; -} - -int main() -{ - College::Run::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp deleted file mode 100644 index 173d91e6ff3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Class1 -{ - // -private: - void SerializeObject( String^ filename ) - { - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,"http://www.cpandl.com" ); - - // Create an instance of the class to be serialized. - OrderedItem^ i = gcnew OrderedItem; - - // Insert code to set property values. - - // Writing the document requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - // Serialize the object, and close the TextWriter - serializer->Serialize( writer, i ); - writer->Close(); - } - - void DeserializeObject( String^ filename ) - { - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,"http://www.cpandl.com" ); - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - OrderedItem^ i; - - // Deserialize the object. - i = dynamic_cast(serializer->Deserialize( fs )); - - // Insert code to use the properties and methods of the object. - } - // - -public: - ref class OrderedItem{ - // Members of OrderedItem go here - }; -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp deleted file mode 100644 index 2ce08d9f7a1..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Class1 -{ - // -private: - void SerializeObject( String^ filename ) - { - // Create an XmlRootAttribute, and set its properties. - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - xRoot->ElementName = "CustomRoot"; - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->IsNullable = true; - - // Construct the XmlSerializer with the XmlRootAttribute. - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,xRoot ); - - // Create an instance of the object to serialize. - OrderedItem^ i = gcnew OrderedItem; - // Insert code to set properties of the ordered item. - - // Writing the document requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - serializer->Serialize( writer, i ); - writer->Close(); - } - - void DeserializeObject( String^ filename ) - { - // Create an XmlRootAttribute, and set its properties. - XmlRootAttribute^ xRoot = gcnew XmlRootAttribute; - xRoot->ElementName = "CustomRoot"; - xRoot->Namespace = "http://www.cpandl.com"; - xRoot->IsNullable = true; - - XmlSerializer^ serializer = gcnew XmlSerializer( - OrderedItem::typeid,xRoot ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - // Deserialize the object. - OrderedItem^ i = dynamic_cast(serializer->Deserialize( fs )); - // Insert code to use the object's properties and methods. - } - // - -public: - ref class OrderedItem{ - // Members of OrderedItem go here - }; -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp deleted file mode 100644 index 669af6e0644..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp +++ /dev/null @@ -1,137 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -ref class Address; -ref class Phone; - -// This defines the object that will be serialized. -public ref class Teacher -{ -public: - String^ Name; - Teacher(){} - - /* Note that the Info field returns an array of objects. - Any object can be added to the array by adding the - object type to the array passed to the extraTypes argument. */ - - [XmlArray(ElementName="ExtraInfo",IsNullable=true)] - array^Info; - Phone^ PhoneInfo; -}; - - -// This defines one of the extra types to be included. -public ref class Address -{ -public: - String^ City; - Address(){} - - Address( String^ city ) - { - City = city; - } -}; - -// Another extra type to include. -public ref class Phone -{ -public: - String^ PhoneNumber; - Phone(){} - - Phone( String^ phoneNumber ) - { - PhoneNumber = phoneNumber; - } -}; - -// Another type, derived from Phone -public ref class InternationalPhone: public Phone -{ -public: - String^ CountryCode; - InternationalPhone(){} - - InternationalPhone( String^ countryCode ) - { - CountryCode = countryCode; - } -}; - -public ref class Run -{ -public: - static void main() - { - Run^ test = gcnew Run; - test->SerializeObject( "Teacher.xml" ); - test->DeserializeObject( "Teacher.xml" ); - } - -private: - void SerializeObject( String^ filename ) - { - // Writing the file requires a TextWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - // Create a Type array. - array^extraTypes = gcnew array(3); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - extraTypes[ 2 ] = InternationalPhone::typeid; - - // Create the XmlSerializer instance. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Teacher::typeid,extraTypes ); - Teacher^ teacher = gcnew Teacher; - teacher->Name = "Mike"; - - // Add extra types to the Teacher object - array^info = gcnew array(2); - info[ 0 ] = gcnew Address( "Springville" ); - info[ 1 ] = gcnew Phone( "555-0100" ); - teacher->Info = info; - teacher->PhoneInfo = gcnew InternationalPhone( "000" ); - mySerializer->Serialize( myStreamWriter, teacher ); - myStreamWriter->Close(); - } - - void DeserializeObject( String^ filename ) - { - // Create a Type array. - array^extraTypes = gcnew array(3); - extraTypes[ 0 ] = Address::typeid; - extraTypes[ 1 ] = Phone::typeid; - extraTypes[ 2 ] = InternationalPhone::typeid; - - // Create the XmlSerializer instance. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Teacher::typeid,extraTypes ); - - // Reading a file requires a FileStream. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Teacher^ teacher = dynamic_cast(mySerializer->Deserialize( fs )); - - // Read the extra information. - Address^ a = dynamic_cast(teacher->Info[ 0 ]); - Phone^ p = dynamic_cast(teacher->Info[ 1 ]); - InternationalPhone^ Ip = dynamic_cast(teacher->PhoneInfo); - Console::WriteLine( teacher->Name ); - Console::WriteLine( a->City ); - Console::WriteLine( p->PhoneNumber ); - Console::WriteLine( Ip->CountryCode ); - } -}; - -int main() -{ - Run::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp deleted file mode 100644 index 0050ba6a3ce..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp +++ /dev/null @@ -1,133 +0,0 @@ - - -// -// Beginning of HighSchool.dll -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -namespace HighSchool -{ - public ref class Student - { - public: - String^ Name; - int ID; - }; - - public ref class MyClass - { - public: - array^Students; - }; -} - -namespace College -{ - -using namespace HighSchool; - public ref class Graduate: public HighSchool::Student - { - public: - Graduate(){} - - // Add a new field named University. - String^ University; - }; - - public ref class Run - { - public: - static void main() - { - Run^ test = gcnew Run; - test->WriteOverriddenAttributes( "College.xml" ); - test->ReadOverriddenAttributes( "College.xml" ); - } - - private: - void WriteOverriddenAttributes( String^ filename ) - { - // Writing the file requires a TextWriter. - TextWriter^ myStreamWriter = gcnew StreamWriter( filename ); - - // Create an XMLAttributeOverrides class. - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - - // Create the XmlAttributes class. - XmlAttributes^ attrs = gcnew XmlAttributes; - - /* Override the Student class. "Alumni" is the name - of the overriding element in the XML output. */ - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - - /* Add the XmlElementAttribute to the collection of - elements in the XmlAttributes object. */ - attrs->XmlElements->Add( attr ); - - /* Add the XmlAttributes to the XmlAttributeOverrides. - "Students" is the name being overridden. */ - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - - // Create the XmlSerializer. - XmlSerializer^ mySerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides ); - MyClass ^ myClass = gcnew MyClass; - Graduate^ g1 = gcnew Graduate; - g1->Name = "Jackie"; - g1->ID = 1; - g1->University = "Alma Mater"; - Graduate^ g2 = gcnew Graduate; - g2->Name = "Megan"; - g2->ID = 2; - g2->University = "CM"; - array^myArray = {g1,g2}; - myClass->Students = myArray; - mySerializer->Serialize( myStreamWriter, myClass ); - myStreamWriter->Close(); - } - - void ReadOverriddenAttributes( String^ filename ) - { - /* The majority of the code here is the same as that in the - WriteOverriddenAttributes method. Because the XML being read - doesn't conform to the schema defined by the DLL, the - XMLAttributesOverrides must be used to create an - XmlSerializer instance to read the XML document.*/ - XmlAttributeOverrides^ attrOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlElementAttribute^ attr = gcnew XmlElementAttribute( "Alumni",Graduate::typeid ); - attrs->XmlElements->Add( attr ); - attrOverrides->Add( HighSchool::MyClass::typeid, "Students", attrs ); - XmlSerializer^ readSerializer = gcnew XmlSerializer( HighSchool::MyClass::typeid,attrOverrides ); - - // To read the file, a FileStream object is required. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - MyClass ^ myClass; - myClass = dynamic_cast(readSerializer->Deserialize( fs )); - - /* Here is the difference between reading and writing an - XML document: You must declare an object of the derived - type (Graduate) and cast the Student instance to it.*/ - Graduate^ g; - System::Collections::IEnumerator^ myEnum = myClass->Students->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Graduate^ grad = safe_cast(myEnum->Current); - g = dynamic_cast(grad); - Console::Write( "{0}\t", g->Name ); - Console::Write( "{0}\t", g->ID ); - Console::Write( "{0}\n", g->University ); - } - } - }; -} - -int main() -{ - College::Run::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp deleted file mode 100644 index 6dabc064fb4..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void SerializeObject( String^ filename ) - { - XmlSerializer^ serializer = - gcnew XmlSerializer( OrderedItem::typeid ); - - // Create an instance of the class to be serialized. - OrderedItem^ i = gcnew OrderedItem; - - // Set the public property values. - i->ItemName = "Widget"; - i->Description = "Regular Widget"; - i->Quantity = 10; - i->UnitPrice = (Decimal)2.30; - - // Writing the document requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Serialize the object, and close the TextWriter. - serializer->Serialize( writer, i ); - writer->Close(); - } - -public: - // This is the class that will be serialized. - ref class OrderedItem - { - public: - String^ ItemName; - String^ Description; - Decimal UnitPrice; - int Quantity; - }; - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp deleted file mode 100644 index 01f91598da8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp +++ /dev/null @@ -1,82 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Price -{ -public: - - [XmlAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ currency; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Decimal price; -}; - -[XmlType(Namespace="http://www.cpandl.com")] -public ref class Book -{ -public: - - [XmlElement(Namespace="http://www.cpandl.com")] - String^ TITLE; - - [XmlElement(Namespace="http://www.cohowinery.com")] - Price^ PRICE; -}; - -public ref class Books -{ -public: - - [XmlElement(Namespace="http://www.cohowinery.com")] - Book^ Book; -}; - -public ref class Run -{ -public: - static void main() - { - Run^ test = gcnew Run; - test->SerializeObject( "XmlNamespaces.xml" ); - } - - void SerializeObject( String^ filename ) - { - XmlSerializer^ s = gcnew XmlSerializer( Books::typeid ); - - // Writing a file requires a TextWriter. - TextWriter^ t = gcnew StreamWriter( filename ); - - /* Create an XmlSerializerNamespaces object and add two - prefix-namespace pairs. */ - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - ns->Add( "books", "http://www.cpandl.com" ); - ns->Add( "money", "http://www.cohowinery.com" ); - - // Create a Book instance. - Book^ b = gcnew Book; - b->TITLE = "A Book Title"; - Price^ p = gcnew Price; - p->price = (Decimal)9.95; - p->currency = "US Dollar"; - b->PRICE = p; - Books^ bks = gcnew Books; - bks->Book = b; - s->Serialize( t, bks, ns ); - t->Close(); - } -}; - -int main() -{ - Run::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp deleted file mode 100644 index 825b960ef4a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - XmlSerializerNamespaces^ AddNamespaces() - { - XmlSerializerNamespaces^ xmlNamespaces = - gcnew XmlSerializerNamespaces; - - // Add three prefix-namespace pairs. - xmlNamespaces->Add( "money", "http://www.cpandl.com" ); - xmlNamespaces->Add( "books", "http://www.cohowinery.com" ); - xmlNamespaces->Add( "software", "http://www.microsoft.com" ); - - return xmlNamespaces; - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp deleted file mode 100644 index 89a101a18a2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - void PrintNamespacePairs( XmlSerializerNamespaces^ namespaces ) - { - array^ qualifiedNames = namespaces->ToArray(); - for ( int i = 0; i < qualifiedNames->Length; i++ ) - { - Console::WriteLine( "{0}\t{1}", - qualifiedNames[ i ]->Name, qualifiedNames[ i ]->Namespace ); - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp deleted file mode 100644 index 58d5dd55649..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Sample -{ - // -private: - XmlSerializerNamespaces^ CreateFromQNames() - { - XmlQualifiedName^ q1 = - gcnew XmlQualifiedName( "money","http://www.cohowinery.com" ); - - XmlQualifiedName^ q2 = - gcnew XmlQualifiedName( "books","http://www.cpandl.com" ); - - array^ names = { q1, q2 }; - - return gcnew XmlSerializerNamespaces( names ); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp deleted file mode 100644 index fadecdb274e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,99 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml::Serialization; -using namespace System::IO; - -public ref class Group1 -{ -public: - - // The XmlTextAttribute with type set to string informs the - // XmlSerializer that strings should be serialized as XML text. - - [XmlText(String::typeid)] - [XmlElement(Int32::typeid)] - [XmlElement(Double::typeid)] - array^All; - Group1() - { - array^temp = {321,"One",2,3.0,"Two"}; - All = temp; - } -}; - -public enum class GroupType -{ - Small, Medium, Large -}; - -public ref class Group2 -{ -public: - - [XmlText(Type=GroupType::typeid)] - GroupType Type; -}; - -public ref class Group3 -{ -public: - - [XmlText(Type=DateTime::typeid)] - DateTime CreationTime; - Group3() - { - CreationTime = DateTime::Now; - } -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - t->SerializeArray( "XmlText1.xml" ); - t->SerializeEnum( "XmlText2.xml" ); - t->SerializeDateTime( "XmlText3.xml" ); - } - -private: - void SerializeArray( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group1::typeid ); - Group1^ myGroup1 = gcnew Group1; - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup1 ); - writer->Close(); - } - - void SerializeEnum( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group2::typeid ); - Group2^ myGroup = gcnew Group2; - myGroup->Type = GroupType::Medium; - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup ); - writer->Close(); - } - - void SerializeDateTime( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group3::typeid ); - Group3^ myGroup = gcnew Group3; - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup ); - writer->Close(); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp deleted file mode 100644 index d6719698f71..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - String^ GroupName; - String^ Comment; -}; - -public ref class Test -{ -public: - static void main() - { - Test^ t = gcnew Test; - t->SerializerOrder( "TextOverride.xml" ); - } - - /* Create an instance of the XmlSerializer class that overrides - the default way it serializes an object. */ - XmlSerializer^ CreateOverrider() - { - /* Create instances of the XmlAttributes and - XmlAttributeOverrides classes. */ - XmlAttributes^ attrs = gcnew XmlAttributes; - XmlAttributeOverrides^ xOver = gcnew XmlAttributeOverrides; - - /* Create an XmlTextAttribute to override the default - serialization process. */ - XmlTextAttribute^ xText = gcnew XmlTextAttribute; - attrs->XmlText = xText; - - // Add the XmlAttributes to the XmlAttributeOverrides. - xOver->Add( Group::typeid, "Comment", attrs ); - - // Create the XmlSerializer, and return it. - XmlSerializer^ xSer = gcnew XmlSerializer( Group::typeid,xOver ); - return xSer; - } - - void SerializerOrder( String^ filename ) - { - // Create an XmlSerializer instance. - XmlSerializer^ xSer = CreateOverrider(); - - // Create the object and serialize it. - Group^ myGroup = gcnew Group; - myGroup->Comment = "This is a great product."; - TextWriter^ writer = gcnew StreamWriter( filename ); - xSer->Serialize( writer, myGroup ); - } -}; - -int main() -{ - Test::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp deleted file mode 100644 index 0b402e1de87..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlType(Namespace="http://www.cpandl.com", -TypeName="GroupMember")] -public ref class Person -{ -public: - String^ Name; -}; - - -[XmlType(Namespace="http://www.cohowinery.com", -TypeName="GroupAddress")] -public ref class Address -{ -public: - String^ Line1; - String^ Line2; - String^ City; - String^ State; - String^ Zip; -}; - -public ref class Group -{ -public: - array^Staff; - Person^ Manager; - Address^ Location; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp deleted file mode 100644 index 592b8ccb053..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlType(IncludeInSchema=false)] -public ref class ExtraneousInfo{}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp deleted file mode 100644 index 04919033ae5..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp +++ /dev/null @@ -1,15 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// - -[XmlType(Namespace="http://www.cpandl.com")] -public ref class Book{}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp deleted file mode 100644 index 87847fcbb3e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// -ref class Person; -ref class Job; -ref class Group -{ -public: - array^Staff; -}; - - -[XmlType(TypeName="Employee", -Namespace="http://www.cpandl.com")] -public ref class Person -{ -public: - String^ PersonName; - Job^ Position; -}; - - -[XmlType(TypeName="Occupation", -Namespace="http://www.cohowinery.com")] -public ref class Job -{ -public: - String^ JobName; -}; - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp b/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp deleted file mode 100644 index 1418ec5d414..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; - -public ref class Forest -{ - // Set the NestingLevel for each array. The first - // attribute (NestingLevel = 0) is optional. -public: - [XmlArrayItem(ElementName = "tree", NestingLevel = 0)] - [XmlArrayItem(ElementName = "branch", NestingLevel = 1)] - [XmlArrayItem(ElementName = "leaf",NestingLevel = 2)] - array^>^>^ TreeArray; -}; - -int main() -{ - XmlSerializer^ serializer = gcnew XmlSerializer(Forest::typeid); - - Forest^ constructedForest = gcnew Forest(); - array^>^>^ tree = - gcnew array^>^>(2); - - array^>^ firstBranch = gcnew array^>(1); - firstBranch[0] = gcnew array{"One"}; - tree[0] = firstBranch; - - array^>^ secondBranch = gcnew array^>(2); - secondBranch[0] = gcnew array{"One","Two"}; - secondBranch[1] = gcnew array{"One","Two","Three"}; - tree[1] = secondBranch; - - constructedForest->TreeArray = tree; - - serializer->Serialize(Console::Out, constructedForest); -} - -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp deleted file mode 100644 index 076a9f19088..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp +++ /dev/null @@ -1,126 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; -using namespace System::ComponentModel; -public ref class Group -{ -public: - - // The default is set to .NET. - - [DefaultValue(".NET")] - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Setting the GroupName to '.NET' is like not setting it at all - // because it is the default value. So no value will be - // serialized, and on deserialization it will appear as a blank. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); - } - - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // The specifies that the default value is now - // 'Team1'. So setting the GroupName to '.NET' means - // the value will be serialized. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - - void DeserializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = gcnew XmlSerializer( Group::typeid ); - - // Reading the file requires a TextReader. - TextReader^ reader = gcnew StreamReader( filename ); - - // Deserialize and cast the Object*. - Group^ myGroup; - myGroup = safe_cast(mySerializer->Deserialize( reader )); - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine(); - } - - void DeserializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Reading the file requires a TextReader. - TextReader^ reader = gcnew StreamReader( filename ); - - // Deserialize and cast the Object*. - Group^ myGroup; - myGroup = safe_cast(overRideSerializer->Deserialize( reader )); - Console::WriteLine( myGroup->GroupName ); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ soapAtts = gcnew SoapAttributes; - - // Create a new DefaultValueAttribute Object* for the GroupName - // property. - DefaultValueAttribute^ newDefault = gcnew DefaultValueAttribute( "Team1" ); - soapAtts->SoapDefaultValue = newDefault; - mySoapAttributeOverrides->Add( Group::typeid, "GroupName", soapAtts ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer Object*. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOriginal( "SoapOriginal.xml" ); - test->SerializeOverride( "mySoapAttributeOverridesideAttributes.xml" ); - test->DeserializeOriginal( "SoapOriginal.xml" ); - test->DeserializeOverride( "mySoapAttributeOverridesideAttributes.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp deleted file mode 100644 index 6c2fca3bb4d..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp +++ /dev/null @@ -1,115 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -//using namespace System::Runtime::Remoting::Metadata; -public ref class Vehicle -{ -public: - String^ licenseNumber; -}; - - -[SoapInclude(Vehicle::typeid)] -public ref class Group -{ -public: - - [SoapAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; - - [SoapAttributeAttribute(DataType="base64Binary")] - array^GroupNumber; - - [SoapAttributeAttribute(DataType="date",AttributeName="CreationDate")] - DateTime Today; - - [SoapElement(DataType="nonNegativeInteger",ElementName="PosInt")] - String^ PostitiveInt; - Vehicle^ GroupVehicle; -}; - -public ref class Run -{ -public: - void SerializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // can generate encoded SOAP messages. - XmlSerializer^ mySerializer = ReturnSOAPSerializer(); - Group^ myGroup = MakeGroup(); - - // Writing the file requires a TextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->WriteEndElement(); - writer->Close(); - } - - -private: - Group^ MakeGroup() - { - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - array^hexByte = {Convert::ToByte( 100 ),Convert::ToByte( 50 )}; - myGroup->GroupNumber = hexByte; - DateTime myDate = DateTime(2002,5,2); - myGroup->Today = myDate; - myGroup->PostitiveInt = "10000"; - myGroup->GroupVehicle = gcnew Vehicle; - myGroup->GroupVehicle->licenseNumber = "1234"; - return myGroup; - } - -public: - void DeserializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // can generate encoded SOAP messages. - XmlSerializer^ mySerializer = ReturnSOAPSerializer(); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement( "wrapper" ); - - // Deserialize and cast the Object*. - Group^ myGroup; - myGroup = safe_cast(mySerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - } - -private: - XmlSerializer^ ReturnSOAPSerializer() - { - - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - return gcnew XmlSerializer( myMapping ); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeObject( "SoapAtts.xml" ); - test->DeserializeObject( "SoapAtts.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp deleted file mode 100644 index ca2b9a2176d..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp +++ /dev/null @@ -1,76 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Group -{ -public: - - // This attribute will be overridden. - - [SoapAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ mySoapAttributes = gcnew SoapAttributes; - - // Create a new SoapAttributeAttribute to the - // one applied to the Group class. The resulting XML - // stream will use the new namespace and attribute name. - SoapAttributeAttribute^ mySoapAttribute = gcnew SoapAttributeAttribute; - mySoapAttribute->AttributeName = "TeamName"; - - // Change the Namespace. - mySoapAttribute->Namespace = "http://www.cohowinery.com"; - mySoapAttributes->SoapAttribute = mySoapAttribute; - mySoapAttributeOverrides->Add( Group::typeid, "GroupName", mySoapAttributes ); - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOverride( "SoapOveride.xml" ); -} - -// -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp deleted file mode 100644 index 723d53337e0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -public ref class Group -{ -public: - // Override the serialization of this member. - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ mySoapAttributes = gcnew SoapAttributes; - SoapElementAttribute^ mySoapElement = gcnew SoapElementAttribute; - mySoapElement->ElementName = "TeamName"; - mySoapAttributes->SoapElement = mySoapElement; - - // Add the SoapAttributes to the - // mySoapAttributeOverridesrides object. - mySoapAttributeOverrides->Add( Group::typeid, "GroupName", mySoapAttributes ); - - // Get the SoapAttributes with the Item property. - SoapAttributes^ thisSoapAtts = mySoapAttributeOverrides[Group::typeid, "GroupName"]; - Console::WriteLine( "New serialized element name: {0}", thisSoapAtts->SoapElement->ElementName ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer object. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))-> - ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOverride( "GetSoapAttributes.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp deleted file mode 100644 index e35e9d519f2..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// The name of this type will be overridden using -// the SoapTypeAttribute. -public ref class Group -{ -public: - String^ GroupName; -}; - -public ref class Run -{ -public: - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ mySoapAttributes = gcnew SoapAttributes; - SoapTypeAttribute^ mySoapType = gcnew SoapTypeAttribute; - mySoapType->TypeName = "Team"; - mySoapAttributes->SoapType = mySoapType; - - // Add the SoapAttributes to the - // mySoapAttributeOverridesrides object. - mySoapAttributeOverrides->Add( Group::typeid, mySoapAttributes ); - - // Get the SoapAttributes with the Item property. - SoapAttributes^ thisSoapAtts = mySoapAttributeOverrides[ Group::typeid ]; - Console::WriteLine( "New serialized type name: {0}", thisSoapAtts->SoapType->TypeName ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer object. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))-> - ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOverride( "GetSoapAttributes2.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp deleted file mode 100644 index cd4ad348629..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp +++ /dev/null @@ -1,246 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; -ref class Car; - -// SoapInclude allows Vehicle to accept Car type. - -[SoapInclude(Car::typeid)] -public ref class Vehicle abstract -{ -public: - String^ licenseNumber; - DateTime makeDate; -}; - -public ref class Car: public Vehicle{}; - -public enum class GroupType -{ - // These enums can be overridden. - [SoapEnum("Small")] - A, - [SoapEnum("Large")] - B -}; - -public ref class Group -{ -public: - - [SoapAttributeAttribute(Namespace="http://www.cpandl.com")] - String^ GroupName; - - [SoapAttributeAttribute(DataType="base64Binary")] - array^GroupNumber; - - [SoapAttributeAttribute(DataType="date",AttributeName="CreationDate")] - DateTime Today; - - [SoapElement(DataType="nonNegativeInteger",ElementName="PosInt")] - String^ PostitiveInt; - - // This is ignored when serialized unless it's overridden. - - [SoapIgnore] - bool IgnoreThis; - GroupType Grouptype; - Vehicle^ MyVehicle; - - // The SoapInclude allows the method to return a Car. - - [SoapInclude(Car::typeid)] - Vehicle^ myCar( String^ licNumber ) - { - Vehicle^ v; - if ( licNumber->Equals( "" ) ) - { - v = gcnew Car; - v->licenseNumber = "!!!!!!"; - } - else - { - v = gcnew Car; - v->licenseNumber = licNumber; - } - - return v; - } -}; - -public ref class Run -{ -public: - static void main() - { - Run^ test = gcnew Run; - test->SerializeOriginal( "SoapOriginal.xml" ); - test->SerializeOverride( "SoapOverrides.xml" ); - test->DeserializeOriginal( "SoapOriginal.xml" ); - test->DeserializeOverride( "SoapOverrides.xml" ); - } - - void SerializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( myMapping ); - Group^ myGroup = MakeGroup(); - - // Writing the file requires a TextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->WriteEndElement(); - writer->Close(); - } - - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class - // that overrides the serialization. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - Group^ myGroup = MakeGroup(); - - // Writing the file requires a TextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - - // Serialize the class, and close the TextWriter. - overRideSerializer->Serialize( writer, myGroup ); - writer->WriteEndElement(); - writer->Close(); - } - -private: - Group^ MakeGroup() - { - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the object properties. - myGroup->GroupName = ".NET"; - array^hexByte = {Convert::ToByte( 100 ),Convert::ToByte( 50 )}; - myGroup->GroupNumber = hexByte; - DateTime myDate = DateTime(2002,5,2); - myGroup->Today = myDate; - myGroup->PostitiveInt = "10000"; - myGroup->IgnoreThis = true; - myGroup->Grouptype = GroupType::B; - Car^ thisCar = dynamic_cast(myGroup->myCar( "1234566" )); - myGroup->MyVehicle = thisCar; - return myGroup; - } - -public: - void DeserializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( myMapping ); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement( "wrapper" ); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(mySerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - } - - void DeserializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ overRideSerializer = CreateOverrideSerializer(); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement( "wrapper" ); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(overRideSerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - ReadGroup( myGroup ); - } - -private: - void ReadGroup( Group^ myGroup ) - { - Console::WriteLine( myGroup->GroupName ); - Console::WriteLine( myGroup->GroupNumber[ 0 ] ); - Console::WriteLine( myGroup->GroupNumber[ 1 ] ); - Console::WriteLine( myGroup->Today ); - Console::WriteLine( myGroup->PostitiveInt ); - Console::WriteLine( myGroup->IgnoreThis ); - Console::WriteLine(); - } - - XmlSerializer^ CreateOverrideSerializer() - { - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ soapAtts = gcnew SoapAttributes; - SoapElementAttribute^ mySoapElement = gcnew SoapElementAttribute; - mySoapElement->ElementName = "xxxx"; - soapAtts->SoapElement = mySoapElement; - mySoapAttributeOverrides->Add( Group::typeid, "PostitiveInt", soapAtts ); - - // Override the IgnoreThis property. - SoapIgnoreAttribute^ myIgnore = gcnew SoapIgnoreAttribute; - soapAtts = gcnew SoapAttributes; - soapAtts->SoapIgnore = false; - mySoapAttributeOverrides->Add( Group::typeid, "IgnoreThis", soapAtts ); - - // Override the GroupType enumeration. - soapAtts = gcnew SoapAttributes; - SoapEnumAttribute^ xSoapEnum = gcnew SoapEnumAttribute; - xSoapEnum->Name = "Over1000"; - soapAtts->GroupType::SoapEnum = xSoapEnum; - - // Add the SoapAttributes to the - // mySoapAttributeOverridesrides object. - mySoapAttributeOverrides->Add( GroupType::typeid, "A", soapAtts ); - - // Create second enumeration and add it. - soapAtts = gcnew SoapAttributes; - xSoapEnum = gcnew SoapEnumAttribute; - xSoapEnum->Name = "ZeroTo1000"; - soapAtts->GroupType::SoapEnum = xSoapEnum; - mySoapAttributeOverrides->Add( GroupType::typeid, "B", soapAtts ); - - // Override the Group type. - soapAtts = gcnew SoapAttributes; - SoapTypeAttribute^ soapType = gcnew SoapTypeAttribute; - soapType->TypeName = "Team"; - soapAtts->SoapType = soapType; - mySoapAttributeOverrides->Add( Group::typeid, soapAtts ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer object. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run::main(); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp deleted file mode 100644 index bbc969c59c5..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp +++ /dev/null @@ -1,106 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Text; -public ref class Thing -{ -public: - - [SoapElement(IsNullable=true)] - String^ ThingName; -}; - -public ref class Transportation -{ -public: - - // The SoapElementAttribute specifies that the - // generated XML element name will be S"Wheels" - // instead of S"Vehicle". - - [SoapElement("Wheels")] - String^ Vehicle; - - [SoapElement(DataType="dateTime")] - DateTime CreationDate; - - [SoapElement(IsNullable=true)] - Thing^ thing; -}; - -public ref class Test -{ -public: - - // Return an XmlSerializer used for overriding. - XmlSerializer^ CreateSoapOverrider() - { - // Create the SoapAttributes and SoapAttributeOverrides objects. - SoapAttributes^ soapAttrs = gcnew SoapAttributes; - SoapAttributeOverrides^ soapOverrides = gcnew SoapAttributeOverrides; - - // Create an SoapElementAttribute to the Vehicles property. - SoapElementAttribute^ soapElement1 = gcnew SoapElementAttribute( "Truck" ); - - // Set the SoapElement to the Object*. - soapAttrs->SoapElement = soapElement1; - - // Add the SoapAttributes to the SoapAttributeOverrides,specifying the member to. - soapOverrides->Add( Transportation::typeid, "Vehicle", soapAttrs ); - - // Create the XmlSerializer, and return it. - XmlTypeMapping^ myTypeMapping = (gcnew SoapReflectionImporter( soapOverrides ))->ImportTypeMapping( Transportation::typeid ); - return gcnew XmlSerializer( myTypeMapping ); - } - - void SerializeOverride( String^ filename ) - { - // Create an XmlSerializer instance. - XmlSerializer^ ser = CreateSoapOverrider(); - - // Create the Object* and serialize it. - Transportation^ myTransportation = gcnew Transportation; - myTransportation->Vehicle = "MyCar"; - myTransportation->CreationDate = DateTime::Now; - myTransportation->thing = gcnew Thing; - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - ser->Serialize( writer, myTransportation ); - writer->WriteEndElement(); - writer->Close(); - } - - void SerializeObject( String^ filename ) - { - // Create an XmlSerializer instance. - XmlSerializer^ ser = gcnew XmlSerializer( Transportation::typeid ); - Transportation^ myTransportation = gcnew Transportation; - myTransportation->Vehicle = "MyCar"; - myTransportation->CreationDate = DateTime::Now; - myTransportation->thing = gcnew Thing; - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - ser->Serialize( writer, myTransportation ); - writer->WriteEndElement(); - writer->Close(); - } -}; - -int main() -{ - Test^ t = gcnew Test; - t->SerializeObject( "SoapElementOriginal.xml" ); - t->SerializeOverride( "SoapElementOverride.xml" ); - Console::WriteLine( "Finished writing two XML files." ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp deleted file mode 100644 index a91c48a0ab8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp +++ /dev/null @@ -1,94 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public enum class GroupType -{ - // Use the SoapEnumAttribute to instruct the XmlSerializer - // to generate Small and Large instead of A and B. - [SoapEnum("Small")] - A, - [SoapEnum("Large")] - B -}; - -public ref class Group -{ -public: - String^ GroupName; - GroupType Grouptype; -}; - -public ref class Run -{ -public: - void SerializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer Class. - XmlTypeMapping^ mapp = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( mapp ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an instance of the Class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - myGroup->Grouptype = GroupType::A; - - // Serialize the Class, and close the TextWriter. - mySerializer->Serialize( writer, myGroup ); - writer->Close(); - } - - void SerializeOverride( String^ fileName ) - { - SoapAttributeOverrides^ soapOver = gcnew SoapAttributeOverrides; - SoapAttributes^ SoapAtts = gcnew SoapAttributes; - - // Add a SoapEnumAttribute for the GroupType::A enumerator. - // Instead of 'A' it will be S"West". - SoapEnumAttribute^ soapEnum = gcnew SoapEnumAttribute( "West" ); - - // Override the S"A" enumerator. - SoapAtts->GroupType::SoapEnum = soapEnum; - soapOver->Add( GroupType::typeid, "A", SoapAtts ); - - // Add another SoapEnumAttribute for the GroupType::B enumerator. - // Instead of //B// it will be S"East". - SoapAtts = gcnew SoapAttributes; - soapEnum = gcnew SoapEnumAttribute; - soapEnum->Name = "East"; - SoapAtts->GroupType::SoapEnum = soapEnum; - soapOver->Add( GroupType::typeid, "B", SoapAtts ); - - // Create an XmlSerializer used for overriding. - XmlTypeMapping^ map = (gcnew SoapReflectionImporter( soapOver ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( map ); - Group^ myGroup = gcnew Group; - myGroup->GroupName = ".NET"; - myGroup->Grouptype = GroupType::B; - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( fileName ); - ser->Serialize( writer, myGroup ); - writer->Close(); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeObject( "SoapEnum.xml" ); - test->SerializeOverride( "SoapOverride.xml" ); - Console::WriteLine( "Fininished writing two files" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp b/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp deleted file mode 100644 index 1c316326d9c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp +++ /dev/null @@ -1,171 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -[SoapType("EmployeeType")] -public ref class Employee -{ -public: - String^ Name; -}; - - -// The SoapType is overridden when the -// SerializeOverride method is called. - -[SoapType("SoapGroupType","http://www.cohowinery.com")] -public ref class Group -{ -public: - String^ GroupName; - array^Employees; -}; - -public ref class Run -{ -public: - void SerializeOriginal( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // can be used for serializing as a SOAP message. - XmlTypeMapping^ mapp = (gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid ); - XmlSerializer^ mySerializer = gcnew XmlSerializer( mapp ); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an XML text writer. - XmlTextWriter^ xmlWriter = gcnew XmlTextWriter( writer ); - xmlWriter->Formatting = Formatting::Indented; - xmlWriter->Indentation = 2; - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - Employee^ e1 = gcnew Employee; - e1->Name = "Pat"; - myGroup->Employees = gcnew array(1); - myGroup->Employees[ 0 ] = e1; - - // Write the root element. - xmlWriter->WriteStartElement( "root" ); - - // Serialize the class. - mySerializer->Serialize( xmlWriter, myGroup ); - - // Close the root tag. - xmlWriter->WriteEndElement(); - - // Close the XmlWriter. - xmlWriter->Close(); - - // Close the TextWriter. - writer->Close(); - } - - void SerializeOverride( String^ filename ) - { - // Create an instance of the XmlSerializer class that - // uses a SoapAttributeOverrides Object*. - XmlSerializer^ mySerializer = CreateOverrideSerializer(); - - // Writing the file requires a TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create an XML text writer. - XmlTextWriter^ xmlWriter = gcnew XmlTextWriter( writer ); - xmlWriter->Formatting = Formatting::Indented; - xmlWriter->Indentation = 2; - - // Create an instance of the class that will be serialized. - Group^ myGroup = gcnew Group; - - // Set the Object* properties. - myGroup->GroupName = ".NET"; - Employee^ e1 = gcnew Employee; - e1->Name = "Pat"; - myGroup->Employees = gcnew array(1); - myGroup->Employees[ 0 ] = e1; - - // Write the root element. - xmlWriter->WriteStartElement( "root" ); - - // Serialize the class. - mySerializer->Serialize( xmlWriter, myGroup ); - - // Close the root tag. - xmlWriter->WriteEndElement(); - - // Close the XmlWriter. - xmlWriter->Close(); - - // Close the TextWriter. - writer->Close(); - } - - void DeserializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlSerializer^ mySerializer = CreateOverrideSerializer(); - - // Reading the file requires a TextReader. - TextReader^ reader = gcnew StreamReader( filename ); - - // Create an XML text reader. - XmlTextReader^ xmlReader = gcnew XmlTextReader( reader ); - xmlReader->ReadStartElement(); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(mySerializer->Deserialize( xmlReader )); - xmlReader->ReadEndElement(); - Console::WriteLine( "The GroupName is {0}", myGroup->GroupName ); - Console::WriteLine( "Look at the SoapType.xml and SoapType2.xml " - "files for the generated XML." ); - - // Close the readers. - xmlReader->Close(); - reader->Close(); - } - -private: - XmlSerializer^ CreateOverrideSerializer() - { - // Create and return an XmlSerializer instance used to - // and create SOAP messages. - SoapAttributeOverrides^ mySoapAttributeOverrides = gcnew SoapAttributeOverrides; - SoapAttributes^ soapAtts = gcnew SoapAttributes; - - // Override the SoapTypeAttribute. - SoapTypeAttribute^ soapType = gcnew SoapTypeAttribute; - soapType->TypeName = "Team"; - soapType->IncludeInSchema = false; - soapType->Namespace = "http://www.microsoft.com"; - soapAtts->SoapType = soapType; - mySoapAttributeOverrides->Add( Group::typeid, soapAtts ); - - // Create an XmlTypeMapping that is used to create an instance - // of the XmlSerializer. Then return the XmlSerializer Object*. - XmlTypeMapping^ myMapping = (gcnew SoapReflectionImporter( mySoapAttributeOverrides ))->ImportTypeMapping( Group::typeid ); - XmlSerializer^ ser = gcnew XmlSerializer( myMapping ); - return ser; - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->SerializeOriginal( "SoapType.xml" ); - test->SerializeOverride( "SoapType2.xml" ); - test->DeserializeObject( "SoapType2.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp b/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp deleted file mode 100644 index 0f5bd7c7799..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp +++ /dev/null @@ -1,90 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::Xml::Schema; - -ref class Vehicle; - -[SoapInclude(Vehicle::typeid)] -public ref class Vehicle -{ -public: - String^ licenseNumber; -}; - - -// You must use the SoapIncludeAttribute to inform the XmlSerializer -// that the Vehicle type should be recognized when deserializing. - -[SoapInclude(Vehicle::typeid)] -public ref class Group -{ -public: - String^ GroupName; - Vehicle^ GroupVehicle; -}; - -public ref class Run -{ -public: - void DeserializeObject( String^ filename ) - { - // Create an instance of the XmlSerializer class. - XmlTypeMapping^ myMapping = ((gcnew SoapReflectionImporter)->ImportTypeMapping( Group::typeid )); - XmlSerializer^ mySerializer = gcnew XmlSerializer( myMapping ); - mySerializer->UnreferencedObject += gcnew UnreferencedObjectEventHandler( this, &Run::Serializer_UnreferencedObject ); - - // Reading the file requires an XmlTextReader. - XmlTextReader^ reader = gcnew XmlTextReader( filename ); - reader->ReadStartElement(); - - // Deserialize and cast the object. - Group^ myGroup; - myGroup = dynamic_cast(mySerializer->Deserialize( reader )); - reader->ReadEndElement(); - reader->Close(); - } - -private: - void Serializer_UnreferencedObject( Object^ /*sender*/, UnreferencedObjectEventArgs^ e ) - { - Console::WriteLine( "UnreferencedObject:" ); - Console::WriteLine( "ID: {0}", e->UnreferencedId ); - Console::WriteLine( "UnreferencedObject: {0}", e->UnreferencedObject ); - Vehicle^ myVehicle = dynamic_cast(e->UnreferencedObject); - Console::WriteLine( "License: {0}", myVehicle->licenseNumber ); - } -}; - -int main() -{ - Run^ test = gcnew Run; - test->DeserializeObject( "UnrefObj.xml" ); -} - -// The file named S"UnrefObj.xml" should contain this XML: -// -// -// -// -// ABCD -// -// -// 1234 -// -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XMLAttributeAttribute_ctr1_2/CPP/xmlAttributeAttribute_ctr1_2.cpp b/snippets/cpp/VS_Snippets_Remoting/XMLAttributeAttribute_ctr1_2/CPP/xmlAttributeAttribute_ctr1_2.cpp deleted file mode 100644 index 165da0b159e..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XMLAttributeAttribute_ctr1_2/CPP/xmlAttributeAttribute_ctr1_2.cpp +++ /dev/null @@ -1,100 +0,0 @@ - - -// System.Xml.Serialization.XmlAttributeAttribute.XmlAttributeAttribute() -// System.Xml.Serialization.XmlAttributeAttribute.XmlAttributeAttribute(String) -/* The following example demonstrates the XmlAttributeAttribute constructor. -* This sample serializes a class named 'Student'. The StudentName property is -* serialized as an XML attribute. It also serializes a class named 'Book'. -*/ -// -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -// This is the class that will be serialized. -public ref class Student -{ -public: - String^ StudentName; - int StudentNumber; -}; - -public ref class Book -{ -public: - String^ BookName; - int BookNumber; -}; - -void SerializeObject( String^ studentFilename, String^ bookFilename ) -{ - XmlSerializer^ mySerializer; - TextWriter^ writer; - - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ myXmlAttributeOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ myXmlAttributes = gcnew XmlAttributes; - - /* Create an XmlAttributeAttribute set it to - the XmlAttribute property of the XmlAttributes object.*/ - XmlAttributeAttribute^ myXmlAttributeAttribute = gcnew XmlAttributeAttribute; - myXmlAttributeAttribute->AttributeName = "Name"; - myXmlAttributes->XmlAttribute = myXmlAttributeAttribute; - - // Add to the XmlAttributeOverrides. Specify the member name. - myXmlAttributeOverrides->Add( Student::typeid, "StudentName", myXmlAttributes ); - - // Create the XmlSerializer. - mySerializer = gcnew XmlSerializer( Student::typeid,myXmlAttributeOverrides ); - writer = gcnew StreamWriter( studentFilename ); - - // Create an instance of the class that will be serialized. - Student^ myStudent = gcnew Student; - - // Set the Name property, which will be generated as an XML attribute. - myStudent->StudentName = "James"; - myStudent->StudentNumber = 1; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myStudent ); - writer->Close(); - - // Create the XmlAttributeOverrides and XmlAttributes objects. - XmlAttributeOverrides^ myXmlBookAttributeOverrides = gcnew XmlAttributeOverrides; - XmlAttributes^ myXmlBookAttributes = gcnew XmlAttributes; - - /* Create an XmlAttributeAttribute set it to - the XmlAttribute property of the XmlAttributes object.*/ - XmlAttributeAttribute^ myXmlBookAttributeAttribute = gcnew XmlAttributeAttribute( "Name" ); - myXmlBookAttributes->XmlAttribute = myXmlBookAttributeAttribute; - - // Add to the XmlAttributeOverrides. Specify the member name. - myXmlBookAttributeOverrides->Add( Book::typeid, "BookName", myXmlBookAttributes ); - - // Create the XmlSerializer. - mySerializer = gcnew XmlSerializer( Book::typeid,myXmlBookAttributeOverrides ); - writer = gcnew StreamWriter( bookFilename ); - - // Create an instance of the class that will be serialized. - Book^ myBook = gcnew Book; - - // Set the Name property, which will be generated as an XML attribute. - myBook->BookName = ".NET"; - myBook->BookNumber = 10; - - // Serialize the class, and close the TextWriter. - mySerializer->Serialize( writer, myBook ); - writer->Close(); -} - -int main() -{ - SerializeObject( "Student.xml", "Book.xml" ); -} -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_Constructor/CPP/xmlrootattribute_constructor.cpp b/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_Constructor/CPP/xmlrootattribute_constructor.cpp deleted file mode 100644 index a12e4ff3e02..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_Constructor/CPP/xmlrootattribute_constructor.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// System::Xml::Serialization::XmlRootAttribute.XmlRootAttribute(String*) - -/* The following example demonstrates the constructor -'XmlRootAttribute(String*)' of class 'XmlRootAttribute'. -This program demonstrates 'Student' class to -which the 'XmlRootAttribute(String*)' constructor has been applied. -*/ - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that is the default root element. -public ref class Student -{ -public: - String^ Name; -}; - -public ref class XMLRootAttributeClass -{ -// -public: - void SerializeOrder( String^ filename ) - { - // Create an XmlSerializer instance using the method below. - XmlSerializer^ myXmlSerializer = CreateOverrider(); - - // Create the object, and set its Name property. - Student^ myStudent = gcnew Student; - myStudent->Name = "Student class1"; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - myXmlSerializer->Serialize( writer, myStudent ); - writer->Close(); - } - - // Return an XmlSerializer to the root serialization. - XmlSerializer^ CreateOverrider() - { - // Create an XmlAttributes to the default root element. - XmlAttributes^ myXmlAttributes = gcnew XmlAttributes; - - // Create an XmlRootAttribute overloaded constructer - // and set its namespace. - XmlRootAttribute^ myXmlRootAttribute = - gcnew XmlRootAttribute( "OverriddenRootElementName" ); - myXmlRootAttribute->Namespace = "http://www.microsoft.com"; - - // Set the XmlRoot property to the XmlRoot object. - myXmlAttributes->XmlRoot = myXmlRootAttribute; - XmlAttributeOverrides^ myXmlAttributeOverrides = - gcnew XmlAttributeOverrides; - - // Add the XmlAttributes object to the XmlAttributeOverrides object - myXmlAttributeOverrides->Add( Student::typeid, myXmlAttributes ); - - // Create the Serializer, and return it. - XmlSerializer^ myXmlSerializer = gcnew XmlSerializer( - Student::typeid, myXmlAttributeOverrides ); - return myXmlSerializer; - } -// -}; - -int main() -{ - XMLRootAttributeClass^ myXMLRootAttributeClass = - gcnew XMLRootAttributeClass; - myXMLRootAttributeClass->SerializeOrder( - "XMLRootAttributeConstructor.xml" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp b/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp deleted file mode 100644 index c87e784d7f0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// System::Xml::Serialization::XmlRootAttribute.ElementName - -// The following example demonstrates the property -// 'ElementName' of class 'XmlRootAttribute'. -// This program demonstrates 'Student' class to -// which the 'ElementName' property has been applied. - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -// This is the class that is the default root element. -public ref class Student -{ -public: - String^ Name; -}; - -public ref class XMLRootAttributeClass -{ -// -public: - void SerializeOrder( String^ filename ) - { - // Create an XmlSerializer instance using the method below. - XmlSerializer^ myXmlSerializer = CreateOverrider(); - - // Create the object, and set its Name property. - Student^ myStudent = gcnew Student; - myStudent->Name = "Student class1"; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - myXmlSerializer->Serialize( writer, myStudent ); - writer->Close(); - } - - // Return an XmlSerializer to the root serialization. - XmlSerializer^ CreateOverrider() - { - // Create an XmlAttributes to the default root element. - XmlAttributes^ myXmlAttributes = gcnew XmlAttributes; - - // Create an XmlRootAttribute and set its element name and namespace. - XmlRootAttribute^ myXmlRootAttribute = gcnew XmlRootAttribute; - myXmlRootAttribute->ElementName = "OverriddenRootElementName"; - myXmlRootAttribute->Namespace = "http://www.microsoft.com"; - - // Set the XmlRoot property to the XmlRoot object. - myXmlAttributes->XmlRoot = myXmlRootAttribute; - XmlAttributeOverrides^ myXmlAttributeOverrides = - gcnew XmlAttributeOverrides; - - // Add the XmlAttributes object to the XmlAttributeOverrides object. - myXmlAttributeOverrides->Add( Student::typeid, myXmlAttributes ); - - // Create the Serializer, and return it. - XmlSerializer^ myXmlSerializer = gcnew XmlSerializer( - Student::typeid, myXmlAttributeOverrides ); - return myXmlSerializer; - } -// -}; - -int main() -{ - XMLRootAttributeClass^ myXMLRootAttributeClass = - gcnew XMLRootAttributeClass; - myXMLRootAttributeClass->SerializeOrder( - "XMLRootAttributeConstuctor.xml" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp b/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp deleted file mode 100644 index d2b959c3203..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp +++ /dev/null @@ -1,77 +0,0 @@ - - -// System::Xml::Serialization::XmlTypeAttribute.XmlTypeAttribute() -// System::Xml::Serialization::XmlTypeAttribute.XmlTypeAttribute(String*) -// The following example demonstrates the contructors 'XmlTypeAttribute()' -// and 'XmlTypeAttribute(String*)' of class 'XmlTypeAttribute'. -// This program demonstrates 'Person' and 'Address' classes to -// which the 'XmlTypeAttribute' has been applied. This sample then -// serializes an Object* of class 'Person' into an XML document. -// -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -public ref class Address -{ -public: - String^ state; - String^ zip; -}; - -public ref class Person -{ -public: - String^ personName; - Address^ address; -}; - -public ref class PersonTypeAttribute -{ -public: - XmlSerializer^ CreateOverrider() - { - XmlAttributeOverrides^ personOverride = gcnew XmlAttributeOverrides; - XmlAttributes^ personAttributes = gcnew XmlAttributes; - XmlTypeAttribute^ personType = gcnew XmlTypeAttribute; - personType->TypeName = "Employee"; - personType->Namespace = "http://www.microsoft.com"; - personAttributes->XmlType = personType; - XmlAttributes^ addressAttributes = gcnew XmlAttributes; - - // Create 'XmlTypeAttribute' with 'TypeName' as an argument. - XmlTypeAttribute^ addressType = gcnew XmlTypeAttribute( "Address" ); - addressType->Namespace = "http://www.microsoft.com"; - addressAttributes->XmlType = addressType; - personOverride->Add( Person::typeid, personAttributes ); - personOverride->Add( Address::typeid, addressAttributes ); - XmlSerializer^ myXmlSerializer = gcnew XmlSerializer( Person::typeid,personOverride ); - return myXmlSerializer; - } - - void SerializeObject( String^ filename ) - { - XmlSerializer^ myXmlSerializer = CreateOverrider(); - Address^ myAddress = gcnew Address; - myAddress->state = "AAA"; - myAddress->zip = "11111"; - Person^ myPerson = gcnew Person; - myPerson->personName = "Smith"; - myPerson->address = myAddress; - - // Serialize to a file. - TextWriter^ writer = gcnew StreamWriter( filename ); - myXmlSerializer->Serialize( writer, myPerson ); - } -}; - -int main() -{ - PersonTypeAttribute^ myPersonTypeAttribute = gcnew PersonTypeAttribute; - myPersonTypeAttribute->SerializeObject( "XmlType.xml" ); -} -// -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp deleted file mode 100644 index 5c3508dc8e8..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; - -public ref class Group -{ -public: - String^ GroupName; - - // The UnknownAttributes array will be used to collect all unknown - // attributes found when deserializing. - - [XmlAnyAttributeAttribute] - array^XAttributes; -}; - -void SerializeObject( String^ filename, Object^ g ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, g ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = safe_cast(ser->Deserialize( fs )); - fs->Close(); - - // Write out the data, including unknown attributes. - Console::WriteLine( g->GroupName ); - Console::WriteLine( "Number of unknown attributes: {0}", g->XAttributes->Length ); - for ( IEnumerator ^ e = g->XAttributes->GetEnumerator(); e->MoveNext(); ) - { - XmlAttribute^ xAtt = safe_cast(e->Current); - Console::WriteLine( "{0}: {1}", xAtt->Name, xAtt->InnerXml ); - } - SerializeObject( "AttributesAdded.xml", g ); -} - -int main() -{ - // Deserialize the file containing unknown attributes. - DeserializeObject( "UnknownAttributes.xml" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp deleted file mode 100644 index 31e83e62519..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -public ref class Group -{ -public: - String^ GroupName; - - // The Things array will be used to collect all unknown - // attributes found when deserializing. - array^Things; -}; - -XmlSerializer^ CreateOverrideSerializer(); -void DeserializeObject( String^ filename ) -{ - // Use the CreateOverrideSerializer to return an instance - // of the XmlSerializer customized for overrides. - XmlSerializer^ ser = CreateOverrideSerializer(); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = safe_cast(ser->Deserialize( fs )); - fs->Close(); - Console::WriteLine( g->GroupName ); - Console::WriteLine( g->Things->Length ); - for ( IEnumerator ^ e = g->Things->GetEnumerator(); e->MoveNext(); ) - { - XmlAttribute^ xAtt = safe_cast(e->Current); - Console::WriteLine( "{0}: {1}", xAtt->Name, xAtt->InnerXml ); - } -} - -XmlSerializer^ CreateOverrideSerializer() -{ - // Override the Things field to capture all - // unknown XML attributes. - XmlAnyAttributeAttribute^ myAnyAttribute = gcnew XmlAnyAttributeAttribute; - XmlAttributeOverrides^ xOverride = gcnew XmlAttributeOverrides; - XmlAttributes^ xAtts = gcnew XmlAttributes; - xAtts->XmlAnyAttribute = myAnyAttribute; - xOverride->Add( Group::typeid, "Things", xAtts ); - return gcnew XmlSerializer( Group::typeid,xOverride ); -} - -int main() -{ - DeserializeObject( "UnknownAttributes.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp deleted file mode 100644 index 9915009fc75..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp +++ /dev/null @@ -1,117 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Text; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -using namespace System::Xml::Schema; - -[XmlRoot(Namespace="http://www.cohowinery.com")] -public ref class Group -{ -public: - String^ GroupName; - - // This is for serializing Employee elements. - - [XmlAnyElement(Name="Employee")] - array^UnknownEmployees; - - // This is for serializing City elements. - - [XmlAnyElement - (Name="City", - Namespace="http://www.cpandl.com")] - array^UnknownCity; - - // This one is for all other unknown elements. - - [XmlAnyElement] - array^UnknownElements; -}; - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // Create an XmlNamespaces to use. - XmlSerializerNamespaces^ namespaces = gcnew XmlSerializerNamespaces; - namespaces->Add( "c", "http://www.cohowinery.com" ); - namespaces->Add( "i", "http://www.cpandl.com" ); - Group^ myGroup = gcnew Group; - - // Create arrays of arbitrary XmlElement objects. - // First create an XmlDocument, used to create the - // XmlElement objects. - XmlDocument^ xDoc = gcnew XmlDocument; - - // Create an array of Employee XmlElement objects. - XmlElement^ El1 = xDoc->CreateElement( "Employee", "http://www.cohowinery.com" ); - El1->InnerText = "John"; - XmlElement^ El2 = xDoc->CreateElement( "Employee", "http://www.cohowinery.com" ); - El2->InnerText = "Joan"; - XmlElement^ El3 = xDoc->CreateElement( "Employee", "http://www.cohowinery.com" ); - El3->InnerText = "Jim"; - array^employees = {El1,El2,El3}; - myGroup->UnknownEmployees = employees; - - // Create an array of City XmlElement objects. - XmlElement^ inf1 = xDoc->CreateElement( "City", "http://www.cpandl.com" ); - inf1->InnerText = "Tokyo"; - XmlElement^ inf2 = xDoc->CreateElement( "City", "http://www.cpandl.com" ); - inf2->InnerText = "New York"; - XmlElement^ inf3 = xDoc->CreateElement( "City", "http://www.cpandl.com" ); - inf3->InnerText = "Rome"; - array^cities = {inf1,inf2,inf3}; - myGroup->UnknownCity = cities; - XmlElement^ xEl1 = xDoc->CreateElement( "bld" ); - xEl1->InnerText = "42"; - XmlElement^ xEl2 = xDoc->CreateElement( "Region" ); - xEl2->InnerText = "West"; - XmlElement^ xEl3 = xDoc->CreateElement( "type" ); - xEl3->InnerText = "Technical"; - array^elements = {xEl1,xEl2,xEl3}; - myGroup->UnknownElements = elements; - - // Serialize the class, and close the TextWriter. - TextWriter^ writer = gcnew StreamWriter( filename ); - ser->Serialize( writer, myGroup, namespaces ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ myGroup; - myGroup = safe_cast(ser->Deserialize( fs )); - fs->Close(); - for ( int i = 0; i < myGroup->UnknownEmployees->Length; ++i ) - { - XmlElement^ xEmp = myGroup->UnknownEmployees[ i ]; - Console::WriteLine( "{0}: {1}", xEmp->LocalName, xEmp->InnerText ); - } - for ( int i = 0; i < myGroup->UnknownCity->Length; ++i ) - { - XmlElement^ xCity = myGroup->UnknownCity[ i ]; - Console::WriteLine( "{0}: {1}", xCity->LocalName, xCity->InnerText ); - } - for ( int i = 0; i < myGroup->UnknownElements->Length; ++i ) - { - XmlElement^ xEmp = myGroup->UnknownElements[ i ]; - Console::WriteLine( "{0}: {1}", xEmp->LocalName, xEmp->InnerText ); - } -} - -int main() -{ - SerializeObject( "AnyElementArray.xml" ); - DeserializeObject( "AnyElementArray.xml" ); - Console::WriteLine( "Done" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp deleted file mode 100644 index 9787259757c..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp +++ /dev/null @@ -1,107 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; -using namespace System::Xml::Schema; -public ref class Item -{ -public: - String^ ItemID; - Item(){} - - Item( String^ id ) - { - ItemID = id; - } -}; - -public ref class NewItem: public Item -{ -public: - String^ Category; - NewItem(){} - - NewItem( String^ id, String^ cat ) - { - ItemID = id; - Category = cat; - } -}; - -public ref class PurchaseOrder -{ -public: - - [XmlArrayItem(DataType="gMonth", - ElementName="MyMonths", - Namespace="http://www.cohowinery.com")] - array^Months; - - [XmlArrayItem(Item::typeid),XmlArrayItem(NewItem::typeid)] - array^Items; - - [XmlArray(IsNullable=true)] - [XmlArrayItem(String::typeid), - XmlArrayItem(Double::typeid), - XmlArrayItem(NewItem::typeid)] - array^Things; -}; - -void SerializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class; - // specify the type of object to serialize. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - - // Create a PurchaseOrder and set its properties. - PurchaseOrder^ po = gcnew PurchaseOrder; - array^months = {"March","May","August"}; - po->Months = months; - array^items = {gcnew Item( "a1" ),gcnew NewItem( "b1","book" )}; - po->Items = items; - array^things = {"String",2003.31,gcnew NewItem( "Item100","book" )}; - po->Things = things; - - // Serialize the purchase order, and close the TextWriter. - serializer->Serialize( writer, po ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - // Create an instance of the XmlSerializer class; - // specify the type of object to be deserialized. - XmlSerializer^ serializer = gcnew XmlSerializer( PurchaseOrder::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - - // Declare an object variable of the type to be deserialized. - PurchaseOrder^ po; - - /* Use the Deserialize method to restore the object's state with - data from the XML document. */ - po = safe_cast(serializer->Deserialize( fs )); - for ( int i = 0; i < po->Months->Length; ++i ) - Console::WriteLine( po->Months[ i ] ); - for ( int i = 0; i < po->Items->Length; ++i ) - Console::WriteLine( po->Items[ i ]->ItemID ); - for ( int i = 0; i < po->Things->Length; ++i ) - Console::WriteLine( po->Things[ i ] ); -} - -int main() -{ - // Read and write purchase orders. - SerializeObject( "ArrayItemEx.xml" ); - DeserializeObject( "ArrayItemEx.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp deleted file mode 100644 index 37278b0a8b3..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -public ref class Group -{ -public: - String^ GroupName; - - [XmlAnyElement] - array^Things; -}; - -void SerializeObject( String^ filename ); -void DeserializeObject( String^ filename ); -XmlSerializer^ CreateOverrideSerializer(); -int main() -{ - // 1 Run this and create the XML document. - // 2 Add new elements to the XML document. - // 3 Comment out the next line, and uncomment - // the DeserializeObject line to deserialize the - // XML document and see unknown elements. - SerializeObject( "UnknownElements.xml" ); - - // DeserializeObject(S"UnknownElements.xml"); -} - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - Group^ g = gcnew Group; - g->GroupName = "MyGroup"; - ser->Serialize( writer, g ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = CreateOverrideSerializer(); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = safe_cast(ser->Deserialize( fs )); - fs->Close(); - Console::WriteLine( g->GroupName ); - Console::WriteLine( g->Things->Length ); - for ( int i = 0; i < g->Things->Length; ++i ) - { - XmlElement^ xelement = safe_cast(g->Things[ i ]); - Console::WriteLine( "{0}: {1}", xelement->Name, xelement->InnerXml ); - } -} - -XmlSerializer^ CreateOverrideSerializer() -{ - XmlAnyElementAttribute^ myAnyElement = gcnew XmlAnyElementAttribute; - XmlAttributeOverrides^ xOverride = gcnew XmlAttributeOverrides; - XmlAttributes^ xAtts = gcnew XmlAttributes; - xAtts->XmlAnyElements->Add( myAnyElement ); - xOverride->Add( Group::typeid, "Things", xAtts ); - return gcnew XmlSerializer( Group::typeid,xOverride ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp deleted file mode 100644 index a86b3632f06..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp +++ /dev/null @@ -1,86 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Xml::Serialization; -public ref class Student -{ -public: - - [XmlAttributeAttribute] - String^ Name; - - [XmlNamespaceDeclarationsAttribute] - XmlSerializerNamespaces^ myNamespaces; -}; - -void SerializeStudent( String^ filename ); -void DeserializeStudent( String^ filename ); -int main() -{ - SerializeStudent( "Student.xml" ); - DeserializeStudent( "Student.xml" ); -} - -void SerializeStudent( String^ filename ) -{ - XmlAttributes^ atts = gcnew XmlAttributes; - - // Set to true to preserve namespaces, - // or false to ignore them. - atts->Xmlns = true; - XmlAttributeOverrides^ xover = gcnew XmlAttributeOverrides; - - // Add the XmlAttributes and specify the name of the element - // containing namespaces. - xover->Add( Student::typeid, "myNamespaces", atts ); - - // Create the XmlSerializer using the - // XmlAttributeOverrides object. - XmlSerializer^ xser = gcnew XmlSerializer( Student::typeid,xover ); - Student^ myStudent = gcnew Student; - XmlSerializerNamespaces^ ns = gcnew XmlSerializerNamespaces; - ns->Add( "myns1", "http://www.cpandl.com" ); - ns->Add( "myns2", "http://www.cohowinery.com" ); - myStudent->myNamespaces = ns; - myStudent->Name = "Student1"; - FileStream^ fs = gcnew FileStream( filename,FileMode::Create ); - xser->Serialize( fs, myStudent ); - fs->Close(); -} - -void DeserializeStudent( String^ filename ) -{ - XmlAttributes^ atts = gcnew XmlAttributes; - - // Set to true to preserve namespaces, or false to ignore them. - atts->Xmlns = true; - XmlAttributeOverrides^ xover = gcnew XmlAttributeOverrides; - - // Add the XmlAttributes and specify the name of the - // element containing namespaces. - xover->Add( Student::typeid, "myNamespaces", atts ); - - // Create the XmlSerializer using the - // XmlAttributeOverrides object. - XmlSerializer^ xser = gcnew XmlSerializer( Student::typeid,xover ); - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Student^ myStudent; - myStudent = safe_cast(xser->Deserialize( fs )); - fs->Close(); - - // Use the ToArray method to get an array of - // XmlQualifiedName objects. - array^qNames = myStudent->myNamespaces->ToArray(); - for ( int i = 0; i < qNames->Length; i++ ) - { - Console::WriteLine( "{0}:{1}", qNames[ i ]->Name, qNames[ i ]->Namespace ); - - } -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp deleted file mode 100644 index 51329745b7a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp +++ /dev/null @@ -1,131 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; - -[XmlType(IncludeInSchema=false)] - -public enum class ItemChoiceType -{ - None, Word, Number, DecimalNumber -}; - -public enum class MoreChoices -{ - None, Item, Amount, Temp -}; - -public ref class Choices -{ -public: - - // The MyChoice field can be set to any one of - // the types below. - - [XmlChoiceIdentifier("EnumType")] - [XmlElement("Word",String::typeid)] - [XmlElement("Number",Int32::typeid)] - [XmlElement("DecimalNumber",Double::typeid)] - Object^ MyChoice; - - // Don't serialize this field. The EnumType field - // contains the enumeration value that corresponds - // to the MyChoice field value. - - [XmlIgnore] - ItemChoiceType EnumType; - - // The ManyChoices field can contain an array - // of choices. Each choice must be matched to - // an array item in the ChoiceArray field. - - [XmlChoiceIdentifier("ChoiceArray")] - [XmlElement("Item",String::typeid)] - [XmlElement("Amount",Int32::typeid)] - [XmlElement("Temp",Double::typeid)] - array^ManyChoices; - - // TheChoiceArray field contains the enumeration - // values, one for each item in the ManyChoices array. - - [XmlIgnore] - array^ChoiceArray; -}; - -void SerializeObject( String^ filename ); -void DeserializeObject( String^ filename ); -int main() -{ - SerializeObject( "Choices.xml" ); - DeserializeObject( "Choices.xml" ); -} - -void SerializeObject( String^ filename ) -{ - XmlSerializer^ mySerializer = gcnew XmlSerializer( Choices::typeid ); - TextWriter^ writer = gcnew StreamWriter( filename ); - Choices^ myChoices = gcnew Choices; - - // Set the MyChoice field to a string. Set the - // EnumType to Word. - myChoices->MyChoice = "Book"; - myChoices->EnumType = ItemChoiceType::Word; - - // Populate an object array with three items, one - // of each enumeration type. Set the array to the - // ManyChoices field. - array^strChoices = {"Food",5,98.6}; - myChoices->ManyChoices = strChoices; - - // For each item in the ManyChoices array, add an - // enumeration value. - array^ itmChoices = {MoreChoices::Item,MoreChoices::Amount,MoreChoices::Temp}; - myChoices->ChoiceArray = itmChoices; - mySerializer->Serialize( writer, myChoices ); - writer->Close(); -} - -void DeserializeObject( String^ filename ) -{ - XmlSerializer^ ser = gcnew XmlSerializer( Choices::typeid ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Choices^ myChoices = safe_cast(ser->Deserialize( fs )); - fs->Close(); - - // Disambiguate the MyChoice value using the enumeration. - if ( myChoices->EnumType == ItemChoiceType::Word ) - { - Console::WriteLine( "Word: {0}", myChoices->MyChoice->ToString() ); - } - else - if ( myChoices->EnumType == ItemChoiceType::Number ) - { - Console::WriteLine( "Number: {0}", myChoices->MyChoice->ToString() ); - } - else - if ( myChoices->EnumType == ItemChoiceType::DecimalNumber ) - { - Console::WriteLine( "DecimalNumber: {0}", myChoices->MyChoice->ToString() ); - } - - // Disambiguate the ManyChoices values using the enumerations. - for ( int i = 0; i < myChoices->ManyChoices->Length; i++ ) - { - if ( myChoices->ChoiceArray[ i ] == MoreChoices::Item ) - Console::WriteLine( "Item: {0}", myChoices->ManyChoices[ i ] ); - else - if ( myChoices->ChoiceArray[ i ] == MoreChoices::Amount ) - Console::WriteLine( "Amount: ", myChoices->ManyChoices[ i ]->ToString() ); - if ( myChoices->ChoiceArray[ i ] == MoreChoices::Temp ) - Console::WriteLine( "Temp: {0}", myChoices->ManyChoices[ i ]->ToString() ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp deleted file mode 100644 index 61dea2ac426..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp +++ /dev/null @@ -1,58 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Schema; -using namespace System::Xml::Serialization; -public ref class Person: public IXmlSerializable -{ -private: - - // Private state - String^ personName; - -public: - - // Constructors - Person( String^ name ) - { - personName = name; - } - - Person() - { - personName = nullptr; - } - - // Xml Serialization Infrastructure - // - virtual void WriteXml( XmlWriter^ writer ) - { - writer->WriteString( personName ); - } - // - - // - virtual void ReadXml( XmlReader^ reader ) - { - personName = reader->ReadString(); - } - // - - // - virtual XmlSchema^ GetSchema() - { - return nullptr; - } - // - - // Print - virtual String^ ToString() override - { - return (personName); - } -}; -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp deleted file mode 100644 index f5ab5ef1cb0..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp +++ /dev/null @@ -1,19 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; - -int main() -{ - XmlSerializer^ serializer = gcnew XmlSerializer( Person::typeid ); - FileStream^ file = gcnew FileStream( "test.xml",FileMode::Open ); - Person^ aPerson = dynamic_cast(serializer->Deserialize( file )); - Console::WriteLine( aPerson ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp deleted file mode 100644 index 35d2a29a532..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp +++ /dev/null @@ -1,22 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; - -int main() -{ - // Create a person object. - Person ^ fred = gcnew Person( "Fred Flintstone" ); - - // Serialize the object to a file. - XmlTextWriter^ writer = gcnew XmlTextWriter( "test.xml", nullptr ); - XmlSerializer^ serializer = gcnew XmlSerializer( Person::typeid ); - serializer->Serialize( writer, fred ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp deleted file mode 100644 index 22cef24ad7a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp +++ /dev/null @@ -1,56 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Xml; -using namespace System::Xml::Schema; - -public ref class Group -{ -public: - String^ GroupName; -}; - -public ref class Test -{ -private: - void Serializer_UnknownElement( Object^ sender, XmlElementEventArgs^ e ) - { - Console::WriteLine( "Unknown Element" ); - Console::Write( "\t {0}", e->Element->Name ); - Console::WriteLine( " {0}", e->Element->InnerXml ); - Console::WriteLine( "\t LineNumber: {0}", e->LineNumber ); - Console::WriteLine( "\t LinePosition: {0}", e->LinePosition ); - Group^ x = dynamic_cast(e->ObjectBeingDeserialized); - Console::WriteLine( x->GroupName ); - Console::WriteLine( sender ); - } - -public: - void DeserializeObject( String^ filename ) - { - XmlSerializer^ ser = gcnew XmlSerializer( Group::typeid ); - - // Add a delegate to handle unknown element events. - ser->UnknownElement += gcnew XmlElementEventHandler( this, &Test::Serializer_UnknownElement ); - - // A FileStream is needed to read the XML document. - FileStream^ fs = gcnew FileStream( filename,FileMode::Open ); - Group^ g = dynamic_cast(ser->Deserialize( fs )); - fs->Close(); - } -}; - -int main() -{ - Test^ t = gcnew Test; - - // Deserialize the file containing unknown elements. - t->DeserializeObject( "UnknownElements.xml" ); -} -// diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp deleted file mode 100644 index e453759982a..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// System::Xml::Serialization::XmlSerializerNamespaces.constructor - -// The following example demonstrates the constructor of class -// XmlSerializerNamespaces. This sample serializes an Object* of 'MyPriceClass' -// into an XML document. - -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Xml::Serialization; -using namespace System::IO; - -public ref class MyPriceClass -{ -public: - [XmlAttributeAttribute] - String^ Units; - Decimal Price; -}; - -public ref class MyBook -{ -public: - String^ BookName; - String^ Author; - MyPriceClass^ BookPrice; - String^ Description; -}; - -public ref class MyMainClass -{ -// -public: - void CreateBook( String^ filename ) - { - try - { - // Create instance of XmlSerializerNamespaces and add the namespaces. - XmlSerializerNamespaces^ myNameSpaces = gcnew XmlSerializerNamespaces; - myNameSpaces->Add( "BookName", "http://www.cpandl.com" ); - - // Create instance of XmlSerializer and specify the type of object - // to be serialized. - XmlSerializer^ mySerializerObject = - gcnew XmlSerializer( MyBook::typeid ); - - TextWriter^ myWriter = gcnew StreamWriter( filename ); - // Create object to be serialized. - MyBook^ myXMLBook = gcnew MyBook; - - myXMLBook->Author = "XMLAuthor"; - myXMLBook->BookName = "DIG THE XML"; - myXMLBook->Description = "This is a XML Book"; - - MyPriceClass^ myBookPrice = gcnew MyPriceClass; - myBookPrice->Price = (Decimal)45.89; - myBookPrice->Units = "$"; - myXMLBook->BookPrice = myBookPrice; - - // Serialize the object. - mySerializerObject->Serialize( myWriter, myXMLBook, myNameSpaces ); - myWriter->Close(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0} occurred", e->Message ); - } - } -// -}; - -int main() -{ - MyMainClass^ myMain = gcnew MyMainClass; - // Create the XML document. - myMain->CreateBook( "myBook.xml" ); -} diff --git a/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp b/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp deleted file mode 100644 index 8f321e5bf24..00000000000 --- a/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp +++ /dev/null @@ -1,67 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml::Serialization; -using namespace System::Collections; -using namespace System::Xml; -using namespace System::Text; - -public ref class Thing -{ -public: - String^ ThingName; -}; - -[SoapType("TheGroup","http://www.cohowinery.com")] -public ref class Group -{ -public: - String^ GroupName; - array^Things; - - [SoapElement(DataType="language")] - static String^ Lang = "en"; - - [SoapElement(DataType="integer")] - String^ MyNumber; - - [SoapElement(DataType="duration")] - static String^ ReDate = "8/31/01"; -}; - -void GetMap( String^ filename ) -{ - // Create an XmlSerializer instance. - SoapReflectionImporter^ sri = gcnew SoapReflectionImporter; - XmlTypeMapping^ map = sri->ImportTypeMapping( Group::typeid ); - Console::WriteLine( "ElementName: {0}", map->ElementName ); - Console::WriteLine( "Namespace: {0}", map->Namespace ); - Console::WriteLine( "TypeFullName: {0}", map->TypeFullName ); - Console::WriteLine( "TypeName: {0}", map->TypeName ); - XmlSerializer^ ser = gcnew XmlSerializer( map ); - Group^ xGroup = gcnew Group; - xGroup->GroupName = "MyCar"; - xGroup->MyNumber = "5454"; - xGroup->Things = gcnew array(2); // {new Thing(), new Thing()}; - xGroup->Things[ 0 ] = gcnew Thing; - xGroup->Things[ 1 ] = gcnew Thing; - - // To write the outer wrapper, use an XmlTextWriter. - XmlTextWriter^ writer = gcnew XmlTextWriter( filename,Encoding::UTF8 ); - writer->Formatting = Formatting::Indented; - writer->WriteStartElement( "wrapper" ); - ser->Serialize( writer, xGroup ); - writer->WriteEndElement(); - writer->Close(); -} - -int main() -{ - GetMap( "MyMap.xml" ); -} -// diff --git a/xml/Microsoft.VisualBasic.Compatibility.VB6/DirListBox.xml b/xml/Microsoft.VisualBasic.Compatibility.VB6/DirListBox.xml index f44f6c5ed4b..de84f800d4d 100644 --- a/xml/Microsoft.VisualBasic.Compatibility.VB6/DirListBox.xml +++ b/xml/Microsoft.VisualBasic.Compatibility.VB6/DirListBox.xml @@ -39,8 +39,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -69,8 +69,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -103,8 +103,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -151,8 +151,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -199,8 +199,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -249,8 +249,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -293,8 +293,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -339,8 +339,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -387,8 +387,8 @@ can be called multiple times by other objects. When you override , make sure not to reference objects that have been previously disposed of in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. For more information about and , see Cleaning Up Unmanaged Resources and Overriding the Finalize Method. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -431,8 +431,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -479,8 +479,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -527,8 +527,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -576,8 +576,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -623,8 +623,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -665,8 +665,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -712,8 +712,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -755,8 +755,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -798,8 +798,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -841,8 +841,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -884,8 +884,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -944,8 +944,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -981,8 +981,8 @@ When you override in a derived class, make sure to call the method so the control and its child controls are invalidated and redrawn. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -1029,8 +1029,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -1078,8 +1078,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -1126,8 +1126,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) diff --git a/xml/Microsoft.VisualBasic.Compatibility.VB6/DriveListBox.xml b/xml/Microsoft.VisualBasic.Compatibility.VB6/DriveListBox.xml index 311fd98103c..42682c9f4c1 100644 --- a/xml/Microsoft.VisualBasic.Compatibility.VB6/DriveListBox.xml +++ b/xml/Microsoft.VisualBasic.Compatibility.VB6/DriveListBox.xml @@ -39,8 +39,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -69,8 +69,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -117,8 +117,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -165,8 +165,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -209,8 +209,8 @@ can be called multiple times by other objects. When you override , make sure not to reference objects that have been previously disposed of in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. For more information about and , see Cleaning Up Unmanaged Resources and Overriding the Finalize Method. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -253,8 +253,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -301,8 +301,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -351,8 +351,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -395,8 +395,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -452,8 +452,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -500,8 +500,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -548,8 +548,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -591,8 +591,8 @@ When you override in a derived class, be sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -634,8 +634,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -677,8 +677,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -720,8 +720,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -763,8 +763,8 @@ When overriding in a derived class, make sure to call the method of the base class so that registered delegates receive the event. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -804,8 +804,8 @@ When you override in a derived class, make sure to call the method so the control and its child controls are invalidated and redrawn. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -853,8 +853,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -901,8 +901,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -949,8 +949,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -992,8 +992,8 @@ Inheriting controls should call the method for the base class to process any messages that they do not handle. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) diff --git a/xml/Microsoft.VisualBasic.Compatibility.VB6/FileListBox.xml b/xml/Microsoft.VisualBasic.Compatibility.VB6/FileListBox.xml index 2a9917ece6d..11b0505ed4f 100644 --- a/xml/Microsoft.VisualBasic.Compatibility.VB6/FileListBox.xml +++ b/xml/Microsoft.VisualBasic.Compatibility.VB6/FileListBox.xml @@ -38,8 +38,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -67,8 +67,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -111,8 +111,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -158,8 +158,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -205,8 +205,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -252,8 +252,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -296,8 +296,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -340,8 +340,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -396,8 +396,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -443,8 +443,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -487,8 +487,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -530,8 +530,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -568,8 +568,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -606,8 +606,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -645,8 +645,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -706,8 +706,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -739,8 +739,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -790,8 +790,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -823,8 +823,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -870,8 +870,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -905,8 +905,8 @@ When you override in a derived class, make sure to call the method of the base class so the control and its child controls are invalidated and redrawn. - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -953,8 +953,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -997,8 +997,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) @@ -1044,8 +1044,8 @@ ]]> - SaveFileDialog Component Overview (Windows Forms) - OpenFileDialog Component Overview (Windows Forms) + SaveFileDialog Component Overview (Windows Forms) + OpenFileDialog Component Overview (Windows Forms) diff --git a/xml/Microsoft.VisualBasic.Compatibility.VB6/Support.xml b/xml/Microsoft.VisualBasic.Compatibility.VB6/Support.xml index efd7893d49d..91a8db5706e 100644 --- a/xml/Microsoft.VisualBasic.Compatibility.VB6/Support.xml +++ b/xml/Microsoft.VisualBasic.Compatibility.VB6/Support.xml @@ -27,15 +27,15 @@ Contains various utility functions for backward compatibility with Visual Basic 6.0. - @@ -70,15 +70,15 @@ Duplicates Visual Basic 6.0 functionality of assigning an to a . The array to copy. - , or methods of the class. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + , or methods of the class. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -113,15 +113,15 @@ Returns an OLE object that corresponds to the specified . An that represents the OLE object. - to a `stdOle.IPicture`. - - To convert a in Visual Basic, use the method of the class. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + to a `stdOle.IPicture`. + + To convert a in Visual Basic, use the method of the class. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -168,22 +168,22 @@ if the two expressions are equal; otherwise . - = Operator (Visual Basic) @@ -221,22 +221,22 @@ Performs a logical equivalence on two expressions. A that contains the result of the bitwise comparison. - Not Operator (Visual Basic) @@ -275,13 +275,13 @@ Performs a logical equivalence on two expressions. A that contains the result of the comparison. - Not Operator (Visual Basic) @@ -320,13 +320,13 @@ Performs a logical equivalence on two expressions. A that contains the result of the comparison. - Not Operator (Visual Basic) @@ -365,13 +365,13 @@ Performs a logical equivalence on two expressions. A that contains the result of the comparison. - Not Operator (Visual Basic) @@ -410,13 +410,13 @@ Performs a logical equivalence on two expressions. A that contains the result of the comparison. - Not Operator (Visual Basic) @@ -460,13 +460,13 @@ Changes the style bit for a font. A with the new style applied. - enumeration. This function is used by the upgrade tools to translate the Visual Basic 6.0 properties to the new enumerations. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + enumeration. This function is used by the upgrade tools to translate the Visual Basic 6.0 properties to the new enumerations. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -503,13 +503,13 @@ Returns a font for a specified GDI character set. A for the specified GDI character set. - constructor. This function is used by the upgrade tools to convert a `stdFont` to a . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + constructor. This function is used by the upgrade tools to convert a `stdFont` to a . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -552,13 +552,13 @@ Changes the style bit for a font. A with the new style applied. - enumeration. This function is used by the upgrade tools to translate the Visual Basic 6.0 properties to the new enumerations. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + enumeration. This function is used by the upgrade tools to translate the Visual Basic 6.0 properties to the new enumerations. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -595,13 +595,13 @@ Returns a new for a given Visual Basic 6.0 . A that matches the Visual Basic 6.0 . - is a property of the object. This function is used by the upgrade tools to convert a Visual Basic 6.0 `Font` to a . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + is a property of the object. This function is used by the upgrade tools to convert a Visual Basic 6.0 `Font` to a . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -638,13 +638,13 @@ Changes the property for a font. A that matches the Visual Basic 6.0 . - is a property of the object. This function is used by the upgrade tools to convert a Visual Basic 6.0 `Font` to a . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + is a property of the object. This function is used by the upgrade tools to convert a Visual Basic 6.0 `Font` to a . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -686,13 +686,13 @@ Changes the style bit for a font. A with the new style applied. - enumeration. This function is used by the upgrade tools to translate the Visual Basic 6.0 properties to the new enumerations. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + enumeration. This function is used by the upgrade tools to translate the Visual Basic 6.0 properties to the new enumerations. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -734,13 +734,13 @@ Changes the style bit for a font. A with the new style applied. - enumeration. This function is used by the upgrade tools to translate the Visual Basic 6.0 properties to the new enumerations. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + enumeration. This function is used by the upgrade tools to translate the Visual Basic 6.0 properties to the new enumerations. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -775,13 +775,13 @@ Converts a to a Visual Basic 6.0 object. A object. - and a `stdFont` during project upgrade. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + and a `stdFont` during project upgrade. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -821,13 +821,13 @@ Converts the Visual Basic 6.0 function to be compatible with Visual Basic. A that contains the formatted data. - @@ -866,13 +866,13 @@ Converts a pixel measurement to a Visual Basic 6.0 measurement. A that contains the converted Visual Basic 6.0 . - @@ -911,13 +911,13 @@ Converts a pixel measurement to a Visual Basic 6.0 measurement. A that contains the converted Visual Basic 6.0 . - @@ -958,13 +958,13 @@ Converts a pixel measurement to a Visual Basic 6.0 measurement. A that contains the converted Visual Basic 6.0 . - @@ -1005,13 +1005,13 @@ Converts a pixel measurement to a Visual Basic 6.0 measurement. A that contains the converted Visual Basic 6.0 . - @@ -1048,13 +1048,13 @@ Converts a pixel measurement to a Visual Basic 6.0 measurement for a given . A that contains the Visual Basic 6.0 value for the specified . - @@ -1091,13 +1091,13 @@ Converts a pixel measurement to a Visual Basic 6.0 measurement for a given . A that contains the Visual Basic 6.0 value for the specified . - @@ -1129,13 +1129,13 @@ Gets the control that currently has focus. The control that currently has focus. - in Visual Basic. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + in Visual Basic. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1171,13 +1171,13 @@ if is the cancel button; otherwise . - property of a . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + property of a . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1213,13 +1213,13 @@ if is the default button; otherwise . - property of a . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + property of a . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1251,11 +1251,11 @@ Gets the name of the executable file (.exe) for the current application. A that contains the name without a file name extension. - @@ -1287,13 +1287,13 @@ Gets the instance handle (HINSTANCE) for the current application. An for the current application instance. - . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1330,13 +1330,13 @@ Gets an associated with a or item. The associated with the specified . - methods can be used to emulate the behavior of `ItemData`. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + methods can be used to emulate the behavior of `ItemData`. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1373,13 +1373,13 @@ Gets a associated with a or item. The associated with the specified . - or property instead. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + or property instead. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1411,11 +1411,11 @@ Gets the current path for the application. A that contains the path of the currently executing assembly. - @@ -1450,13 +1450,13 @@ Gets an OLE object for a given . An representing the OLE object. - . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1491,13 +1491,13 @@ Converts a Visual Basic 6.0 object to a . A specified object to convert. - and a `stdFont` during project upgrade. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + and a `stdFont` during project upgrade. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1532,13 +1532,13 @@ Gets an OLE object for a given . An representing the OLE object. - . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1573,13 +1573,13 @@ Gets an OLE object for a given . An representing the OLE object. - . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1625,15 +1625,15 @@ Performs a logical implication on two expressions. A that contains the result. - Not Operator (Visual Basic) @@ -1672,15 +1672,15 @@ Performs a logical implication on two expressions. A that contains the result. - Not Operator (Visual Basic) @@ -1719,15 +1719,15 @@ Performs a logical implication on two expressions. A that contains the result. - Not Operator (Visual Basic) @@ -1766,15 +1766,15 @@ Performs a logical implication on two expressions. An that contains the result. - Not Operator (Visual Basic) @@ -1813,15 +1813,15 @@ Performs a logical implication on two expressions. A that contains the result. - Not Operator (Visual Basic) @@ -1860,15 +1860,15 @@ Performs a logical implication on two expressions. An that contains the result. - . - - In Visual Basic, use `Not` and `XOr` to replace `Imp`. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + . + + In Visual Basic, use `Not` and `XOr` to replace `Imp`. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> Not Operator (Visual Basic) @@ -1905,13 +1905,13 @@ Gets an for a given OLE object. An image object. - . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1946,13 +1946,13 @@ Gets an for a given OLE object. A converted object to image. - . - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + . + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -1998,18 +1998,18 @@ Loads data of several possible types from a resource (.res) file. An that contains the resource. - - Globalizing Windows Forms + Globalizing Windows Forms @@ -2046,18 +2046,18 @@ Loads data of several possible types from a resource (.res) file, specifying a locale. An that contains the resource. - - Globalizing Windows Forms + Globalizing Windows Forms @@ -2101,18 +2101,18 @@ Loads a bitmap, icon, or cursor from a resource (.res) file. An that contains the resource. - - Globalizing Windows Forms + Globalizing Windows Forms @@ -2149,18 +2149,18 @@ Loads a bitmap, icon, or cursor from a resource (.res) file, specifying a locale. An that contains the resource. - - Globalizing Windows Forms + Globalizing Windows Forms @@ -2202,18 +2202,18 @@ Loads a string from a resource (.res) file. A that contains the resource. - - Globalizing Windows Forms + Globalizing Windows Forms @@ -2248,18 +2248,18 @@ Loads a string from a resource (.res) file, specifying a locale. A that contains the resource. - - Globalizing Windows Forms + Globalizing Windows Forms @@ -2292,13 +2292,13 @@ Converts an X coordinate from pixels to twips. A that contains the X coordinate expressed in twips. - @@ -2333,13 +2333,13 @@ Converts a Y coordinate from pixels to twips. A that contains the Y coordinate expressed in twips. - @@ -2375,13 +2375,13 @@ to process keystrokes before control is returned to the procedure; otherwise . Sends one or more keystrokes to the active window as if typed at the keyboard. - @@ -2418,15 +2418,15 @@ if the Visual Basic 6.0 control's property is ; otherwise . Sets the property of a . - control no longer has `Default` or `Cancel` properties. The object has and properties that provide the same functionality; these properties take the name of a control as an argument. - - This function is used by the upgrade tools to set the property of a .based on the `Cancel` property of an upgraded Visual Basic 6.0 `CommandButton` control. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + control no longer has `Default` or `Cancel` properties. The object has and properties that provide the same functionality; these properties take the name of a control as an argument. + + This function is used by the upgrade tools to set the property of a .based on the `Cancel` property of an upgraded Visual Basic 6.0 `CommandButton` control. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -2463,15 +2463,15 @@ if the Visual Basic 6.0 control's property is ; otherwise . Sets the property of a . - control no longer has `Default` or `Cancel` properties. The object has and properties that provide the same functionality; these properties take the name of a control as an argument. - - This function is used by the upgrade tools to set the property of a .based on the `Default` property of an upgraded Visual Basic 6.0 `CommandButton` control. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + control no longer has `Default` or `Cancel` properties. The object has and properties that provide the same functionality; these properties take the name of a control as an argument. + + This function is used by the upgrade tools to set the property of a .based on the `Default` property of an upgraded Visual Basic 6.0 `CommandButton` control. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -2509,13 +2509,13 @@ An to assign to the property. Sets the property for a . - and `SetItemData` methods can be used to emulate the behavior of `ItemData`. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + and `SetItemData` methods can be used to emulate the behavior of `ItemData`. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -2553,13 +2553,13 @@ A to assign to the property. Sets the property for a . - or property instead. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + or property instead. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -2602,13 +2602,13 @@ A resource file (.res). Assigns the name of a Visual Basic 6.0 resource file to the current Visual Basic project namespace. - @@ -2644,13 +2644,13 @@ A resource file (.res). Assigns the name of a Visual Basic 6.0 resource file to a Visual Basic project namespace. - @@ -2687,13 +2687,13 @@ Optional. The owner parameter of the method. Displays a form by calling either the or method. - and methods. This function is used by the upgrade tools to map the Visual Basic 6.0 `Show` method to either the or method. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + and methods. This function is used by the upgrade tools to map the Visual Basic 6.0 `Show` method to either the or method. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -2735,13 +2735,13 @@ Formats strings to simulate the Visual Basic 6.0 functionality. A formatted . - @@ -2780,13 +2780,13 @@ Converts a Visual Basic 6.0 measurement to a pixel measurement. A that contains the converted Visual Basic 6.0 . - @@ -2825,13 +2825,13 @@ Converts a Visual Basic 6.0 measurement to a pixel measurement. A that contains the converted Visual Basic 6.0 . - @@ -2872,13 +2872,13 @@ Converts a Visual Basic 6.0 measurement to a pixel measurement. A that contains the converted Visual Basic 6.0 . - @@ -2919,13 +2919,13 @@ Converts a Visual Basic 6.0 measurement to a pixel measurement. A that contains the converted Visual Basic 6.0 . - @@ -2962,13 +2962,13 @@ Converts a Visual Basic 6.0 measurement to a pixel measurement for a given . A that contains the pixel value for the specified . - @@ -3005,13 +3005,13 @@ Converts a Visual Basic 6.0 measurement to a pixel measurement for a given . A that contains the pixel value for the specified . - @@ -3043,13 +3043,13 @@ Gets a value that is used to convert twips to pixels based on screen settings. A that contains the conversion factor. - @@ -3081,13 +3081,13 @@ Gets a value that is used to convert twips to pixels based on screen settings. A that contains the conversion factor. - @@ -3122,13 +3122,13 @@ Converts an X coordinate from twips to pixels. A that contains the X coordinate expressed in pixels. - @@ -3163,13 +3163,13 @@ Converts a Y coordinate from twips to pixels. A that contains the Y coordinate expressed in pixels. - @@ -3203,15 +3203,15 @@ The where the control is parented. Emulates the behavior of the Visual Basic 6.0 method. - method, which returns `true` or `false`. - - This function is used by the upgrade tools to emulate the Visual Basic 6.0 behavior. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + method, which returns `true` or `false`. + + This function is used by the upgrade tools to emulate the Visual Basic 6.0 behavior. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -3245,13 +3245,13 @@ A . Displays pop-up Help for a form upgraded from Visual Basic 6.0. - property of a form. This function is used by the upgrade tools to change the method of displaying pop-up Help in an upgraded application. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + property of a form. This function is used by the upgrade tools to change the method of displaying pop-up Help in an upgraded application. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> @@ -3287,13 +3287,13 @@ A enumeration. Converts the Visual Basic method for use in Visual Basic. - and methods. This function is used by the upgrade tools to map between the methods. - - [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] - + and methods. This function is used by the upgrade tools to map between the methods. + + [!INCLUDE[Note_compatibility](~/includes/note-compatibility-md.md)] + ]]> diff --git a/xml/Microsoft.VisualBasic.Devices/Ports.xml b/xml/Microsoft.VisualBasic.Devices/Ports.xml index c8ddf7a2073..1aaf012ae6b 100644 --- a/xml/Microsoft.VisualBasic.Devices/Ports.xml +++ b/xml/Microsoft.VisualBasic.Devices/Ports.xml @@ -21,45 +21,45 @@ Provides a property and a method for accessing the computer's serial ports. - . - - The following table lists examples of tasks involving the `My.Computer.Ports` object. - -|To|See| -|-|-| -|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| -|Send a string to a serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| -|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| -|Show available serial ports|[How to: Show Available Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-show-available-serial-ports)| - -## Availability by Project Type - -|Project type|Available| -|-|-| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example describes how to send strings to the computer's `COM1` serial port. - - The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. - - The method sends the data to the serial port. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: - - For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). - + . + + The following table lists examples of tasks involving the `My.Computer.Ports` object. + +|To|See| +|-|-| +|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| +|Send a string to a serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| +|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| +|Show available serial ports|[How to: Show Available Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-show-available-serial-ports)| + +## Availability by Project Type + +|Project type|Available| +|-|-| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example describes how to send strings to the computer's `COM1` serial port. + + The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. + + The method sends the data to the serial port. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: + + For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). + ]]> Objects (Visual Basic) @@ -132,46 +132,46 @@ Creates and opens a object. An open object, configured with the supplied arguments. - object. The arguments to the `OpenSerialPort` method determine the settings of the object. - - Your code should close the object when it is finished using the object. You can use the method to close the object explicitly or the `Using` statement to close it implicitly. See the example in this topic for more information. - - The following table lists examples of tasks involving the `My.Computer.Ports.OpenSerialPort` method. - -|To|See| -|-|-| -|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| -|Send a string to serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| -|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| - -## Availability by Project Type - -|Project type|Available| -|-|-| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example describes how to send strings to the computer's `COM1` serial port. - - The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. - - The method sends the data to the serial port. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: - - For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). - + object. The arguments to the `OpenSerialPort` method determine the settings of the object. + + Your code should close the object when it is finished using the object. You can use the method to close the object explicitly or the `Using` statement to close it implicitly. See the example in this topic for more information. + + The following table lists examples of tasks involving the `My.Computer.Ports.OpenSerialPort` method. + +|To|See| +|-|-| +|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| +|Send a string to serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| +|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| + +## Availability by Project Type + +|Project type|Available| +|-|-| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example describes how to send strings to the computer's `COM1` serial port. + + The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. + + The method sends the data to the serial port. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: + + For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). + ]]> @@ -215,46 +215,46 @@ Creates and opens a object. An open object, configured with the supplied arguments. - object. The arguments to the `OpenSerialPort` method determine the settings of the object. - - Your code should close the object when it is finished using the object. You can use the method to close the object explicitly or the `Using` statement to close it implicitly. See the example in this topic for more information. - - The following table lists examples of tasks involving the `My.Computer.Ports.OpenSerialPort` method. - -|To|See| -|-|-| -|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| -|Send a string to serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| -|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| - -## Availability by Project Type - -|Project type|Available| -|-|-| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example describes how to send strings to the computer's `COM1` serial port. - - The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. - - The method sends the data to the serial port. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: - - For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). - + object. The arguments to the `OpenSerialPort` method determine the settings of the object. + + Your code should close the object when it is finished using the object. You can use the method to close the object explicitly or the `Using` statement to close it implicitly. See the example in this topic for more information. + + The following table lists examples of tasks involving the `My.Computer.Ports.OpenSerialPort` method. + +|To|See| +|-|-| +|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| +|Send a string to serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| +|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| + +## Availability by Project Type + +|Project type|Available| +|-|-| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example describes how to send strings to the computer's `COM1` serial port. + + The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. + + The method sends the data to the serial port. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: + + For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). + ]]> @@ -303,46 +303,46 @@ Creates and opens a object. An open object, configured with the supplied arguments. - object. The arguments to the `OpenSerialPort` method determine the settings of the object. - - Your code should close the object when it is finished using the object. You can use the method to close the object explicitly or the `Using` statement to close it implicitly. See the example in this topic for more information. - - The following table lists examples of tasks involving the `My.Computer.Ports.OpenSerialPort` method. - -|To|See| -|-|-| -|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| -|Send a string to serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| -|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| - -## Availability by Project Type - -|Project type|Available| -|-|-| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example describes how to send strings to the computer's `COM1` serial port. - - The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. - - The method sends the data to the serial port. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: - - For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). - + object. The arguments to the `OpenSerialPort` method determine the settings of the object. + + Your code should close the object when it is finished using the object. You can use the method to close the object explicitly or the `Using` statement to close it implicitly. See the example in this topic for more information. + + The following table lists examples of tasks involving the `My.Computer.Ports.OpenSerialPort` method. + +|To|See| +|-|-| +|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| +|Send a string to serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| +|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| + +## Availability by Project Type + +|Project type|Available| +|-|-| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example describes how to send strings to the computer's `COM1` serial port. + + The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. + + The method sends the data to the serial port. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: + + For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). + ]]> @@ -396,46 +396,46 @@ Creates and opens a object. An open object, configured with the supplied arguments. - object. The arguments to the `OpenSerialPort` method determine the settings of the object. - - Your code should close the object when it is finished using the object. You can use the method to close the object explicitly or the `Using` statement to close it implicitly. See the example in this topic for more information. - - The following table lists examples of tasks involving the `My.Computer.Ports.OpenSerialPort` method. - -|To|See| -|-|-| -|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| -|Send a string to serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| -|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| - -## Availability by Project Type - -|Project type|Available| -|-|-| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example describes how to send strings to the computer's `COM1` serial port. - - The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. - - The method sends the data to the serial port. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: - - For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). - + object. The arguments to the `OpenSerialPort` method determine the settings of the object. + + Your code should close the object when it is finished using the object. You can use the method to close the object explicitly or the `Using` statement to close it implicitly. See the example in this topic for more information. + + The following table lists examples of tasks involving the `My.Computer.Ports.OpenSerialPort` method. + +|To|See| +|-|-| +|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| +|Send a string to serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| +|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| + +## Availability by Project Type + +|Project type|Available| +|-|-| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example describes how to send strings to the computer's `COM1` serial port. + + The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. + + The method sends the data to the serial port. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: + + For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). + ]]> @@ -492,46 +492,46 @@ Creates and opens a object. An open object, configured with the supplied arguments. - object. The arguments to the `OpenSerialPort` method determine the settings of the object. - - Your code should close the object when it is finished using the object. You can use the method to close the object explicitly or the `Using` statement to close it implicitly. See the example in this topic for more information. - - The following table lists examples of tasks involving the `My.Computer.Ports.OpenSerialPort` method. - -|To|See| -|-|-| -|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| -|Send a string to serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| -|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| - -## Availability by Project Type - -|Project type|Available| -|-|-| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example describes how to send strings to the computer's `COM1` serial port. - - The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. - - The method sends the data to the serial port. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: - - For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). - + object. The arguments to the `OpenSerialPort` method determine the settings of the object. + + Your code should close the object when it is finished using the object. You can use the method to close the object explicitly or the `Using` statement to close it implicitly. See the example in this topic for more information. + + The following table lists examples of tasks involving the `My.Computer.Ports.OpenSerialPort` method. + +|To|See| +|-|-| +|Dial a modem attached to a serial port|[How to: Dial Modems Attached to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-dial-modems-attached-to-serial-ports)| +|Send a string to serial port|[How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports)| +|Receive strings from a serial port|[How to: Receive Strings From Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-receive-strings-from-serial-ports)| + +## Availability by Project Type + +|Project type|Available| +|-|-| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example describes how to send strings to the computer's `COM1` serial port. + + The `Using` block allows the application to close the serial port even if it generates an exception. All code that manipulates the serial port should appear within this block, or within a `Try...Catch...Finally` block with a call to use the method. + + The method sends the data to the serial port. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet33"::: + + For more information, see [How to: Send Strings to Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-send-strings-to-serial-ports). + ]]> @@ -571,46 +571,46 @@ Gets a collection of the names of the serial ports on the computer. A collection of the names of the serial ports on the computer. - control. For more information, see [ListBox Control](/dotnet/framework/winforms/controls/listbox-control-windows-forms). - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet45"::: - - This example requires: - -- A reference to the namespace. - -- That your form have a control named `ListBox1`. - - For more information, see [How to: Show Available Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-show-available-serial-ports). - + + The following table lists an example of a task involving the `My.Computer.Ports.SerialPortNames` property. + +|To|See| +|-|-| +|Show available serial ports|[How to: Show Available Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-show-available-serial-ports)| + +## Availability by Project Type + +|Project type|Available| +|-|-| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example loops over all the strings that the `My.Computer.Ports.SerialPortNames` property returns. These strings are the names of the available serial ports on the computer. + + Typically, a user selects which serial port the application should use from the list of available ports. In this example, the serial port names are stored in a control. For more information, see [ListBox Control](/dotnet/desktop/winforms/controls/listbox-control-windows-forms). + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbalrMyComputer/VB/Class2.vb" id="Snippet45"::: + + This example requires: + +- A reference to the namespace. + +- That your form have a control named `ListBox1`. + + For more information, see [How to: Show Available Serial Ports](/dotnet/visual-basic/developing-apps/programming/computer-resources/how-to-show-available-serial-ports). + ]]> diff --git a/xml/Microsoft.VisualBasic.MyServices/ClipboardProxy.xml b/xml/Microsoft.VisualBasic.MyServices/ClipboardProxy.xml index 83d991c7989..9ab1cbf19e2 100644 --- a/xml/Microsoft.VisualBasic.MyServices/ClipboardProxy.xml +++ b/xml/Microsoft.VisualBasic.MyServices/ClipboardProxy.xml @@ -36,42 +36,42 @@ Provides methods for manipulating the Clipboard. - . When an item is moved or copied to the Clipboard, items in other formats are cleared. To make other formats persist, use , which copies everything existing on the current Clipboard, including items pasted from other applications. Place data on the Clipboard in multiple formats to maximize the possibility that a target application, whose format requirements you might not know, can successfully retrieve the data. - - Because all Windows applications share the system Clipboard, the contents may change when you switch to another application. - - A class must be serializable for it to be put on the Clipboard. For more information, see [Serialization - C#](/dotnet/csharp/programming-guide/concepts/serialization/) or [Serialization - Visual Basic](/dotnet/visual-basic/programming-guide/concepts/serialization/). - - When accessing the Clipboard remotely, a is thrown unless the accessing thread operates in STA (single-threaded apartment) mode. To resolve this issue, set the `ThreadApartmentState` to `STA`. For more information, see . - - For more information, see [Storing Data to and Reading from the Clipboard](/dotnet/visual-basic/developing-apps/programming/computer-resources/storing-data-to-and-reading-from-the-clipboard). - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example reads text from the Clipboard into the string `textOnClipboard`. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet6"::: - - This example will fail if there is no text on the Clipboard. - + . When an item is moved or copied to the Clipboard, items in other formats are cleared. To make other formats persist, use , which copies everything existing on the current Clipboard, including items pasted from other applications. Place data on the Clipboard in multiple formats to maximize the possibility that a target application, whose format requirements you might not know, can successfully retrieve the data. + + Because all Windows applications share the system Clipboard, the contents may change when you switch to another application. + + A class must be serializable for it to be put on the Clipboard. For more information, see [Serialization - C#](/dotnet/csharp/programming-guide/concepts/serialization/) or [Serialization - Visual Basic](/dotnet/visual-basic/programming-guide/concepts/serialization/). + + When accessing the Clipboard remotely, a is thrown unless the accessing thread operates in STA (single-threaded apartment) mode. To resolve this issue, set the `ThreadApartmentState` to `STA`. For more information, see . + + For more information, see [Storing Data to and Reading from the Clipboard](/dotnet/visual-basic/developing-apps/programming/computer-resources/storing-data-to-and-reading-from-the-clipboard). + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example reads text from the Clipboard into the string `textOnClipboard`. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet6"::: + + This example will fail if there is no text on the Clipboard. + ]]> @@ -108,34 +108,34 @@ Clears the Clipboard. - class controls access to the Clipboard, and the associated enumeration value indicates the level of access. For more information, see [Additional Security Considerations in Windows Forms](/dotnet/framework/winforms/additional-security-considerations-in-windows-forms). - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example clears the Clipboard. - -``` -My.Computer.Clipboard.Clear() -``` - - This removes all data from the Clipboard. - + class controls access to the Clipboard, and the associated enumeration value indicates the level of access. For more information, see [Additional Security Considerations in Windows Forms](/dotnet/desktop/winforms/additional-security-considerations-in-windows-forms). + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example clears the Clipboard. + +``` +My.Computer.Clipboard.Clear() +``` + + This removes all data from the Clipboard. + ]]> @@ -175,29 +175,29 @@ My.Computer.Clipboard.Clear() if audio data is stored on the Clipboard; otherwise . - @@ -243,32 +243,32 @@ My.Computer.Clipboard.Clear() if data in the specified custom format is stored on the Clipboard; otherwise . - @@ -312,32 +312,32 @@ My.Computer.Clipboard.Clear() if a file drop list is stored on the Clipboard; otherwise . - @@ -379,31 +379,31 @@ My.Computer.Clipboard.Clear() if an image is stored on the Clipboard; otherwise . - @@ -454,30 +454,30 @@ My.Computer.Clipboard.Clear() if the Clipboard contains text; otherwise . - , , and . - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example determines if HTML text is stored on the Clipboard and reads from the Clipboard if it does. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet5"::: - + , , and . + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example determines if HTML text is stored on the Clipboard and reads from the Clipboard if it does. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet5"::: + ]]> @@ -524,30 +524,30 @@ My.Computer.Clipboard.Clear() if the Clipboard contains text; otherwise . - , , and . - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example determines if HTML text is stored on the Clipboard and reads from the Clipboard if it does. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet5"::: - + , , and . + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example determines if HTML text is stored on the Clipboard and reads from the Clipboard if it does. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet5"::: + ]]> @@ -589,29 +589,29 @@ My.Computer.Clipboard.Clear() Retrieves an audio stream from the Clipboard. A object containing audio data or if the Clipboard does not contain any audio data. - @@ -663,31 +663,31 @@ My.Computer.Clipboard.Clear() Retrieves data in a custom format from the Clipboard. An representing the Clipboard data or if the Clipboard does not contain any data that is in the specified format or can be converted to that format. - @@ -736,32 +736,32 @@ My.Computer.Clipboard.Clear() Retrieves data from the Clipboard as an . An object that represents the data currently on the Clipboard, or if there is no data on the Clipboard. - and then writes it to a file. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet1"::: - - Replace `C:\mylogfile` with the name of the file to which you want to write. - + and then writes it to a file. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet1"::: + + Replace `C:\mylogfile` with the name of the file to which you want to write. + ]]> @@ -805,34 +805,34 @@ My.Computer.Clipboard.Clear() Retrieves a collection of strings representing file names from the Clipboard. A containing file names or if the Clipboard does not contain any data that is in the format or can be converted to that format. - @@ -874,31 +874,31 @@ My.Computer.Clipboard.Clear() Retrieves an image from the Clipboard. An representing the Clipboard image data or if the Clipboard does not contain any data that is in the format or can be converted to that format. - @@ -949,32 +949,32 @@ My.Computer.Clipboard.Clear() Retrieves text from the Clipboard. The Clipboard text data or an empty string if the Clipboard does not contain data in the or format, depending on the operating system. - , , and . - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example reads text from the Clipboard into the string `textOnClipboard`. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet6"::: - - This example fails if there is no text on the Clipboard. - + , , and . + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example reads text from the Clipboard into the string `textOnClipboard`. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet6"::: + + This example fails if there is no text on the Clipboard. + ]]> @@ -1020,32 +1020,32 @@ My.Computer.Clipboard.Clear() Retrieves text from the Clipboard. The Clipboard text data or an empty string if the Clipboard does not contain data in the specified format. - , , and . - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example reads text from the Clipboard into the string `textOnClipboard`. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet6"::: - - This example fails if there is no text on the Clipboard. - + , , and . + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example reads text from the Clipboard into the string `textOnClipboard`. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet6"::: + + This example fails if there is no text on the Clipboard. + ]]> @@ -1099,34 +1099,34 @@ My.Computer.Clipboard.Clear() array. Audio data to be written to the Clipboard. Required. Writes audio data to the Clipboard. - [!IMPORTANT] -> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example creates the byte array `musicReader`, reads the file `cool.wav` into it, and then writes it to the Clipboard. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet2"::: - - Replace `cool.wav` with the name and path of the file you wish to read. - +> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example creates the byte array `musicReader`, reads the file `cool.wav` into it, and then writes it to the Clipboard. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet2"::: + + Replace `cool.wav` with the name and path of the file you wish to read. + ]]> @@ -1170,34 +1170,34 @@ My.Computer.Clipboard.Clear() Audio data to be written to the clipboard. Required. Writes audio data to the Clipboard. - [!IMPORTANT] -> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example creates the byte array `musicReader`, reads the file `cool.wav` into it, and then writes it to the Clipboard. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet2"::: - - Replace `cool.wav` with the name and path of the file you wish to read. - +> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example creates the byte array `musicReader`, reads the file `cool.wav` into it, and then writes it to the Clipboard. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet2"::: + + Replace `cool.wav` with the name and path of the file you wish to read. + ]]> @@ -1245,34 +1245,34 @@ My.Computer.Clipboard.Clear() . Data object to be written to the Clipboard. Required. Writes data in a custom format to the Clipboard. - [!IMPORTANT] -> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example writes the `DataObject.dataChunk` to the Clipboard in the custom format `specialFormat`. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet7"::: - - This example depends on the existence of the custom data format `specialFormat`. - +> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example writes the `DataObject.dataChunk` to the Clipboard in the custom format `specialFormat`. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet7"::: + + This example depends on the existence of the custom data format `specialFormat`. + ]]> @@ -1354,35 +1354,35 @@ My.Computer.Clipboard.Clear() . Data object to be written to the Clipboard. Required. Writes a to the Clipboard. - [!IMPORTANT] -> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example writes the data object `dataChunk` to the Clipboard. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet9"::: - - This example depends on the existence of the data object `dataChunk`. - +> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example writes the data object `dataChunk` to the Clipboard. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet9"::: + + This example depends on the existence of the data object `dataChunk`. + ]]> @@ -1428,33 +1428,33 @@ My.Computer.Clipboard.Clear() . List of file names. Required. Writes a collection of strings representing file paths to the Clipboard. - [!IMPORTANT] -> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example gets the collection of file names from **MyDocuments**, converts it to a file drop list, and writes it to the Clipboard. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet3"::: - +> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example gets the collection of file names from **MyDocuments**, converts it to a file drop list, and writes it to the Clipboard. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbRefClipbd/VB/Class1.vb" id="Snippet3"::: + ]]> @@ -1499,34 +1499,34 @@ My.Computer.Clipboard.Clear() . Image to be written. Required. Writes an image to the Clipboard. - [!IMPORTANT] -> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example writes the image `coolPicture` to the Clipboard. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet8"::: - - This example depends on the existence of the image `coolPicture`. - +> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example writes the image `coolPicture` to the Clipboard. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet8"::: + + This example depends on the existence of the image `coolPicture`. + ]]> @@ -1580,35 +1580,35 @@ My.Computer.Clipboard.Clear() . Text to be written. Required. Writes text to the Clipboard. - , , and . - - Previous Clipboard formats are not preserved. - + , , and . + + Previous Clipboard formats are not preserved. + > [!IMPORTANT] -> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example writes the string `This is a test string.` to the Clipboard. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet1"::: - +> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example writes the string `This is a test string.` to the Clipboard. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet1"::: + ]]> @@ -1660,35 +1660,35 @@ My.Computer.Clipboard.Clear() . Format to be used when writing text. Default is . Required. Writes text to the Clipboard. - , , and . - - Previous Clipboard formats are not preserved. - + , , and . + + Previous Clipboard formats are not preserved. + > [!IMPORTANT] -> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. - -## Availability by Project Type - -|Project type|Available| -|------------------|---------------| -|Windows Application|**Yes**| -|Class Library|**Yes**| -|Console Application|**Yes**| -|Windows Control Library|**Yes**| -|Web Control Library|No| -|Windows Service|**Yes**| -|Web Site|No| - - - -## Examples - This example writes the string `This is a test string.` to the Clipboard. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet1"::: - +> Because the Clipboard can be accessed by other users, do not use it to store sensitive information, such as passwords or confidential data. + +## Availability by Project Type + +|Project type|Available| +|------------------|---------------| +|Windows Application|**Yes**| +|Class Library|**Yes**| +|Console Application|**Yes**| +|Windows Control Library|**Yes**| +|Web Control Library|No| +|Windows Service|**Yes**| +|Web Site|No| + + + +## Examples + This example writes the string `This is a test string.` to the Clipboard. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_VBCSharp/VbVbcnMyClipboard/VB/Class1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Collections.Generic/Dictionary`2.xml b/xml/System.Collections.Generic/Dictionary`2.xml index ba32ea72d21..4cb0c0d8e47 100644 --- a/xml/System.Collections.Generic/Dictionary`2.xml +++ b/xml/System.Collections.Generic/Dictionary`2.xml @@ -152,7 +152,6 @@ The `foreach` statement of the C# language (`For Each` in Visual Basic) returns an object of the type of the elements in the collection. Since the is a collection of keys and values, the element type is not the type of the key or the type of the value. Instead, the element type is a of the key type and the value type. For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source2.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source2.cs" id="Snippet11"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source2.fs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source2.vb" id="Snippet11"::: @@ -176,7 +175,6 @@ Finally, the example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet1"::: @@ -261,7 +259,6 @@ This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet2"::: @@ -896,7 +893,6 @@ This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet2"::: @@ -1108,15 +1104,12 @@ This code example is part of a larger example provided for the class (`openWith` is the name of the Dictionary used in this example). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet4"::: @@ -1546,19 +1539,15 @@ This code example is part of a larger example provided for the class. `openWith` is the name of the Dictionary used in this example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet5"::: @@ -1627,11 +1616,9 @@ This code is part of a larger example that can be compiled and executed (`openWith` is the name of the Dictionary used in this example). See . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet9"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet9"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet7"::: @@ -1763,7 +1750,6 @@ This code example is part of a larger example provided for the class (`openWith` is the name of the Dictionary used in this example). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet10"::: @@ -3534,11 +3520,9 @@ Unlike the method, this This code example is part of a larger example provided for the class (`openWith` is the name of the Dictionary used in this example). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet4"::: @@ -3607,11 +3591,9 @@ Unlike the method, this This code example is part of a larger example provided for the class (`openWith` is the name of the Dictionary used in this example). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet8"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet7"::: diff --git a/xml/System.Collections.Generic/HashSet`1.xml b/xml/System.Collections.Generic/HashSet`1.xml index 071ce0e7d05..df120c11c30 100644 --- a/xml/System.Collections.Generic/HashSet`1.xml +++ b/xml/System.Collections.Generic/HashSet`1.xml @@ -438,7 +438,6 @@ The following example demonstrates how to merge two disparate sets. This example ## Examples The following example uses a supplied to allow case-insensitive comparisons on the elements of a collection of vehicle types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/source2.cpp" id="Snippet03"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/HashSetT/.ctor/source2.cs" interactive="try-dotnet-method" id="Snippet03"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/HashSetT/.ctor/source2.fs" id="Snippet03"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/vb/source2.vb" id="Snippet03"::: @@ -1277,7 +1276,6 @@ The following example demonstrates how to merge two disparate sets. This example ## Examples The following example creates two collections with overlapping sets of data. The lower range of values is then removed from the larger set using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/cpp/program.cpp" id="Snippet02"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/HashSetT/.ctor/Program.cs" interactive="try-dotnet-method" id="Snippet02"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/HashSetT/.ctor/Program.fs" id="Snippet02"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.HashSet_ExceptWith/vb/Program.vb" id="Snippet02"::: diff --git a/xml/System.Collections.Generic/IDictionary`2.xml b/xml/System.Collections.Generic/IDictionary`2.xml index 2c6d89a9de6..4f6592baddc 100644 --- a/xml/System.Collections.Generic/IDictionary`2.xml +++ b/xml/System.Collections.Generic/IDictionary`2.xml @@ -91,7 +91,6 @@ The `foreach` statement of the C# language (`For Each` in Visual Basic) returns an object of the type of the elements in the collection. Since each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source2.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source2.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source2.vb" id="Snippet11"::: @@ -113,7 +112,6 @@ Finally, the example shows how to enumerate the keys and values in the dictionary, and how to enumerate the values alone using the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet1"::: @@ -189,7 +187,6 @@ This code is part of a larger example that can be compiled and executed. See . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet2"::: @@ -262,13 +259,10 @@ This code is part of a larger example that can be compiled and executed. See . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet4"::: @@ -346,13 +340,10 @@ This code is part of a larger example that can be compiled and executed. See . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet5"::: @@ -421,7 +412,6 @@ This code is part of a larger example that can be compiled and executed. See . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet9"::: @@ -489,7 +479,6 @@ This code is part of a larger example that can be compiled and executed. See . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet10"::: @@ -571,10 +560,8 @@ This code is part of a larger example that can be compiled and executed. See . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet4"::: @@ -640,7 +627,6 @@ This code is part of a larger example that can be compiled and executed. See . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source.vb" id="Snippet8"::: diff --git a/xml/System.Collections.Generic/IReadOnlyDictionary`2.xml b/xml/System.Collections.Generic/IReadOnlyDictionary`2.xml index 88399f287f9..b009a8c414a 100644 --- a/xml/System.Collections.Generic/IReadOnlyDictionary`2.xml +++ b/xml/System.Collections.Generic/IReadOnlyDictionary`2.xml @@ -89,7 +89,6 @@ The `foreach` statement of the C# language (`For Each` in Visual Basic) requires the type of each element in the collection. Because each element of the interface is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is , as the following example illustrates. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.IDictionary/cpp/source2.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/IDictionaryTKey,TValue/Overview/source2.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source2.vb" id="Snippet11"::: diff --git a/xml/System.Collections.Generic/KeyValuePair`2.xml b/xml/System.Collections.Generic/KeyValuePair`2.xml index 551be8a1551..76cff684e87 100644 --- a/xml/System.Collections.Generic/KeyValuePair`2.xml +++ b/xml/System.Collections.Generic/KeyValuePair`2.xml @@ -92,7 +92,6 @@ The `foreach` statement of the C# language (`For Each` in Visual Basic) returns an object of the type of the elements in the collection. Since each element of a collection based on is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source2.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source2.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source2.vb" id="Snippet11"::: @@ -105,7 +104,6 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet7"::: @@ -263,7 +261,6 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet7"::: @@ -380,7 +377,6 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet7"::: diff --git a/xml/System.Collections.Generic/LinkedListNode`1.xml b/xml/System.Collections.Generic/LinkedListNode`1.xml index 468161d572f..3279af7d7b6 100644 --- a/xml/System.Collections.Generic/LinkedListNode`1.xml +++ b/xml/System.Collections.Generic/LinkedListNode`1.xml @@ -77,7 +77,6 @@ ## Examples The following code example creates a , adds it to a , and tracks the values of its properties as the changes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/LinkedListNodeT/Overview/llnctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/VB/llnctor.vb" id="Snippet1"::: @@ -141,7 +140,6 @@ ## Examples The following code example creates a , adds it to a , and tracks the values of its properties as the changes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/LinkedListNodeT/Overview/llnctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/VB/llnctor.vb" id="Snippet1"::: @@ -205,7 +203,6 @@ ## Examples The following code example creates a , adds it to a , and tracks the values of its properties as the changes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/LinkedListNodeT/Overview/llnctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/VB/llnctor.vb" id="Snippet1"::: @@ -265,7 +262,6 @@ ## Examples The following code example creates a , adds it to a , and tracks the values of its properties as the changes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/LinkedListNodeT/Overview/llnctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/VB/llnctor.vb" id="Snippet1"::: @@ -325,7 +321,6 @@ ## Examples The following code example creates a , adds it to a , and tracks the values of its properties as the changes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/LinkedListNodeT/Overview/llnctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/VB/llnctor.vb" id="Snippet1"::: @@ -393,7 +388,6 @@ ## Examples The following code example creates a , adds it to a , and tracks the values of its properties as the changes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/cpp/llnctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/LinkedListNodeT/Overview/llnctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.LinkedListNode/VB/llnctor.vb" id="Snippet1"::: diff --git a/xml/System.Collections.Generic/LinkedList`1.xml b/xml/System.Collections.Generic/LinkedList`1.xml index b88018f67b1..7e1a3812fad 100644 --- a/xml/System.Collections.Generic/LinkedList`1.xml +++ b/xml/System.Collections.Generic/LinkedList`1.xml @@ -140,7 +140,6 @@ ## Examples The following code example demonstrates many features of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.LinkedList/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/LinkedListT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.LinkedList/vb/source.vb" id="Snippet1"::: @@ -219,7 +218,6 @@ ## Examples The following code example creates and initializes a of type , adds several nodes, and then displays its contents. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Generic.LinkedList.ctor/CPP/llctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/LinkedListT/.ctor/llctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Generic.LinkedList.ctor/VB/llctor.vb" id="Snippet1"::: diff --git a/xml/System.Collections.Generic/List`1.xml b/xml/System.Collections.Generic/List`1.xml index be53559f1f0..0b6bd98f635 100644 --- a/xml/System.Collections.Generic/List`1.xml +++ b/xml/System.Collections.Generic/List`1.xml @@ -189,7 +189,6 @@ The example adds, inserts, and removes items, showing how the capacity changes as these methods are used. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Overview/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Class/vb/source.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/List`1_Class/fs/listclass.fs" id="Snippet1"::: @@ -248,7 +247,6 @@ ## Examples The following example demonstrates the constructor and various methods of the class that act on ranges. An array of strings is created and passed to the constructor, populating the list with the elements of the array. The property is then displayed, to show that the initial capacity is exactly what is required to hold the input elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/.ctor/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Ranges/vb/source.vb" id="Snippet1"::: @@ -320,7 +318,6 @@ ## Examples The following example demonstrates the constructor. A of strings with a capacity of 4 is created, because the ultimate size of the list is known to be exactly 4. The list is populated with four strings, and a read-only copy is created by using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_AsReadOnly/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/.ctor/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_AsReadOnly/vb/source.vb" id="Snippet1"::: @@ -398,7 +395,6 @@ Other properties and methods are used to search for, insert, and remove elements from the list, and finally to clear the list. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Overview/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Class/vb/source.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/List`1_Class/fs/listclass.fs" id="Snippet1"::: @@ -466,7 +462,6 @@ ## Examples The following example demonstrates the method and various other methods of the class that act on ranges. An array of strings is created and passed to the constructor, populating the list with the elements of the array. The method is called, with the list as its argument. The result is that the current elements of the list are added to the end of the list, duplicating all the elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/.ctor/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Ranges/vb/source.vb" id="Snippet1"::: @@ -535,7 +530,6 @@ An element of the original list is set to "Coelophysis" using the property (the indexer in C#), and the contents of the read-only list are displayed again to demonstrate that it is just a wrapper for the original list. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_AsReadOnly/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/.ctor/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_AsReadOnly/vb/source.vb" id="Snippet1"::: @@ -618,7 +612,6 @@ The method overload is then used to search for two strings that are not in the list, and the method is used to insert them. The return value of the method is negative in each case, because the strings are not in the list. Taking the bitwise complement (the ~ operator in C#, `Xor` -1 in Visual Basic) of this negative number produces the index of the first element in the list that is larger than the search string, and inserting at this location preserves the sort order. The second search string is larger than any element in the list, so the insertion position is at the end of the list. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_SortSearch/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/BinarySearch/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_SortSearch/vb/source.vb" id="Snippet1"::: @@ -714,7 +707,6 @@ The method overload is then used to search for several strings that are not in the list, employing the alternate comparer. The method is used to insert the strings. These two methods are located in the function named `SearchAndInsert`, along with code to take the bitwise complement (the ~ operator in C#, `Xor` -1 in Visual Basic) of the negative number returned by and use it as an index for inserting the new string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparer/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/BinarySearch/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_SortSearchComparer/vb/source.vb" id="Snippet1"::: @@ -811,7 +803,6 @@ The method overload is then used to search only the range of herbivores for "Brachiosaurus". The string is not found, and the bitwise complement (the ~ operator in C#, `Xor` -1 in Visual Basic) of the negative number returned by the method is used as an index for inserting the new string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparerRange/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/BinarySearch/source2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_SortSearchComparerRange/vb/source.vb" id="Snippet1"::: @@ -900,7 +891,6 @@ The property is displayed again after the method is used to reduce the capacity to match the count. Finally, the method is used to remove all items from the list, and the and properties are displayed again. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Overview/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Class/vb/source.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/List`1_Class/fs/listclass.fs" id="Snippet1"::: @@ -970,7 +960,6 @@ The following example demonstrates the method and various other properties and methods of the generic class. The method is used at the end of the program, to remove all items from the list, and the and properties are then displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Overview/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Class/vb/source.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/List`1_Class/fs/listclass.fs" id="Snippet1"::: @@ -1120,7 +1109,6 @@ ## Examples The following example defines a method named `PointFToPoint` that converts a structure to a structure. The example then creates a of structures, creates a `Converter\` delegate (`Converter(Of PointF, Point)` in Visual Basic) to represent the `PointFToPoint` method, and passes the delegate to the method. The method passes each element of the input list to the `PointFToPoint` method and puts the converted elements into a new list of structures. Both lists are displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_ConvertAll/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ConverterTInput,TOutput/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_ConvertAll/vb/source.vb" id="Snippet1"::: @@ -1146,7 +1134,6 @@ ## Examples The following example demonstrates all three overloads of the method. A of strings is created and populated with 5 strings. An empty string array of 15 elements is created, and the method overload is used to copy all the elements of the list to the array beginning at the first element of the array. The method overload is used to copy all the elements of the list to the array beginning at array index 6 (leaving index 5 empty). Finally, the method overload is used to copy 3 elements from the list, beginning with index 2, to the array beginning at array index 12 (leaving index 11 empty). The contents of the array are then displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_CopyTo/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/CopyTo/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_CopyTo/vb/source.vb" id="Snippet1"::: @@ -1428,7 +1415,6 @@ The following example shows the value of the property at various points in the life of a list. After the list has been created and populated and its elements displayed, the and properties are displayed. These properties are displayed again after the method has been called, and again after the contents of the list are cleared. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Overview/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Class/vb/source.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/List`1_Class/fs/listclass.fs" id="Snippet1"::: @@ -1542,7 +1528,6 @@ > [!NOTE] > In C# and Visual Basic, it is not necessary to create the `Predicate` delegate (`Predicate(Of String)` in Visual Basic) explicitly. These languages infer the correct delegate from context and create it automatically. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_FindEtAl/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Exists/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_FindEtAl/vb/source.vb" id="Snippet1"::: @@ -2603,7 +2588,6 @@ Public Function StartsWith(e As Employee) As Boolean ## Examples The following example demonstrates the method and other methods of the class that act on ranges. At the end of the example, the method is used to get three items from the list, beginning with index location 2. The method is called on the resulting , creating an array of three elements. The elements of the array are displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/.ctor/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Ranges/vb/source.vb" id="Snippet1"::: @@ -2637,7 +2621,6 @@ Public Function StartsWith(e As Employee) As Boolean ## Examples The following example demonstrates all three overloads of the method. A of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the list from the beginning, and finds the first occurrence of the string. The method overload is used to search the list beginning with index location 3 and continuing to the end of the list, and finds the second occurrence of the string. Finally, the method overload is used to search a range of two entries, beginning at index location two; it returns -1 because there are no instances of the search string in that range. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_IndexOf/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/IndexOf/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_IndexOf/vb/source.vb" id="Snippet1"::: @@ -2921,7 +2904,6 @@ Public Function StartsWith(e As Employee) As Boolean The following example demonstrates the method, along with various other properties and methods of the generic class. After the list is created, elements are added. The method is used to insert an item into the middle of the list. The item inserted is a duplicate, which is later removed using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Overview/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Class/vb/source.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/List`1_Class/fs/listclass.fs" id="Snippet1"::: @@ -3000,7 +2982,6 @@ Public Function StartsWith(e As Employee) As Boolean ## Examples The following example demonstrates method and various other methods of the class that act on ranges. After the list has been created and populated with the names of several peaceful plant-eating dinosaurs, the method is used to insert an array of three ferocious meat-eating dinosaurs into the list, beginning at index location 3. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/.ctor/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Ranges/vb/source.vb" id="Snippet1"::: @@ -3125,7 +3106,6 @@ Public Function StartsWith(e As Employee) As Boolean ## Examples The following example demonstrates all three overloads of the method. A of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the entire list from the end, and finds the second occurrence of the string. The method overload is used to search the list backward beginning with index location 3 and continuing to the beginning of the list, so it finds the first occurrence of the string in the list. Finally, the method overload is used to search a range of four entries, beginning at index location 4 and extending backward (that is, it searches the items at locations 4, 3, 2, and 1); this search returns -1 because there are no instances of the search string in that range. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_LastIndexOf/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/LastIndexOf/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_LastIndexOf/vb/source.vb" id="Snippet1"::: @@ -3402,7 +3382,6 @@ Public Function StartsWith(e As Employee) As Boolean The following example demonstrates method. Several properties and methods of the generic class are used to add, insert, and search the list. After these operations, the list contains a duplicate. The method is used to remove the first instance of the duplicate item, and the contents are displayed. The method always removes the first instance it encounters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Overview/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Class/vb/source.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/List`1_Class/fs/listclass.fs" id="Snippet1"::: @@ -3481,7 +3460,6 @@ Public Function StartsWith(e As Employee) As Boolean Finally, the method verifies that there are no strings in the list that end with "saurus". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_FindEtAl/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Exists/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_FindEtAl/vb/source.vb" id="Snippet1"::: @@ -3626,7 +3604,6 @@ Public Function StartsWith(e As Employee) As Boolean ## Examples The following example demonstrates the method and various other methods of the class that act on ranges. After the list has been created and modified, the method is used to remove two elements from the list, beginning at index location 2. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/.ctor/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Ranges/vb/source.vb" id="Snippet1"::: @@ -3662,7 +3639,6 @@ Public Function StartsWith(e As Employee) As Boolean ## Examples The following example demonstrates both overloads of the method. The example creates a of strings and adds six strings. The method overload is used to reverse the list, and then the method overload is used to reverse the middle of the list, beginning with element 1 and encompassing four elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Reverse/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Reverse/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Reverse/vb/source.vb" id="Snippet1"::: @@ -3911,7 +3887,6 @@ Public Function StartsWith(e As Employee) As Boolean The method overload is then used to search for two strings that are not in the list, and the method is used to insert them. The return value of the method is negative in each case, because the strings are not in the list. Taking the bitwise complement (the ~ operator in C#, `Xor` -1 in Visual Basic) of this negative number produces the index of the first element in the list that is larger than the search string, and inserting at this location preserves the sort order. The second search string is larger than any element in the list, so the insertion position is at the end of the list. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_SortSearch/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/BinarySearch/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_SortSearch/vb/source.vb" id="Snippet1"::: @@ -4000,7 +3975,6 @@ Public Function StartsWith(e As Employee) As Boolean The method overload is then used to search for several strings that are not in the list, employing the alternate comparer. The method is used to insert the strings. These two methods are located in the function named `SearchAndInsert`, along with code to take the bitwise complement (the ~ operator in C#, `Xor` -1 in Visual Basic) of the negative number returned by and use it as an index for inserting the new string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparer/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/BinarySearch/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_SortSearchComparer/vb/source.vb" id="Snippet1"::: @@ -4086,7 +4060,6 @@ Public Function StartsWith(e As Employee) As Boolean A of strings is created and populated with four strings, in no particular order. The list also includes an empty string and a null reference. The list is displayed, sorted using a generic delegate representing the `CompareDinosByLength` method, and displayed again. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_SortComparison/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ComparisonT/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_SortComparison/vb/source.vb" id="Snippet1"::: @@ -4182,7 +4155,6 @@ Public Function StartsWith(e As Employee) As Boolean The method overload is then used to search only the range of herbivores for "Brachiosaurus". The string is not found, and the bitwise complement (the ~ operator in C#, `Xor` -1 in Visual Basic) of the negative number returned by the method is used as an index for inserting the new string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_SortSearchComparerRange/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/BinarySearch/source2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_SortSearchComparerRange/vb/source.vb" id="Snippet1"::: @@ -5199,7 +5171,6 @@ Retrieving the value of this property is an O(1) operation. ## Examples The following example demonstrates the method and other methods of the class that act on ranges. At the end of the example, the method is used to get three items from the list, beginning with index location 2. The method is called on the resulting , creating an array of three elements. The elements of the array are displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Ranges/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/.ctor/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Ranges/vb/source.vb" id="Snippet1"::: @@ -5270,7 +5241,6 @@ Retrieving the value of this property is an O(1) operation. The following example demonstrates the method. Several properties and methods of the class are used to add, insert, and remove items from a list of strings. Then the method is used to reduce the capacity to match the count, and the and properties are displayed. If the unused capacity had been less than 10 percent of total capacity, the list would not have been resized. Finally, the contents of the list are cleared. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_Class/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Overview/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_Class/vb/source.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/List`1_Class/fs/listclass.fs" id="Snippet1"::: @@ -5344,7 +5314,6 @@ Retrieving the value of this property is an O(1) operation. > [!NOTE] > In C# and Visual Basic, it is not necessary to create the `Predicate` delegate (`Predicate(Of String)` in Visual Basic) explicitly. These languages infer the correct delegate from context and create it automatically. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/List`1_FindEtAl/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ListT/Exists/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_FindEtAl/vb/source.vb" id="Snippet1"::: diff --git a/xml/System.Collections.Generic/SortedDictionary`2.xml b/xml/System.Collections.Generic/SortedDictionary`2.xml index a05c958be61..c1ffc58be1e 100644 --- a/xml/System.Collections.Generic/SortedDictionary`2.xml +++ b/xml/System.Collections.Generic/SortedDictionary`2.xml @@ -132,7 +132,6 @@ The `foreach` statement of the C# language (`For Each` in Visual Basic) returns an object of the type of the elements in the collection. Since each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . The following code shows the syntax. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.Dictionary/cpp/source2.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/DictionaryTKey,TValue/Overview/source2.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source2.vb" id="Snippet11"::: diff --git a/xml/System.Collections.Generic/SortedList`2.xml b/xml/System.Collections.Generic/SortedList`2.xml index cbfd5bc244d..3d3dc3dfe67 100644 --- a/xml/System.Collections.Generic/SortedList`2.xml +++ b/xml/System.Collections.Generic/SortedList`2.xml @@ -127,7 +127,6 @@ Another difference between the and classes is that supports efficient indexed retrieval of keys and values through the collections returned by the and properties. It is not necessary to regenerate the lists when the properties are accessed, because the lists are just wrappers for the internal arrays of keys and values. The following code shows the use of the property for indexed retrieval of values from a sorted list of strings: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/remarks.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/remarks.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/remarks.vb" id="Snippet11"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/remarks.fs" id="Snippet11"::: @@ -144,7 +143,6 @@ The `foreach` statement of the C# language (`For Each` in Visual Basic) returns an object of the type of the elements in the collection. Since the elements of the are key/value pairs, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/remarks.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/remarks.cs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/remarks.vb" id="Snippet12"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/remarks.fs" id="Snippet12"::: @@ -164,7 +162,6 @@ Finally, the example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet1"::: @@ -244,7 +241,6 @@ This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet2"::: @@ -713,7 +709,6 @@ This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet2"::: @@ -960,15 +955,12 @@ This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet4"::: @@ -1419,15 +1411,12 @@ This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet5"::: @@ -1494,7 +1483,6 @@ The collection returned by the property provides an efficient way to retrieve keys by index. It is not necessary to regenerate the list when the property is accessed, because the list is just a wrapper for the internal array of keys. The following code shows the use of the property for indexed retrieval of keys from a sorted list of elements with string keys: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/remarks.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/remarks.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/remarks.vb" id="Snippet11"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/remarks.fs" id="Snippet11"::: @@ -1510,11 +1498,9 @@ This code is part of a larger example that can be compiled and executed. See . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet9"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet9"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet7"::: @@ -1584,7 +1570,6 @@ This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet10"::: @@ -3265,11 +3250,9 @@ Retrieving the value of this property is an O(1) operation. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet4"::: @@ -3338,7 +3321,6 @@ Retrieving the value of this property is an O(1) operation. The collection returned by the property provides an efficient way to retrieve values by index. It is not necessary to regenerate the list when the property is accessed, because the list is just a wrapper for the internal array of values. The following code shows the use of the property for indexed retrieval of values from a sorted list of strings: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/remarks.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/remarks.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/remarks.vb" id="Snippet11"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/remarks.fs" id="Snippet11"::: @@ -3354,11 +3336,9 @@ Retrieving the value of this property is an O(1) operation. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet8"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Generic.SortedList/cpp/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.SortedList/VB/source.vb" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System.Collections.Generic/SortedListTKey,TValue/Overview/source.fs" id="Snippet7"::: diff --git a/xml/System.Collections.ObjectModel/Collection`1.xml b/xml/System.Collections.ObjectModel/Collection`1.xml index 1062d7a7528..c9a92648d2d 100644 --- a/xml/System.Collections.ObjectModel/Collection`1.xml +++ b/xml/System.Collections.ObjectModel/Collection`1.xml @@ -138,7 +138,6 @@ The following code example demonstrates many of the properties and methods of . The code example creates a collection of strings, uses the method to add several strings, displays the , and lists the strings. The example uses the method to find the index of a string and the method to determine whether a string is in the collection. The example inserts a string using the method and retrieves and sets strings using the default property (the indexer in C#). The example removes strings by string identity using the method and by index using the method. Finally, the method is used to clear all strings from the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/CollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjectModel.Collection/VB/source.vb" id="Snippet1"::: @@ -232,7 +231,6 @@ ## Examples The following code example demonstrates many of the properties and methods of . The code example creates a collection of strings with the constructor, uses the method to add several strings, displays the , and lists the strings. The example uses the method to find the index of a string and the method to determine whether a string is in the collection. The example inserts a string using the method and retrieves and sets strings using the default property (the indexer in C#). The example removes strings by string identity using the method and by index using the method. Finally, the method is used to clear all strings from the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/CollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjectModel.Collection/VB/source.vb" id="Snippet1"::: @@ -355,7 +353,6 @@ ## Examples The following code example demonstrates many of the properties and methods of . The code example creates a collection of strings, uses the method to add several strings, displays the , and lists the strings. The example uses the method to find the index of a string and the method to determine whether a string is in the collection. The example inserts a string using the method and retrieves and sets strings using the default property (the indexer in C#). The example removes strings by string identity using the method and by index using the method. Finally, the method is used to clear all strings from the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/CollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjectModel.Collection/VB/source.vb" id="Snippet1"::: @@ -433,7 +430,6 @@ ## Examples The following code example demonstrates many of the properties and methods of . The code example creates a collection of strings, uses the method to add several strings, displays the , and lists the strings. The example uses the method to find the index of a string and the method to determine whether a string is in the collection. The example inserts a string using the method and retrieves and sets strings using the default property (the indexer in C#). The example removes strings by string identity using the method and by index using the method. Finally, the method is used to clear all strings from the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/CollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjectModel.Collection/VB/source.vb" id="Snippet1"::: @@ -728,7 +724,6 @@ ## Examples The following code example demonstrates many of the properties and methods of . The code example creates a collection of strings, uses the method to add several strings, displays the , and lists the strings. The example uses the method to find the index of a string and the method to determine whether a string is in the collection. The example inserts a string using the method and retrieves and sets strings using the default property (the indexer in C#). The example removes strings by string identity using the method and by index using the method. Finally, the method is used to clear all strings from the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/CollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjectModel.Collection/VB/source.vb" id="Snippet1"::: @@ -877,7 +872,6 @@ ## Examples The following code example demonstrates many of the properties and methods of . The code example creates a collection of strings, uses the method to add several strings, displays the , and lists the strings. The example uses the method to find the index of a string and the method to determine whether a string is in the collection. The example inserts a string using the method and retrieves and sets strings using the default property (the indexer in C#). The example removes strings by string identity using the method and by index using the method. Finally, the method is used to clear all strings from the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/CollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjectModel.Collection/VB/source.vb" id="Snippet1"::: @@ -1119,7 +1113,6 @@ ## Examples The following code example demonstrates many of the properties and methods of . The code example creates a collection of strings, uses the method to add several strings, displays the , and lists the strings. The example uses the method to find the index of a string and the method to determine whether a string is in the collection. The example inserts a string using the method and retrieves and sets strings using the default property (the indexer in C#). The example removes strings by string identity using the method and by index using the method. Finally, the method is used to clear all strings from the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/CollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjectModel.Collection/VB/source.vb" id="Snippet1"::: @@ -1252,7 +1245,6 @@ ## Examples The following code example demonstrates many of the properties and methods of . The code example creates a collection of strings, uses the method to add several strings, displays the , and lists the strings. The example uses the method to find the index of a string and the method to determine whether a string is in the collection. The example inserts a string using the method and retrieves and sets strings using the default property (the indexer in C#). The example removes strings by string identity using the method and by index using the method. Finally, the method is used to clear all strings from the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/CollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjectModel.Collection/VB/source.vb" id="Snippet1"::: @@ -1326,7 +1318,6 @@ ## Examples The following code example demonstrates many of the properties and methods of . The code example creates a collection of strings, uses the method to add several strings, displays the , and lists the strings. The example uses the method to find the index of a string and the method to determine whether a string is in the collection. The example inserts a string using the method and retrieves and sets strings using the default property (the indexer in C#). The example removes strings by string identity using the method and by index using the method. Finally, the method is used to clear all strings from the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjectModel.Collection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/CollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjectModel.Collection/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Collections.ObjectModel/KeyedCollection`2.xml b/xml/System.Collections.ObjectModel/KeyedCollection`2.xml index 6eedf72ba81..de6541996cc 100644 --- a/xml/System.Collections.ObjectModel/KeyedCollection`2.xml +++ b/xml/System.Collections.ObjectModel/KeyedCollection`2.xml @@ -112,7 +112,6 @@ The `SimpleOrder` class is a very simple requisition list that contains `OrderItem` objects, each of which represents a line item in the order. The key of `OrderItem` is immutable, an important consideration for classes that derive from . For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection/VB/source.vb" id="Snippet1"::: @@ -126,7 +125,6 @@ This code example uses objects with immutable keys. For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection2/vb/source.vb" id="Snippet1"::: @@ -201,7 +199,6 @@ The `SimpleOrder` class is a very simple requisition list that contains `OrderItem` objects, each of which represents a line item in the order. The key of `OrderItem` is immutable, an important consideration for classes that derive from . For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection/VB/source.vb" id="Snippet1"::: @@ -348,7 +345,6 @@ This code example uses objects with immutable keys. For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection2/vb/source.vb" id="Snippet1"::: @@ -502,7 +498,6 @@ In order to maintain the connection between a `MutableKey` object and the `Mutab This code example uses objects with immutable keys. For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection2/vb/source.vb" id="Snippet1"::: @@ -631,7 +626,6 @@ In order to maintain the connection between a `MutableKey` object and the `Mutab The `SimpleOrder` class is a very simple requisition list that contains `OrderItem` objects, each of which represents a line item in the order. The key of `OrderItem` is immutable, an important consideration for classes that derive from . For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection/VB/source.vb" id="Snippet1"::: @@ -777,7 +771,6 @@ In order to maintain the connection between a `MutableKey` object and the `Mutab The `SimpleOrder` class is a very simple requisition list that contains `OrderItem` objects, each of which represents a line item in the order. The key of `OrderItem` is immutable, an important consideration for classes that derive from . For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection/VB/source.vb" id="Snippet1"::: @@ -862,7 +855,6 @@ In order to maintain the connection between a `MutableKey` object and the `Mutab This code example uses objects with immutable keys. For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection2/vb/source.vb" id="Snippet1"::: @@ -953,7 +945,6 @@ In order to maintain the connection between a `MutableKey` object and the `Mutab The `SimpleOrder` class is a very simple requisition list that contains `OrderItem` objects, each of which represents a line item in the order. The key of `OrderItem` is immutable, an important consideration for classes that derive from . For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection/VB/source.vb" id="Snippet1"::: @@ -1031,7 +1022,6 @@ In order to maintain the connection between a `MutableKey` object and the `Mutab The `SimpleOrder` class is a very simple requisition list that contains `OrderItem` objects, each of which represents a line item in the order. The key of `OrderItem` is immutable, an important consideration for classes that derive from . For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection/VB/source.vb" id="Snippet1"::: @@ -1116,7 +1106,6 @@ In order to maintain the connection between a `MutableKey` object and the `Mutab This code example uses objects with immutable keys. For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection2/vb/source.vb" id="Snippet1"::: @@ -1213,7 +1202,6 @@ In order to maintain the connection between a `MutableKey` object and the `Mutab This code example uses objects with immutable keys. For a code example that uses mutable keys, see . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/KeyedCollection2/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/KeyedCollectionTKey,TItem/Overview/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/KeyedCollection2/vb/source.vb" id="Snippet1"::: diff --git a/xml/System.Collections.ObjectModel/ReadOnlyCollection`1.xml b/xml/System.Collections.ObjectModel/ReadOnlyCollection`1.xml index bfad36ee848..78a705d87d4 100644 --- a/xml/System.Collections.ObjectModel/ReadOnlyCollection`1.xml +++ b/xml/System.Collections.ObjectModel/ReadOnlyCollection`1.xml @@ -134,7 +134,6 @@ Finally, the code example creates an array larger than the collection and uses the method to insert the elements of the collection into the middle of the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/ReadOnlyCollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/generic.ReadOnlyCollection/vb/source.vb" id="Snippet1"::: @@ -211,7 +210,6 @@ Finally, the code example creates an array larger than the collection and uses the method to insert the elements of the collection into the middle of the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/ReadOnlyCollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/generic.ReadOnlyCollection/vb/source.vb" id="Snippet1"::: @@ -294,7 +292,6 @@ Finally, the code example creates an array larger than the collection and uses the method to insert the elements of the collection into the middle of the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/ReadOnlyCollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/generic.ReadOnlyCollection/vb/source.vb" id="Snippet1"::: @@ -372,7 +369,6 @@ Finally, the code example creates an array larger than the collection and uses the method to insert the elements of the collection into the middle of the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/ReadOnlyCollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/generic.ReadOnlyCollection/vb/source.vb" id="Snippet1"::: @@ -452,7 +448,6 @@ Finally, the code example creates an array larger than the collection and uses the method to insert the elements of the collection into the middle of the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/ReadOnlyCollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/generic.ReadOnlyCollection/vb/source.vb" id="Snippet1"::: @@ -565,7 +560,6 @@ ## Examples The following code example uses the enumerator to display the contents of a that wraps a . The enumerator is concealed by the `foreach` statement (`For Each` in Visual Basic). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/ReadOnlyCollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/generic.ReadOnlyCollection/vb/source.vb" id="Snippet1"::: @@ -711,7 +705,6 @@ Finally, the code example creates an array larger than the collection and uses the method to insert the elements of the collection into the middle of the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/ReadOnlyCollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/generic.ReadOnlyCollection/vb/source.vb" id="Snippet1"::: @@ -782,7 +775,6 @@ Finally, the code example creates an array larger than the collection and uses the method to insert the elements of the collection into the middle of the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/generic.ReadOnlyCollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.ObjectModel/ReadOnlyCollectionT/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/generic.ReadOnlyCollection/vb/source.vb" id="Snippet1"::: diff --git a/xml/System.Collections.Specialized/BitVector32+Section.xml b/xml/System.Collections.Specialized/BitVector32+Section.xml index 07da3bd32c3..fee75177bec 100644 --- a/xml/System.Collections.Specialized/BitVector32+Section.xml +++ b/xml/System.Collections.Specialized/BitVector32+Section.xml @@ -61,20 +61,19 @@ Represents a section of the vector that can contain an integer number. - to define a new section. A is a window into the and is composed of the smallest number of consecutive bits that can contain the maximum value specified in . For example, a section with a maximum value of 1 is composed of only one bit, whereas a section with a maximum value of 5 is composed of three bits. You can create a with a maximum value of 1 to serve as a Boolean, thereby allowing you to store integers and Booleans in the same . + + + +## Examples + The following code example uses a as a collection of sections. -## Remarks - Use to define a new section. A is a window into the and is composed of the smallest number of consecutive bits that can contain the maximum value specified in . For example, a section with a maximum value of 1 is composed of only one bit, whereas a section with a maximum value of 5 is composed of three bits. You can create a with a maximum value of 1 to serve as a Boolean, thereby allowing you to store integers and Booleans in the same . - - - -## Examples - The following code example uses a as a collection of sections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/CPP/bitvector32_sections.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/BitVector32+Section/Overview/bitvector32_sections.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/VB/bitvector32_sections.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/VB/bitvector32_sections.vb" id="Snippet1"::: + ]]> @@ -196,13 +195,13 @@ if the specified object is the same as the current object; otherwise, . - . - - Two instances are considered equal if both sections are of the same length and are in the same location within a . - + . + + Two instances are considered equal if both sections are of the same length and are in the same location within a . + ]]> @@ -250,13 +249,13 @@ Serves as a hash function for the current , suitable for hashing algorithms and data structures, such as a hash table. A hash code for the current . - . - - This method generates the same hash code for two objects that are equal according to the method. - + . + + This method generates the same hash code for two objects that are equal according to the method. + ]]> @@ -516,11 +515,11 @@ Returns a string that represents the current . A string that represents the current . - . - + . + ]]> diff --git a/xml/System.Collections.Specialized/BitVector32.xml b/xml/System.Collections.Specialized/BitVector32.xml index 9fcb6dd8076..22dd3aff7c7 100644 --- a/xml/System.Collections.Specialized/BitVector32.xml +++ b/xml/System.Collections.Specialized/BitVector32.xml @@ -54,29 +54,27 @@ Provides a simple structure that stores Boolean values and small integers in 32 bits of memory. - is more efficient than for Boolean values and small integers that are used internally. A can grow indefinitely as needed, but it has the memory and performance overhead that a class instance requires. In contrast, a uses only 32 bits. - - A structure can be set up to contain either sections for small integers or bit flags for Booleans, but not both. A is a window into the and is composed of the smallest number of consecutive bits that can contain the maximum value specified in . For example, a section with a maximum value of 1 is composed of only one bit, whereas a section with a maximum value of 5 is composed of three bits. You can create a with a maximum value of 1 to serve as a Boolean, thereby allowing you to store integers and Booleans in the same . - - Some members can be used for a that is set up as sections, while other members can be used for one that is set up as bit flags. For example, the property is the indexer for a that is set up as sections, and the property is the indexer for a that is set up as bit flags. creates a series of masks that can be used to access individual bits in a that is set up as bit flags. - - Using a mask on a that is set up as sections might cause unexpected results. - - - -## Examples - The following code example uses a as a collection of bit flags. + is more efficient than for Boolean values and small integers that are used internally. A can grow indefinitely as needed, but it has the memory and performance overhead that a class instance requires. In contrast, a uses only 32 bits. + + A structure can be set up to contain either sections for small integers or bit flags for Booleans, but not both. A is a window into the and is composed of the smallest number of consecutive bits that can contain the maximum value specified in . For example, a section with a maximum value of 1 is composed of only one bit, whereas a section with a maximum value of 5 is composed of three bits. You can create a with a maximum value of 1 to serve as a Boolean, thereby allowing you to store integers and Booleans in the same . + + Some members can be used for a that is set up as sections, while other members can be used for one that is set up as bit flags. For example, the property is the indexer for a that is set up as sections, and the property is the indexer for a that is set up as bit flags. creates a series of masks that can be used to access individual bits in a that is set up as bit flags. + + Using a mask on a that is set up as sections might cause unexpected results. + + + +## Examples + The following code example uses a as a collection of bit flags. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_BitFlags/CPP/bitvector32_bitflags.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/BitVector32/Overview/bitvector32_bitflags.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_BitFlags/VB/bitvector32_bitflags.vb" id="Snippet1"::: - The following code example uses a as a collection of sections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/CPP/bitvector32_sections.cpp" id="Snippet1"::: + The following code example uses a as a collection of sections. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/BitVector32+Section/Overview/bitvector32_sections.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/VB/bitvector32_sections.vb" id="Snippet1"::: @@ -136,11 +134,11 @@ A structure that contains the data to copy. Initializes a new instance of the structure containing the data represented in an existing structure. - @@ -192,11 +190,11 @@ An integer representing the data of the new . Initializes a new instance of the structure containing the data represented in an integer. - @@ -210,15 +208,14 @@ Creates a series of masks that can be used to retrieve individual bits in a that is set up as bit flags. - @@ -271,19 +268,19 @@ Creates the first mask in a series of masks that can be used to retrieve individual bits in a that is set up as bit flags. A mask that isolates the first bit flag in the . - . You can combine masks using the bitwise OR operation to create a mask that isolates multiple bit flags in the . - - Using a mask on a that is set up as sections might cause unexpected results. - - This method is an O(1) operation. - + . You can combine masks using the bitwise OR operation to create a mask that isolates multiple bit flags in the . + + Using a mask on a that is set up as sections might cause unexpected results. + + This method is an O(1) operation. + ]]> @@ -333,19 +330,19 @@ Creates an additional mask following the specified mask in a series of masks that can be used to retrieve individual bits in a that is set up as bit flags. A mask that isolates the bit flag following the one that points to in . - . You can combine masks using the bitwise OR operation to create a mask that isolates multiple bit flags in the . - - Using a mask on a that is set up as sections might cause unexpected results. - - This method is an O(1) operation. - + . You can combine masks using the bitwise OR operation to create a mask that isolates multiple bit flags in the . + + Using a mask on a that is set up as sections might cause unexpected results. + + This method is an O(1) operation. + ]]> @@ -361,15 +358,14 @@ Creates a series of sections that contain small integers. - as a collection of sections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/CPP/bitvector32_sections.cpp" id="Snippet1"::: + as a collection of sections. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/BitVector32+Section/Overview/bitvector32_sections.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/VB/bitvector32_sections.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32_Sections/VB/bitvector32_sections.vb" id="Snippet1"::: + ]]> @@ -425,15 +421,15 @@ Creates the first in a series of sections that contain small integers. A that can hold a number from zero to . - is a window into the and is composed of the smallest number of consecutive bits that can contain the maximum value specified in . For example, a section with a maximum value of 1 is composed of only one bit, whereas a section with a maximum value of 5 is composed of three bits. You can create a with a maximum value of 1 to serve as a Boolean, thereby allowing you to store integers and Booleans in the same . - - If sections already exist in the , those sections are still accessible; however, overlapping sections might cause unexpected results. - - This method is an O(1) operation. - + is a window into the and is composed of the smallest number of consecutive bits that can contain the maximum value specified in . For example, a section with a maximum value of 1 is composed of only one bit, whereas a section with a maximum value of 5 is composed of three bits. You can create a with a maximum value of 1 to serve as a Boolean, thereby allowing you to store integers and Booleans in the same . + + If sections already exist in the , those sections are still accessible; however, overlapping sections might cause unexpected results. + + This method is an O(1) operation. + ]]> @@ -487,24 +483,24 @@ Creates a new following the specified in a series of sections that contain small integers. A that can hold a number from zero to . - is a window into the and is composed of the smallest number of consecutive bits that can contain the maximum value specified in . For example, a section with a maximum value of 1 is composed of only one bit, whereas a section with a maximum value of 5 is composed of three bits. You can create a with a maximum value of 1 to serve as a Boolean, thereby allowing you to store integers and Booleans in the same . - - If sections already exist after `previous` in the , those sections are still accessible; however, overlapping sections might cause unexpected results. - - This method is an O(1) operation. - + is a window into the and is composed of the smallest number of consecutive bits that can contain the maximum value specified in . For example, a section with a maximum value of 1 is composed of only one bit, whereas a section with a maximum value of 5 is composed of three bits. You can create a with a maximum value of 1 to serve as a Boolean, thereby allowing you to store integers and Booleans in the same . + + If sections already exist after `previous` in the , those sections are still accessible; however, overlapping sections might cause unexpected results. + + This method is an O(1) operation. + ]]> is less than 1. - includes the final bit in the . - - -or- - + includes the final bit in the . + + -or- + is greater than the highest value that can be represented by the number of bits after . @@ -555,13 +551,13 @@ Gets the value of the as an integer. The value of the as an integer. - property. - - Retrieving the value of this property is an O(1) operation. - + property. + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -656,22 +652,21 @@ if the specified object is equal to the ; otherwise, . - if the type of `o` is compatible with the type and if the value of `o` is equal to the value of . - - This method is an O(1) operation. - - - -## Examples - The following code example compares a with another and with an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.Equals/CPP/bitvector32_equals.cpp" id="Snippet1"::: + if the type of `o` is compatible with the type and if the value of `o` is equal to the value of . + + This method is an O(1) operation. + + + +## Examples + The following code example compares a with another and with an . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/BitVector32/Equals/bitvector32_equals.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.Equals/VB/bitvector32_equals.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.BitVector32.Equals/VB/bitvector32_equals.vb" id="Snippet1"::: + ]]> @@ -718,13 +713,13 @@ Serves as a hash function for the . A hash code for the . - is based on the value of . Two instances of with the same value for will also generate the same hash code. - - This method is an O(1) operation. - + is based on the value of . Two instances of with the same value for will also generate the same hash code. + + This method is an O(1) operation. + ]]> @@ -784,17 +779,17 @@ Gets or sets the value stored in the specified . The value stored in the specified . - [Section] property is the indexer for a that is set up as sections, and the [int] property is the indexer for a that is set up as bit flags. - - A is a window into the and is composed of the smallest number of consecutive bits that can contain the maximum value specified in . For example, a section with a maximum value of 1 is composed of only one bit, whereas a section with a maximum value of 5 is composed of three bits. You can create a with a maximum value of 1 to serve as a Boolean, thereby allowing you to store integers and Booleans in the same . - - The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a [default property](/dotnet/visual-basic/language-reference/modifiers/default), which provides the same indexing functionality. - - Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. - + [Section] property is the indexer for a that is set up as sections, and the [int] property is the indexer for a that is set up as bit flags. + + A is a window into the and is composed of the smallest number of consecutive bits that can contain the maximum value specified in . For example, a section with a maximum value of 1 is composed of only one bit, whereas a section with a maximum value of 5 is composed of three bits. You can create a with a maximum value of 1 to serve as a Boolean, thereby allowing you to store integers and Booleans in the same . + + The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a [default property](/dotnet/visual-basic/language-reference/modifiers/default), which provides the same indexing functionality. + + Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. + ]]> @@ -847,17 +842,17 @@ if the specified bit flag is on (1); otherwise, . - [Section] property is the indexer for a that is set up as sections, and the [int] property is the indexer for a that is set up as bit flags. - - Using this property on a that is set up as sections might cause unexpected results. - - The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a [default property](/dotnet/visual-basic/language-reference/modifiers/default), which provides the same indexing functionality. - - Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. - + [Section] property is the indexer for a that is set up as sections, and the [int] property is the indexer for a that is set up as bit flags. + + Using this property on a that is set up as sections might cause unexpected results. + + The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a [default property](/dotnet/visual-basic/language-reference/modifiers/default), which provides the same indexing functionality. + + Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. + ]]> @@ -915,13 +910,13 @@ Returns a string that represents the current . A string that represents the current . - . - - This method is an O(1) operation. - + . + + This method is an O(1) operation. + ]]> @@ -973,11 +968,11 @@ Returns a string that represents the specified . A string that represents the specified . - diff --git a/xml/System.Collections.Specialized/CollectionsUtil.xml b/xml/System.Collections.Specialized/CollectionsUtil.xml index 5525d11c79d..1985f814ca4 100644 --- a/xml/System.Collections.Specialized/CollectionsUtil.xml +++ b/xml/System.Collections.Specialized/CollectionsUtil.xml @@ -52,28 +52,27 @@ Creates collections that ignore the case in strings. - - A can support one writer and multiple readers concurrently. To support multiple writers, all operations must be done through the wrapper returned by the method. - - A can support multiple readers concurrently, as long as the collection is not modified. To guarantee the thread safety of the , all operations must be done through the wrapper returned by the method. - + A can support one writer and multiple readers concurrently. To support multiple writers, all operations must be done through the wrapper returned by the method. + + A can support multiple readers concurrently, as long as the collection is not modified. To guarantee the thread safety of the , all operations must be done through the wrapper returned by the method. + Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. Performing Culture-Insensitive String Operations in Collections @@ -176,11 +175,11 @@ Creates a new case-insensitive instance of the class with the default initial capacity. A new case-insensitive instance of the class with the default initial capacity. - method, use the constructor to create a case-insensitive class. - + method, use the constructor to create a case-insensitive class. + ]]> @@ -234,11 +233,11 @@ Copies the entries from the specified dictionary to a new case-insensitive instance of the class with the same initial capacity as the number of entries copied. A new case-insensitive instance of the class containing the entries from the specified . - method, use the constructor to create a case-insensitive class. - + method, use the constructor to create a case-insensitive class. + ]]> @@ -295,11 +294,11 @@ Creates a new case-insensitive instance of the class with the specified initial capacity. A new case-insensitive instance of the class with the specified initial capacity. - method, use the constructor to create a case-insensitive class. - + method, use the constructor to create a case-insensitive class. + ]]> @@ -352,11 +351,11 @@ Creates a new instance of the class that ignores the case of strings. A new instance of the class that ignores the case of strings. - instance is sorted according to the . - + instance is sorted according to the . + ]]> diff --git a/xml/System.Collections.Specialized/HybridDictionary.xml b/xml/System.Collections.Specialized/HybridDictionary.xml index de9a4c7fcca..49b3bdc2613 100644 --- a/xml/System.Collections.Specialized/HybridDictionary.xml +++ b/xml/System.Collections.Specialized/HybridDictionary.xml @@ -81,7 +81,6 @@ The `foreach` statement of the C# language (`For Each` in Visual Basic) returns an object of the type of the elements in the collection. Since each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/source2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/VB/source2.vb" id="Snippet2"::: @@ -92,7 +91,6 @@ ## Examples The following code example demonstrates several of the properties and methods of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/hybriddictionary.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/hybriddictionary.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/VB/hybriddictionary.vb" id="Snippet1"::: @@ -179,7 +177,6 @@ ## Examples The following code example demonstrates several of the properties and methods of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/hybriddictionary.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/hybriddictionary.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/VB/hybriddictionary.vb" id="Snippet1"::: @@ -444,7 +441,6 @@ ## Examples The following code example adds to and removes elements from a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/CPP/hybriddictionary_addremove.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Add/hybriddictionary_addremove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/VB/hybriddictionary_addremove.vb" id="Snippet1"::: @@ -516,7 +512,6 @@ ## Examples The following code example adds to and removes elements from a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/CPP/hybriddictionary_addremove.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Add/hybriddictionary_addremove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/VB/hybriddictionary_addremove.vb" id="Snippet1"::: @@ -586,7 +581,6 @@ ## Examples The following code example searches for an element in a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Contains/CPP/hybriddictionary_contains.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Contains/hybriddictionary_contains.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Contains/VB/hybriddictionary_contains.vb" id="Snippet1"::: @@ -661,7 +655,6 @@ ## Examples The following code example copies the elements of a to an array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_CopyTo/CPP/hybriddictionary_copyto.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/CopyTo/hybriddictionary_copyto.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_CopyTo/VB/hybriddictionary_copyto.vb" id="Snippet1"::: @@ -734,7 +727,6 @@ ## Examples The following code example enumerates the elements of a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Count/hybriddictionary_enumerator.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/VB/hybriddictionary_enumerator.vb" id="Snippet1"::: @@ -811,7 +803,6 @@ ## Examples The following code example enumerates the elements of a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Count/hybriddictionary_enumerator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/VB/hybriddictionary_enumerator.vb" id="Snippet1"::: @@ -997,7 +988,6 @@ ## Examples The following code example shows how to lock the collection using the during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/source2.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/source2.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/VB/source2.vb" id="Snippet3"::: @@ -1081,7 +1071,6 @@ ## Examples The following code example enumerates the elements of a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Count/hybriddictionary_enumerator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/VB/hybriddictionary_enumerator.vb" id="Snippet1"::: @@ -1151,7 +1140,6 @@ ## Examples The following code example enumerates the elements of a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Count/hybriddictionary_enumerator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/VB/hybriddictionary_enumerator.vb" id="Snippet1"::: @@ -1222,7 +1210,6 @@ ## Examples The following code example adds to and removes elements from a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/CPP/hybriddictionary_addremove.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Add/hybriddictionary_addremove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_AddRemove/VB/hybriddictionary_addremove.vb" id="Snippet1"::: @@ -1291,7 +1278,6 @@ ## Examples The following code example shows how to lock the collection using the during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/CPP/source2.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Overview/source2.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary2/VB/source2.vb" id="Snippet3"::: @@ -1371,7 +1357,6 @@ ## Examples The following code example enumerates the elements of a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Count/hybriddictionary_enumerator.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/VB/hybriddictionary_enumerator.vb" id="Snippet1"::: @@ -1439,7 +1424,6 @@ ## Examples The following code example enumerates the elements of a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/CPP/hybriddictionary_enumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/HybridDictionary/Count/hybriddictionary_enumerator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.HybridDictionary_Enumerator/VB/hybriddictionary_enumerator.vb" id="Snippet1"::: diff --git a/xml/System.Collections.Specialized/IOrderedDictionary.xml b/xml/System.Collections.Specialized/IOrderedDictionary.xml index 8c581803014..41af70b606b 100644 --- a/xml/System.Collections.Specialized/IOrderedDictionary.xml +++ b/xml/System.Collections.Specialized/IOrderedDictionary.xml @@ -54,32 +54,30 @@ Represents an indexed collection of key/value pairs. - elements can be accessed either with the key or with the index. - - Each element is a key/value pair stored in a structure. - - Each pair must have a unique key that is not `null`, but the value can be `null` and does not have to be unique. The interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order. - - The `foreach` statement of the C# language (`For Each` in Visual Basic) returns an object of the type of the elements in the collection. Because each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is , as the following example shows. + elements can be accessed either with the key or with the index. + + Each element is a key/value pair stored in a structure. + + Each pair must have a unique key that is not `null`, but the value can be `null` and does not have to be unique. The interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order. + + The `foreach` statement of the C# language (`For Each` in Visual Basic) returns an object of the type of the elements in the collection. Because each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is , as the following example shows. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/remarks.cpp" id="Snippet03"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/remarks.cs" id="Snippet03"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/remarks.vb" id="Snippet03"::: - - The `foreach` statement is a wrapper around the enumerator, which allows only reading from, not writing to, the collection. - - - -## Examples - The following code example demonstrates the implementation of a simple based on the class. The implemented stores first names as the keys and last names as the values, with the added requirement that each first name is unique. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp" id="Snippet00"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/remarks.vb" id="Snippet03"::: + + The `foreach` statement is a wrapper around the enumerator, which allows only reading from, not writing to, the collection. + + + +## Examples + The following code example demonstrates the implementation of a simple based on the class. The implemented stores first names as the keys and last names as the values, with the added requirement that each first name is unique. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/iordereddictionary.cs" interactive="try-dotnet" id="Snippet00"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/iordereddictionary.vb" id="Snippet00"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/iordereddictionary.vb" id="Snippet00"::: + ]]> @@ -133,33 +131,32 @@ Returns an enumerator that iterates through the collection. An for the entire collection. - also brings the enumerator back to this position. At this position, the property is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. + + + +## Examples + The following code example demonstrates the implementation of a simple based on the class. The implemented stores first names as the keys and last names as the values, with the added requirement that each first name is unique. This code is part of a larger code example provided for the class. - The `foreach` statement of the C# language (`for each` in Visual Basic) hides the complexity of the enumerators. Therefore, using `foreach` is recommended instead of directly manipulating the enumerator. - - Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection. - - Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, the property is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - - - -## Examples - The following code example demonstrates the implementation of a simple based on the class. The implemented stores first names as the keys and last names as the values, with the added requirement that each first name is unique. This code is part of a larger code example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/iordereddictionary.cs" id="Snippet01"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/iordereddictionary.vb" id="Snippet01"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/iordereddictionary.vb" id="Snippet01"::: + ]]> @@ -219,39 +216,38 @@ The object to use as the value of the element to add. The value can be . Inserts a key/value pair into the collection at the specified index. - accepts `null` as a valid value and allows duplicate elements. - - If the `index` parameter is equal to , the `value` parameter is added to the end of the collection. - - In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped together, such as a hash table. - - - -## Examples - The following code example demonstrates the implementation of a simple based on the class. The implemented stores first names as the keys and last names as the values, with the added requirement that each first name is unique. This code is part of a larger code example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp" id="Snippet01"::: + accepts `null` as a valid value and allows duplicate elements. + + If the `index` parameter is equal to , the `value` parameter is added to the end of the collection. + + In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped together, such as a hash table. + + + +## Examples + The following code example demonstrates the implementation of a simple based on the class. The implemented stores first names as the keys and last names as the values, with the added requirement that each first name is unique. This code is part of a larger code example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/iordereddictionary.cs" id="Snippet01"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/iordereddictionary.vb" id="Snippet01"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/iordereddictionary.vb" id="Snippet01"::: + ]]> - is less than 0. - - -or- - + is less than 0. + + -or- + is greater than . is . An element with the same key already exists in the collection. - The collection is read-only. - - -or- - + The collection is read-only. + + -or- + The collection has a fixed size. @@ -306,36 +302,34 @@ Gets or sets the element at the specified index. The element at the specified index. - accepts `null` as a valid value and allows duplicate elements. The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a [default property](/dotnet/visual-basic/language-reference/modifiers/default), which provides the same indexing functionality. -This property allows you to access a specific element in the collection by using the following syntax: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/remarks.cpp" id="Snippet04"::: +This property allows you to access a specific element in the collection by using the following syntax: + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/remarks.cs" id="Snippet04"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/remarks.vb" id="Snippet04"::: - - - -## Examples - The following code example demonstrates the implementation of a simple based on the class. The implemented stores first names as the keys and last names as the values, with the added requirement that each first name is unique. This code is part of a larger code example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp" id="Snippet01"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/remarks.vb" id="Snippet04"::: + + + +## Examples + The following code example demonstrates the implementation of a simple based on the class. The implemented stores first names as the keys and last names as the values, with the added requirement that each first name is unique. This code is part of a larger code example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/iordereddictionary.cs" id="Snippet01"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/iordereddictionary.vb" id="Snippet01"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/iordereddictionary.vb" id="Snippet01"::: + ]]> - is less than 0. - - -or- - + is less than 0. + + -or- + is equal to or greater than . @@ -383,32 +377,31 @@ This property allows you to access a specific element in the collection by using The zero-based index of the element to remove. Removes the element at the specified index. - based on the class. The implemented stores first names as the keys and last names as the values, with the added requirement that each first name is unique. This code is part of a larger code example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/cpp/iordereddictionary.cpp" id="Snippet01"::: + based on the class. The implemented stores first names as the keys and last names as the values, with the added requirement that each first name is unique. This code is part of a larger code example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/IOrderedDictionary/Overview/iordereddictionary.cs" id="Snippet01"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/iordereddictionary.vb" id="Snippet01"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.IOrderedDictionary_Implementation/vb/iordereddictionary.vb" id="Snippet01"::: + ]]> - is less than 0. - - -or- - + is less than 0. + + -or- + is equal to or greater than . - The collection is read-only. - - -or- - + The collection is read-only. + + -or- + The collection has a fixed size. diff --git a/xml/System.Collections.Specialized/ListDictionary.xml b/xml/System.Collections.Specialized/ListDictionary.xml index 3863fe11f91..637784c6f3f 100644 --- a/xml/System.Collections.Specialized/ListDictionary.xml +++ b/xml/System.Collections.Specialized/ListDictionary.xml @@ -68,40 +68,38 @@ Implements using a singly linked list. Recommended for collections that typically include fewer than 10 items. - using a singly linked list. It is smaller and faster than a if the number of elements is 10 or less. This should not be used if performance is important for large numbers of elements. - - Items in a are not in any guaranteed order; code should not depend on the current order. The is implemented for fast keyed retrieval; the actual internal order of items is implementation-dependent and could change in future versions of the product. - - Members, such as , , , and are O(`n`) operations, where `n` is . - - A key cannot be `null`, but a value can. - - The `foreach` statement of the C# language (`for each` in Visual Basic) returns an object of the type of the elements in the collection. Since each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: + using a singly linked list. It is smaller and faster than a if the number of elements is 10 or less. This should not be used if performance is important for large numbers of elements. + + Items in a are not in any guaranteed order; code should not depend on the current order. The is implemented for fast keyed retrieval; the actual internal order of items is implementation-dependent and could change in future versions of the product. + + Members, such as , , , and are O(`n`) operations, where `n` is . + + A key cannot be `null`, but a value can. + + The `foreach` statement of the C# language (`for each` in Visual Basic) returns an object of the type of the elements in the collection. Since each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/source2.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/source2.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/VB/source2.vb" id="Snippet3"::: - The `foreach` statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection. - - - -## Examples - The following code example demonstrates several of the properties and methods of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/listdictionary.cpp" id="Snippet1"::: + The `foreach` statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection. + + + +## Examples + The following code example demonstrates several of the properties and methods of . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/listdictionary.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/VB/listdictionary.vb" id="Snippet1"::: - + ]]> - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - - This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + + This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. @@ -161,22 +159,21 @@ Creates an empty using the default comparer. - must be unique. The default comparer is the key's implementation of . - - This constructor is an O(1) operation. - - - -## Examples - The following code example demonstrates several of the properties and methods of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/listdictionary.cpp" id="Snippet1"::: + must be unique. The default comparer is the key's implementation of . + + This constructor is an O(1) operation. + + + +## Examples + The following code example demonstrates several of the properties and methods of . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/listdictionary.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/VB/listdictionary.vb" id="Snippet1"::: - + ]]> Performing Culture-Insensitive String Operations @@ -227,22 +224,22 @@ - The to use to determine whether two keys are equal. - - -or- - + The to use to determine whether two keys are equal. + + -or- + to use the default comparer, which is each key's implementation of . Creates an empty using the specified comparer. - must be unique. The default comparer is the key's implementation of . - - The custom comparer enables such scenarios as doing lookups with case-insensitive strings. - - This constructor is an O(1) operation. - + must be unique. The default comparer is the key's implementation of . + + The custom comparer enables such scenarios as doing lookups with case-insensitive strings. + + This constructor is an O(1) operation. + ]]> @@ -307,21 +304,20 @@ The value of the entry to add. The value can be . Adds an entry with the specified key and value into the . - property to add new elements by setting the value of a key that does not exist in the ; for example, `myCollection["myNonexistentKey"] = myValue`. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. - - This method is an O(`n`) operation, where `n` is . - - - -## Examples - The following code example adds to and removes elements from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/CPP/listdictionary_addremove.cpp" id="Snippet1"::: + property to add new elements by setting the value of a key that does not exist in the ; for example, `myCollection["myNonexistentKey"] = myValue`. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. + + This method is an O(`n`) operation, where `n` is . + + + +## Examples + The following code example adds to and removes elements from a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Add/listdictionary_addremove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/VB/listdictionary_addremove.vb" id="Snippet1"::: @@ -379,19 +375,18 @@ Removes all entries from the . - is set to zero, and references to other objects from elements of the collection are also released. - - This method is an O(1) operation. - - - -## Examples - The following code example adds to and removes elements from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/CPP/listdictionary_addremove.cpp" id="Snippet1"::: + is set to zero, and references to other objects from elements of the collection are also released. + + This method is an O(1) operation. + + + +## Examples + The following code example adds to and removes elements from a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Add/listdictionary_addremove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/VB/listdictionary_addremove.vb" id="Snippet1"::: @@ -449,22 +444,21 @@ if the contains an entry with the specified key; otherwise, . - . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `key` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example searches for an element in a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Contains/CPP/listdictionary_contains.cpp" id="Snippet1"::: + . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `key` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example searches for an element in a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Contains/listdictionary_contains.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Contains/VB/listdictionary_contains.vb" id="Snippet1"::: - + ]]> @@ -522,23 +516,22 @@ The zero-based index in at which copying begins. Copies the entries to a one-dimensional instance at the specified index. - in the same order in which the enumerator iterates through the . - - To copy only the keys in the , use `ListDictionary.Keys.CopyTo`. - - To copy only the values in the , use `ListDictionary.Values.CopyTo`. - - This method is an O(`n`) operation, where `n` is . - - - -## Examples - The following code example copies the elements of a to an array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_CopyTo/CPP/listdictionary_copyto.cpp" id="Snippet1"::: + in the same order in which the enumerator iterates through the . + + To copy only the keys in the , use `ListDictionary.Keys.CopyTo`. + + To copy only the values in the , use `ListDictionary.Values.CopyTo`. + + This method is an O(`n`) operation, where `n` is . + + + +## Examples + The following code example copies the elements of a to an array. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/CopyTo/listdictionary_copyto.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_CopyTo/VB/listdictionary_copyto.vb" id="Snippet1"::: @@ -549,10 +542,10 @@ is less than zero. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source is greater than the available space from to the end of the destination . The type of the source cannot be cast automatically to the type of the destination . @@ -610,17 +603,16 @@ Gets the number of key/value pairs contained in the . The number of key/value pairs contained in the . - . - -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp" id="Snippet1"::: + . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Count/listdictionary_enumerator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/VB/listdictionary_enumerator.vb" id="Snippet1"::: @@ -673,31 +665,30 @@ Returns an that iterates through the . An for the . - also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - - This method is an O(1) operation. - - - -## Examples - The following code example enumerates the elements of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp" id="Snippet1"::: + also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. + + This method is an O(1) operation. + + + +## Examples + The following code example enumerates the elements of a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Count/listdictionary_enumerator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/VB/listdictionary_enumerator.vb" id="Snippet1"::: @@ -751,17 +742,17 @@ Gets a value indicating whether the has a fixed size. This property always returns . - implements the property because it is required by the interface. - - A collection with a fixed size does not allow the addition or removal of elements after the collection is created, but it allows the modification of existing elements. - - A collection with a fixed size is simply a collection with a wrapper that prevents adding and removing elements; therefore, if changes are made to the underlying collection, including the addition or removal of elements, the fixed-size collection reflects those changes. - - Retrieving the value of this property is an O(1) operation. - + implements the property because it is required by the interface. + + A collection with a fixed size does not allow the addition or removal of elements after the collection is created, but it allows the modification of existing elements. + + A collection with a fixed size is simply a collection with a wrapper that prevents adding and removing elements; therefore, if changes are made to the underlying collection, including the addition or removal of elements, the fixed-size collection reflects those changes. + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -810,17 +801,17 @@ Gets a value indicating whether the is read-only. This property always returns . - implements the property because it is required by the interface. - - A collection that is read-only does not allow the addition, removal, or modification of elements after the collection is created. - - A collection that is read-only is simply a collection with a wrapper that prevents modifying the collection; therefore, if changes are made to the underlying collection, the read-only collection reflects those changes. - - Retrieving the value of this property is an O(1) operation. - + implements the property because it is required by the interface. + + A collection that is read-only does not allow the addition, removal, or modification of elements after the collection is created. + + A collection that is read-only is simply a collection with a wrapper that prevents modifying the collection; therefore, if changes are made to the underlying collection, the read-only collection reflects those changes. + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -869,26 +860,25 @@ Gets a value indicating whether the is synchronized (thread safe). This property always returns . - implements the property because it is required by the interface. - - Derived classes can provide a synchronized version of the using the property. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/source2.cpp" id="Snippet2"::: + implements the property because it is required by the interface. + + Derived classes can provide a synchronized version of the using the property. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/VB/source2.vb" id="Snippet2"::: - - Retrieving the value of this property is an O(1) operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/VB/source2.vb" id="Snippet2"::: + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -949,28 +939,27 @@ Gets or sets the value associated with the specified key. The value associated with the specified key. If the specified key is not found, attempting to get it returns , and attempting to set it creates a new entry using the specified key. - property to add new elements by setting the value of a key that does not exist in the ; for example, `myCollection["myNonexistentKey"] = myValue`. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. - - A key cannot be `null`, but a value can. To distinguish between `null` that is returned because the specified key is not found and `null` that is returned because the value of the specified key is `null`, use the method to determine if the key exists in the list. - - The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a default property, which provides the same indexing functionality. - - This method is an O(`n`) operation, where `n` is . - - - -## Examples - The following code example enumerates the elements of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp" id="Snippet1"::: + property to add new elements by setting the value of a key that does not exist in the ; for example, `myCollection["myNonexistentKey"] = myValue`. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. + + A key cannot be `null`, but a value can. To distinguish between `null` that is returned because the specified key is not found and `null` that is returned because the value of the specified key is `null`, use the method to determine if the key exists in the list. + + The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a default property, which provides the same indexing functionality. + + This method is an O(`n`) operation, where `n` is . + + + +## Examples + The following code example enumerates the elements of a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Count/listdictionary_enumerator.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/VB/listdictionary_enumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/VB/listdictionary_enumerator.vb" id="Snippet1"::: + ]]> @@ -1023,21 +1012,20 @@ Gets an containing the keys in the . An containing the keys in the . - is unspecified, but it is the same order as the associated values in the returned by the method. - - The returned is not a static copy; instead, the refers back to the keys in the original . Therefore, changes to the continue to be reflected in the . - - Retrieving the value of this property is an O(1) operation. - - - -## Examples - The following code example enumerates the elements of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp" id="Snippet1"::: + is unspecified, but it is the same order as the associated values in the returned by the method. + + The returned is not a static copy; instead, the refers back to the keys in the original . Therefore, changes to the continue to be reflected in the . + + Retrieving the value of this property is an O(1) operation. + + + +## Examples + The following code example enumerates the elements of a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Count/listdictionary_enumerator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/VB/listdictionary_enumerator.vb" id="Snippet1"::: @@ -1094,19 +1082,18 @@ The key of the entry to remove. Removes the entry with the specified key from the . - does not contain an element with the specified key, the remains unchanged. No exception is thrown. - - This method is an O(`n`) operation, where `n` is . - - - -## Examples - The following code example adds to and removes elements from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/CPP/listdictionary_addremove.cpp" id="Snippet1"::: + does not contain an element with the specified key, the remains unchanged. No exception is thrown. + + This method is an O(`n`) operation, where `n` is . + + + +## Examples + The following code example adds to and removes elements from a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Add/listdictionary_addremove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_AddRemove/VB/listdictionary_addremove.vb" id="Snippet1"::: @@ -1163,24 +1150,23 @@ Gets an object that can be used to synchronize access to the . An object that can be used to synchronize access to the . - using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/CPP/source2.cpp" id="Snippet2"::: + using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Overview/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/VB/source2.vb" id="Snippet2"::: - - Retrieving the value of this property is an O(1) operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary2/VB/source2.vb" id="Snippet2"::: + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -1231,34 +1217,33 @@ Returns an that iterates through the . An for the . - also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - This method is an O(1) operation. - - - -## Examples - The following code example enumerates the elements of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp" id="Snippet1"::: + also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + This method is an O(1) operation. + + + +## Examples + The following code example enumerates the elements of a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Count/listdictionary_enumerator.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/VB/listdictionary_enumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/VB/listdictionary_enumerator.vb" id="Snippet1"::: + ]]> @@ -1309,21 +1294,20 @@ Gets an containing the values in the . An containing the values in the . - is unspecified, but it is the same order as the associated keys in the returned by the method. - - The returned is not a static copy; instead, the refers back to the values in the original . Therefore, changes to the continue to be reflected in the . - - Retrieving the value of this property is an O(1) operation. - - - -## Examples - The following code example enumerates the elements of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/CPP/listdictionary_enumerator.cpp" id="Snippet1"::: + is unspecified, but it is the same order as the associated keys in the returned by the method. + + The returned is not a static copy; instead, the refers back to the values in the original . Therefore, changes to the continue to be reflected in the . + + Retrieving the value of this property is an O(1) operation. + + + +## Examples + The following code example enumerates the elements of a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/ListDictionary/Count/listdictionary_enumerator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.ListDictionary_Enumerator/VB/listdictionary_enumerator.vb" id="Snippet1"::: diff --git a/xml/System.Collections.Specialized/NameObjectCollectionBase+KeysCollection.xml b/xml/System.Collections.Specialized/NameObjectCollectionBase+KeysCollection.xml index 99388e01aa8..7e4c940d430 100644 --- a/xml/System.Collections.Specialized/NameObjectCollectionBase+KeysCollection.xml +++ b/xml/System.Collections.Specialized/NameObjectCollectionBase+KeysCollection.xml @@ -60,10 +60,10 @@ Represents a collection of the keys of a collection. To be added. - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - - This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + + This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. @@ -111,11 +111,11 @@ Gets the number of keys in the . The number of keys in the . - @@ -166,11 +166,11 @@ Gets the key at the specified index of the collection. A that contains the key at the specified index of the collection. - @@ -222,27 +222,27 @@ Returns an enumerator that iterates through the . An for the . - also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - - This method is an O(1) operation. - + also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. + + This method is an O(1) operation. + ]]> @@ -303,15 +303,15 @@ Gets the entry at the specified index of the collection. The key of the entry at the specified index of the collection. - property. Visual Basic implements as a [default property](/dotnet/visual-basic/language-reference/modifiers/default), which provides the same indexing functionality. - - Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. - + property. Visual Basic implements as a [default property](/dotnet/visual-basic/language-reference/modifiers/default), which provides the same indexing functionality. + + Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. + ]]> @@ -367,15 +367,15 @@ The zero-based index in at which copying begins. Copies the entire to a compatible one-dimensional , starting at the specified index of the target array. - to copy the elements. - - This method is an O(`n`) operation, where `n` is . - + to copy the elements. + + This method is an O(`n`) operation, where `n` is . + ]]> @@ -383,10 +383,10 @@ is less than zero. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source is greater than the available space from to the end of the destination . The type of the source cannot be cast automatically to the type of the destination . @@ -435,24 +435,23 @@ if access to the is synchronized (thread safe); otherwise, . The default is . - using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the during the entire enumeration. + using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.collections.specialized.nameobjectcollectionbase.keyscollection/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase+KeysCollection/System.Collections.ICollection.IsSynchronized/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.specialized.nameobjectcollectionbase.keyscollection/vb/source.vb" id="Snippet1"::: - - Retrieving the value of this property is an O(1) operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.specialized.nameobjectcollectionbase.keyscollection/vb/source.vb" id="Snippet1"::: + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -507,24 +506,23 @@ Gets an object that can be used to synchronize access to the . An object that can be used to synchronize access to the . - using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.collections.specialized.nameobjectcollectionbase.keyscollection/cpp/source.cpp" id="Snippet1"::: + using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase+KeysCollection/System.Collections.ICollection.IsSynchronized/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.specialized.nameobjectcollectionbase.keyscollection/vb/source.vb" id="Snippet1"::: - - Retrieving the value of this property is an O(1) operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.specialized.nameobjectcollectionbase.keyscollection/vb/source.vb" id="Snippet1"::: + + Retrieving the value of this property is an O(1) operation. + ]]> diff --git a/xml/System.Collections.Specialized/NameObjectCollectionBase.xml b/xml/System.Collections.Specialized/NameObjectCollectionBase.xml index 7fe655f7f92..8f3a59932a3 100644 --- a/xml/System.Collections.Specialized/NameObjectCollectionBase.xml +++ b/xml/System.Collections.Specialized/NameObjectCollectionBase.xml @@ -99,7 +99,6 @@ ## Examples The following code example shows how to implement and use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/nameobjectcollectionbase.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/Overview/nameobjectcollectionbase.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/VB/nameobjectcollectionbase.vb" id="Snippet1"::: @@ -645,7 +644,6 @@ ## Examples The following code example uses to create a new with elements from an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseAdd/CPP/nocb_baseadd.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseAdd/nocb_baseadd.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseAdd/VB/nocb_baseadd.vb" id="Snippet1"::: @@ -707,7 +705,6 @@ ## Examples The following code example uses to remove all elements from a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseClear/CPP/nocb_baseclear.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseClear/nocb_baseclear.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseClear/VB/nocb_baseclear.vb" id="Snippet1"::: @@ -730,7 +727,6 @@ ## Examples The following code example uses and to get specific keys and values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGet/CPP/nocb_baseget.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseGetKey/nocb_baseget.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGet/VB/nocb_baseget.vb" id="Snippet1"::: @@ -909,7 +905,6 @@ ## Examples The following code example uses and to get an array of the keys or an array of the values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGetAll/CPP/nocb_basegetall.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseGetAllKeys/nocb_basegetall.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGetAll/VB/nocb_basegetall.vb" id="Snippet1"::: @@ -980,7 +975,6 @@ ## Examples The following code example uses and to get an array of the keys or an array of the values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGetAll/CPP/nocb_basegetall.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseGetAllKeys/nocb_basegetall.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGetAll/VB/nocb_basegetall.vb" id="Snippet1"::: @@ -1104,7 +1098,6 @@ ## Examples The following code example uses and to get specific keys and values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGet/CPP/nocb_baseget.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseGetKey/nocb_baseget.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseGet/VB/nocb_baseget.vb" id="Snippet1"::: @@ -1167,7 +1160,6 @@ ## Examples The following code example uses to determine if the collection contains keys that are not `null`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseHasKeys/CPP/nocb_basehaskeys.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseHasKeys/nocb_basehaskeys.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseHasKeys/VB/nocb_basehaskeys.vb" id="Snippet1"::: @@ -1234,7 +1226,6 @@ ## Examples The following code example uses and to remove elements from a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseRemove/CPP/nocb_baseremove.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseRemove/nocb_baseremove.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseRemove/VB/nocb_baseremove.vb" id="Snippet1"::: @@ -1300,7 +1291,6 @@ ## Examples The following code example uses and to remove elements from a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseRemove/CPP/nocb_baseremove.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseRemove/nocb_baseremove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseRemove/VB/nocb_baseremove.vb" id="Snippet1"::: @@ -1325,7 +1315,6 @@ ## Examples The following code example uses to set the value of a specific element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseSet/CPP/nocb_baseset.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/BaseSet/nocb_baseset.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.BaseSet/VB/nocb_baseset.vb" id="Snippet1"::: @@ -1720,7 +1709,6 @@ ## Examples The following code example creates a read-only collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.IsReadOnly/CPP/nocb_isreadonly.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/IsReadOnly/nocb_isreadonly.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase.IsReadOnly/VB/nocb_isreadonly.vb" id="Snippet1"::: @@ -1973,7 +1961,6 @@ The following code example shows how to lock the collection using the property during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/remarks.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/Overview/remarks.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/VB/remarks.vb" id="Snippet2"::: @@ -2042,7 +2029,6 @@ The following code example shows how to lock the collection using the during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/CPP/remarks.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameObjectCollectionBase/Overview/remarks.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameObjectCollectionBase/VB/remarks.vb" id="Snippet2"::: diff --git a/xml/System.Collections.Specialized/NameValueCollection.xml b/xml/System.Collections.Specialized/NameValueCollection.xml index 17d631a0b99..f7311b787ea 100644 --- a/xml/System.Collections.Specialized/NameValueCollection.xml +++ b/xml/System.Collections.Specialized/NameValueCollection.xml @@ -79,7 +79,6 @@ > The method does not distinguish between `null` that's returned because the specified key is not found and `null` that's returned because the value associated with the key is `null`. ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/CPP/nvc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/NameValueCollection/Overview/nvc.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.NameValueCollection2/VB/nvc.vb" id="Snippet1"::: diff --git a/xml/System.Collections.Specialized/OrderedDictionary.xml b/xml/System.Collections.Specialized/OrderedDictionary.xml index 55ebdc17782..0ef25e2e521 100644 --- a/xml/System.Collections.Specialized/OrderedDictionary.xml +++ b/xml/System.Collections.Specialized/OrderedDictionary.xml @@ -94,7 +94,6 @@ The `foreach` statement of the C# language (`For Each` in Visual Basic) returns objects that are of the type of each element in the collection. Since each element of the collection is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . The following code shows the syntax. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/source2.cpp" id="Snippet06"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/source2.cs" id="Snippet06"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/source2.vb" id="Snippet06"::: @@ -105,7 +104,6 @@ ## Examples The following code example demonstrates the creation, population and modification of an collection, as well as two techniques to display the contents of the : one using the and properties and the other creating an enumerator through the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet00"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" interactive="try-dotnet" id="Snippet00"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet00"::: @@ -175,7 +173,6 @@ ## Examples The following code example demonstrates the creation and population of an collection. This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet01"::: @@ -495,7 +492,6 @@ ## Examples The following code example demonstrates the creation and population of an collection. This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet01"::: @@ -608,7 +604,6 @@ ## Examples The following code example demonstrates the modification of an collection. In this example, the method is used to empty the , and then the is repopulated. This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet03"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet03"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet03"::: @@ -677,7 +672,6 @@ ## Examples The following code example demonstrates the modification of an collection. In this example, the method is used to determine if an entry exists before attempting to remove it. This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet02"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet02"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet02"::: @@ -790,7 +784,6 @@ ## Examples The following code example demonstrates the modification of an collection. In this example, the property is used to remove the last item in the . This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet02"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet02"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet02"::: @@ -864,11 +857,9 @@ ## Examples The following code example demonstrates the use of the method to display the contents of the collection to the console. In this example, the method is used to obtain an object that is passed to a method that displays the contents. This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet03"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet03"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet03"::: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet05"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet05"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet05"::: @@ -1006,7 +997,6 @@ ## Examples The following code example demonstrates the modification of an collection. In this example, the method is used to add a new entry to the beginning of the , moving the rest of the entries down. This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet02"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet02"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet02"::: @@ -1079,7 +1069,6 @@ ## Examples The following code example demonstrates the modification of an collection. In this example, the property is used to determine whether the can be modified. This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet02"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet02"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet02"::: @@ -1237,7 +1226,6 @@ ## Examples The following code example demonstrates the modification of an collection. In this example, the property is used to modify the dictionary entry with the key `"testKey2"`. This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet02"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet02"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet02"::: @@ -1299,11 +1287,9 @@ ## Examples The following code example demonstrates the creation and population of an collection, and then prints the contents to the console. In this example, the and properties are passed to a method that displays the contents. This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet01"::: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet04"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet04"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet04"::: @@ -1421,7 +1407,6 @@ ## Examples The following code example demonstrates the modification of an collection. In this example, the method is used to remove the entry with the key `"keyToDelete"` from the . This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet02"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet02"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet02"::: @@ -1488,7 +1473,6 @@ ## Examples The following code example demonstrates the modification of an collection. In this example, the method is used with the property to remove the last entry from the . This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet02"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet02"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet02"::: @@ -1822,11 +1806,9 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following code example demonstrates the creation and population of an collection, and then prints the contents to the console. In this example, the and properties are passed to a method that displays the contents. This code is part of a larger code example that can be viewed at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet01"::: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/cpp/ordereddictionary1.cpp" id="Snippet04"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/OrderedDictionary/Overview/OrderedDictionary1.cs" id="Snippet04"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.OrderedDictionary1/VB/OrderedDictionary1.vb" id="Snippet04"::: diff --git a/xml/System.Collections.Specialized/StringCollection.xml b/xml/System.Collections.Specialized/StringCollection.xml index 09741cef6f0..5eedbc11f3b 100644 --- a/xml/System.Collections.Specialized/StringCollection.xml +++ b/xml/System.Collections.Specialized/StringCollection.xml @@ -68,30 +68,29 @@ Represents a collection of strings. - accepts `null` as a valid value and allows duplicate elements. - - String comparisons are case-sensitive. - - Elements in this collection can be accessed using an integer index. Indexes in this collection are zero-based. - - - -## Examples - The following code example demonstrates several of the properties and methods of . + accepts `null` as a valid value and allows duplicate elements. + + String comparisons are case-sensitive. + + Elements in this collection can be accessed using an integer index. Indexes in this collection are zero-based. + + + +## Examples + The following code example demonstrates several of the properties and methods of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/stringcollection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Overview/stringcollection.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/VB/stringcollection.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/VB/stringcollection.vb" id="Snippet1"::: + ]]> - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - - This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + + This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. + Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. Performing Culture-Insensitive String Operations @@ -133,11 +132,11 @@ Initializes a new instance of the class. - @@ -188,22 +187,21 @@ Adds a string to the end of the . The zero-based index at which the new element is inserted. - accepts `null` as a valid value and allows duplicate elements. - - If is less than the capacity, this method is an O(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an O(`n`) operation, where `n` is . - - - -## Examples - The following code example adds new elements to the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/CPP/stringcollectionadd.cpp" id="Snippet1"::: + accepts `null` as a valid value and allows duplicate elements. + + If is less than the capacity, this method is an O(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an O(`n`) operation, where `n` is . + + + +## Examples + The following code example adds new elements to the . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Add/stringcollectionadd.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/VB/stringcollectionadd.vb" id="Snippet1"::: - + ]]> @@ -262,22 +260,21 @@ An array of strings to add to the end of the . The array itself can not be but it can contain elements that are . Copies the elements of a string array to the end of the . - accepts `null` as a valid value and allows duplicate elements. - - If the can accommodate the new elements without increasing the capacity, this method is an O(`n`) operation, where `n` is the number of elements to be added. If the capacity needs to be increased to accommodate the new elements, this method becomes an O(`n` + `m`) operation, where `n` is the number of elements to be added and `m` is . - - - -## Examples - The following code example adds new elements to the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/CPP/stringcollectionadd.cpp" id="Snippet1"::: + accepts `null` as a valid value and allows duplicate elements. + + If the can accommodate the new elements without increasing the capacity, this method is an O(`n`) operation, where `n` is the number of elements to be added. If the capacity needs to be increased to accommodate the new elements, this method becomes an O(`n` + `m`) operation, where `n` is the number of elements to be added and `m` is . + + + +## Examples + The following code example adds new elements to the . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Add/stringcollectionadd.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/VB/stringcollectionadd.vb" id="Snippet1"::: - + ]]> @@ -330,19 +327,18 @@ Removes all the strings from the . - is set to zero, and references to other objects from elements of the collection are also released. - - This method is an O(`n`) operation, where `n` is . - - - -## Examples - The following code example removes elements from the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/CPP/stringcollectionremove.cpp" id="Snippet1"::: + is set to zero, and references to other objects from elements of the collection are also released. + + This method is an O(`n`) operation, where `n` is . + + + +## Examples + The following code example removes elements from the . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Clear/stringcollectionremove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/VB/stringcollectionremove.vb" id="Snippet1"::: @@ -398,26 +394,25 @@ if is found in the ; otherwise, . - method can confirm the existence of a string before performing further operations. - - This method determines equality by calling . String comparisons are case-sensitive. - - This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example searches the for an element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionContains/CPP/stringcollectioncontains.cpp" id="Snippet1"::: + method can confirm the existence of a string before performing further operations. + + This method determines equality by calling . String comparisons are case-sensitive. + + This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example searches the for an element. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Contains/stringcollectioncontains.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionContains/VB/stringcollectioncontains.vb" id="Snippet1"::: - + ]]> @@ -478,24 +473,23 @@ The zero-based index in at which copying begins. Copies the entire values to a one-dimensional array of strings, starting at the specified index of the target array. - in the same order in which the enumerator of the iterates through the . - - This method is an O(`n`) operation, where `n` is . - - - -## Examples - The following code example copies a to an array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionCopyTo/CPP/stringcollectioncopyto.cpp" id="Snippet1"::: + in the same order in which the enumerator of the iterates through the . + + This method is an O(`n`) operation, where `n` is . + + + +## Examples + The following code example copies a to an array. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/CopyTo/stringcollectioncopyto.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionCopyTo/VB/stringcollectioncopyto.vb" id="Snippet1"::: - + ]]> @@ -503,10 +497,10 @@ is less than zero. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source is greater than the available space from to the end of the destination . The type of the source cannot be cast automatically to the type of the destination . @@ -557,20 +551,19 @@ Gets the number of strings contained in the . The number of strings contained in the . - to an array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionCopyTo/CPP/stringcollectioncopyto.cpp" id="Snippet1"::: + to an array. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/CopyTo/stringcollectioncopyto.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionCopyTo/VB/stringcollectioncopyto.vb" id="Snippet1"::: - + ]]> @@ -617,26 +610,26 @@ Returns a that iterates through the . A for the . - also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. + + This method is an O(1) operation. - The `foreach` statement of the C# language (`for each` in Visual Basic) hides the complexity of the enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. - - Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection. - - Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - - This method is an O(1) operation. - ]]> @@ -689,24 +682,23 @@ Searches for the specified string and returns the zero-based index of the first occurrence within the . The zero-based index of the first occurrence of in the , if found; otherwise, -1. - . String comparisons are case-sensitive. - - This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example searches the for an element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionContains/CPP/stringcollectioncontains.cpp" id="Snippet1"::: + . String comparisons are case-sensitive. + + This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example searches the for an element. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Contains/stringcollectioncontains.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionContains/VB/stringcollectioncontains.vb" id="Snippet1"::: - + ]]> @@ -760,33 +752,32 @@ The string to insert. The value can be . Inserts a string into the at the specified index. - . - - If `index` is equal to , `value` is added to the end of . - - In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. - - This method is an O(`n`) operation, where `n` is . - - - -## Examples - The following code example adds new elements to the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/CPP/stringcollectionadd.cpp" id="Snippet1"::: + . + + If `index` is equal to , `value` is added to the end of . + + In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. + + This method is an O(`n`) operation, where `n` is . + + + +## Examples + The following code example adds new elements to the . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Add/stringcollectionadd.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionAdd/VB/stringcollectionadd.vb" id="Snippet1"::: ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + greater than . @@ -836,19 +827,19 @@ Gets a value indicating whether the is read-only. This property always returns . - implements the property because it is required by the interface. - - A collection that is read-only does not allow the addition, removal, or modification of elements after the collection is created. - - A collection that is read-only is simply a collection with a wrapper that prevents modifying the collection; therefore, if changes are made to the underlying collection, the read-only collection reflects those changes. - - A instance is always writable. - - Retrieving the value of this property is an O(1) operation. - + implements the property because it is required by the interface. + + A collection that is read-only does not allow the addition, removal, or modification of elements after the collection is created. + + A collection that is read-only is simply a collection with a wrapper that prevents modifying the collection; therefore, if changes are made to the underlying collection, the read-only collection reflects those changes. + + A instance is always writable. + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -897,21 +888,20 @@ Gets a value indicating whether access to the is synchronized (thread safe). This property always returns . - implements the property because it is required by the interface. - - Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - The following code example shows how to lock the collection using the during the entire enumeration: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/remarks.cpp" id="Snippet2"::: + implements the property because it is required by the interface. + + Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + The following code example shows how to lock the collection using the during the entire enumeration: + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Overview/remarks.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/VB/remarks.vb" id="Snippet2"::: - - Retrieving the value of this property is an O(1) operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/VB/remarks.vb" id="Snippet2"::: + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -963,24 +953,24 @@ Gets or sets the element at the specified index. The element at the specified index. - accepts `null` as a valid value and allows duplicate elements. - - The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a [default property](/dotnet/visual-basic/language-reference/modifiers/default), which provides the same indexing functionality. - - Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. - + accepts `null` as a valid value and allows duplicate elements. + + The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a [default property](/dotnet/visual-basic/language-reference/modifiers/default), which provides the same indexing functionality. + + Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. + ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + is equal to or greater than . @@ -1030,28 +1020,27 @@ The string to remove from the . The value can be . Removes the first occurrence of a specific string from the . - . Only the first occurrence is removed. To remove all occurrences of the specified string, use `RemoveAt(IndexOf(value))` repeatedly while does not return -1. - - If the does not contain the specified object, the remains unchanged. No exception is thrown. - - In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. - - This method determines equality by calling . String comparisons are case-sensitive. - - This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . - - - -## Examples - The following code example removes elements from the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/CPP/stringcollectionremove.cpp" id="Snippet1"::: + . Only the first occurrence is removed. To remove all occurrences of the specified string, use `RemoveAt(IndexOf(value))` repeatedly while does not return -1. + + If the does not contain the specified object, the remains unchanged. No exception is thrown. + + In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. + + This method determines equality by calling . String comparisons are case-sensitive. + + This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . + + + +## Examples + The following code example removes elements from the . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Clear/stringcollectionremove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/VB/stringcollectionremove.vb" id="Snippet1"::: - + ]]> Performing Culture-Insensitive String Operations @@ -1104,29 +1093,28 @@ The zero-based index of the string to remove. Removes the string at the specified index of the . - . - - - -## Examples - The following code example removes elements from the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/CPP/stringcollectionremove.cpp" id="Snippet1"::: + . + + + +## Examples + The following code example removes elements from the . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Clear/stringcollectionremove.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/VB/stringcollectionremove.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollectionRemove/VB/stringcollectionremove.vb" id="Snippet1"::: + ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + is equal to or greater than . @@ -1180,21 +1168,20 @@ Gets an object that can be used to synchronize access to the . An object that can be used to synchronize access to the . - using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - The following code example shows how to lock the collection using the during the entire enumeration: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/CPP/remarks.cpp" id="Snippet2"::: + using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + The following code example shows how to lock the collection using the during the entire enumeration: + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringCollection/Overview/remarks.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/VB/remarks.vb" id="Snippet2"::: - - Retrieving the value of this property is an O(1) operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringCollection2/VB/remarks.vb" id="Snippet2"::: + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -1250,15 +1237,15 @@ The zero-based index in at which copying begins. Copies the entire to a compatible one-dimensional , starting at the specified index of the target array. - to copy the elements. - - This method is an O(`n`) operation, where `n` is . - + to copy the elements. + + This method is an O(`n`) operation, where `n` is . + ]]> @@ -1266,10 +1253,10 @@ is less than zero. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source is greater than the available space from to the end of the destination . The type of the source cannot be cast automatically to the type of the destination . @@ -1320,26 +1307,26 @@ Returns a that iterates through the . A for the . - also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + This method is an O(1) operation. - The `foreach` statement of the C# language (`for each` in Visual Basic) hides the complexity of the enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. - - Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection. - - Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - This method is an O(1) operation. - ]]> @@ -1395,21 +1382,21 @@ Adds an object to the end of the . The index at which the has been added. - accepts `null` as a valid value and allows duplicate elements. - - If already equals the capacity, the capacity of the is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added. - - If is less than the capacity, this method is an O(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an O(`n`) operation, where `n` is . - + accepts `null` as a valid value and allows duplicate elements. + + If already equals the capacity, the capacity of the is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added. + + If is less than the capacity, this method is an O(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an O(`n`) operation, where `n` is . + ]]> - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. @@ -1466,15 +1453,15 @@ if is found in the ; otherwise, . - . - - This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - + . + + This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + ]]> @@ -1530,17 +1517,17 @@ Searches for the specified and returns the zero-based index of the first occurrence within the entire . The zero-based index of the first occurrence of within the entire , if found; otherwise, -1. - is searched forward starting at the first element and ending at the last element. - - This method determines equality by calling . - - This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - + is searched forward starting at the first element and ending at the last element. + + This method determines equality by calling . + + This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + ]]> @@ -1597,29 +1584,29 @@ The to insert. The value can be . Inserts an element into the at the specified index. - already equals the capacity, the capacity of the is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added. - - If `index` is equal to , `value` is added to the end of . - - In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. - - This method is an O(`n`) operation, where `n` is . - + already equals the capacity, the capacity of the is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added. + + If `index` is equal to , `value` is added to the end of . + + In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. + + This method is an O(`n`) operation, where `n` is . + ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + is greater than . - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. @@ -1670,15 +1657,15 @@ if the object has a fixed size; otherwise, . The default is . - @@ -1727,15 +1714,15 @@ if the object is read-only; otherwise, . The default is . - @@ -1794,24 +1781,24 @@ Gets or sets the element at the specified index. The element at the specified index. - property. Visual Basic implements as a default property, which provides the same indexing functionality. - - accepts `null` as a valid value and allows duplicate elements. - - Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. - + property. Visual Basic implements as a default property, which provides the same indexing functionality. + + accepts `null` as a valid value and allows duplicate elements. + + Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. + ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + is equal to or greater than . @@ -1864,23 +1851,23 @@ The to remove from the . The value can be . Removes the first occurrence of a specific object from the . - does not contain the specified object, the remains unchanged. No exception is thrown. - - In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. - - This method determines equality by calling . - - This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . - + does not contain the specified object, the remains unchanged. No exception is thrown. + + In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. + + This method determines equality by calling . + + This method performs a linear search; therefore, this method is an O(`n`) operation, where `n` is . + ]]> - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. diff --git a/xml/System.Collections.Specialized/StringDictionary.xml b/xml/System.Collections.Specialized/StringDictionary.xml index 62be1aa3655..566e8ca0531 100644 --- a/xml/System.Collections.Specialized/StringDictionary.xml +++ b/xml/System.Collections.Specialized/StringDictionary.xml @@ -73,30 +73,29 @@ Implements a hash table with the key and the value strongly typed to be strings rather than objects. - when comparing strings. For more information about how culture affects comparisons and sorting, see [Performing Culture-Insensitive String Operations](/dotnet/standard/globalization-localization/performing-culture-insensitive-string-operations). - - - -## Examples - The following code example demonstrates several of the properties and methods of . + when comparing strings. For more information about how culture affects comparisons and sorting, see [Performing Culture-Insensitive String Operations](/dotnet/standard/globalization-localization/performing-culture-insensitive-string-operations). + + + +## Examples + The following code example demonstrates several of the properties and methods of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/stringdictionary.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Overview/stringdictionary.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/VB/stringdictionary.vb" id="Snippet1"::: ]]> - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - - This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + + This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. Performing Culture-Insensitive String Operations @@ -139,20 +138,19 @@ Initializes a new instance of the class. - . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/stringdictionary.cpp" id="Snippet1"::: + . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Overview/stringdictionary.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/VB/stringdictionary.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/VB/stringdictionary.vb" id="Snippet1"::: + ]]> @@ -211,22 +209,21 @@ The value of the entry to add. The value can be . Adds an entry with the specified key and value into the . - . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/CPP/stringdictionary_addremove.cpp" id="Snippet1"::: + . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Add/stringdictionary_addremove.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/VB/stringdictionary_addremove.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/VB/stringdictionary_addremove.vb" id="Snippet1"::: + ]]> @@ -277,20 +274,19 @@ Removes all entries from the . - . - - - -## Examples - The following code example demonstrates how to add and remove elements from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/CPP/stringdictionary_addremove.cpp" id="Snippet1"::: + . + + + +## Examples + The following code example demonstrates how to add and remove elements from a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Add/stringdictionary_addremove.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/VB/stringdictionary_addremove.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/VB/stringdictionary_addremove.vb" id="Snippet1"::: + ]]> The is read-only. @@ -342,24 +338,23 @@ if the contains an entry with the specified key; otherwise, . - and methods on `item` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example searches for an element in a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/CPP/stringdictionary_contains.cpp" id="Snippet1"::: + and methods on `item` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example searches for an element in a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/ContainsKey/stringdictionary_contains.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/VB/stringdictionary_contains.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/VB/stringdictionary_contains.vb" id="Snippet1"::: + ]]> The key is . @@ -413,24 +408,23 @@ if the contains an element with the specified value; otherwise, . - method. - - This method performs a linear search; therefore, the average execution time is proportional to . That is, this method is an O(`n`) operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example searches for an element in a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/CPP/stringdictionary_contains.cpp" id="Snippet1"::: + method. + + This method performs a linear search; therefore, the average execution time is proportional to . That is, this method is an O(`n`) operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example searches for an element in a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/ContainsKey/stringdictionary_contains.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/VB/stringdictionary_contains.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Contains/VB/stringdictionary_contains.vb" id="Snippet1"::: + ]]> Performing Culture-Insensitive String Operations @@ -482,31 +476,30 @@ The index in the array where copying begins. Copies the string dictionary values to a one-dimensional instance at the specified index. - copies objects that can be typecast to . contains both the key and the value. - - The elements copied to the are sorted in the same order that the enumerator iterates through the . - - This method is an O(`n`) operation, where `n` is . - - - -## Examples - The following code example shows how a StringDictionary can be copied to an array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringDictionary.CopyTo/CPP/stringdictionary_copyto.cpp" id="Snippet1"::: + copies objects that can be typecast to . contains both the key and the value. + + The elements copied to the are sorted in the same order that the enumerator iterates through the . + + This method is an O(`n`) operation, where `n` is . + + + +## Examples + The following code example shows how a StringDictionary can be copied to an array. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/CopyTo/stringdictionary_copyto.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringDictionary.CopyTo/VB/stringdictionary_copyto.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringDictionary.CopyTo/VB/stringdictionary_copyto.vb" id="Snippet1"::: + ]]> - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the is greater than the available space from to the end of . is . @@ -553,19 +546,18 @@ Gets the number of key/value pairs in the . - The number of key/value pairs in the . - + The number of key/value pairs in the . + Retrieving the value of this property is an O(1) operation. - . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/stringdictionary_enumeration.cpp" id="Snippet1"::: + . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Count/stringdictionary_enumeration.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/VB/stringdictionary_enumeration.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/VB/stringdictionary_enumeration.vb" id="Snippet1"::: + ]]> @@ -615,34 +607,33 @@ Returns an enumerator that iterates through the string dictionary. An that iterates through the string dictionary. - also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - - This method is an O(1) operation. - - - -## Examples - The following code example enumerates the elements of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/stringdictionary_enumeration.cpp" id="Snippet1"::: + also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. + + This method is an O(1) operation. + + + +## Examples + The following code example enumerates the elements of a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Count/stringdictionary_enumeration.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/VB/stringdictionary_enumeration.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/VB/stringdictionary_enumeration.vb" id="Snippet1"::: + ]]> @@ -689,24 +680,23 @@ if access to the is synchronized (thread safe); otherwise, . - instance is not synchronized. Derived classes can provide a synchronized version of the using the property. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/source2.cpp" id="Snippet2"::: + instance is not synchronized. Derived classes can provide a synchronized version of the using the property. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Overview/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/VB/source2.vb" id="Snippet2"::: - - Retrieving the value of this property is an O(1) operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/VB/source2.vb" id="Snippet2"::: + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -763,26 +753,25 @@ Gets or sets the value associated with the specified key. The value associated with the specified key. If the specified key is not found, Get returns , and Set creates a new entry with the specified key. - method to determine if the key exists in the list. - - The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a default property, which provides the same indexing functionality. - - Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. - - - -## Examples - The following code example enumerates the elements of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/stringdictionary_enumeration.cpp" id="Snippet1"::: + method to determine if the key exists in the list. + + The C# language uses the [this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a default property, which provides the same indexing functionality. + + Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation. + + + +## Examples + The following code example enumerates the elements of a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Count/stringdictionary_enumeration.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/VB/stringdictionary_enumeration.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/VB/stringdictionary_enumeration.vb" id="Snippet1"::: + ]]> @@ -831,24 +820,23 @@ Gets a collection of keys in the . An that provides the keys in the . - is unspecified, but it is the same order as the associated values in the returned by the method. - - The returned is not a static copy; instead, the refers back to the keys in the original . Therefore, changes to the continue to be reflected in the . - - Retrieving the value of this property is an O(1) operation. - - - -## Examples - The following code example enumerates the elements of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/stringdictionary_enumeration.cpp" id="Snippet1"::: + is unspecified, but it is the same order as the associated values in the returned by the method. + + The returned is not a static copy; instead, the refers back to the keys in the original . Therefore, changes to the continue to be reflected in the . + + Retrieving the value of this property is an O(1) operation. + + + +## Examples + The following code example enumerates the elements of a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Count/stringdictionary_enumeration.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/VB/stringdictionary_enumeration.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/VB/stringdictionary_enumeration.vb" id="Snippet1"::: + ]]> @@ -897,24 +885,23 @@ The key of the entry to remove. Removes the entry with the specified key from the string dictionary. - does not contain an element with the specified key, the remains unchanged. No exception is thrown. - - The key is handled in a case-insensitive manner; it is translated to lowercase before it is used to find the entry to remove from the string dictionary. - - This method is an O(1) operation. - - - -## Examples - The following code example demonstrates how to add and remove elements from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/CPP/stringdictionary_addremove.cpp" id="Snippet1"::: + does not contain an element with the specified key, the remains unchanged. No exception is thrown. + + The key is handled in a case-insensitive manner; it is translated to lowercase before it is used to find the entry to remove from the string dictionary. + + This method is an O(1) operation. + + + +## Examples + The following code example demonstrates how to add and remove elements from a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Add/stringdictionary_addremove.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/VB/stringdictionary_addremove.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_AddRemove/VB/stringdictionary_addremove.vb" id="Snippet1"::: + ]]> The key is . @@ -964,24 +951,23 @@ Gets an object that can be used to synchronize access to the . An that can be used to synchronize access to the . - using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/CPP/source2.cpp" id="Snippet2"::: + using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Overview/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/VB/source2.vb" id="Snippet2"::: - - Retrieving the value of this property is an O(1) operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary/VB/source2.vb" id="Snippet2"::: + + Retrieving the value of this property is an O(1) operation. + ]]> @@ -1027,24 +1013,23 @@ Gets a collection of values in the . An that provides the values in the . - is unspecified, but it is the same order as the associated keys in the returned by the method. - - The returned is not a static copy; instead, the refers back to the values in the original . Therefore, changes to the continue to be reflected in the . - - Retrieving the value of this property is an O(1) operation. - - - -## Examples - The following code example enumerates the elements of a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/CPP/values.cpp" id="Snippet2"::: + is unspecified, but it is the same order as the associated keys in the returned by the method. + + The returned is not a static copy; instead, the refers back to the values in the original . Therefore, changes to the continue to be reflected in the . + + Retrieving the value of this property is an O(1) operation. + + + +## Examples + The following code example enumerates the elements of a . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringDictionary/Count/values.cs" interactive="try-dotnet" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/VB/values.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collection.Specialized.StringDictionary_Enumeration/VB/values.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Collections.Specialized/StringEnumerator.xml b/xml/System.Collections.Specialized/StringEnumerator.xml index 2f466df8233..49d1f0bb885 100644 --- a/xml/System.Collections.Specialized/StringEnumerator.xml +++ b/xml/System.Collections.Specialized/StringEnumerator.xml @@ -52,36 +52,35 @@ Supports a simple iteration over a . - also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example demonstrates several of the properties and methods of . -## Remarks - The `foreach` statement of the C# language (`for each` in Visual Basic) hides the complexity of the enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. - - Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection. - - Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example demonstrates several of the properties and methods of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/CPP/stringenumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringEnumerator/Overview/stringenumerator.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/VB/stringenumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/VB/stringenumerator.vb" id="Snippet1"::: + ]]> - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. @@ -130,26 +129,25 @@ Gets the current element in the collection. The current element in the collection. - is called, must be called to advance the enumerator to the first element of the collection before reading the value of ; otherwise, is undefined. - - also throws an exception if the last call to returned `false`, which indicates the end of the collection. - - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. - - - -## Examples - The following code example demonstrates several of the properties and methods of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/CPP/stringenumerator.cpp" id="Snippet1"::: + is called, must be called to advance the enumerator to the first element of the collection before reading the value of ; otherwise, is undefined. + + also throws an exception if the last call to returned `false`, which indicates the end of the collection. + + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. + + + +## Examples + The following code example demonstrates several of the properties and methods of . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringEnumerator/Overview/stringenumerator.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/VB/stringenumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/VB/stringenumerator.vb" id="Snippet1"::: + ]]> The enumerator is positioned before the first element of the collection or after the last element. @@ -201,24 +199,23 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - is called, an enumerator is positioned before the first element of the collection, and the first call to moves the enumerator over the first element of the collection. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false` until is called. - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. - - - -## Examples - The following code example demonstrates several of the properties and methods of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/CPP/stringenumerator.cpp" id="Snippet1"::: + is called, an enumerator is positioned before the first element of the collection, and the first call to moves the enumerator over the first element of the collection. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false` until is called. + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. + + + +## Examples + The following code example demonstrates several of the properties and methods of . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringEnumerator/Overview/stringenumerator.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/VB/stringenumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/VB/stringenumerator.vb" id="Snippet1"::: + ]]> The collection was modified after the enumerator was created. @@ -268,20 +265,19 @@ Sets the enumerator to its initial position, which is before the first element in the collection. - moves the enumerator to the beginning of the collection, before the first element. After , must be called to advance the enumerator to the first element of the collection before reading the value of . - - - -## Examples - The following code example demonstrates several of the properties and methods of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/CPP/stringenumerator.cpp" id="Snippet1"::: + moves the enumerator to the beginning of the collection, before the first element. After , must be called to advance the enumerator to the first element of the collection before reading the value of . + + + +## Examples + The following code example demonstrates several of the properties and methods of . + :::code language="csharp" source="~/snippets/csharp/System.Collections.Specialized/StringEnumerator/Overview/stringenumerator.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/VB/stringenumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Specialized.StringEnumerator2/VB/stringenumerator.vb" id="Snippet1"::: + ]]> The collection was modified after the enumerator was created. diff --git a/xml/System.Collections/ArrayList.xml b/xml/System.Collections/ArrayList.xml index 9a732e300af..7700a460ee7 100644 --- a/xml/System.Collections/ArrayList.xml +++ b/xml/System.Collections/ArrayList.xml @@ -133,12 +133,9 @@ Using multidimensional arrays as elements in an collection is not supported. - - ## Examples The following example shows how to create and initialize an and how to display its values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList Example/VB/source.vb" id="Snippet1"::: @@ -493,7 +490,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to add elements to the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Add/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/VB/source.vb" id="Snippet1"::: @@ -582,7 +578,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to add elements to the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Add/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/VB/source.vb" id="Snippet1"::: @@ -682,7 +677,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to use to locate a specific object in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/BinarySearch/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/VB/source.vb" id="Snippet1"::: @@ -772,7 +766,6 @@ This method is an `O(1)` operation. ## Examples The following example creates an of colored animals. The provided performs the string comparison for the binary search. The results of both an iterative search and a binary search are displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/CPP/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/BinarySearch/source2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.BinarySearch1 Example/VB/source2.vb" id="Snippet2"::: @@ -1015,7 +1008,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to trim the unused portions of the and how to clear the values of the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Clear/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/VB/source.vb" id="Snippet1"::: @@ -1242,7 +1234,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to copy an into a one-dimensional . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/CopyTo/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo Example/VB/source.vb" id="Snippet1"::: @@ -1330,7 +1321,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to copy an into a one-dimensional . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/CopyTo/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/VB/source.vb" id="Snippet1"::: @@ -1421,7 +1411,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to copy an into a one-dimensional . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/CopyTo/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.CopyTo1 Example/VB/source.vb" id="Snippet1"::: @@ -1590,7 +1579,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to create a fixed-size wrapper around an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IsFixedSize/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/VB/source.vb" id="Snippet1"::: @@ -1926,7 +1914,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to set and get a range of elements in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/SetRange/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/VB/source.vb" id="Snippet1"::: @@ -2032,7 +2019,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to determine the index of the first occurrence of a specified element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IndexOf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/VB/source.vb" id="Snippet1"::: @@ -2113,7 +2099,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to determine the index of the first occurrence of a specified element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IndexOf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/VB/source.vb" id="Snippet1"::: @@ -2198,7 +2183,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to determine the index of the first occurrence of a specified element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IndexOf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IndexOf Example/VB/source.vb" id="Snippet1"::: @@ -2293,7 +2277,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to insert elements into the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Insert/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/VB/source.vb" id="Snippet1"::: @@ -2387,7 +2370,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to insert elements into the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Insert/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Insert Example/VB/source.vb" id="Snippet1"::: @@ -2478,7 +2460,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to create a fixed-size wrapper around an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IsFixedSize/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IsFixedSize Example/VB/source.vb" id="Snippet1"::: @@ -2551,7 +2532,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to create a read-only wrapper around an and how to determine if an is read-only. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/ReadOnly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/VB/source.vb" id="Snippet1"::: @@ -2623,7 +2603,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to lock the collection using the during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IsSynchronized/source2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: @@ -2631,7 +2610,6 @@ This method is an `O(1)` operation. The following code example shows how to synchronize an , determine if an is synchronized and use a synchronized . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IsSynchronized/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/VB/source.vb" id="Snippet1"::: @@ -2720,13 +2698,11 @@ This method is an `O(1)` operation. ## Examples The following code example creates an and adds several items. The example demonstrates accessing elements with the property (the indexer in C#), and changing an element by assigning a new value to the property for a specified index. The example also shows that the property cannot be used to access or add elements outside the current size of the list. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Item/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/VB/source.vb" id="Snippet1"::: The following example uses the property explicitly to assign values to items in the list. The example defines a class that inherits an and adds a method to scramble the list items. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/cpp/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Item/source2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ArrayList.Item/VB/source2.vb" id="Snippet2"::: @@ -2816,7 +2792,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to determine the index of the last occurrence of a specified element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/LastIndexOf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/VB/source.vb" id="Snippet1"::: @@ -2897,7 +2872,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to determine the index of the last occurrence of a specified element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/LastIndexOf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/VB/source.vb" id="Snippet1"::: @@ -2982,7 +2956,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to determine the index of the last occurrence of a specified element. Note that `LastIndexOf` is a backward search; therefore, `count` must be less than or equal to `startIndex` + 1. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/LastIndexOf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.LastIndexOf Example/VB/source.vb" id="Snippet1"::: @@ -3077,7 +3050,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to create a read-only wrapper around an and how to determine if an is read-only. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/ReadOnly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.ReadOnly1 Example/VB/source.vb" id="Snippet1"::: @@ -3231,7 +3203,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to remove elements from the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Remove/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/VB/source.vb" id="Snippet1"::: @@ -3316,7 +3287,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to remove elements from the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Remove/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/VB/source.vb" id="Snippet1"::: @@ -3403,7 +3373,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to remove elements from the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Remove/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Remove Example/VB/source.vb" id="Snippet1"::: @@ -3503,7 +3472,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to create and initialize a new with the same value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Repeat Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Repeat/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Repeat Example/VB/source.vb" id="Snippet1"::: @@ -3581,7 +3549,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to reverse the sort order of the values in an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Reverse/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Reverse Example/VB/source.vb" id="Snippet1"::: @@ -3654,7 +3621,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to reverse the sort order of the values in a range of elements in an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Reverse1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Reverse/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Reverse1 Example/VB/source.vb" id="Snippet1"::: @@ -3737,7 +3703,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to set and get a range of elements in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/SetRange/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.SetRange Example/VB/source.vb" id="Snippet1"::: @@ -3826,7 +3791,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to sort the values in an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Sort Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Sort/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Sort Example/VB/source.vb" id="Snippet1"::: @@ -3905,7 +3869,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to sort the values in an using the default comparer and a custom comparer that reverses the sort order. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_2/CPP/arraylist_sort2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Sort/arraylist_sort2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_2/VB/arraylist_sort2.vb" id="Snippet1"::: @@ -3989,7 +3952,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to sort the values in a range of elements in an using the default comparer and a custom comparer that reverses the sort order. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_3/CPP/arraylist_sort3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Sort/arraylist_sort3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ArrayList.Sort_3/VB/arraylist_sort3.vb" id="Snippet1"::: @@ -4080,7 +4042,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to lock the collection using the during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IsSynchronized/source2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: @@ -4088,7 +4049,6 @@ This method is an `O(1)` operation. The following code example shows how to synchronize an , determine if an is synchronized and use a synchronized . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IsSynchronized/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/VB/source.vb" id="Snippet1"::: @@ -4163,7 +4123,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to lock the collection using the during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IsSynchronized/source2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: @@ -4239,7 +4198,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to lock the collection using the during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/IsSynchronized/source2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: @@ -4391,7 +4349,6 @@ This method is an `O(1)` operation. ## Examples The following copy example shows how to copy the elements of an to a string array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/CPP/arraylist_toarray.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/ToArray/arraylist_toarray.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ArrayList.ToArray/VB/arraylist_toarray.vb" id="Snippet1"::: @@ -4464,7 +4421,6 @@ This method is an `O(1)` operation. ## Examples The following code example shows how to trim the unused portions of the and how to clear the values of the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ArrayList/Clear/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ArrayList.Clear Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Collections/BitArray.xml b/xml/System.Collections/BitArray.xml index 909524711c5..8290a60923c 100644 --- a/xml/System.Collections/BitArray.xml +++ b/xml/System.Collections/BitArray.xml @@ -95,7 +95,6 @@ ## Examples The following code example shows how to create and initialize a and how to print out its values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray Example/VB/source.vb" id="Snippet1"::: @@ -497,7 +496,6 @@ ## Examples The following code example shows how to perform the bitwise AND operation between two objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.And Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/And/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray.And Example/VB/source.vb" id="Snippet1"::: @@ -626,7 +624,6 @@ ## Examples The following code example shows how to copy a into a one-dimensional . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.CopyTo Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/CopyTo/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray.CopyTo Example/VB/source.vb" id="Snippet1"::: @@ -754,7 +751,6 @@ ## Examples The following code example shows how to set and get specific elements in a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Get Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/Get/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray.Get Example/VB/source.vb" id="Snippet1"::: @@ -1007,7 +1003,6 @@ ## Examples The following code example shows how to lock the collection using the during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/Overview/source2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray Example/VB/source2.vb" id="Snippet2"::: @@ -1242,7 +1237,6 @@ The current is updated and returned. ## Examples The following code example shows how to apply NOT to a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Not Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/Not/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray.Not Example/VB/source.vb" id="Snippet1"::: @@ -1307,7 +1301,6 @@ The current is updated and returned. ## Examples The following code example shows how to perform the OR operation between two objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Or Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/Or/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray.Or Example/VB/source.vb" id="Snippet1"::: @@ -1425,7 +1418,6 @@ The current is updated and returned. ## Examples The following code example shows how to set and get specific elements in a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Get Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/Get/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray.Get Example/VB/source.vb" id="Snippet1"::: @@ -1493,7 +1485,6 @@ The current is updated and returned. ## Examples The following code example shows how to set and get specific elements in a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Get Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/Get/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray.Get Example/VB/source.vb" id="Snippet1"::: @@ -1555,7 +1546,6 @@ The current is updated and returned. ## Examples The following code example shows how to lock the collection using the during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray Example/CPP/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/Overview/source2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray Example/VB/source2.vb" id="Snippet2"::: @@ -1774,7 +1764,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following code example shows how to perform the XOR operation between two objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BitArray.Xor Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/BitArray/Xor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BitArray.Xor Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Collections/CaseInsensitiveComparer.xml b/xml/System.Collections/CaseInsensitiveComparer.xml index fe4cd50064b..41699c1c217 100644 --- a/xml/System.Collections/CaseInsensitiveComparer.xml +++ b/xml/System.Collections/CaseInsensitiveComparer.xml @@ -65,30 +65,29 @@ Compares two objects for equivalence, ignoring the case of strings. - implements the interface supporting case-insensitive comparisons on strings, just as implements the interface supporting case-insensitive comparisons on strings. + implements the interface supporting case-insensitive comparisons on strings, just as implements the interface supporting case-insensitive comparisons on strings. > [!IMPORTANT] > We don't recommend that you use the `CaseInsensitiveComparer` class for new development. Instead, we recommend that you use the object returned by the , , or property. -The class is the default implementation of the interface and performs case-sensitive string comparisons. - - The objects used as keys by a are required to override the method (or the interface) and the method (or the interface). The implementation of both methods or interfaces must handle case sensitivity the same way; otherwise, the might behave incorrectly. For example, when creating a , you must use this class with the class or any case-insensitive implementation. - - String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. +The class is the default implementation of the interface and performs case-sensitive string comparisons. + + The objects used as keys by a are required to override the method (or the interface) and the method (or the interface). The implementation of both methods or interfaces must handle case sensitivity the same way; otherwise, the might behave incorrectly. For example, when creating a , you must use this class with the class or any case-insensitive implementation. + + String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). + + + +## Examples + The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: + ]]> @@ -148,20 +147,19 @@ The class is the default implementation of th Initializes a new instance of the class using the of the current thread. - instance is created using this constructor, the of the current thread is saved. Comparison procedures use the saved culture to determine the sort order and casing rules; therefore, string comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp" id="Snippet1"::: + instance is created using this constructor, the of the current thread is saved. Comparison procedures use the saved culture to determine the sort order and casing rules; therefore, string comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). + + + +## Examples + The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: + ]]> @@ -211,20 +209,19 @@ The class is the default implementation of th The to use for the new . Initializes a new instance of the class using the specified . - to determine the sort order and casing rules. String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp" id="Snippet1"::: + to determine the sort order and casing rules. String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). + + + +## Examples + The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: + ]]> @@ -283,41 +280,41 @@ The class is the default implementation of th The first object to compare. The second object to compare. Performs a case-insensitive comparison of two objects of the same type and returns a value indicating whether one is less than, equal to, or greater than the other. - A signed integer that indicates the relative values of and , as shown in the following table. - - Value - - Meaning - - Less than zero - - is less than , with casing ignored. - - Zero - - equals , with casing ignored. - - Greater than zero - - is greater than , with casing ignored. - + A signed integer that indicates the relative values of and , as shown in the following table. + + Value + + Meaning + + Less than zero + + is less than , with casing ignored. + + Zero + + equals , with casing ignored. + + Greater than zero + + is greater than , with casing ignored. + - to compare the strings with the casing ignored; otherwise, it uses the implementation of either object. That is, if `a` implements , then this method returns the result of `a`. `CompareTo` (`b`); otherwise, if `b` implements , then it returns the negated result of `b`. `CompareTo` (`a`). - - Comparing `null` with any type is allowed and does not generate an exception when using . When sorting, `null` is considered to be less than any other object. - - String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - + to compare the strings with the casing ignored; otherwise, it uses the implementation of either object. That is, if `a` implements , then this method returns the result of `a`. `CompareTo` (`b`); otherwise, if `b` implements , then it returns the negated result of `b`. `CompareTo` (`a`). + + Comparing `null` with any type is allowed and does not generate an exception when using . When sorting, `null` is considered to be less than any other object. + + String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). + ]]> - Neither nor implements the interface. - - -or- - + Neither nor implements the interface. + + -or- + and are of different types. @@ -367,11 +364,11 @@ The class is the default implementation of th Gets an instance of that is associated with the of the current thread and that is always available. An instance of that is associated with the of the current thread. - instance is created using the parameterless constructor, the of the current thread is saved. Comparison procedures use the saved culture to determine the sort order and casing rules; therefore, string comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - + instance is created using the parameterless constructor, the of the current thread is saved. Comparison procedures use the saved culture to determine the sort order and casing rules; therefore, string comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). + ]]> @@ -420,20 +417,19 @@ The class is the default implementation of th Gets an instance of that is associated with and that is always available. An instance of that is associated with . - to determine the sort order and casing rules. String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp" id="Snippet1"::: + to determine the sort order and casing rules. String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). + + + +## Examples + The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Collections/CaseInsensitiveHashCodeProvider.xml b/xml/System.Collections/CaseInsensitiveHashCodeProvider.xml index 893f5476cb0..1c75c58768e 100644 --- a/xml/System.Collections/CaseInsensitiveHashCodeProvider.xml +++ b/xml/System.Collections/CaseInsensitiveHashCodeProvider.xml @@ -71,26 +71,25 @@ Supplies a hash code for an object, using a hashing algorithm that ignores the case of strings. - implements the interface supporting case-insensitive comparisons on strings, just as implements the interface supporting case-insensitive comparisons on strings. - + + implements the interface supporting case-insensitive comparisons on strings, just as implements the interface supporting case-insensitive comparisons on strings. + > [!IMPORTANT] > We don't recommend that you use the `CaseInsensitiveHashCodeProvider` class for new development. Instead, we recommend that you use the object returned by the , , or property. - The objects used as keys by a are required to override the method (or the interface) and the method (or the interface). The implementation of both methods or interfaces must handle case sensitivity the same way; otherwise, the might behave incorrectly. For example, when creating a , you must use this class with the class or any case-insensitive implementation. - - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. + The objects used as keys by a are required to override the method (or the interface) and the method (or the interface). The implementation of both methods or interfaces must handle case sensitivity the same way; otherwise, the might behave incorrectly. For example, when creating a , you must use this class with the class or any case-insensitive implementation. + + + +## Examples + The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: + ]]> @@ -146,20 +145,19 @@ Initializes a new instance of the class using the of the current thread. - instance is created using this constructor, the of the current thread is saved. Comparison procedures use the saved culture to determine the casing rules; therefore, hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp" id="Snippet1"::: + instance is created using this constructor, the of the current thread is saved. Comparison procedures use the saved culture to determine the casing rules; therefore, hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). + + + +## Examples + The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: + ]]> @@ -207,20 +205,19 @@ The to use for the new . Initializes a new instance of the class using the specified . - to determine the casing rules. Hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp" id="Snippet1"::: + to determine the casing rules. Hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). + + + +## Examples + The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: + ]]> @@ -268,11 +265,11 @@ Gets an instance of that is associated with the of the current thread and that is always available. An instance of that is associated with the of the current thread. - instance is created using the parameterless constructor, the of the current thread is saved. Comparison procedures use the saved culture to determine the casing rules; therefore, hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - + instance is created using the parameterless constructor, the of the current thread is saved. Comparison procedures use the saved culture to determine the casing rules; therefore, hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). + ]]> @@ -318,20 +315,19 @@ Gets an instance of that is associated with and that is always available. An instance of that is associated with . - to determine the casing rules. Hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). - - - -## Examples - The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/CPP/caseinsensitive.cpp" id="Snippet1"::: + to determine the casing rules. Hash code comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the namespace and [Globalization and Localization](/dotnet/standard/globalization-localization/). + + + +## Examples + The following code example creates a case-sensitive hash table and a case-insensitive hash table and demonstrates the difference in their behavior, even if both contain the same elements. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CaseInsensitiveComparer/Overview/caseinsensitive.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CaseInsensitive/VB/caseinsensitive.vb" id="Snippet1"::: + ]]> @@ -384,11 +380,11 @@ Returns a hash code for the given object, using a hashing algorithm that ignores the case of strings. A hash code for the given object, using a hashing algorithm that ignores the case of strings. - diff --git a/xml/System.Collections/CollectionBase.xml b/xml/System.Collections/CollectionBase.xml index d078c881922..d5f9239538e 100644 --- a/xml/System.Collections/CollectionBase.xml +++ b/xml/System.Collections/CollectionBase.xml @@ -72,32 +72,31 @@ Provides the base class for a strongly typed collection. - [!IMPORTANT] > We don't recommend that you use the `CollectionBase` class for new development. Instead, we recommend that you use the generic class. For more information, see [Non-generic collections shouldn't be used](https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md) on GitHub. -A instance is always modifiable. See for a read-only version of this class. - - The capacity of a is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by setting the property explicitly. - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. +A instance is always modifiable. See for a read-only version of this class. + + The capacity of a is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by setting the property explicitly. + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - - This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + + This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. + Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. This base class is provided to make it easier for implementers to create a strongly typed custom collection. Implementers are encouraged to extend this base class instead of creating their own. @@ -156,15 +155,15 @@ A instance is always modifiable. See Initializes a new instance of the class with the default initial capacity. - is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . - - This constructor is an `O(1)` operation. - + is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . + + This constructor is an `O(1)` operation. + ]]> @@ -210,15 +209,15 @@ A instance is always modifiable. See The number of elements that the new list can initially store. Initializes a new instance of the class with the specified capacity. - is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . - - This constructor is an `O(n)` operation, where `n` is `capacity`. - + is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . + + This constructor is an `O(n)` operation, where `n` is `capacity`. + ]]> @@ -270,17 +269,17 @@ A instance is always modifiable. See Gets or sets the number of elements that the can contain. The number of elements that the can contain. - is the number of elements that the can store. is the number of elements that are actually in the . - - is always greater than or equal to . If exceeds while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements. - - The capacity can be decreased by setting the property explicitly. When the value of is set explicitly, the internal array is also reallocated to accommodate the specified capacity. - - Retrieving the value of this property is an `O(1)` operation; setting the property is an `O(n)` operation, where `n` is the new capacity. - + is the number of elements that the can store. is the number of elements that are actually in the . + + is always greater than or equal to . If exceeds while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements. + + The capacity can be decreased by setting the property explicitly. When the value of is set explicitly, the internal array is also reallocated to accommodate the specified capacity. + + Retrieving the value of this property is an `O(1)` operation; setting the property is an `O(n)` operation, where `n` is the new capacity. + ]]> @@ -333,15 +332,15 @@ A instance is always modifiable. See Removes all objects from the instance. This method cannot be overridden. - is set to zero. - - This method is an `O(n)` operation, where `n` is . - - To perform custom actions before or after the collection is cleared, override the protected or method. - + is set to zero. + + This method is an `O(n)` operation, where `n` is . + + To perform custom actions before or after the collection is cleared, override the protected or method. + ]]> @@ -390,15 +389,14 @@ A instance is always modifiable. See Gets the number of elements contained in the instance. This property cannot be overridden. The number of elements contained in the instance. Retrieving the value of this property is an O(1) operation. - class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> @@ -448,37 +446,36 @@ A instance is always modifiable. See Returns an enumerator that iterates through the instance. An for the instance. - also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - While the method is not visible to COM clients by default, inheriting the class can expose it and can cause undesirable behavior in COM clients. - - This method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + While the method is not visible to COM clients by default, inheriting the class can expose it and can cause undesirable behavior in COM clients. + + This method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> @@ -525,11 +522,11 @@ A instance is always modifiable. See Gets an containing the list of elements in the instance. An representing the instance itself. Retrieving the value of this property is an O(1) operation. - property, but not on the instance returned by the property. - + property, but not on the instance returned by the property. + ]]> @@ -575,22 +572,21 @@ A instance is always modifiable. See Gets an containing the list of elements in the instance. An representing the instance itself. - property, but not on the instance returned by the property. - - Retrieving the value of this property is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + property, but not on the instance returned by the property. + + Retrieving the value of this property is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> @@ -636,24 +632,24 @@ A instance is always modifiable. See Performs additional custom processes when clearing the contents of the instance. - property, but not on the instance returned by the property. - - If the process fails, the collection reverts back to its previous state. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + If the process fails, the collection reverts back to its previous state. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed before deleting all the elements from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - - is invoked before the standard Clear behavior, whereas is invoked after the standard Clear behavior. - + This method allows implementers to define processes that must be performed before deleting all the elements from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + + is invoked before the standard Clear behavior, whereas is invoked after the standard Clear behavior. + For example, implementers can exempt certain elements from deletion by a global Clear. @@ -701,20 +697,20 @@ A instance is always modifiable. See Performs additional custom processes after clearing the contents of the instance. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed after deleting all the elements from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - + This method allows implementers to define processes that must be performed after deleting all the elements from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + is invoked before the standard Clear behavior, whereas is invoked after the standard Clear behavior. @@ -768,35 +764,34 @@ A instance is always modifiable. See The new value of the element at . Performs additional custom processes before inserting a new element into the instance. - property, but not on the instance returned by the property. - - If the process fails, the collection reverts back to its previous state. - - The default implementation of this method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + property, but not on the instance returned by the property. + + If the process fails, the collection reverts back to its previous state. + + The default implementation of this method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> - This method allows implementers to define processes that must be performed before inserting the element into the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - - is invoked before the standard Insert behavior, whereas is invoked after the standard Insert behavior. - - For example, implementers can restrict which types of objects can be inserted into the . - + This method allows implementers to define processes that must be performed before inserting the element into the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + + is invoked before the standard Insert behavior, whereas is invoked after the standard Insert behavior. + + For example, implementers can restrict which types of objects can be inserted into the . + is called prior to this method. @@ -851,26 +846,26 @@ A instance is always modifiable. See The new value of the element at . Performs additional custom processes after inserting a new element into the instance. - property, but not on the instance returned by the property. - - The collection reverts back to its previous state if one of the following occurs: - -- The process fails. - -- This method is overridden to throw an exception. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + The collection reverts back to its previous state if one of the following occurs: + +- The process fails. + +- This method is overridden to throw an exception. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed after inserting the element into the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - + This method allows implementers to define processes that must be performed after inserting the element into the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + is invoked before the standard Insert behavior, whereas is invoked after the standard Insert behavior. @@ -924,35 +919,34 @@ A instance is always modifiable. See The value of the element to remove from . Performs additional custom processes when removing an element from the instance. - property, but not on the instance returned by the property. - - If the process fails, the collection reverts back to its previous state. - - The default implementation of this method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + property, but not on the instance returned by the property. + + If the process fails, the collection reverts back to its previous state. + + The default implementation of this method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> - This method allows implementers to define processes that must be performed before removing the element from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - - is invoked before the standard Remove behavior, whereas is invoked after the standard Remove behavior. - - For example, implementers can prevent removal of elements by always throwing an exception in . - + This method allows implementers to define processes that must be performed before removing the element from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + + is invoked before the standard Remove behavior, whereas is invoked after the standard Remove behavior. + + For example, implementers can prevent removal of elements by always throwing an exception in . + is called prior to this method. @@ -1006,26 +1000,26 @@ A instance is always modifiable. See The value of the element to remove from . Performs additional custom processes after removing an element from the instance. - property, but not on the instance returned by the property. - - The collection reverts back to its previous state if one of the following occurs: - -- The process fails. - -- This method is overridden to throw an exception. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + The collection reverts back to its previous state if one of the following occurs: + +- The process fails. + +- This method is overridden to throw an exception. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed after removing the element from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - + This method allows implementers to define processes that must be performed after removing the element from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + is invoked before the standard Remove behavior, whereas is invoked after the standard Remove behavior. @@ -1081,35 +1075,34 @@ A instance is always modifiable. See The new value of the element at . Performs additional custom processes before setting a value in the instance. - property, but not on the instance returned by the property. - - If the process fails, the collection reverts back to its previous state. - - The default implementation of this method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + property, but not on the instance returned by the property. + + If the process fails, the collection reverts back to its previous state. + + The default implementation of this method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> - This method allows implementers to define processes that must be performed before setting the specified element in the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - - is invoked before the standard Set behavior, whereas is invoked after the standard Set behavior. - - For example, implementers can restrict which values can be overwritten by performing a check inside . - + This method allows implementers to define processes that must be performed before setting the specified element in the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + + is invoked before the standard Set behavior, whereas is invoked after the standard Set behavior. + + For example, implementers can restrict which values can be overwritten by performing a check inside . + is called prior to this method. @@ -1166,26 +1159,26 @@ A instance is always modifiable. See The new value of the element at . Performs additional custom processes after setting a value in the instance. - property, but not on the instance returned by the property. - - The collection reverts back to its previous state if one of the following occurs: - -- The process fails. - -- This method is overridden to throw an exception. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + The collection reverts back to its previous state if one of the following occurs: + +- The process fails. + +- This method is overridden to throw an exception. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed after setting the specified element in the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - + This method allows implementers to define processes that must be performed after setting the specified element in the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + is invoked before the standard Set behavior, whereas is invoked after the standard Set behavior. @@ -1236,33 +1229,32 @@ A instance is always modifiable. See The object to validate. Performs additional custom processes when validating a value. - . It is intended to be overridden by a derived class to perform additional action when the specified element is validated. - - The On* methods are invoked only on the instance returned by the property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + . It is intended to be overridden by a derived class to perform additional action when the specified element is validated. + + The On* methods are invoked only on the instance returned by the property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> is . - This method allows implementers to define processes that must be performed when executing the standard behavior of the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - - can be used to impose restrictions on the type of objects that are accepted into the collection. The default implementation prevents from being added to or removed from the underlying . - + This method allows implementers to define processes that must be performed when executing the standard behavior of the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + + can be used to impose restrictions on the type of objects that are accepted into the collection. The default implementation prevents from being added to or removed from the underlying . + is called prior to , , and . @@ -1316,20 +1308,20 @@ A instance is always modifiable. See The zero-based index of the element to remove. Removes the element at the specified index of the instance. This method is not overridable. - . - + . + ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + is equal to or greater than . This method calls , , and . @@ -1385,15 +1377,15 @@ A instance is always modifiable. See The zero-based index in at which copying begins. Copies the entire to a compatible one-dimensional , starting at the specified index of the target array. - to copy the elements. - - This method is an `O(n)` operation, where `n` is . - + to copy the elements. + + This method is an `O(n)` operation, where `n` is . + ]]> @@ -1401,10 +1393,10 @@ A instance is always modifiable. See is less than zero. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source is greater than the available space from to the end of the destination . The type of the source cannot be cast automatically to the type of the destination . @@ -1454,21 +1446,20 @@ A instance is always modifiable. See if access to the is synchronized (thread safe); otherwise, . The default is . - instance is not synchronized. Derived classes can provide a synchronized version of the using the property. - - Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - The following code example shows how to lock the collection using the during the entire enumeration: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/remarks.cpp" id="Snippet2"::: + instance is not synchronized. Derived classes can provide a synchronized version of the using the property. + + Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + The following code example shows how to lock the collection using the during the entire enumeration: + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/remarks.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/remarks.vb" id="Snippet2"::: - - Retrieving the value of this property is an `O(1)` operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/remarks.vb" id="Snippet2"::: + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -1518,21 +1509,20 @@ A instance is always modifiable. See Gets an object that can be used to synchronize access to the . An object that can be used to synchronize access to the . - using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - The following code example shows how to lock the collection using the during the entire enumeration: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/remarks.cpp" id="Snippet2"::: + using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + The following code example shows how to lock the collection using the during the entire enumeration: + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/remarks.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/remarks.vb" id="Snippet2"::: - - Retrieving the value of this property is an `O(1)` operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/remarks.vb" id="Snippet2"::: + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -1586,28 +1576,27 @@ A instance is always modifiable. See Adds an object to the end of the . The index at which the has been added. - already equals the capacity, the capacity of the list is doubled by automatically reallocating the internal array and copying the existing elements to the new array before the new element is added. - - If is less than the capacity, this method is an `O(1)` operation. If the capacity needs to be increased to accommodate the new element, this method becomes an `O(n)` operation, where `n` is . - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + already equals the capacity, the capacity of the list is doubled by automatically reallocating the internal array and copying the existing elements to the new array before the new element is added. + + If is less than the capacity, this method is an `O(1)` operation. If the capacity needs to be increased to accommodate the new element, this method becomes an `O(n)` operation, where `n` is . + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. This method calls , , and . @@ -1666,24 +1655,23 @@ A instance is always modifiable. See if the contains the specified ; otherwise, . - . - - This method determines equality by calling . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + . + + This method determines equality by calling . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> @@ -1738,24 +1726,23 @@ A instance is always modifiable. See Searches for the specified and returns the zero-based index of the first occurrence within the entire . The zero-based index of the first occurrence of within the entire , if found; otherwise, -1. - . - - This method determines equality by calling . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + . + + This method determines equality by calling . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> @@ -1811,38 +1798,37 @@ A instance is always modifiable. See The to insert. Inserts an element into the at the specified index. - already equals the capacity, the capacity of the list is doubled by automatically reallocating the internal array before the new element is inserted. - - If `index` is equal to , `value` is added to the end of . - - In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + already equals the capacity, the capacity of the list is doubled by automatically reallocating the internal array before the new element is inserted. + + If `index` is equal to , `value` is added to the end of . + + In collections of contiguous elements, such as lists, the elements that follow the insertion point move down to accommodate the new element. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + is greater than . - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. This method calls , , and . @@ -1896,15 +1882,15 @@ A instance is always modifiable. See if the has a fixed size; otherwise, . The default is . - @@ -1954,15 +1940,15 @@ A instance is always modifiable. See if the is read-only; otherwise, . The default is . - @@ -2022,29 +2008,28 @@ A instance is always modifiable. See Gets or sets the element at the specified index. The element at the specified index. - class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + is equal to or greater than . When this property is set, the methods , , and are called. @@ -2099,33 +2084,32 @@ A instance is always modifiable. See The to remove from the . Removes the first occurrence of a specific object from the . - does not contain the specified object, the remains unchanged. No exception is thrown. - - This method performs a linear search; therefore, this method is an `O(n)` operation, where `n` is . - - This method determines equality by calling . - - In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. - - - -## Examples - The following code example implements the class and uses that implementation to create a collection of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.CollectionBase/CPP/collectionbase.cpp" id="Snippet1"::: + does not contain the specified object, the remains unchanged. No exception is thrown. + + This method performs a linear search; therefore, this method is an `O(n)` operation, where `n` is . + + This method determines equality by calling . + + In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. + + + +## Examples + The following code example implements the class and uses that implementation to create a collection of objects. + :::code language="csharp" source="~/snippets/csharp/System.Collections/CollectionBase/Overview/collectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.CollectionBase/VB/collectionbase.vb" id="Snippet1"::: + ]]> The parameter was not found in the object. - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. This method calls , , and . diff --git a/xml/System.Collections/Comparer.xml b/xml/System.Collections/Comparer.xml index 8bf36a0074a..bca396229f4 100644 --- a/xml/System.Collections/Comparer.xml +++ b/xml/System.Collections/Comparer.xml @@ -106,7 +106,6 @@ ## Examples The following code example shows how returns different values depending on the culture associated with the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Comparer/CPP/comparercultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Comparer/Overview/comparercultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Comparer/VB/comparercultures.vb" id="Snippet1"::: @@ -178,7 +177,6 @@ ## Examples The following code example shows how returns different values depending on the culture associated with the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Comparer/CPP/comparercultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Comparer/Overview/comparercultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Comparer/VB/comparercultures.vb" id="Snippet1"::: @@ -279,7 +277,6 @@ ## Examples The following code example shows how returns different values depending on the culture associated with the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Comparer/CPP/comparercultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Comparer/Overview/comparercultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Comparer/VB/comparercultures.vb" id="Snippet1"::: @@ -409,7 +406,6 @@ ## Examples The following code example shows how returns different values depending on the culture associated with the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Comparer/CPP/comparercultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Comparer/Overview/comparercultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Comparer/VB/comparercultures.vb" id="Snippet1"::: diff --git a/xml/System.Collections/DictionaryBase.xml b/xml/System.Collections/DictionaryBase.xml index 0654344f5f2..83828ed337f 100644 --- a/xml/System.Collections/DictionaryBase.xml +++ b/xml/System.Collections/DictionaryBase.xml @@ -72,39 +72,38 @@ Provides the base class for a strongly typed collection of key/value pairs. - [!IMPORTANT] > We don't recommend that you use the `DictionaryBase` class for new development. Instead, we recommend that you use the generic or class . For more information, see [Non-generic collections shouldn't be used](https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md) on GitHub. -The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statement and the Visual Basic [For Each](/dotnet/visual-basic/language-reference/statements/for-each-next-statement) statement return an object of the type of the elements in the collection. Since each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . - - The `foreach` statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection. - +The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statement and the Visual Basic [For Each](/dotnet/visual-basic/language-reference/statements/for-each-next-statement) statement return an object of the type of the elements in the collection. Since each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . + + The `foreach` statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection. + > [!NOTE] -> Because keys can be inherited and their behavior changed, their absolute uniqueness cannot be guaranteed by comparisons using the method. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. +> Because keys can be inherited and their behavior changed, their absolute uniqueness cannot be guaranteed by comparisons using the method. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - - This implementation does not provide a synchronized (thread-safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + + This implementation does not provide a synchronized (thread-safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - This base class is provided to make it easier for implementers to create a strongly typed custom collection. Implementers are encouraged to extend this base class instead of creating their own. - + This base class is provided to make it easier for implementers to create a strongly typed custom collection. Implementers are encouraged to extend this base class instead of creating their own. + Members of this base class are protected and are intended to be used through a derived class only. @@ -150,11 +149,11 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Initializes a new instance of the class. - @@ -203,13 +202,13 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Clears the contents of the instance. - is set to zero, and references to other objects from elements of the collection are also released. - - This method is an `O(n)` operation, where `n` is . - + is set to zero, and references to other objects from elements of the collection are also released. + + This method is an `O(n)` operation, where `n` is . + ]]> @@ -263,13 +262,13 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen The zero-based index in at which copying begins. Copies the elements to a one-dimensional at the specified index. - in the same order in which the enumerator iterates through the . - - This method is an `O(n)` operation, where `n` is . - + in the same order in which the enumerator iterates through the . + + This method is an `O(n)` operation, where `n` is . + ]]> @@ -277,10 +276,10 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen is less than zero. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source is greater than the available space from to the end of the destination . The type of the source cannot be cast automatically to the type of the destination . @@ -332,11 +331,11 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Gets the number of elements contained in the instance. The number of elements contained in the instance. - @@ -382,22 +381,21 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Gets the list of elements contained in the instance. An representing the instance itself. - property, but not on the instance returned by the property. - - Retrieving the value of this property is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + property, but not on the instance returned by the property. + + Retrieving the value of this property is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> @@ -447,34 +445,33 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Returns an that iterates through the instance. An for the instance. - also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - - This method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. + + This method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> @@ -522,13 +519,13 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Gets the list of elements contained in the instance. A representing the instance itself. - property, but not on the instance returned by the property. - - Retrieving the value of this property is an `O(1)` operation. - + property, but not on the instance returned by the property. + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -574,22 +571,22 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Performs additional custom processes before clearing the contents of the instance. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed before deleting all the elements from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - - is invoked before the standard Clear behavior, whereas is invoked after the standard Clear behavior. - + This method allows implementers to define processes that must be performed before deleting all the elements from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + + is invoked before the standard Clear behavior, whereas is invoked after the standard Clear behavior. + For example, implementers can exempt certain elements from deletion by a global Clear. @@ -637,20 +634,20 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Performs additional custom processes after clearing the contents of the instance. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed after deleting all the elements from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - + This method allows implementers to define processes that must be performed after deleting all the elements from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + is invoked before the standard Clear behavior, whereas is invoked after the standard Clear behavior. @@ -712,20 +709,20 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Gets the element with the specified key and value in the instance. An containing the element with the specified key and value. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed when executing the standard Get behavior of the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - + This method allows implementers to define processes that must be performed when executing the standard Get behavior of the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + can be used to specify processes to perform before returning the value retrieved from the underlying . For example, implementers can cast the value into another type before returning it. @@ -784,31 +781,30 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen The value of the element to insert. Performs additional custom processes before inserting a new element into the instance. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> - This method allows implementers to define processes that must be performed before inserting the element into the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - - is invoked before the standard Insert behavior, whereas is invoked after the standard Insert behavior. - + This method allows implementers to define processes that must be performed before inserting the element into the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + + is invoked before the standard Insert behavior, whereas is invoked after the standard Insert behavior. + For example, implementers can restrict which types of objects can be inserted into the . @@ -870,20 +866,20 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen The value of the element to insert. Performs additional custom processes after inserting a new element into the instance. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed after inserting the element into the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - + This method allows implementers to define processes that must be performed after inserting the element into the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + is invoked before the standard Insert behavior, whereas is invoked after the standard Insert behavior. @@ -944,31 +940,30 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen The value of the element to remove. Performs additional custom processes before removing an element from the instance. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> - This method allows implementers to define processes that must be performed before removing the element from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - - is invoked before the standard Remove behavior, whereas is invoked after the standard Remove behavior. - + This method allows implementers to define processes that must be performed before removing the element from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + + is invoked before the standard Remove behavior, whereas is invoked after the standard Remove behavior. + For example, implementers can prevent removal of elements by always throwing an exception in . @@ -1029,20 +1024,20 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen The value of the element to remove. Performs additional custom processes after removing an element from the instance. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed after removing the element from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - + This method allows implementers to define processes that must be performed after removing the element from the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + is invoked before the standard Remove behavior, whereas is invoked after the standard Remove behavior. @@ -1105,31 +1100,30 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen The new value of the element associated with . Performs additional custom processes before setting a value in the instance. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> - This method allows implementers to define processes that must be performed before setting the specified element in the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - - is invoked before the standard Set behavior, whereas is invoked after the standard Set behavior. - + This method allows implementers to define processes that must be performed before setting the specified element in the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + + is invoked before the standard Set behavior, whereas is invoked after the standard Set behavior. + For example, implementers can restrict which values can be overwritten by performing a check inside . @@ -1193,20 +1187,20 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen The new value of the element associated with . Performs additional custom processes after setting a value in the instance. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + ]]> - This method allows implementers to define processes that must be performed after setting the specified element in the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - + This method allows implementers to define processes that must be performed after setting the specified element in the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + is invoked before the standard Set behavior, whereas is invoked after the standard Set behavior. @@ -1267,29 +1261,28 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen The value of the element to validate. Performs additional custom processes when validating the element with the specified key and value. - property, but not on the instance returned by the property. - - The default implementation of this method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + property, but not on the instance returned by the property. + + The default implementation of this method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> - This method allows implementers to define processes that must be performed when executing the standard behavior of the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. - + This method allows implementers to define processes that must be performed when executing the standard behavior of the underlying . By defining this method, implementers can add functionality to inherited methods without having to override all other methods. + can be used to impose restrictions on the type of objects that are accepted into the collection. The default implementation prevents from being added to or removed from the underlying . @@ -1341,24 +1334,23 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen if access to the object is synchronized (thread safe); otherwise, . The default is . - object is not synchronized. Derived classes can provide a synchronized version of the class using the property. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the property during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/source2.cpp" id="Snippet3"::: + object is not synchronized. Derived classes can provide a synchronized version of the class using the property. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the property during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/source2.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/source2.vb" id="Snippet3"::: - - Retrieving the value of this property is an `O(1)` operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/source2.vb" id="Snippet3"::: + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -1409,24 +1401,23 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Gets an object that can be used to synchronize access to a object. An object that can be used to synchronize access to the object. - class using the property. The synchronizing code must perform operations on the property of the object, not directly on the object. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the property during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/source2.cpp" id="Snippet3"::: + class using the property. The synchronizing code must perform operations on the property of the object, not directly on the object. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the property during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/source2.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/source2.vb" id="Snippet3"::: - - Retrieving the value of this property is an `O(1)` operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/source2.vb" id="Snippet3"::: + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -1482,33 +1473,32 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen The value of the element to add. Adds an element with the specified key and value into the . - objects are better than objects for use as keys. - - You can also use the property to add new elements by setting the value of a key that does not exist in the ; for example, `myCollection["myNonexistentKey"] = myValue`. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. - - This method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + objects are better than objects for use as keys. + + You can also use the property to add new elements by setting the value of a key that does not exist in the ; for example, `myCollection["myNonexistentKey"] = myValue`. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. + + This method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> is . An element with the same key already exists in the . - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. @@ -1564,22 +1554,21 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen if the contains an element with the specified key; otherwise, . - and methods on `key` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `key` parameter on the objects in the collection. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + and methods on `key` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `key` parameter on the objects in the collection. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> @@ -1632,15 +1621,15 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen if the object has a fixed size; otherwise, . The default is . - @@ -1690,15 +1679,15 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen if the object is read-only; otherwise, . The default is . - @@ -1758,32 +1747,31 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Gets or sets the value associated with the specified key. The value associated with the specified key. If the specified key is not found, attempting to get it returns , and attempting to set it creates a new element using the specified key. - property to add new elements by setting the value of a key that does not exist in the ; for example, `myCollection["myNonexistentKey"] = myValue`. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. - - Retrieving the value of this property is an `O(1)` operation; setting the property is also an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + property to add new elements by setting the value of a key that does not exist in the ; for example, `myCollection["myNonexistentKey"] = myValue`. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. + + Retrieving the value of this property is an `O(1)` operation; setting the property is also an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> is . - The property is set and the is read-only. - - -or- - + The property is set and the is read-only. + + -or- + The property is set, does not exist in the collection, and the has a fixed size. @@ -1832,24 +1820,23 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Gets an object containing the keys in the object. An object containing the keys in the object. - object is unspecified, but is the same order as the associated values in the object returned by the property. - - The returned is not a static copy; instead, the refers back to the keys in the original object. Therefore, changes to the continue to be reflected in the returned . - - Retrieving the value of this property is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a property of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + object is unspecified, but is the same order as the associated values in the object returned by the property. + + The returned is not a static copy; instead, the refers back to the keys in the original object. Therefore, changes to the continue to be reflected in the returned . + + Retrieving the value of this property is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a property of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> @@ -1903,30 +1890,29 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen The key of the element to remove. Removes the element with the specified key from the . - does not contain an element with the specified key, the remains unchanged. No exception is thrown. - - This method is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + does not contain an element with the specified key, the remains unchanged. No exception is thrown. + + This method is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> is . - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. @@ -1977,24 +1963,23 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Gets an object containing the values in the object. An object containing the values in the object. - object is unspecified, but is the same order as the associated keys in the object returned by the property. - - The returned is not a static copy; instead, the refers back to the values in the original object. Therefore, changes to the continue to be reflected in the returned . - - Retrieving the value of this property is an `O(1)` operation. - - - -## Examples - The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a property of 5 characters or less. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryBase/CPP/dictionarybase.cpp" id="Snippet1"::: + object is unspecified, but is the same order as the associated keys in the object returned by the property. + + The returned is not a static copy; instead, the refers back to the values in the original object. Therefore, changes to the continue to be reflected in the returned . + + Retrieving the value of this property is an `O(1)` operation. + + + +## Examples + The following code example implements the class and uses that implementation to create a dictionary of keys and values that have a property of 5 characters or less. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryBase/Overview/dictionarybase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryBase/VB/dictionarybase.vb" id="Snippet1"::: + ]]> @@ -2046,25 +2031,25 @@ The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statemen Returns an that iterates through the . An for the . - also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - This method is an `O(1)` operation. - + also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + This method is an `O(1)` operation. + ]]> diff --git a/xml/System.Collections/DictionaryEntry.xml b/xml/System.Collections/DictionaryEntry.xml index 41d0f9f7673..fc1cd812584 100644 --- a/xml/System.Collections/DictionaryEntry.xml +++ b/xml/System.Collections/DictionaryEntry.xml @@ -65,31 +65,29 @@ Defines a dictionary key/value pair that can be set or retrieved. - method returns an instance of this type. + method returns an instance of this type. > [!IMPORTANT] > We don't recommend that you use the `DictionaryEntry` structure for new development. Instead, we recommend that you use a generic structure along with the class. For more information, see [Non-generic collections shouldn't be used](https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md) on GitHub. - The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statement and the Visual Basic [For Each](/dotnet/visual-basic/language-reference/statements/for-each-next-statement) statement require the type of each element in the collection. Since each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: + The C# [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) statement and the Visual Basic [For Each](/dotnet/visual-basic/language-reference/statements/for-each-next-statement) statement require the type of each element in the collection. Since each element of the is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/cpp/dictionaryentrysample.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Overview/DictionaryEntrySample.cs" id="Snippet01"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/vb/DictionaryEntrySample.vb" id="Snippet01"::: - - The `foreach` statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection. - - - -## Examples - The following example demonstrates the use of to iterate through a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/cpp/dictionaryentrysample.cpp" id="Snippet00"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/vb/DictionaryEntrySample.vb" id="Snippet01"::: + + The `foreach` statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection. + + + +## Examples + The following example demonstrates the use of to iterate through a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Overview/DictionaryEntrySample.cs" id="Snippet00"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/vb/DictionaryEntrySample.vb" id="Snippet00"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.DictionaryEntry/vb/DictionaryEntrySample.vb" id="Snippet00"::: + ]]> @@ -150,11 +148,11 @@ The The definition associated with . Initializes an instance of the type with the specified key and value. - @@ -259,15 +257,14 @@ The Gets or sets the key in the key/value pair. The key in the key/value pair. - property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet9"::: + property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet9"::: + ]]> @@ -322,15 +319,14 @@ The Gets or sets the value in the key/value pair. The value in the key/value pair. - property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet9"::: + property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet9"::: + ]]> diff --git a/xml/System.Collections/Hashtable.xml b/xml/System.Collections/Hashtable.xml index 75579ba35b0..b418bb4bb36 100644 --- a/xml/System.Collections/Hashtable.xml +++ b/xml/System.Collections/Hashtable.xml @@ -145,7 +145,6 @@ Each element is a key/value pair stored in a is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/remarks.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/Overview/remarks.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/vb/remarks.vb" id="Snippet01"::: @@ -161,7 +160,6 @@ Each element is a key/value pair stored in a and how to print out its keys and values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/cpp/hashtable_example.cpp" id="Snippet00"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/Overview/hashtable_example.cs" id="Snippet00"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ClassExample/vb/hashtable_example.vb" id="Snippet00"::: :::code language="powershell" source="~/snippets/powershell/VS_Snippets_CLR_System/system.collections.hashtable.class/ps/hashtable.ps1" id="Snippet00"::: @@ -253,7 +251,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/VB/hashtable_ctor.vb" id="Snippet1"::: @@ -332,7 +329,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/CPP/hashtable_ctordictionary.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctordictionary.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/VB/hashtable_ctordictionary.vb" id="Snippet1"::: @@ -420,7 +416,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/VB/hashtable_ctor.vb" id="Snippet1"::: @@ -496,7 +491,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/CPP/hashtable_ctorint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctorint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/VB/hashtable_ctorint.vb" id="Snippet1"::: @@ -594,7 +588,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/CPP/hashtable_ctordictionary.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctordictionary.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/VB/hashtable_ctordictionary.vb" id="Snippet1"::: @@ -677,7 +670,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/CPP/hashtable_ctordictionaryfloat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctordictionaryfloat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/VB/hashtable_ctordictionaryfloat.vb" id="Snippet1"::: @@ -788,7 +780,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/VB/hashtable_ctor.vb" id="Snippet1"::: @@ -877,7 +868,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/CPP/hashtable_ctorint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctorint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/VB/hashtable_ctorint.vb" id="Snippet1"::: @@ -957,7 +947,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/CPP/hashtable_ctorintfloat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctorintfloat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/VB/hashtable_ctorintfloat.vb" id="Snippet1"::: @@ -1164,7 +1153,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/CPP/hashtable_ctordictionary.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctordictionary.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionary/VB/hashtable_ctordictionary.vb" id="Snippet1"::: @@ -1267,7 +1255,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/CPP/hashtable_ctordictionaryfloat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctordictionaryfloat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/VB/hashtable_ctordictionaryfloat.vb" id="Snippet1"::: @@ -1374,7 +1361,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/CPP/hashtable_ctorint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctorint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorInt/VB/hashtable_ctorint.vb" id="Snippet1"::: @@ -1467,7 +1453,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/CPP/hashtable_ctorintfloat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctorintfloat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/VB/hashtable_ctorintfloat.vb" id="Snippet1"::: @@ -1587,7 +1572,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/CPP/hashtable_ctordictionaryfloat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctordictionaryfloat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorDictionaryFloat/VB/hashtable_ctordictionaryfloat.vb" id="Snippet1"::: @@ -1695,7 +1679,6 @@ Each element is a key/value pair stored in a constructors and demonstrates the differences in the behavior of the hash tables, even if each one contains the same elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/CPP/hashtable_ctorintfloat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctorintfloat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctorIntFloat/VB/hashtable_ctorintfloat.vb" id="Snippet1"::: @@ -1802,7 +1785,6 @@ Each element is a key/value pair stored in a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Add Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/Add/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.Add Example/VB/source.vb" id="Snippet1"::: @@ -1889,7 +1871,6 @@ Each element is a key/value pair stored in a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Clear Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/Clear/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.Clear Example/VB/source.vb" id="Snippet1"::: @@ -2112,7 +2093,6 @@ Each element is a key/value pair stored in a contains a specific element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/Contains/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/VB/source.vb" id="Snippet1"::: @@ -2190,7 +2170,6 @@ Each element is a key/value pair stored in a contains a specific element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/Contains/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/VB/source.vb" id="Snippet1"::: @@ -2269,7 +2248,6 @@ Each element is a key/value pair stored in a contains a specific element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/Contains/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.Contains Example/VB/source.vb" id="Snippet1"::: @@ -2350,7 +2328,6 @@ Each element is a key/value pair stored in a into a one-dimensional . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.CopyTo Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/CopyTo/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.CopyTo Example/VB/source.vb" id="Snippet1"::: @@ -2582,7 +2559,6 @@ Each element is a key/value pair stored in a and `foreach` to enumerate the contents of a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable Example/CPP/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/GetEnumerator/source2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable Example/VB/source2.vb" id="Snippet2"::: @@ -3007,7 +2983,6 @@ Each element is a key/value pair stored in a during the entire enumeration: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/remarks.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/IsSynchronized/remarks.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/VB/remarks.vb" id="Snippet2"::: @@ -3016,7 +2991,6 @@ Each element is a key/value pair stored in a , determine if a is synchronized, and use a synchronized . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/IsSynchronized/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/VB/source.vb" id="Snippet1"::: @@ -3406,7 +3380,6 @@ Each element is a key/value pair stored in a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.Remove Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/Remove/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.Remove Example/VB/source.vb" id="Snippet1"::: @@ -3483,7 +3456,6 @@ Each element is a key/value pair stored in a during the entire enumeration: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/remarks.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/IsSynchronized/remarks.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/VB/remarks.vb" id="Snippet2"::: @@ -3494,7 +3466,6 @@ Each element is a key/value pair stored in a , determine if a is synchronized, and use a synchronized . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/IsSynchronized/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/VB/source.vb" id="Snippet1"::: @@ -3565,7 +3536,6 @@ Each element is a key/value pair stored in a during the entire enumeration: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/CPP/remarks.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/IsSynchronized/remarks.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Hashtable.IsSynchronized Example/VB/remarks.vb" id="Snippet2"::: diff --git a/xml/System.Collections/ICollection.xml b/xml/System.Collections/ICollection.xml index b4dc19d5de4..123f5d76202 100644 --- a/xml/System.Collections/ICollection.xml +++ b/xml/System.Collections/ICollection.xml @@ -58,20 +58,20 @@ Defines size, enumerators, and synchronization methods for all nongeneric collections. - interface is the base interface for classes in the namespace. Its generic equivalent is the interface. - - The interface extends ; and are more specialized interfaces that extend . An implementation is a collection of key/value pairs, like the class. An implementation is a collection of values and its members can be accessed by index, like the class. - - Some collections that limit access to their elements, such as the class and the class, directly implement the interface. - - If neither the interface nor the interface meet the requirements of the required collection, derive the new collection class from the interface instead for more flexibility. - - For the generic version of this interface, see . - +The interface is the base interface for classes in the namespace. Its generic equivalent is the interface. + + The interface extends ; and are more specialized interfaces that extend . An implementation is a collection of key/value pairs, like the class. An implementation is a collection of values and its members can be accessed by index, like the class. + + Some collections that limit access to their elements, such as the class and the class, directly implement the interface. + + If neither the interface nor the interface meet the requirements of the required collection, derive the new collection class from the interface instead for more flexibility. + + For the generic version of this interface, see . + ]]> @@ -132,14 +132,14 @@ The interface is the base interface for cl is less than zero. - is multidimensional. - - -or- - - The number of elements in the source is greater than the available space from to the end of the destination . - - -or- - + is multidimensional. + + -or- + + The number of elements in the source is greater than the available space from to the end of the destination . + + -or- + The type of the source cannot be cast automatically to the type of the destination . @@ -232,21 +232,20 @@ The interface is the base interface for cl if access to the is synchronized (thread safe); otherwise, . - returns an object, which can be used to synchronize access to the . - - Most collection classes in the namespace also implement a Synchronized method, which provides a synchronized wrapper around the underlying collection. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - The following code example shows how to lock the collection using the property during the entire enumeration. + returns an object, which can be used to synchronize access to the . + + Most collection classes in the namespace also implement a Synchronized method, which provides a synchronized wrapper around the underlying collection. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + The following code example shows how to lock the collection using the property during the entire enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.collections.icollection/cpp/remarks.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ICollection/IsSynchronized/remarks.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.icollection/vb/remarks.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.icollection/vb/remarks.vb" id="Snippet1"::: + ]]> @@ -295,27 +294,25 @@ The interface is the base interface for cl Gets an object that can be used to synchronize access to the . An object that can be used to synchronize access to the . - namespace also implement a `Synchronized` method, which provides a synchronized wrapper around the underlying collection. However, derived classes can provide their own synchronized version of the collection using the property. The synchronizing code must perform operations on the property of the collection, not directly on the collection. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the collection instance. - - In the absence of a `Synchronized` method on a collection, the expected usage for looks as follows: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.collections.icollection/cpp/remarks.cpp" id="Snippet2"::: + namespace also implement a `Synchronized` method, which provides a synchronized wrapper around the underlying collection. However, derived classes can provide their own synchronized version of the collection using the property. The synchronizing code must perform operations on the property of the collection, not directly on the collection. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the collection instance. + + In the absence of a `Synchronized` method on a collection, the expected usage for looks as follows: + :::code language="csharp" source="~/snippets/csharp/System.Collections/ICollection/IsSynchronized/remarks.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.icollection/vb/remarks.vb" id="Snippet2"::: - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - The following code example shows how to lock the collection using the property during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.collections.icollection/cpp/remarks.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.icollection/vb/remarks.vb" id="Snippet2"::: + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + The following code example shows how to lock the collection using the property during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/ICollection/IsSynchronized/remarks.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.icollection/vb/remarks.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.icollection/vb/remarks.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Collections/IDictionary.xml b/xml/System.Collections/IDictionary.xml index 5b21b89accb..53a43d820f6 100644 --- a/xml/System.Collections/IDictionary.xml +++ b/xml/System.Collections/IDictionary.xml @@ -61,34 +61,32 @@ Represents a nongeneric collection of key/value pairs. - interface is the base interface for nongeneric collections of key/value pairs. For the generic version of this interface, see . - - Each element is a key/value pair stored in a object. - - Each pair must have a unique key. Implementations can vary in whether they allow the key to be null. The value can be null and does not have to be unique. The interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order. - - implementations fall into three categories: read-only, fixed-size, variable-size. A read-only object cannot be modified. A fixed-size object does not allow the addition or removal of elements, but does allow the modification of existing elements. A variable-size object allows the addition, removal, and modification of elements. - - The `foreach` statement of the C# language (`For Each` in Visual Basic) returns an object of the type of the elements in the collection. Since each element of the object is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: + interface is the base interface for nongeneric collections of key/value pairs. For the generic version of this interface, see . + + Each element is a key/value pair stored in a object. + + Each pair must have a unique key. Implementations can vary in whether they allow the key to be null. The value can be null and does not have to be unique. The interface allows the contained keys and values to be enumerated, but it does not imply any particular sort order. + + implementations fall into three categories: read-only, fixed-size, variable-size. A read-only object cannot be modified. A fixed-size object does not allow the addition or removal of elements, but does allow the modification of existing elements. A variable-size object allows the addition, removal, and modification of elements. + + The `foreach` statement of the C# language (`For Each` in Visual Basic) returns an object of the type of the elements in the collection. Since each element of the object is a key/value pair, the element type is not the type of the key or the type of the value. Instead, the element type is . For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/remarks.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/remarks.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/remarks.vb" id="Snippet14"::: - - The `foreach` statement is a wrapper around the enumerator, which allows only reading from but not writing to the collection. - - - -## Examples - The following code example demonstrates how to define a simple dictionary class that implements the interface. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/remarks.vb" id="Snippet14"::: + + The `foreach` statement is a wrapper around the enumerator, which allows only reading from but not writing to the collection. + + + +## Examples + The following code example demonstrates how to define a simple dictionary class that implements the interface. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet1"::: + ]]> @@ -154,31 +152,30 @@ The to use as the value of the element to add. Adds an element with the provided key and value to the object. - property to add new elements by setting the value of a key that does not exist in the dictionary (for example, `myCollection["myNonexistentKey"] = myValue`). However, if the specified key already exists in the dictionary, setting the property overwrites the old value. In contrast, the method does not modify existing elements. - - Implementations can vary in whether they allow the key to be `null`. - - - -## Examples - The following code example demonstrates how to implement the method. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet9"::: + property to add new elements by setting the value of a key that does not exist in the dictionary (for example, `myCollection["myNonexistentKey"] = myValue`). However, if the specified key already exists in the dictionary, setting the property overwrites the old value. In contrast, the method does not modify existing elements. + + Implementations can vary in whether they allow the key to be `null`. + + + +## Examples + The following code example demonstrates how to implement the method. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet9"::: + ]]> is . An element with the same key already exists in the object. - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. @@ -226,15 +223,14 @@ Removes all elements from the object. - method. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet8"::: + method. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet8"::: + ]]> The object is read-only. @@ -288,22 +284,21 @@ if the contains an element with the key; otherwise, . - and methods on `item` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example demonstrates how to implement the method. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet5"::: + and methods on `item` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example demonstrates how to implement the method. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet5"::: + ]]> @@ -354,24 +349,24 @@ Returns an object for the object. An object for the object. - also brings the enumerator back to this position. At this position, the property is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - The `foreach` statement of the C# language (`for each` in Visual Basic) hides the complexity of the enumerators. Therefore, using `foreach` is recommended instead of directly manipulating the enumerator. - - Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection. - - Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, the property is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - ]]> @@ -422,22 +417,21 @@ if the object has a fixed size; otherwise, . - property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet6"::: + property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet6"::: + ]]> @@ -486,20 +480,19 @@ if the object is read-only; otherwise, . - property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet4"::: + property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet4"::: + ]]> @@ -558,34 +551,33 @@ Gets or sets the element with the specified key. The element with the specified key, or if the key does not exist. - property to add new elements by setting the value of a key that does not exist in the dictionary (for example, `myCollection["myNonexistentKey"] = myValue`). However, if the specified key already exists in the dictionary, setting the property overwrites the old value. In contrast, the method does not modify existing elements. - - Implementations can vary in whether they allow the key to be `null`. - - The C# language uses the `this`[this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a default property, which provides the same indexing functionality. - - - -## Examples - The following code example demonstrates how to implement the property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet13"::: + property to add new elements by setting the value of a key that does not exist in the dictionary (for example, `myCollection["myNonexistentKey"] = myValue`). However, if the specified key already exists in the dictionary, setting the property overwrites the old value. In contrast, the method does not modify existing elements. + + Implementations can vary in whether they allow the key to be `null`. + + The C# language uses the `this`[this](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a default property, which provides the same indexing functionality. + + + +## Examples + The following code example demonstrates how to implement the property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet13"::: + ]]> is . - The property is set and the object is read-only. - - -or- - + The property is set and the object is read-only. + + -or- + The property is set, does not exist in the collection, and the has a fixed size. @@ -633,20 +625,19 @@ Gets an object containing the keys of the object. An object containing the keys of the object. - object is unspecified, but is guaranteed to be the same order as the corresponding values in the returned by the property. - - - -## Examples - The following code example demonstrates how to implement the property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet10"::: + object is unspecified, but is guaranteed to be the same order as the corresponding values in the returned by the property. + + + +## Examples + The following code example demonstrates how to implement the property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet10"::: + ]]> @@ -698,28 +689,27 @@ The key of the element to remove. Removes the element with the specified key from the object. - object does not contain an element with the specified key, the remains unchanged. No exception is thrown. - - - -## Examples - The following code example demonstrates how to implement the method. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet7"::: + object does not contain an element with the specified key, the remains unchanged. No exception is thrown. + + + +## Examples + The following code example demonstrates how to implement the method. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet7"::: + ]]> is . - The object is read-only. - - -or- - + The object is read-only. + + -or- + The has a fixed size. @@ -766,20 +756,19 @@ Gets an object containing the values in the object. An object containing the values in the object. - object is unspecified, but is guaranteed to be the same order as the corresponding keys in the returned by the property. - - - -## Examples - The following code example demonstrates how to implement the property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet11"::: + object is unspecified, but is guaranteed to be the same order as the corresponding keys in the returned by the property. + + + +## Examples + The following code example demonstrates how to implement the property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet11"::: + ]]> diff --git a/xml/System.Collections/IDictionaryEnumerator.xml b/xml/System.Collections/IDictionaryEnumerator.xml index f4f6d35d9af..df5a6182083 100644 --- a/xml/System.Collections/IDictionaryEnumerator.xml +++ b/xml/System.Collections/IDictionaryEnumerator.xml @@ -58,32 +58,31 @@ Enumerates the elements of a nongeneric dictionary. - method also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call the method to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - + method also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call the method to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + This code example shows how to define a dictionary enumerator that implements the interface. - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - This code example shows how to define a dictionary enumerator that implements the interface. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet1"::: + ]]> @@ -137,20 +136,20 @@ Gets both the key and the value of the current dictionary entry. A containing both the key and the value of the current dictionary entry. - is undefined under any of the following conditions: + +- The enumerator is positioned before the first element in the collection, immediately after the enumerator is created. must be called to advance the enumerator to the first element of the collection before reading the value of . + +- The last call to returned `false`, which indicates the end of the collection. + +- The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. + + returns the same object until is called. sets to the next element. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element in the collection, immediately after the enumerator is created. must be called to advance the enumerator to the first element of the collection before reading the value of . - -- The last call to returned `false`, which indicates the end of the collection. - -- The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - - returns the same object until is called. sets to the next element. - ]]> @@ -206,20 +205,20 @@ Gets the key of the current dictionary entry. The key of the current element of the enumeration. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element in the collection, immediately after the enumerator is created. must be called to advance the enumerator to the first element of the collection before reading the value of . - -- The last call to returned `false`, which indicates the end of the collection. - -- The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - - returns the same object until is called. sets to the key of the next element in enumeration. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element in the collection, immediately after the enumerator is created. must be called to advance the enumerator to the first element of the collection before reading the value of . + +- The last call to returned `false`, which indicates the end of the collection. + +- The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. + + returns the same object until is called. sets to the key of the next element in enumeration. + ]]> @@ -279,19 +278,19 @@ Gets the value of the current dictionary entry. The value of the current element of the enumeration. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element in the collection, immediately after the enumerator is created. must be called to advance the enumerator to the first element of the collection before reading the value of . - -- The last call to returned `false`, which indicates the end of the collection. - -- The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - - returns the same object until is called. sets to the value of the next element in enumeration. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element in the collection, immediately after the enumerator is created. must be called to advance the enumerator to the first element of the collection before reading the value of . + +- The last call to returned `false`, which indicates the end of the collection. + +- The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. + + returns the same object until is called. sets to the value of the next element in enumeration. + ]]> diff --git a/xml/System.Collections/IEqualityComparer.xml b/xml/System.Collections/IEqualityComparer.xml index 811a911da87..cadc5737719 100644 --- a/xml/System.Collections/IEqualityComparer.xml +++ b/xml/System.Collections/IEqualityComparer.xml @@ -131,7 +131,6 @@ The `IEqualityComparer` interface supports only equality comparisons. Customizat ## Examples The following code example demonstrates the implementation of a case-insensitive . In this example, the method is used to determine whether two objects are equal, based on the provided . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctor.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/VB/hashtable_ctor.vb" id="Snippet2"::: @@ -200,7 +199,6 @@ The `IEqualityComparer` interface supports only equality comparisons. Customizat ## Examples The following code example demonstrates the implementation of a case-insensitive . In this example, the method returns the hash code provided by the type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/CPP/hashtable_ctor.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Hashtable/.ctor/hashtable_ctor.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.Hashtable_ctor/VB/hashtable_ctor.vb" id="Snippet2"::: diff --git a/xml/System.Collections/Queue.xml b/xml/System.Collections/Queue.xml index 647d43ec630..0aaa43694a5 100644 --- a/xml/System.Collections/Queue.xml +++ b/xml/System.Collections/Queue.xml @@ -84,48 +84,47 @@ Represents a first-in, first-out collection of objects. - are inserted at one end and removed from the other. +This class implements a queue as a circular array. Objects stored in a are inserted at one end and removed from the other. > [!IMPORTANT] > We don't recommend that you use the `Queue` class for new development. Instead, we recommend that you use the generic class. For more information, see [Non-generic collections shouldn't be used](https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md) on GitHub. - Queues and stacks are useful when you need temporary storage for information; that is, when you might want to discard an element after retrieving its value. Use if you need to access the information in the same order that it is stored in the collection. Use if you need to access the information in reverse order. Use or if you need to access the collection from multiple threads concurrently. - - Three main operations can be performed on a and its elements: - -- adds an element to the end of the . - -- removes the oldest element from the start of the . - -- returns the oldest element that is at the start of the but does not remove it from the . - - The capacity of a is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . - - The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. The default growth factor is 2.0. The capacity of the will always increase by at least a minimum of four, regardless of the growth factor. For example, a with a growth factor of 1.0 will always increase in capacity by four when a greater capacity is required. - - accepts `null` as a valid value and allows duplicate elements. - - For the generic version of this collection, see - - - -## Examples - The following example shows how to create and add values to a and how to print out its values. + Queues and stacks are useful when you need temporary storage for information; that is, when you might want to discard an element after retrieving its value. Use if you need to access the information in the same order that it is stored in the collection. Use if you need to access the information in reverse order. Use or if you need to access the collection from multiple threads concurrently. + + Three main operations can be performed on a and its elements: + +- adds an element to the end of the . + +- removes the oldest element from the start of the . + +- returns the oldest element that is at the start of the but does not remove it from the . + + The capacity of a is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . + + The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. The default growth factor is 2.0. The capacity of the will always increase by at least a minimum of four, regardless of the growth factor. For example, a with a growth factor of 1.0 will always increase in capacity by four when a greater capacity is required. + + accepts `null` as a valid value and allows duplicate elements. + + For the generic version of this collection, see + + + +## Examples + The following example shows how to create and add values to a and how to print out its values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue Example/VB/source.vb" id="Snippet1"::: + ]]> - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - - To guarantee the thread safety of the , all operations must be done through the wrapper returned by the method. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + + To guarantee the thread safety of the , all operations must be done through the wrapper returned by the method. + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. @@ -177,15 +176,15 @@ This class implements a queue as a circular array. Objects stored in a Initializes a new instance of the class that is empty, has the default initial capacity, and uses the default growth factor. - is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . - - The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. - - This constructor is an `O(1)` operation. - + is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . + + The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. + + This constructor is an `O(1)` operation. + ]]> @@ -231,17 +230,17 @@ This class implements a queue as a circular array. Objects stored in a The to copy elements from. Initializes a new instance of the class that contains elements copied from the specified collection, has the same initial capacity as the number of elements copied, and uses the default growth factor. - is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . - - The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. - - The elements are copied onto the in the same order they are read by the of the . - - This constructor is an `O(n)` operation, where `n` is the number of elements in `col`. - + is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . + + The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. + + The elements are copied onto the in the same order they are read by the of the . + + This constructor is an `O(n)` operation, where `n` is the number of elements in `col`. + ]]> @@ -290,17 +289,17 @@ This class implements a queue as a circular array. Objects stored in a The initial number of elements that the can contain. Initializes a new instance of the class that is empty, has the specified initial capacity, and uses the default growth factor. - is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . - - The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . - - This constructor is an `O(n)` operation, where `n` is `capacity`. - + is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . + + The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . + + This constructor is an `O(n)` operation, where `n` is `capacity`. + ]]> @@ -350,24 +349,24 @@ This class implements a queue as a circular array. Objects stored in a The factor by which the capacity of the is expanded. Initializes a new instance of the class that is empty, has the specified initial capacity, and uses the specified growth factor. - is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . - - The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. The capacity of the will always increase by a minimum value, regardless of the growth factor; a growth factor of 1.0 will not prevent the from increasing in size. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . - - This constructor is an `O(n)` operation, where `n` is `capacity`. - + is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . + + The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. The capacity of the will always increase by a minimum value, regardless of the growth factor; a growth factor of 1.0 will not prevent the from increasing in size. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . + + This constructor is an `O(n)` operation, where `n` is `capacity`. + ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + is less than 1.0 or greater than 10.0. @@ -412,24 +411,23 @@ This class implements a queue as a circular array. Objects stored in a Removes all objects from the . - is set to zero, and references to other objects from elements of the collection are also released. - - The capacity remains unchanged. To reset the capacity of the , call . Trimming an empty sets the capacity of the to the default capacity. - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following example shows how to clear the values of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Clear Example/CPP/source.cpp" id="Snippet1"::: + is set to zero, and references to other objects from elements of the collection are also released. + + The capacity remains unchanged. To reset the capacity of the , call . Trimming an empty sets the capacity of the to the default capacity. + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following example shows how to clear the values of the . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/Clear/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.Clear Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.Clear Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -480,15 +478,15 @@ This class implements a queue as a circular array. Objects stored in a Creates a shallow copy of the . A shallow copy of the . - . - + . + ]]> @@ -540,15 +538,15 @@ This class implements a queue as a circular array. Objects stored in a if is found in the ; otherwise, . - . - - This method performs a linear search; therefore, this method is an `O(n)` operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `obj` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `obj` parameter on the objects in the collection. - + . + + This method performs a linear search; therefore, this method is an `O(n)` operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `obj` to determine whether `item` exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `obj` parameter on the objects in the collection. + ]]> Performing Culture-Insensitive String Operations @@ -603,22 +601,21 @@ This class implements a queue as a circular array. Objects stored in a The zero-based index in at which copying begins. Copies the elements to an existing one-dimensional , starting at the specified array index. - in the same order in which the enumerator iterates through the . - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following example shows how to copy a into a one-dimensional array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/CPP/source.cpp" id="Snippet1"::: + in the same order in which the enumerator iterates through the . + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following example shows how to copy a into a one-dimensional array. + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/CopyTo/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -626,10 +623,10 @@ This class implements a queue as a circular array. Objects stored in a is less than zero. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source is greater than the available space from to the end of the destination . The type of the source cannot be cast automatically to the type of the destination . @@ -678,17 +675,17 @@ This class implements a queue as a circular array. Objects stored in a Gets the number of elements contained in the . The number of elements contained in the . - is the number of elements that the can store. is the number of elements that are actually in the . - - The capacity of a is always greater than or equal to . If exceeds the capacity while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements. The new capacity is determined by multiplying the current capacity by the growth factor, which is determined when the is constructed. The capacity of the will always increase by a minimum value, regardless of the growth factor; a growth factor of 1.0 will not prevent the from increasing in size. - - The capacity can be decreased by calling . - - Retrieving the value of this property is an `O(1)` operation. - + is the number of elements that the can store. is the number of elements that are actually in the . + + The capacity of a is always greater than or equal to . If exceeds the capacity while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements. The new capacity is determined by multiplying the current capacity by the growth factor, which is determined when the is constructed. The capacity of the will always increase by a minimum value, regardless of the growth factor; a growth factor of 1.0 will not prevent the from increasing in size. + + The capacity can be decreased by calling . + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -736,24 +733,23 @@ This class implements a queue as a circular array. Objects stored in a Removes and returns the object at the beginning of the . The object that is removed from the beginning of the . - method, but does not modify the . - - `null` can be added to the as a value. To distinguish between a null value and the end of the , check the property or catch the , which is thrown when the is empty. - - This method is an `O(1)` operation. - - - -## Examples - The following example shows how to add elements to the , remove elements from the , or view the element at the beginning of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/CPP/source.cpp" id="Snippet1"::: + method, but does not modify the . + + `null` can be added to the as a value. To distinguish between a null value and the end of the , check the property or catch the , which is thrown when the is empty. + + This method is an `O(1)` operation. + + + +## Examples + The following example shows how to add elements to the , remove elements from the , or view the element at the beginning of the . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/Dequeue/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/VB/source.vb" id="Snippet1"::: + ]]> The is empty. @@ -806,24 +802,23 @@ This class implements a queue as a circular array. Objects stored in a The object to add to the . The value can be . Adds an object to the end of the . - is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . - - The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. The capacity of the will always increase by a minimum value, regardless of the growth factor; a growth factor of 1.0 will not prevent the from increasing in size. - - If is less than the capacity of the internal array, this method is an `O(1)` operation. If the internal array needs to be reallocated to accommodate the new element, this method becomes an `O(n)` operation, where `n` is . - - - -## Examples - The following example shows how to add elements to the , remove elements from the , or view the element at the beginning of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/CPP/source.cpp" id="Snippet1"::: + is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling . + + The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the is constructed. The capacity of the will always increase by a minimum value, regardless of the growth factor; a growth factor of 1.0 will not prevent the from increasing in size. + + If is less than the capacity of the internal array, this method is an `O(1)` operation. If the internal array needs to be reallocated to accommodate the new element, this method becomes an `O(n)` operation, where `n` is . + + + +## Examples + The following example shows how to add elements to the , remove elements from the , or view the element at the beginning of the . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/Dequeue/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -875,25 +870,25 @@ This class implements a queue as a circular array. Objects stored in a Returns an enumerator that iterates through the . An for the . - also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - - This method is an `O(1)` operation. - + also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. + + This method is an `O(1)` operation. + ]]> @@ -944,28 +939,26 @@ This class implements a queue as a circular array. Objects stored in a if access to the is synchronized (thread safe); otherwise, . The default is . - , all operations must be done through the wrapper returned by the method. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the during the entire enumeration. Retrieving the value of this property is an `O(1)` operation. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: + , all operations must be done through the wrapper returned by the method. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the during the entire enumeration. Retrieving the value of this property is an `O(1)` operation. + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/IsSynchronized/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: - - The following example shows how to synchronize a , determine if a is synchronized, and use a synchronized . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: + + The following example shows how to synchronize a , determine if a is synchronized, and use a synchronized . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/IsSynchronized/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1015,24 +1008,23 @@ This class implements a queue as a circular array. Objects stored in a Returns the object at the beginning of the without removing it. The object at the beginning of the . - method, but does not modify the . - - `null` can be added to the as a value. To distinguish between a null value and the end of the , check the property or catch the , which is thrown when the is empty. - - This method is an `O(1)` operation. - - - -## Examples - The following example shows how to add elements to the , remove elements from the , or view the element at the beginning of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/CPP/source.cpp" id="Snippet1"::: + method, but does not modify the . + + `null` can be added to the as a value. To distinguish between a null value and the end of the , check the property or catch the , which is thrown when the is empty. + + This method is an `O(1)` operation. + + + +## Examples + The following example shows how to add elements to the , remove elements from the , or view the element at the beginning of the . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/Dequeue/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.Enqueue Example/VB/source.vb" id="Snippet1"::: + ]]> The is empty. @@ -1085,30 +1077,28 @@ This class implements a queue as a circular array. Objects stored in a Returns a new that wraps the original queue, and is thread safe. A wrapper that is synchronized (thread safe). - , all operations must be done through this wrapper only. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the during the entire enumeration. This method is an `O(1)` operation. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: + , all operations must be done through this wrapper only. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the during the entire enumeration. This method is an `O(1)` operation. + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/IsSynchronized/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: - - The following example shows how to synchronize a , determine if a is synchronized and use a synchronized . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: + + The following example shows how to synchronize a , determine if a is synchronized and use a synchronized . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/IsSynchronized/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1161,22 +1151,21 @@ This class implements a queue as a circular array. Objects stored in a Gets an object that can be used to synchronize access to the . An object that can be used to synchronize access to the . - , use the method. However, derived classes can provide their own synchronized version of the using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the during the entire enumeration. Retrieving the value of this property is an `O(1)` operation. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: + , use the method. However, derived classes can provide their own synchronized version of the using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the during the entire enumeration. Retrieving the value of this property is an `O(1)` operation. + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/IsSynchronized/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: + ]]> @@ -1226,22 +1215,21 @@ This class implements a queue as a circular array. Objects stored in a Copies the elements to a new array. A new array containing elements copied from the . - is not modified. The order of the elements in the new array is the same as the order of the elements from the beginning of the to its end. - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following example shows how to copy a into a one-dimensional array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/CPP/source.cpp" id="Snippet1"::: + is not modified. The order of the elements in the new array is the same as the order of the elements from the beginning of the to its end. + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following example shows how to copy a into a one-dimensional array. + :::code language="csharp" source="~/snippets/csharp/System.Collections/Queue/CopyTo/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Queue.CopyTo Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1287,15 +1275,15 @@ This class implements a queue as a circular array. Objects stored in a Sets the capacity to the actual number of elements in the . - to its initial state, call the method before calling . Trimming an empty sets the capacity of the to the default capacity. - - This method is an `O(n)` operation, where `n` is . - + to its initial state, call the method before calling . Trimming an empty sets the capacity of the to the default capacity. + + This method is an `O(n)` operation, where `n` is . + ]]> The is read-only. diff --git a/xml/System.Collections/ReadOnlyCollectionBase.xml b/xml/System.Collections/ReadOnlyCollectionBase.xml index 56253b9f802..f40aa9aab08 100644 --- a/xml/System.Collections/ReadOnlyCollectionBase.xml +++ b/xml/System.Collections/ReadOnlyCollectionBase.xml @@ -68,33 +68,32 @@ Provides the base class for a strongly typed non-generic read-only collection. - instance is always read-only. See for a modifiable version of this class. +A instance is always read-only. See for a modifiable version of this class. > [!IMPORTANT] > We don't recommend that you use the `ReadOnlyCollectionBase` class for new development. Instead, we recommend that you use the generic class. For more information, see [Non-generic collections shouldn't be used](https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md) on GitHub. -## Examples - The following code example implements the class. +## Examples + The following code example implements the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/readonlycollectionbase.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/ReadOnlyCollectionBase/Overview/readonlycollectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/readonlycollectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/readonlycollectionbase.vb" id="Snippet1"::: + ]]> - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - - This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + + This implementation does not provide a synchronized (thread safe) wrapper for a , but derived classes can create their own synchronized versions of the using the property. + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - This base class is provided to make it easier for implementers to create a strongly typed read-only custom collection. Implementers are encouraged to extend this base class instead of creating their own. Members of this base class are protected and are intended to be used through a derived class only. - + This base class is provided to make it easier for implementers to create a strongly typed read-only custom collection. Implementers are encouraged to extend this base class instead of creating their own. Members of this base class are protected and are intended to be used through a derived class only. + This class makes the underlying collection available through the property, which is intended for use only by classes that are derived directly from . The derived class must ensure that its own users cannot modify the underlying collection. @@ -139,11 +138,11 @@ A instance is always read-only. Initializes a new instance of the class. - @@ -195,15 +194,14 @@ A instance is always read-only. Gets the number of elements contained in the instance. The number of elements contained in the instance. Retrieving the value of this property is an O(1) operation. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/readonlycollectionbase.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/ReadOnlyCollectionBase/Overview/readonlycollectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/readonlycollectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/readonlycollectionbase.vb" id="Snippet1"::: + ]]> @@ -255,34 +253,33 @@ A instance is always read-only. Returns an enumerator that iterates through the instance. An for the instance. - also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - - This method is an `O(1)` operation. - - - -## Examples - The following code example implements the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/readonlycollectionbase.cpp" id="Snippet1"::: + also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. + + This method is an `O(1)` operation. + + + +## Examples + The following code example implements the class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/ReadOnlyCollectionBase/Overview/readonlycollectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/readonlycollectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/readonlycollectionbase.vb" id="Snippet1"::: + ]]> @@ -329,20 +326,19 @@ A instance is always read-only. Gets the list of elements contained in the instance. An representing the instance itself. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/readonlycollectionbase.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Collections/ReadOnlyCollectionBase/Overview/readonlycollectionbase.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/readonlycollectionbase.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/readonlycollectionbase.vb" id="Snippet1"::: + ]]> @@ -399,15 +395,15 @@ A instance is always read-only. The zero-based index in at which copying begins. Copies the entire to a compatible one-dimensional , starting at the specified index of the target array. - to copy the elements. - - This method is an `O(n)` operation, where `n` is . - + to copy the elements. + + This method is an `O(n)` operation, where `n` is . + ]]> @@ -415,10 +411,10 @@ A instance is always read-only. is less than zero. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source is greater than the available space from to the end of the destination . The type of the source cannot be cast automatically to the type of the destination . @@ -468,24 +464,23 @@ A instance is always read-only. if access to the object is synchronized (thread safe); otherwise, . The default is . - object is not synchronized. Derived classes can provide a synchronized version of the class using the property. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the property during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/source2.cpp" id="Snippet2"::: + object is not synchronized. Derived classes can provide a synchronized version of the class using the property. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the property during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/ReadOnlyCollectionBase/Overview/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/source2.vb" id="Snippet2"::: - - Retrieving the value of this property is an `O(1)` operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/source2.vb" id="Snippet2"::: + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -535,24 +530,23 @@ A instance is always read-only. Gets an object that can be used to synchronize access to a object. An object that can be used to synchronize access to the object. - class using the property. The synchronizing code must perform operations on the property of the object, not directly on the object. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the property during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/CPP/source2.cpp" id="Snippet2"::: + class using the property. The synchronizing code must perform operations on the property of the object, not directly on the object. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the property during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/ReadOnlyCollectionBase/Overview/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/source2.vb" id="Snippet2"::: - - Retrieving the value of this property is an `O(1)` operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.ReadOnlyCollectionBase/VB/source2.vb" id="Snippet2"::: + + Retrieving the value of this property is an `O(1)` operation. + ]]> diff --git a/xml/System.Collections/SortedList.xml b/xml/System.Collections/SortedList.xml index d0266aa1be2..c37013f9805 100644 --- a/xml/System.Collections/SortedList.xml +++ b/xml/System.Collections/SortedList.xml @@ -88,52 +88,50 @@ Represents a collection of key/value pairs that are sorted by the keys and are accessible by key and by index. - element can be accessed by its key, like an element in any implementation, or by its index, like an element in any implementation. +A element can be accessed by its key, like an element in any implementation, or by its index, like an element in any implementation. > [!IMPORTANT] > We don't recommend that you use the `SortedList` class for new development. Instead, we recommend that you use the generic class. For more information, see [Non-generic collections shouldn't be used](https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md) on GitHub. - A object internally maintains two arrays to store the elements of the list; that is, one array for the keys and another array for the associated values. Each element is a key/value pair that can be accessed as a object. A key cannot be `null`, but a value can be. - - The capacity of a object is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling or by setting the property explicitly. - - **.NET Framework only:** For very large objects, you can increase the maximum capacity to 2 billion elements on a 64-bit system by setting the `enabled` attribute of the [``](/dotnet/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element) configuration element to `true` in the run-time environment. - - The elements of a object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. In either case, a does not allow duplicate keys. - - The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. - - Operations on a object tend to be slower than operations on a object because of the sorting. However, the offers more flexibility by allowing access to the values either through the associated keys or through the indexes. - - Elements in this collection can be accessed using an integer index. Indexes in this collection are zero-based. - - The `foreach` statement of the C# language (`for each` in Visual Basic) returns an object of the type of the elements in the collection. Since each element of the object is a key/value pair, the element type is not the type of the key or the type of the value. Rather, the element type is . For example: + A object internally maintains two arrays to store the elements of the list; that is, one array for the keys and another array for the associated values. Each element is a key/value pair that can be accessed as a object. A key cannot be `null`, but a value can be. + + The capacity of a object is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling or by setting the property explicitly. + + **.NET Framework only:** For very large objects, you can increase the maximum capacity to 2 billion elements on a 64-bit system by setting the `enabled` attribute of the [``](/dotnet/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element) configuration element to `true` in the run-time environment. + + The elements of a object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. In either case, a does not allow duplicate keys. + + The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. + + Operations on a object tend to be slower than operations on a object because of the sorting. However, the offers more flexibility by allowing access to the values either through the associated keys or through the indexes. + + Elements in this collection can be accessed using an integer index. Indexes in this collection are zero-based. + + The `foreach` statement of the C# language (`for each` in Visual Basic) returns an object of the type of the elements in the collection. Since each element of the object is a key/value pair, the element type is not the type of the key or the type of the value. Rather, the element type is . For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/remarks.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/Overview/remarks.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList Example/VB/remarks.vb" id="Snippet2"::: - - The `foreach` statement is a wrapper around the enumerator, which allows only reading from, not writing to, the collection. - - - -## Examples - The following code example shows how to create and initialize a object and how to print out its keys and values. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList Example/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList Example/VB/remarks.vb" id="Snippet2"::: + + The `foreach` statement is a wrapper around the enumerator, which allows only reading from, not writing to, the collection. + + + +## Examples + The following code example shows how to create and initialize a object and how to print out its keys and values. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList Example/VB/source.vb" id="Snippet1"::: + ]]> - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - - A object can support multiple readers concurrently, as long as the collection is not modified. To guarantee the thread safety of the , all operations must be done through the wrapper returned by the method. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + + A object can support multiple readers concurrently, as long as the collection is not modified. To guarantee the thread safety of the , all operations must be done through the wrapper returned by the method. + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. @@ -190,26 +188,25 @@ A element can be accessed by its key, like Initializes a new instance of the class that is empty, has the default initial capacity, and is sorted according to the interface implemented by each key added to the object. - interface to be capable of comparisons with every other key in the object. The elements are sorted according to the implementation of each key added to the . - - The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. - - This constructor is an `O(1)` operation. - - - -## Examples - The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/CPP/sortedlist_ctor.cpp" id="Snippet1"::: + interface to be capable of comparisons with every other key in the object. The elements are sorted according to the implementation of each key added to the . + + The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. + + This constructor is an `O(1)` operation. + + + +## Examples + The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/.ctor/sortedlist_ctor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/VB/sortedlist_ctor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/VB/sortedlist_ctor.vb" id="Snippet1"::: + ]]> @@ -256,33 +253,32 @@ A element can be accessed by its key, like - The implementation to use when comparing keys. - - -or- - + The implementation to use when comparing keys. + + -or- + to use the implementation of each key. Initializes a new instance of the class that is empty, has the default initial capacity, and is sorted according to the specified interface. - implementation. If the `comparer` parameter is `null`, the implementation of each key is used; therefore, each key must implement the interface to be capable of comparisons with every other key in the object. - - The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. - - This constructor is an `O(1)` operation. - - - -## Examples - The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/CPP/sortedlist_ctor.cpp" id="Snippet1"::: + implementation. If the `comparer` parameter is `null`, the implementation of each key is used; therefore, each key must implement the interface to be capable of comparisons with every other key in the object. + + The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. + + This constructor is an `O(1)` operation. + + + +## Examples + The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/.ctor/sortedlist_ctor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/VB/sortedlist_ctor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctor/VB/sortedlist_ctor.vb" id="Snippet1"::: + ]]> @@ -332,28 +328,27 @@ A element can be accessed by its key, like The implementation to copy to a new object. Initializes a new instance of the class that contains elements copied from the specified dictionary, has the same initial capacity as the number of elements copied, and is sorted according to the interface implemented by each key. - interface to be capable of comparisons with every other key in the object. The elements are sorted according to the implementation of each key added to the . - - A object is an example of an implementation that can be passed to this constructor. The new object contains a copy of the keys and values stored in the . - - The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. - - This constructor is an `O(n)` operation, where `n` is the number of elements in `d`. - - - -## Examples - The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/CPP/sortedlist_ctordictionary.cpp" id="Snippet1"::: + interface to be capable of comparisons with every other key in the object. The elements are sorted according to the implementation of each key added to the . + + A object is an example of an implementation that can be passed to this constructor. The new object contains a copy of the keys and values stored in the . + + The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. + + This constructor is an `O(n)` operation, where `n` is the number of elements in `d`. + + + +## Examples + The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/.ctor/sortedlist_ctordictionary.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/VB/sortedlist_ctordictionary.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/VB/sortedlist_ctordictionary.vb" id="Snippet1"::: + ]]> @@ -407,26 +402,25 @@ A element can be accessed by its key, like The initial number of elements that the object can contain. Initializes a new instance of the class that is empty, has the specified initial capacity, and is sorted according to the interface implemented by each key added to the object. - interface to be capable of comparisons with every other key in the object. The elements are sorted according to the implementation of each key added to the . - - The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. - - This constructor is an `O(n)` operation, where `n` is `initialCapacity`. - - - -## Examples - The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/CPP/sortedlist_ctorint.cpp" id="Snippet1"::: + interface to be capable of comparisons with every other key in the object. The elements are sorted according to the implementation of each key added to the . + + The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. + + This constructor is an `O(n)` operation, where `n` is `initialCapacity`. + + + +## Examples + The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/.ctor/sortedlist_ctorint.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/VB/sortedlist_ctorint.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/VB/sortedlist_ctorint.vb" id="Snippet1"::: + ]]> @@ -477,34 +471,33 @@ A element can be accessed by its key, like - The implementation to use when comparing keys. - - -or- - + The implementation to use when comparing keys. + + -or- + to use the implementation of each key. The initial number of elements that the object can contain. Initializes a new instance of the class that is empty, has the specified initial capacity, and is sorted according to the specified interface. - implementation. If the `comparer` parameter is `null`, the implementation of each key is used; therefore, each key must implement the interface to be capable of comparisons with every other key in the object. - - The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. - - This constructor is an `O(n)` operation, where `n` is `capacity`. - - - -## Examples - The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/CPP/sortedlist_ctorint.cpp" id="Snippet1"::: + implementation. If the `comparer` parameter is `null`, the implementation of each key is used; therefore, each key must implement the interface to be capable of comparisons with every other key in the object. + + The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. + + This constructor is an `O(n)` operation, where `n` is `capacity`. + + + +## Examples + The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/.ctor/sortedlist_ctorint.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/VB/sortedlist_ctorint.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctorInt/VB/sortedlist_ctorint.vb" id="Snippet1"::: + ]]> @@ -564,35 +557,34 @@ A element can be accessed by its key, like The implementation to copy to a new object. - The implementation to use when comparing keys. - - -or- - + The implementation to use when comparing keys. + + -or- + to use the implementation of each key. Initializes a new instance of the class that contains elements copied from the specified dictionary, has the same initial capacity as the number of elements copied, and is sorted according to the specified interface. - implementation. If the `comparer` parameter is `null`, the implementation of each key is used; therefore, each key must implement the interface to be capable of comparisons with every other key in the object. - - A object is an example of an implementation that can be passed to this constructor. The new object contains a copy of the keys and values stored in the . - - The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. - - This constructor is an `O(n)` operation, where `n` is the number of elements in `d`. - - - -## Examples - The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/CPP/sortedlist_ctordictionary.cpp" id="Snippet1"::: + implementation. If the `comparer` parameter is `null`, the implementation of each key is used; therefore, each key must implement the interface to be capable of comparisons with every other key in the object. + + A object is an example of an implementation that can be passed to this constructor. The new object contains a copy of the keys and values stored in the . + + The capacity of a object is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the object. + + This constructor is an `O(n)` operation, where `n` is the number of elements in `d`. + + + +## Examples + The following code example creates collections using different constructors and demonstrates the differences in the behavior of the collections. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/.ctor/sortedlist_ctordictionary.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/VB/sortedlist_ctordictionary.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Collections.SortedList_ctorDictionary/VB/sortedlist_ctordictionary.vb" id="Snippet1"::: + ]]> @@ -664,43 +656,42 @@ A element can be accessed by its key, like The value of the element to add. The value can be . Adds an element with the specified key and value to a object. - object was created. - - If already equals , the capacity of the object is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added. - - You can also use the property to add new elements by setting the value of a key that does not exist in the object (for example, `myCollection["myNonexistentKey"] = myValue`). However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. - - The elements of a object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. - - A key cannot be `null`, but a value can be. - - This method is an `O(n)` operation for unsorted data, where `n` is . It is an `O(log n)` operation if the new element is added at the end of the list. If insertion causes a resize, the operation is `O(n)`. - - - -## Examples - The following code example shows how to add elements to a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Add Example/CPP/source.cpp" id="Snippet1"::: + object was created. + + If already equals , the capacity of the object is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added. + + You can also use the property to add new elements by setting the value of a key that does not exist in the object (for example, `myCollection["myNonexistentKey"] = myValue`). However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. + + The elements of a object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. + + A key cannot be `null`, but a value can be. + + This method is an `O(n)` operation for unsorted data, where `n` is . It is an `O(log n)` operation if the new element is added at the end of the list. If insertion causes a resize, the operation is `O(n)`. + + + +## Examples + The following code example shows how to add elements to a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/Add/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Add Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Add Example/VB/source.vb" id="Snippet1"::: + ]]> is . - An element with the specified already exists in the object. - - -or- - + An element with the specified already exists in the object. + + -or- + The is set to use the interface, and does not implement the interface. - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. There is not enough available memory to add the element to the . The comparer throws an exception. @@ -751,17 +742,17 @@ A element can be accessed by its key, like Gets or sets the capacity of a object. The number of elements that the object can contain. - is the number of elements that the object can store. is the number of elements that are actually in the . - - is always greater than or equal to . If exceeds while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements. - - The capacity can be decreased by calling or by setting the property explicitly. When the value of is set explicitly, the internal array is also reallocated to accommodate the specified capacity. - - Retrieving the value of this property is an `O(1)` operation; setting the property is an `O(n)` operation, where `n` is the new capacity. - + is the number of elements that the object can store. is the number of elements that are actually in the . + + is always greater than or equal to . If exceeds while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements. + + The capacity can be decreased by calling or by setting the property explicitly. When the value of is set explicitly, the internal array is also reallocated to accommodate the specified capacity. + + Retrieving the value of this property is an `O(1)` operation; setting the property is an `O(n)` operation, where `n` is the new capacity. + ]]> The value assigned is less than the current number of elements in the object. @@ -813,30 +804,29 @@ A element can be accessed by its key, like Removes all elements from a object. - is set to zero and references to other objects from elements of the collection are also released. - - remains unchanged. To reset the capacity of the object, call or set the property directly. Trimming an empty sets the capacity of the to the default capacity. - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following code example shows how to trim the unused portions of a object and how to clear the values of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/CPP/source.cpp" id="Snippet1"::: + is set to zero and references to other objects from elements of the collection are also released. + + remains unchanged. To reset the capacity of the object, call or set the property directly. Trimming an empty sets the capacity of the to the default capacity. + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following code example shows how to trim the unused portions of a object and how to clear the values of the . + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/Clear/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/VB/source.vb" id="Snippet1"::: + ]]> - The object is read-only. - - -or- - + The object is read-only. + + -or- + The has a fixed size. @@ -888,15 +878,15 @@ A element can be accessed by its key, like Creates a shallow copy of a object. A shallow copy of the object. - . - + . + ]]> @@ -951,26 +941,25 @@ A element can be accessed by its key, like if the object contains an element with the specified ; otherwise, . - object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. - - implements . It behaves exactly as . - - This method uses a binary search algorithm; therefore, this method is an `O(log n)` operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example shows how to determine whether a object contains a specific element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/CPP/source.cpp" id="Snippet1"::: + object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. + + implements . It behaves exactly as . + + This method uses a binary search algorithm; therefore, this method is an `O(log n)` operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example shows how to determine whether a object contains a specific element. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/Contains/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1027,26 +1016,25 @@ A element can be accessed by its key, like if the object contains an element with the specified ; otherwise, . - object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. - - This method behaves exactly as the method. - - This method uses a binary search algorithm; therefore, this method is an `O(log n)` operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example shows how to determine whether a object contains a specific element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/CPP/source.cpp" id="Snippet1"::: + object are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. + + This method behaves exactly as the method. + + This method uses a binary search algorithm; therefore, this method is an `O(log n)` operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example shows how to determine whether a object contains a specific element. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/Contains/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1105,24 +1093,23 @@ A element can be accessed by its key, like if the object contains an element with the specified ; otherwise, . - object are compared to the specified value using the method. - - This method performs a linear search; therefore, the average execution time is proportional to . That is, this method is an `O(n)` operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example shows how to determine whether a object contains a specific element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/CPP/source.cpp" id="Snippet1"::: + object are compared to the specified value using the method. + + This method performs a linear search; therefore, the average execution time is proportional to . That is, this method is an `O(n)` operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example shows how to determine whether a object contains a specific element. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/Contains/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Contains Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1179,26 +1166,25 @@ A element can be accessed by its key, like The zero-based index in at which copying begins. Copies elements to a one-dimensional object, starting at the specified index in the array. - object in the same order in which the enumerator iterates through the object. - - To copy only the keys in the , use `SortedList.Keys.CopyTo`. - - To copy only the values in the , use `SortedList.Values.CopyTo`. - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following code example shows how to copy the values in a object into a one-dimensional object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.CopyTo Example/CPP/source.cpp" id="Snippet1"::: + object in the same order in which the enumerator iterates through the object. + + To copy only the keys in the , use `SortedList.Keys.CopyTo`. + + To copy only the values in the , use `SortedList.Values.CopyTo`. + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following code example shows how to copy the values in a object into a one-dimensional object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/CopyTo/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.CopyTo Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.CopyTo Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1206,10 +1192,10 @@ A element can be accessed by its key, like is less than zero. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source object is greater than the available space from to the end of the destination . The type of the source cannot be cast automatically to the type of the destination . @@ -1261,17 +1247,17 @@ A element can be accessed by its key, like Gets the number of elements contained in a object. The number of elements contained in the object. - object. - - is the number of elements that the object can store. is the number of elements that are actually in the . - - is always greater than or equal to . If exceeds while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements. - - Retrieving the value of this property is an `O(1)` operation. - + object. + + is the number of elements that the object can store. is the number of elements that are actually in the . + + is always greater than or equal to . If exceeds while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements. + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -1323,22 +1309,21 @@ A element can be accessed by its key, like Gets the value at the specified index of a object. The value at the specified index of the object. - in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. - - This method is an `O(1)` operation. - - - -## Examples - The following code example shows how to get one or all the keys or values in a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp" id="Snippet1"::: + in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. + + This method is an `O(1)` operation. + + + +## Examples + The following code example shows how to get one or all the keys or values in a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/GetByIndex/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1392,25 +1377,25 @@ A element can be accessed by its key, like Returns an object that iterates through a object. An object for the object. - also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - - This method is an `O(1)` operation. - + also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. + + This method is an `O(1)` operation. + ]]> @@ -1462,22 +1447,21 @@ A element can be accessed by its key, like Gets the key at the specified index of a object. The key at the specified index of the object. - in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. - - This method is an `O(1)` operation. - - - -## Examples - The following code example shows how to get one or all the keys or values in a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp" id="Snippet1"::: + in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. + + This method is an `O(1)` operation. + + + +## Examples + The following code example shows how to get one or all the keys or values in a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/GetByIndex/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1526,26 +1510,25 @@ A element can be accessed by its key, like Gets the keys in a object. An object containing the keys in the object. - object is a read-only view of the keys of the object. Modifications made to the underlying are immediately reflected in the . - - The elements of the returned are sorted in the same order as the keys of the . - - This method is similar to the property, but returns an object instead of an object. - - This method is an `O(1)` operation. - - - -## Examples - The following code example shows how to get one or all the keys or values in a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp" id="Snippet1"::: + object is a read-only view of the keys of the object. Modifications made to the underlying are immediately reflected in the . + + The elements of the returned are sorted in the same order as the keys of the . + + This method is similar to the property, but returns an object instead of an object. + + This method is an `O(1)` operation. + + + +## Examples + The following code example shows how to get one or all the keys or values in a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/GetByIndex/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1595,26 +1578,25 @@ A element can be accessed by its key, like Gets the values in a object. An object containing the values in the object. - object is a read-only view of the values of the object. Modifications made to the underlying are immediately reflected in the . - - The elements of the returned are sorted in the same order as the values of the . - - This method is similar to the property, but returns an object instead of an object. - - This method is an `O(1)` operation. - - - -## Examples - The following code example shows how to get one or all the keys or values in a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/CPP/source.cpp" id="Snippet1"::: + object is a read-only view of the values of the object. Modifications made to the underlying are immediately reflected in the . + + The elements of the returned are sorted in the same order as the values of the . + + This method is similar to the property, but returns an object instead of an object. + + This method is an `O(1)` operation. + + + +## Examples + The following code example shows how to get one or all the keys or values in a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/GetByIndex/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.GetByIndex Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1667,26 +1649,25 @@ A element can be accessed by its key, like Returns the zero-based index of the specified key in a object. The zero-based index of the parameter, if is found in the object; otherwise, -1. - object are sorted by the keys either according to a specific implementation specified when the is created, or according to the implementation provided by the keys themselves. - - The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the . - - This method uses a binary search algorithm; therefore, this method is an `O(log n)` operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example shows how to determine the index of a key or a value in a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/CPP/source.cpp" id="Snippet1"::: + object are sorted by the keys either according to a specific implementation specified when the is created, or according to the implementation provided by the keys themselves. + + The index sequence is based on the sort sequence. When an element is added, it is inserted into in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the . + + This method uses a binary search algorithm; therefore, this method is an `O(log n)` operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example shows how to determine the index of a key or a value in a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/IndexOfKey/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1743,26 +1724,25 @@ A element can be accessed by its key, like Returns the zero-based index of the first occurrence of the specified value in a object. The zero-based index of the first occurrence of the parameter, if is found in the object; otherwise, -1. - in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. - - The values of the elements of the are compared to the specified value using the method. - - This method uses a linear search; therefore, this method is an `O(n)` operation, where `n` is . - - Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. - - - -## Examples - The following code example shows how to determine the index of a key or a value in a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/CPP/source.cpp" id="Snippet1"::: + in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. + + The values of the elements of the are compared to the specified value using the method. + + This method uses a linear search; therefore, this method is an `O(n)` operation, where `n` is . + + Starting with the .NET Framework 2.0, this method uses the collection's objects' and methods on `item` to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the and methods of the `item` parameter on the objects in the collection. + + + +## Examples + The following code example shows how to determine the index of a key or a value in a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/IndexOfKey/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IndexOfKey Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1815,15 +1795,15 @@ A element can be accessed by its key, like if the object has a fixed size; otherwise, . The default is . - @@ -1873,15 +1853,15 @@ A element can be accessed by its key, like if the object is read-only; otherwise, . The default is . - @@ -1931,30 +1911,28 @@ A element can be accessed by its key, like if access to the object is synchronized (thread safe); otherwise, . The default is . - object, all operations must be done through the wrapper returned by the method. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock a collection using the property during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: + object, all operations must be done through the wrapper returned by the method. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock a collection using the property during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/IsSynchronized/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: - - Retrieving the value of this property is an `O(1)` operation. - - The following code example shows how to synchronize a object, determine whether a is synchronized, and use a synchronized . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: + + Retrieving the value of this property is an `O(1)` operation. + + The following code example shows how to synchronize a object, determine whether a is synchronized, and use a synchronized . + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/IsSynchronized/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2016,29 +1994,29 @@ A element can be accessed by its key, like Gets or sets the value associated with a specific key in a object. The value associated with the parameter in the object, if is found; otherwise, . - property to access a specific element in a collection by specifying the following syntax: `myCollection[key]`. - - You can also use this property to add new elements by setting the value of a key that does not exist in the object (for example, `myCollection["myNonexistentKey"] = myValue)`. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. - - A key cannot be `null`, but a value can be. To distinguish between `null` that is returned because the specified key is not found and `null` that is returned because the value of the specified key is `null`, use the method or the method to determine if the key exists in the list. - - The elements of a are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. - - The C# language uses the [`this`](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a default property, which provides the same indexing functionality. - - Retrieving the value of this property is an `O(log n)` operation, where `n` is . Setting the property is an `O(log n)` operation if the key is already in the . If the key is not in the list, setting the property is an `O(n)` operation for unsorted data, or `O(log n)` if the new element is added at the end of the list. If insertion causes a resize, the operation is `O(n)`. - + property to access a specific element in a collection by specifying the following syntax: `myCollection[key]`. + + You can also use this property to add new elements by setting the value of a key that does not exist in the object (for example, `myCollection["myNonexistentKey"] = myValue)`. However, if the specified key already exists in the , setting the property overwrites the old value. In contrast, the method does not modify existing elements. + + A key cannot be `null`, but a value can be. To distinguish between `null` that is returned because the specified key is not found and `null` that is returned because the value of the specified key is `null`, use the method or the method to determine if the key exists in the list. + + The elements of a are sorted by the keys either according to a specific implementation specified when the is created or according to the implementation provided by the keys themselves. + + The C# language uses the [`this`](/dotnet/csharp/language-reference/keywords/this) keyword to define the indexers instead of implementing the property. Visual Basic implements as a default property, which provides the same indexing functionality. + + Retrieving the value of this property is an `O(log n)` operation, where `n` is . Setting the property is an `O(log n)` operation if the key is already in the . If the key is not in the list, setting the property is an `O(n)` operation for unsorted data, or `O(log n)` if the new element is added at the end of the list. If insertion causes a resize, the operation is `O(n)`. + ]]> is . - The property is set and the object is read-only. - - -or- - + The property is set and the object is read-only. + + -or- + The property is set, does not exist in the collection, and the has a fixed size. There is not enough available memory to add the element to the . The comparer throws an exception. @@ -2092,17 +2070,17 @@ A element can be accessed by its key, like Gets the keys in a object. An object containing the keys in the object. - object is a read-only view of the keys of the object. Modifications made to the underlying are immediately reflected in the . - - The elements of the are sorted in the same order as the keys of the . - - This property is similar to the method, but returns an object instead of an object. - - This method is an `O(1)` operation. - + object is a read-only view of the keys of the object. Modifications made to the underlying are immediately reflected in the . + + The elements of the are sorted in the same order as the keys of the . + + This property is similar to the method, but returns an object instead of an object. + + This method is an `O(1)` operation. + ]]> @@ -2158,32 +2136,31 @@ A element can be accessed by its key, like The key of the element to remove. Removes the element with the specified key from a object. - object does not contain an element with the specified key, the remains unchanged. No exception is thrown. - - In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following code example shows how to remove elements from a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/CPP/source.cpp" id="Snippet1"::: + object does not contain an element with the specified key, the remains unchanged. No exception is thrown. + + In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following code example shows how to remove elements from a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/Remove/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/VB/source.vb" id="Snippet1"::: + ]]> is . - The object is read-only. - - -or- - + The object is read-only. + + -or- + The has a fixed size. Performing Culture-Insensitive String Operations in Collections @@ -2233,32 +2210,31 @@ A element can be accessed by its key, like The zero-based index of the element to remove. Removes the element at the specified index of a object. - in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. - - In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following code example shows how to remove elements from a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/CPP/source.cpp" id="Snippet1"::: + in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. + + In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table. + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following code example shows how to remove elements from a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/Remove/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.RemoveAt Example/VB/source.vb" id="Snippet1"::: + ]]> is outside the range of valid indexes for the object. - The is read-only. - - -or- - + The is read-only. + + -or- + The has a fixed size. @@ -2310,22 +2286,21 @@ A element can be accessed by its key, like The to save into the object. The value can be . Replaces the value at a specific index in a object. - in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. - - This method is an `O(1)` operation. - - - -## Examples - The following code example shows how to replace the value of an existing element in a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.SetByIndex Example/CPP/source.cpp" id="Snippet1"::: + in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. Therefore, the index of a specific key/value pair might change as elements are added or removed from the object. + + This method is an `O(1)` operation. + + + +## Examples + The following code example shows how to replace the value of an existing element in a object. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/SetByIndex/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.SetByIndex Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.SetByIndex Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2379,30 +2354,28 @@ A element can be accessed by its key, like Returns a synchronized (thread-safe) wrapper for a object. A synchronized (thread-safe) wrapper for the object. - object, all operations must be done through this wrapper only. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the property during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: + object, all operations must be done through this wrapper only. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the property during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/IsSynchronized/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: - - This method is an `O(1)` operation. - - The following code example shows how to synchronize a object, determine whether a is synchronized, and use a synchronized . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: + + This method is an `O(1)` operation. + + The following code example shows how to synchronize a object, determine whether a is synchronized, and use a synchronized . + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/IsSynchronized/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2455,24 +2428,23 @@ A element can be accessed by its key, like Gets an object that can be used to synchronize access to a object. An object that can be used to synchronize access to the object. - object, use the method. However, derived classes can provide their own synchronized version of the using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following code example shows how to lock the collection using the property during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: + object, use the method. However, derived classes can provide their own synchronized version of the using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following code example shows how to lock the collection using the property during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/IsSynchronized/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: - - Retrieving the value of this property is an `O(1)` operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -2524,26 +2496,26 @@ A element can be accessed by its key, like Returns an that iterates through the . An for the . - also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + This method is an `O(1)` operation. - The `foreach` statement of the C# language (`for each` in Visual Basic) hides the complexity of the enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. - - Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection. - - Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , returns the element that it is set to, even if the enumerator is already invalidated. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - This method is an `O(1)` operation. - ]]> @@ -2591,30 +2563,29 @@ A element can be accessed by its key, like Sets the capacity to the actual number of elements in a object. - object to its initial state, call the method before calling . Trimming an empty sets the capacity of the to the default capacity. - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following code example shows how to trim the unused portions of a object and how to clear its values. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/CPP/source.cpp" id="Snippet1"::: + object to its initial state, call the method before calling . Trimming an empty sets the capacity of the to the default capacity. + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following code example shows how to trim the unused portions of a object and how to clear its values. + :::code language="csharp" source="~/snippets/csharp/System.Collections/SortedList/Clear/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SortedList.Clear Example/VB/source.vb" id="Snippet1"::: + ]]> - The object is read-only. - - -or- - + The object is read-only. + + -or- + The has a fixed size. @@ -2665,17 +2636,17 @@ A element can be accessed by its key, like Gets the values in a object. An object containing the values in the object. - object is a read-only view of the values of the object. Modifications made to the underlying are immediately reflected in the . - - The elements of the are sorted in the same order as the values of the . - - This property is similar to the method, but returns an object instead of an object. - - This method is an `O(1)` operation. - + object is a read-only view of the values of the object. Modifications made to the underlying are immediately reflected in the . + + The elements of the are sorted in the same order as the values of the . + + This property is similar to the method, but returns an object instead of an object. + + This method is an `O(1)` operation. + ]]> diff --git a/xml/System.Collections/Stack.xml b/xml/System.Collections/Stack.xml index 08db73fb7f7..7cb407c243d 100644 --- a/xml/System.Collections/Stack.xml +++ b/xml/System.Collections/Stack.xml @@ -84,34 +84,33 @@ Represents a simple last-in-first-out (LIFO) non-generic collection of objects. - is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. + is the number of elements the can hold. As elements are added to a , the capacity is automatically increased as required through reallocation. > [!IMPORTANT] > We don't recommend that you use the `Stack` class for new development. Instead, we recommend that you use the generic class. For more information, see [Non-generic collections shouldn't be used](https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md) on GitHub. -If is less than the capacity of the stack, is an `O(1)` operation. If the capacity needs to be increased to accommodate the new element, becomes an `O(n)` operation, where `n` is . is an `O(1)` operation. - - accepts `null` as a valid value and allows duplicate elements. - - - -## Examples - The following example shows how to create and add values to a Stack and how to display its values. +If is less than the capacity of the stack, is an `O(1)` operation. If the capacity needs to be increased to accommodate the new element, becomes an `O(n)` operation, where `n` is . is an `O(1)` operation. + + accepts `null` as a valid value and allows duplicate elements. + + + +## Examples + The following example shows how to create and add values to a Stack and how to display its values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack Example/VB/source.vb" id="Snippet1"::: + ]]> - Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. - - To guarantee the thread safety of the , all operations must be done through the wrapper returned by the method. - + Public static ( in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe. + + To guarantee the thread safety of the , all operations must be done through the wrapper returned by the method. + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. @@ -163,15 +162,15 @@ If is less than the capacity of the sta Initializes a new instance of the class that is empty and has the default initial capacity. - is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . - - This constructor is an `O(1)` operation. - + is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . + + This constructor is an `O(1)` operation. + ]]> @@ -217,17 +216,17 @@ If is less than the capacity of the sta The to copy elements from. Initializes a new instance of the class that contains elements copied from the specified collection and has the same initial capacity as the number of elements copied. - is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . - - The elements are copied onto the in the same order they are read by the of the . - - This constructor is an `O(n)` operation, where `n` is the number of elements in `col`. - + is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . + + The elements are copied onto the in the same order they are read by the of the . + + This constructor is an `O(n)` operation, where `n` is the number of elements in `col`. + ]]> @@ -277,15 +276,15 @@ If is less than the capacity of the sta The initial number of elements that the can contain. Initializes a new instance of the class that is empty and has the specified initial capacity or the default initial capacity, whichever is greater. - is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. - - If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . - - This constructor is an `O(n)` operation, where `n` is `initialCapacity`. - + is the number of elements that the can hold. As elements are added to a , the capacity is automatically increased as required by reallocating the internal array. + + If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the . + + This constructor is an `O(n)` operation, where `n` is `initialCapacity`. + ]]> @@ -333,22 +332,21 @@ If is less than the capacity of the sta Removes all objects from the . - is set to zero, and references to other objects from elements of the collection are also released. - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following example shows how to clear the values of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Clear Example/CPP/source.cpp" id="Snippet1"::: + is set to zero, and references to other objects from elements of the collection are also released. + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following example shows how to clear the values of the . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/Clear/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.Clear Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.Clear Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -398,15 +396,15 @@ If is less than the capacity of the sta Creates a shallow copy of the . A shallow copy of the . - . - + . + ]]> @@ -458,15 +456,15 @@ If is less than the capacity of the sta , if is found in the ; otherwise, . - method. - - This method performs a linear search; therefore, this method is an `O(n)` operation, where `n` is . - - Starting with the .NET Framework 2.0, this method tests for equality by passing the `obj` argument to the method of individual objects in the collection. In the earlier versions of the .NET Framework, this determination was made by using passing the individual items in the collection to the method of the `obj` argument. - + method. + + This method performs a linear search; therefore, this method is an `O(n)` operation, where `n` is . + + Starting with the .NET Framework 2.0, this method tests for equality by passing the `obj` argument to the method of individual objects in the collection. In the earlier versions of the .NET Framework, this determination was made by using passing the individual items in the collection to the method of the `obj` argument. + ]]> Performing Culture-Insensitive String Operations @@ -521,22 +519,21 @@ If is less than the capacity of the sta The zero-based index in at which copying begins. Copies the to an existing one-dimensional , starting at the specified array index. - . - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following example shows how to copy a into a one-dimensional array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/CPP/source.cpp" id="Snippet1"::: + . + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following example shows how to copy a into a one-dimensional array. + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/CopyTo/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -544,10 +541,10 @@ If is less than the capacity of the sta is less than zero. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source is greater than the available space from to the end of the destination . The type of the source cannot be cast automatically to the type of the destination . @@ -597,15 +594,15 @@ If is less than the capacity of the sta Gets the number of elements contained in the . The number of elements contained in the . - can store. is the number of elements that are actually in the . - - The capacity is always greater than or equal to . If exceeds the capacity while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements. - - Retrieving the value of this property is an `O(1)` operation. - + can store. is the number of elements that are actually in the . + + The capacity is always greater than or equal to . If exceeds the capacity while adding elements, the capacity is automatically increased by reallocating the internal array before copying the old elements and adding the new elements. + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -655,26 +652,26 @@ If is less than the capacity of the sta Returns an for the . An for the . - also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. + + This method is an `O(1)` operation. - The `foreach` statement of the C# language (`for each` in Visual Basic) hides the complexity of the enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. - - Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection. - - Initially, the enumerator is positioned before the first element in the collection. also brings the enumerator back to this position. At this position, is undefined. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns `false`. When the enumerator is at this position, subsequent calls to also return `false`. If the last call to returned `false`, is undefined. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization. - - This method is an `O(1)` operation. - ]]> @@ -725,30 +722,28 @@ If is less than the capacity of the sta , if access to the is synchronized (thread safe); otherwise, . The default is . - , all operations must be done through the wrapper returned by the method. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - The following code example shows how to lock the collection using the during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: + , all operations must be done through the wrapper returned by the method. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + The following code example shows how to lock the collection using the during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/IsSynchronized/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: - - Retrieving the value of this property is an `O(1)` operation. - - - -## Examples - The following example shows how to synchronize a , determine if a is synchronized, and use a synchronized . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: + + Retrieving the value of this property is an `O(1)` operation. + + + +## Examples + The following example shows how to synchronize a , determine if a is synchronized, and use a synchronized . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/IsSynchronized/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -796,24 +791,23 @@ If is less than the capacity of the sta Returns the object at the top of the without removing it. The at the top of the . - method, but does not modify the . - - `null` can be pushed onto the as a placeholder, if needed. To distinguish between a null value and the end of the stack, check the property or catch the , which is thrown when the is empty. - - This method is an `O(1)` operation. - - - -## Examples - The following example shows how to add elements to the , remove elements from the , or view the element at the top of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Peek Example/CPP/source.cpp" id="Snippet1"::: + method, but does not modify the . + + `null` can be pushed onto the as a placeholder, if needed. To distinguish between a null value and the end of the stack, check the property or catch the , which is thrown when the is empty. + + This method is an `O(1)` operation. + + + +## Examples + The following example shows how to add elements to the , remove elements from the , or view the element at the top of the . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/Peek/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.Peek Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.Peek Example/VB/source.vb" id="Snippet1"::: + ]]> The is empty. @@ -864,24 +858,23 @@ If is less than the capacity of the sta Removes and returns the object at the top of the . The removed from the top of the . - method, but does not modify the . - - `null` can be pushed onto the as a placeholder, if needed. To distinguish between a null value and the end of the stack, check the property or catch the , which is thrown when the is empty. - - This method is an `O(1)` operation. - - - -## Examples - The following example shows how to add elements to the , remove elements from the , or view the element at the top of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Peek Example/CPP/source.cpp" id="Snippet1"::: + method, but does not modify the . + + `null` can be pushed onto the as a placeholder, if needed. To distinguish between a null value and the end of the stack, check the property or catch the , which is thrown when the is empty. + + This method is an `O(1)` operation. + + + +## Examples + The following example shows how to add elements to the , remove elements from the , or view the element at the top of the . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/Peek/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.Peek Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.Peek Example/VB/source.vb" id="Snippet1"::: + ]]> The is empty. @@ -934,24 +927,23 @@ If is less than the capacity of the sta The to push onto the . The value can be . Inserts an object at the top of the . - already equals the capacity, the capacity of the is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added. - - `null` can be pushed onto the as a placeholder, if needed. It occupies a slot in the stack and is treated like any object. - - If is less than the capacity of the stack, is an `O(1)` operation. If the capacity needs to be increased to accommodate the new element, becomes an `O(n)` operation, where `n` is . - - - -## Examples - The following example shows how to add elements to the , remove elements from the , or view the element at the top of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.Peek Example/CPP/source.cpp" id="Snippet1"::: + already equals the capacity, the capacity of the is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added. + + `null` can be pushed onto the as a placeholder, if needed. It occupies a slot in the stack and is treated like any object. + + If is less than the capacity of the stack, is an `O(1)` operation. If the capacity needs to be increased to accommodate the new element, becomes an `O(n)` operation, where `n` is . + + + +## Examples + The following example shows how to add elements to the , remove elements from the , or view the element at the top of the . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/Peek/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.Peek Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.Peek Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1003,30 +995,28 @@ If is less than the capacity of the sta Returns a synchronized (thread safe) wrapper for the . A synchronized wrapper around the . - , all operations must be done through this wrapper. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - The following code example shows how to lock the collection using the during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: + , all operations must be done through this wrapper. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + The following code example shows how to lock the collection using the during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/IsSynchronized/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: - - This method is an `O(1)` operation. - - - -## Examples - The following example shows how to synchronize a , determine if a is synchronized, and use a synchronized . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: + + This method is an `O(1)` operation. + + + +## Examples + The following example shows how to synchronize a , determine if a is synchronized, and use a synchronized . + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/IsSynchronized/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1077,21 +1067,20 @@ If is less than the capacity of the sta Gets an object that can be used to synchronize access to the . An that can be used to synchronize access to the . - , use the method. However, derived classes can provide their own synchronized version of the using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - The following code example shows how to lock the collection using the during the entire enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/CPP/source2.cpp" id="Snippet2"::: + , use the method. However, derived classes can provide their own synchronized version of the using the property. The synchronizing code must perform operations on the of the , not directly on the . This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + The following code example shows how to lock the collection using the during the entire enumeration. + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/IsSynchronized/source2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: - - Retrieving the value of this property is an `O(1)` operation. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.IsSynchronized Example/VB/source2.vb" id="Snippet2"::: + + Retrieving the value of this property is an `O(1)` operation. + ]]> @@ -1139,22 +1128,21 @@ If is less than the capacity of the sta Copies the to a new array. A new array containing copies of the elements of the . - . - - This method is an `O(n)` operation, where `n` is . - - - -## Examples - The following example shows how to copy a into a one-dimensional array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/CPP/source.cpp" id="Snippet1"::: + . + + This method is an `O(n)` operation, where `n` is . + + + +## Examples + The following example shows how to copy a into a one-dimensional array. + :::code language="csharp" source="~/snippets/csharp/System.Collections/Stack/CopyTo/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stack.CopyTo Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Configuration/ApplicationScopedSettingAttribute.xml b/xml/System.Configuration/ApplicationScopedSettingAttribute.xml index 70c13fd5c9b..22c771ce9e1 100644 --- a/xml/System.Configuration/ApplicationScopedSettingAttribute.xml +++ b/xml/System.Configuration/ApplicationScopedSettingAttribute.xml @@ -53,7 +53,7 @@ - Application Settings Architecture + Application Settings Architecture diff --git a/xml/System.Configuration/ApplicationSettingsBase.xml b/xml/System.Configuration/ApplicationSettingsBase.xml index 0b6c871e78c..f6e7023645c 100644 --- a/xml/System.Configuration/ApplicationSettingsBase.xml +++ b/xml/System.Configuration/ApplicationSettingsBase.xml @@ -36,58 +36,58 @@ Acts as a base class for deriving concrete wrapper classes to implement the application settings feature in Window Forms applications. - adds the following functionality to the class, which is used by Web-based applications: - -- The ability to detect attributes on a derived, settings wrapper class. supports the declarative model used for wrapper class properties, as described later. - -- Higher-level and methods. - -- Additional validation events that you can handle to ensure the correctness of individual settings. - - In the application settings architecture, to access a group of settings properties you need to derive a concrete wrapper class from . The wrapper class customizes in the following ways: - -- For every settings property to be accessed, a corresponding strongly typed public property is added to the wrapper class. This property has `get` and `set` accessors for read/write application settings, but only a `get` accessor for read-only settings. - -- Appropriated attributes must be applied to the wrapper class's public properties to indicate characteristics of the settings property, such as the setting's scope (application or user), whether the setting should support roaming, the default value for the setting, the settings provider to be used, and so on. Each property is required to specify its scope, using either or . Application-scoped settings are read-only if the default is used. - - The class uses reflection to detect these attributes at run time. Most of this information gets passed to the settings provider layer, which is responsible for storage, persistence format, and so on. - - When an application has multiple settings wrapper classes, each class defines a *settings group*. Each group has the following characteristics: - -- A group can contain any number or type of property settings. - -- If the group name is not explicitly set by the decorating the wrapper class with a , then a name is automatically generated. - - By default, all client-based applications use the to provide storage. If an alternate settings provider is desired, then the wrapper class or property must be decorated with a corresponding . - - For more information about using application settings, see [Application Settings for Windows Forms](/dotnet/framework/winforms/advanced/application-settings-for-windows-forms). - - - -## Examples - The following code example demonstrates the use of application settings to persist the following attributes of the main form: location, size, background color, and title bar text. All of these attributes are persisted as single application settings properties in the `FormSettings` class, named `FormLocation`, `FormSize`, `FormBackColor` and `FormText`, respectively. All except for `FormText` and `Size` are data bound to their associated form properties and have a default setting value applied using . - - The form contains four child controls that have the following names and functions: - -- A button named `btnBackColor` used to display the **Color** common dialog box. - -- A button named `btnReload` used to the application settings. - -- A button named `btnReset` used to the application settings. - -- A textbox named `tbStatus` used to display status information about the program. - - Notice that after every execution of the application, an additional period character is appended to the title text of the form. - - This code example requires a Form with a class named `colorDialog1`, and a control with a named `tbStatus`. Additionally, it requires three objects named `btnReload`, `btnReset`, and `btnBackColor`. - + adds the following functionality to the class, which is used by Web-based applications: + +- The ability to detect attributes on a derived, settings wrapper class. supports the declarative model used for wrapper class properties, as described later. + +- Higher-level and methods. + +- Additional validation events that you can handle to ensure the correctness of individual settings. + + In the application settings architecture, to access a group of settings properties you need to derive a concrete wrapper class from . The wrapper class customizes in the following ways: + +- For every settings property to be accessed, a corresponding strongly typed public property is added to the wrapper class. This property has `get` and `set` accessors for read/write application settings, but only a `get` accessor for read-only settings. + +- Appropriated attributes must be applied to the wrapper class's public properties to indicate characteristics of the settings property, such as the setting's scope (application or user), whether the setting should support roaming, the default value for the setting, the settings provider to be used, and so on. Each property is required to specify its scope, using either or . Application-scoped settings are read-only if the default is used. + + The class uses reflection to detect these attributes at run time. Most of this information gets passed to the settings provider layer, which is responsible for storage, persistence format, and so on. + + When an application has multiple settings wrapper classes, each class defines a *settings group*. Each group has the following characteristics: + +- A group can contain any number or type of property settings. + +- If the group name is not explicitly set by the decorating the wrapper class with a , then a name is automatically generated. + + By default, all client-based applications use the to provide storage. If an alternate settings provider is desired, then the wrapper class or property must be decorated with a corresponding . + + For more information about using application settings, see [Application Settings for Windows Forms](/dotnet/desktop/winforms/advanced/application-settings-for-windows-forms). + + + +## Examples + The following code example demonstrates the use of application settings to persist the following attributes of the main form: location, size, background color, and title bar text. All of these attributes are persisted as single application settings properties in the `FormSettings` class, named `FormLocation`, `FormSize`, `FormBackColor` and `FormText`, respectively. All except for `FormText` and `Size` are data bound to their associated form properties and have a default setting value applied using . + + The form contains four child controls that have the following names and functions: + +- A button named `btnBackColor` used to display the **Color** common dialog box. + +- A button named `btnReload` used to the application settings. + +- A button named `btnReset` used to the application settings. + +- A textbox named `tbStatus` used to display status information about the program. + + Notice that after every execution of the application, an additional period character is appended to the title text of the form. + + This code example requires a Form with a class named `colorDialog1`, and a control with a named `tbStatus`. Additionally, it requires three objects named `btnReload`, `btnReset`, and `btnBackColor`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/AppSettingsSample/cpp/AppSettingsSample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Configuration/ApplicationSettingsBase/Overview/AppSettingsSample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet1"::: + ]]> @@ -95,7 +95,7 @@ - Application Settings for Windows Forms + Application Settings for Windows Forms @@ -134,25 +134,25 @@ Initializes an instance of the class to its default state. - . - - When an instance of a wrapper class is created, inherited code will automatically perform the following actions: - -1. Reflect over the class. - -2. For each property on the wrapper marked with either `[UserScopedSettingAttribute]` or `[ApplicationScopedSettingAttribute]`, a corresponding is created. - -3. Each has some of its properties set based on other attributes that are optionally present on the wrapper's properties, such as the default value or the settings provider. - -4. All other attributes are simply put into an attribute bag, the property of the class. - -5. All objects are added to a represented by the property of the class. This collection is then passed to the method. - - As implied by step 3 mentioned previously, natively works with several property attributes, specifically the following: , , and . All other settings attributes are simply passed through to the appropriate underlying provider. - + . + + When an instance of a wrapper class is created, inherited code will automatically perform the following actions: + +1. Reflect over the class. + +2. For each property on the wrapper marked with either `[UserScopedSettingAttribute]` or `[ApplicationScopedSettingAttribute]`, a corresponding is created. + +3. Each has some of its properties set based on other attributes that are optionally present on the wrapper's properties, such as the default value or the settings provider. + +4. All other attributes are simply put into an attribute bag, the property of the class. + +5. All objects are added to a represented by the property of the class. This collection is then passed to the method. + + As implied by step 3 mentioned previously, natively works with several property attributes, specifically the following: , , and . All other settings attributes are simply passed through to the appropriate underlying provider. + ]]> @@ -191,15 +191,15 @@ The component that will act as the owner of the application settings object. Initializes an instance of the class using the supplied owner component. - constructor using the invocation: - - `ApplicationSettingsBase(owner, String.Empty)` - - For information about how reflection is used during the instantiation of a wrapper class, see the default constructor. - + constructor using the invocation: + + `ApplicationSettingsBase(owner, String.Empty)` + + For information about how reflection is used during the instantiation of a wrapper class, see the default constructor. + ]]> @@ -239,13 +239,13 @@ A that uniquely identifies separate instances of the wrapper class. Initializes an instance of the class using the supplied settings key. - property to the value of the `settingsKey` parameter. This property is useful in disambiguating different instances of the settings wrapper class in the same application domain. - - For information about how reflection is used during the instantiation of a wrapper class, see the default constructor. - + property to the value of the `settingsKey` parameter. This property is useful in disambiguating different instances of the settings wrapper class in the same application domain. + + For information about how reflection is used during the instantiation of a wrapper class, see the default constructor. + ]]> @@ -284,15 +284,15 @@ A that uniquely identifies separate instances of the wrapper class. Initializes an instance of the class using the supplied owner component and settings key. - object specified by the `owner` parameter acts as the owner of the current instance of this applications settings class. During the initialization of the settings wrapper class derived from , the owner's site is queried for a . If one exists, it is used in preference to native settings provider for all the properties of the wrapper class, as specified by the . - - This constructor initializes the property to the value of the `settingsKey` parameter. This property is useful in disambiguating different instances of the wrapper class in the same application domain. - - For information about how reflection is used during the instantiation of a wrapper class, see the default constructor. - + object specified by the `owner` parameter acts as the owner of the current instance of this applications settings class. During the initialization of the settings wrapper class derived from , the owner's site is queried for a . If one exists, it is used in preference to native settings provider for all the properties of the wrapper class, as specified by the . + + This constructor initializes the property to the value of the `settingsKey` parameter. This property is useful in disambiguating different instances of the wrapper class in the same application domain. + + For information about how reflection is used during the instantiation of a wrapper class, see the default constructor. + ]]> @@ -339,13 +339,13 @@ Gets the application settings context associated with the settings group. A associated with the settings group. - has a context associated with it. The context is passed to the settings provider for each property to identify how the property is used. Context therefore acts as a hint to help the settings provider determine how best to persist the associated application settings values. - - In contrast, the property enables the settings provider to disambiguate multiple instances of the same wrapper class. - + has a context associated with it. The context is passed to the settings provider for each property to identify how the property is used. Context therefore acts as a hint to help the settings provider determine how best to persist the associated application settings values. + + In contrast, the property enables the settings provider to disambiguate multiple instances of the same wrapper class. + ]]> @@ -390,11 +390,11 @@ Returns the value of the named settings property for the previous version of the same application. An containing the value of the specified if found; otherwise, . - method is often used in conjunction with the method when migrating application settings during the installation of a new version of an application. - + method is often used in conjunction with the method when migrating application settings during the installation of a new version of an application. + ]]> The property does not exist. The property count is zero or the property cannot be found in the data store. @@ -441,17 +441,17 @@ Gets or sets the value of the specified application settings property. If found, the value of the named settings property; otherwise, . - property, also known as the indexer, is routinely used in the settings wrapper class derived from . binds the public property of the wrapper class to the corresponding settings property. - - raises several events depending on the operation being performed: - -- The first time a property is retrieved, the event is raised. - -- When a property is set, the event is raised. If the handler does not cancel the event, then the property value is set and the event is raised. - + property, also known as the indexer, is routinely used in the settings wrapper class derived from . binds the public property of the wrapper class to the corresponding settings property. + + raises several events depending on the operation being performed: + +- The first time a property is retrieved, the event is raised. + +- When a property is set, the event is raised. If the handler does not cancel the event, then the property value is set and the event is raised. + ]]> There are no properties associated with the current wrapper or the specified property could not be found. @@ -498,13 +498,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -549,13 +549,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -602,13 +602,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -655,13 +655,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -709,13 +709,13 @@ Gets the collection of settings properties in the wrapper. A containing all the objects used in the current wrapper. - property reflects over the metadata of the settings wrapper class, which is derived from , to dynamically determine the set of available application settings properties. - - The class natively recognizes certain characteristics of an application setting, such as its name, property type, settings provider, default value, read only status, and a serialization preference. These characteristics are mirrored as properties in the class. All other attributes of the settings property are just passed through to its associated settings provider. - + property reflects over the metadata of the settings wrapper class, which is derived from , to dynamically determine the set of available application settings properties. + + The class natively recognizes certain characteristics of an application setting, such as its name, property type, settings provider, default value, read only status, and a serialization preference. These characteristics are mirrored as properties in the class. All other attributes of the settings property are just passed through to its associated settings provider. + ]]> The associated settings provider could not be found or its instantiation failed. @@ -759,13 +759,13 @@ Occurs after the value of an application settings property is changed. - event is raised when a settings property is changed through the `set` accessor of the method, or for every property that is restored when a call is made to the or methods. - - There is no corresponding `PropertyChanging` event for this class; instead, see the event. - + event is raised when a settings property is changed through the `set` accessor of the method, or for every property that is restored when a call is made to the or methods. + + There is no corresponding `PropertyChanging` event for this class; instead, see the event. + ]]> @@ -852,11 +852,11 @@ Gets the collection of application settings providers used by the wrapper. A containing all the objects used by the settings properties of the current settings wrapper. - determines what setting provider is used by a settings wrapper class or an individual setting property. If this attribute is not specified, a client application will use the . - + determines what setting provider is used by a settings wrapper class or an individual setting property. If this attribute is not specified, a client application will use the . + ]]> @@ -895,26 +895,26 @@ Refreshes the application settings property values from persistent storage. - method clears the currently cached property values, causing a reload of these values from persistent storage when they are subsequently accessed. This method performs the following actions: - -- It clears the currently cached properties by clearing the collection represented by the property. - -- It raises the event for every member of the collection. - - contrasts with in that the former will load the last set of saved application settings values, whereas the latter will load the saved default values. - - - -## Examples - The following code example shows the method being invoked in the body of the event handler for a button named `btnReload`. As a result of this call, the currently stored values for the application settings are reloaded into their corresponding properties. The full code example is listed in the class overview. - + method clears the currently cached property values, causing a reload of these values from persistent storage when they are subsequently accessed. This method performs the following actions: + +- It clears the currently cached properties by clearing the collection represented by the property. + +- It raises the event for every member of the collection. + + contrasts with in that the former will load the last set of saved application settings values, whereas the latter will load the saved default values. + + + +## Examples + The following code example shows the method being invoked in the body of the event handler for a button named `btnReload`. As a result of this call, the currently stored values for the application settings are reloaded into their corresponding properties. The full code example is listed in the class overview. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/AppSettingsSample/cpp/AppSettingsSample.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Configuration/ApplicationSettingsBase/Overview/AppSettingsSample.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet6"::: + ]]> @@ -957,26 +957,26 @@ Restores the persisted application settings values to their corresponding default properties. - method overwrites the user-scoped settings properties by restoring the currently persisted value of each application settings. This method performs the following actions: - -- It calls the method on every settings provider that supports this optional method. - -- It calls the method to force a refresh of the settings property values. - - contrasts with in that the former will load the last set of saved application settings values, whereas the latter will load the saved default values. - - - -## Examples - The following code example shows the method being invoked in the body of the event handler for a button named `btnReset`. As a result of this call, the stored default values for the application settings are reloaded into their corresponding properties. The full code example is listed in the class overview. - + method overwrites the user-scoped settings properties by restoring the currently persisted value of each application settings. This method performs the following actions: + +- It calls the method on every settings provider that supports this optional method. + +- It calls the method to force a refresh of the settings property values. + + contrasts with in that the former will load the last set of saved application settings values, whereas the latter will load the saved default values. + + + +## Examples + The following code example shows the method being invoked in the body of the event handler for a button named `btnReset`. As a result of this call, the stored default values for the application settings are reloaded into their corresponding properties. The full code example is listed in the class overview. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/AppSettingsSample/cpp/AppSettingsSample.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Configuration/ApplicationSettingsBase/Overview/AppSettingsSample.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet5"::: + ]]> The configuration file could not be parsed. @@ -1016,29 +1016,29 @@ Stores the current values of the application settings properties. - method writes the current value of each settings property to its associated data store. For each property, this method calls the method on the associated settings provider. - - This method differs from the base class implementation in that it raises the event before the values are written. - - If the only settings defined are application-scoped settings, will have no effect and return no error if called with the default . only saves user-scoped settings. - + method writes the current value of each settings property to its associated data store. For each property, this method calls the method on the associated settings provider. + + This method differs from the base class implementation in that it raises the event before the values are written. + + If the only settings defined are application-scoped settings, will have no effect and return no error if called with the default . only saves user-scoped settings. + > [!IMPORTANT] -> There is no corresponding Load method because the values of application settings are automatically loaded during wrapper class initialization. In contrast, these values are not automatically saved when an application ends. Therefore, you must explicitly call the method to persist the current values of the application settings. This is typically performed in the event handler of the primary or containing . - - - -## Examples - The following code example shows the method being called from the event handler for the primary form. This method also appends an extra period to the settings property that is associated with the form's property. - - The full code example is listed in the class overview. - +> There is no corresponding Load method because the values of application settings are automatically loaded during wrapper class initialization. In contrast, these values are not automatically saved when an application ends. Therefore, you must explicitly call the method to persist the current values of the application settings. This is typically performed in the event handler of the primary or containing . + + + +## Examples + The following code example shows the method being called from the event handler for the primary form. This method also appends an extra period to the settings property that is associated with the form's property. + + The full code example is listed in the class overview. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/AppSettingsSample/cpp/AppSettingsSample.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Configuration/ApplicationSettingsBase/Overview/AppSettingsSample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet3"::: + ]]> @@ -1078,31 +1078,31 @@ Occurs before the value of an application settings property is changed. - event occurs before an application setting value property is changed through the method. This event is not raised when the or methods are called. can be canceled through the event data class. - - You typically use the event to handle immediate validation of an individual settings property. For more information about validation, see [How to: Validate Application Settings](/dotnet/framework/winforms/advanced/how-to-validate-application-settings). - - There is no corresponding `SettingChanged` event for this class; instead, see the event. - - - -## Examples - The following code example shows the event handler for object of type `FormSettings`, which is a wrapper class derived from . The handler displays the event information in a textbox named `tbStatus`. The full code example is listed in the class overview. - + event occurs before an application setting value property is changed through the method. This event is not raised when the or methods are called. can be canceled through the event data class. + + You typically use the event to handle immediate validation of an individual settings property. For more information about validation, see [How to: Validate Application Settings](/dotnet/desktop/winforms/advanced/how-to-validate-application-settings). + + There is no corresponding `SettingChanged` event for this class; instead, see the event. + + + +## Examples + The following code example shows the event handler for object of type `FormSettings`, which is a wrapper class derived from . The handler displays the event information in a textbox named `tbStatus`. The full code example is listed in the class overview. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/AppSettingsSample/cpp/AppSettingsSample.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Configuration/ApplicationSettingsBase/Overview/AppSettingsSample.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet7"::: + ]]> - How to: Validate Application Settings + How to: Validate Application Settings @@ -1146,21 +1146,21 @@ Gets or sets the settings key for the application settings group. A containing the settings key for the current settings group. - property is provided to enable client code, and in particular the settings provider, to disambiguate between multiple instances of the same application settings class. - - Unless the settings wrapper class is designed using the singleton pattern, there can be multiple instances of the same application settings class in a single application. The value of should be set according to how the property values are intended to be shared. - -- If the settings properties of the wrapper are intended to be shared across all instances of the wrapper in the same application, then should have the same value in all of the instances. This is the default behavior of the class. - -- If the settings properties of the wrapper are intended to be per instance, then should have a unique value for every instance. The version of the constructor enables you to initialize to a unique string. - - In contrast, the property provides hints to the settings provider to enable it to persist values in an efficient and orderly manner. - - The class contains a similar property that helps identify the source of the event. - + property is provided to enable client code, and in particular the settings provider, to disambiguate between multiple instances of the same application settings class. + + Unless the settings wrapper class is designed using the singleton pattern, there can be multiple instances of the same application settings class in a single application. The value of should be set according to how the property values are intended to be shared. + +- If the settings properties of the wrapper are intended to be shared across all instances of the wrapper in the same application, then should have the same value in all of the instances. This is the default behavior of the class. + +- If the settings properties of the wrapper are intended to be per instance, then should have a unique value for every instance. The version of the constructor enables you to initialize to a unique string. + + In contrast, the property provides hints to the settings provider to enable it to persist values in an efficient and orderly manner. + + The class contains a similar property that helps identify the source of the event. + ]]> @@ -1197,11 +1197,11 @@ Occurs after the application settings are retrieved from storage. - event occurs only after the initial `get` access of the first configuration property used, typically through the method. Subsequent accesses use values for the settings property that are cached locally. The and methods will clear all cached values so this event will be raised again upon subsequent property access. - + event occurs only after the initial `get` access of the first configuration property used, typically through the method. Subsequent accesses use values for the settings property that are cached locally. The and methods will clear all cached values so this event will be raised again upon subsequent property access. + ]]> @@ -1241,20 +1241,20 @@ Occurs before values are saved to the data store. - event is raised by the method before it stores the application settings properties to their associated data store. The associated event handler can cancel this event. - - - -## Examples - The following code example shows the event handler for object of type `FormSettings`, which is a wrapper class derived from . The handler queries the user to save the current application settings property values. The full code example is listed in the class overview. - + event is raised by the method before it stores the application settings properties to their associated data store. The associated event handler can cancel this event. + + + +## Examples + The following code example shows the event handler for object of type `FormSettings`, which is a wrapper class derived from . The handler queries the user to save the current application settings property values. The full code example is listed in the class overview. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/AppSettingsSample/cpp/AppSettingsSample.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Configuration/ApplicationSettingsBase/Overview/AppSettingsSample.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet8"::: + ]]> @@ -1292,21 +1292,21 @@ Updates application settings to reflect a more recent installation of the application. - method performs two actions to assure smooth transition to a new version of an application: - -- It notifies all of the corresponding settings providers of the existence of the upgraded application through a call to their method, assuming they have implemented the interface. This action is not performed if the settings wrapper class is marked with . - -- It reloads the values for all of the application settings. - - You can override the default behavior of to implement custom upgrading or merging behavior. Use the method to retrieve individual values for a setting for the previous version of the application. Examples of custom upgrade behavior include: - -- Using new policy defaults that override one or more of the previous user-specified values or previous defaults. - -- Special translation of old values to be compatible with newer ranges, a different settings property group, and so on. - + method performs two actions to assure smooth transition to a new version of an application: + +- It notifies all of the corresponding settings providers of the existence of the upgraded application through a call to their method, assuming they have implemented the interface. This action is not performed if the settings wrapper class is marked with . + +- It reloads the values for all of the application settings. + + You can override the default behavior of to implement custom upgrading or merging behavior. Use the method to retrieve individual values for a setting for the previous version of the application. Examples of custom upgrade behavior include: + +- Using new policy defaults that override one or more of the previous user-specified values or previous defaults. + +- Special translation of old values to be compatible with newer ranges, a different settings property group, and so on. + ]]> The configuration file could not be parsed. diff --git a/xml/System.Configuration/ClientSettingsSection.xml b/xml/System.Configuration/ClientSettingsSection.xml index 5f354fdb2e2..8dde93cc2f3 100644 --- a/xml/System.Configuration/ClientSettingsSection.xml +++ b/xml/System.Configuration/ClientSettingsSection.xml @@ -33,21 +33,21 @@ Represents a group of user-scoped application settings in a configuration file. - , which stores configuration data to the local file system in files with the extension `.config`. The contents of configuration files are structured as XML documents. User-scoped settings are persisted in a file with the name `username.config`. Within this file, data is stored as elements within a `` section. Each of these sections is represented by a corresponding . Each section object is owned and administered by a configuration section handler, which is an . - - The class represents a simple extension of the class, which is used in the .NET Framework support for general configuration files. - - For more information about application settings, see the topic [Application Settings for Windows Forms](/dotnet/framework/winforms/advanced/application-settings-for-windows-forms). - + , which stores configuration data to the local file system in files with the extension `.config`. The contents of configuration files are structured as XML documents. User-scoped settings are persisted in a file with the name `username.config`. Within this file, data is stored as elements within a `` section. Each of these sections is represented by a corresponding . Each section object is owned and administered by a configuration section handler, which is an . + + The class represents a simple extension of the class, which is used in the .NET Framework support for general configuration files. + + For more information about application settings, see the topic [Application Settings for Windows Forms](/dotnet/desktop/winforms/advanced/application-settings-for-windows-forms). + ]]> - Application Settings for Windows Forms + Application Settings for Windows Forms @@ -83,11 +83,11 @@ Initializes a new instance of the class. - constructor initializes the property. - + constructor initializes the property. + ]]> @@ -172,11 +172,11 @@ Gets the collection of client settings for the section. A containing all the client settings found in the current configuration section. - property is itself a configuration property. - + property is itself a configuration property. + ]]> diff --git a/xml/System.Configuration/DefaultSettingValueAttribute.xml b/xml/System.Configuration/DefaultSettingValueAttribute.xml index 97758453624..d1f85638afb 100644 --- a/xml/System.Configuration/DefaultSettingValueAttribute.xml +++ b/xml/System.Configuration/DefaultSettingValueAttribute.xml @@ -38,37 +38,37 @@ Specifies the default value for an application settings property. - [!IMPORTANT] -> can only be applied to individual settings properties; it is invalid to apply this attribute to an entire application settings class. - - Different settings providers may have different requirements or limitations on the use of the . For example, the does not require this attribute, and will override any value provided by this attribute if there are any values - default or user-modified - already present in the data store. - - requires that the default value can be represented as a string. As a result, settings using XML serialization cannot have a default value specified by means of this attribute. Some providers may choose to support multiple serialization schemes which can be specified at compile time using the . - +> can only be applied to individual settings properties; it is invalid to apply this attribute to an entire application settings class. + + Different settings providers may have different requirements or limitations on the use of the . For example, the does not require this attribute, and will override any value provided by this attribute if there are any values - default or user-modified - already present in the data store. + + requires that the default value can be represented as a string. As a result, settings using XML serialization cannot have a default value specified by means of this attribute. Some providers may choose to support multiple serialization schemes which can be specified at compile time using the . + > [!CAUTION] -> The default values specified by this attribute are stored as plain text in the resultant compiled .exe or .dll file. Therefore these default values are inherently insecure. - - - -## Examples - The following code example demonstrates the use of the applied to three of the four properties of the `FormSettings` wrapper class, which is derived from the class. This class is used to persist the location, size, background color, and text of form. The first three of these form properties have default values associated with them. - - The full code example is listed in the class overview. - +> The default values specified by this attribute are stored as plain text in the resultant compiled .exe or .dll file. Therefore these default values are inherently insecure. + + + +## Examples + The following code example demonstrates the use of the applied to three of the four properties of the `FormSettings` wrapper class, which is derived from the class. This class is used to persist the location, size, background color, and text of form. The first three of these form properties have default values associated with them. + + The full code example is listed in the class overview. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/AppSettingsSample/cpp/AppSettingsSample.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Configuration/ApplicationSettingsBase/Overview/AppSettingsSample.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/AppSettingsSample/VB/Form1.vb" id="Snippet9"::: + ]]> - Application Settings for Windows Forms + Application Settings for Windows Forms @@ -108,14 +108,14 @@ A that represents the default value for the property. Initializes an instance of the class. - , then a `value` of `"Azure"` would be valid. - + , then a `value` of `"Azure"` would be valid. + > [!CAUTION] -> The default values specified by this attribute are stored as plain text in the resultant compiled .exe or .dll file. Therefore these default values are inherently insecure. - +> The default values specified by this attribute are stored as plain text in the resultant compiled .exe or .dll file. Therefore these default values are inherently insecure. + ]]> @@ -159,13 +159,13 @@ Gets the default value for the application settings property. A that represents the default value for the property. - property is set in the constructor. - - Setting providers may support multiple serialization schemes that can be specified with the . - + property is set in the constructor. + + Setting providers may support multiple serialization schemes that can be specified with the . + ]]> diff --git a/xml/System.Configuration/IApplicationSettingsProvider.xml b/xml/System.Configuration/IApplicationSettingsProvider.xml index d54bfa0b123..42ae92224bf 100644 --- a/xml/System.Configuration/IApplicationSettingsProvider.xml +++ b/xml/System.Configuration/IApplicationSettingsProvider.xml @@ -30,27 +30,27 @@ Defines extended capabilities for client-based application settings providers. - . Such a class contains the basic functionality for storing and retrieving properties. However, you can add additional standardized functionality by implementing the interface in the custom settings provider. This interface contains three methods that primarily enable the settings provider to more intelligently handle application version changes. Typically, the settings provider will store application settings for different versions of an application separately to anticipate the following circumstances: - -- Side-by-side execution of different versions of an application. - -- Retaining application settings when upgrading an application. - -- Resetting the application settings to their default values for the currently used version. - - The class implements the interface. The same set of methods contained by is also found in the class, enabling the establishment of a predefined communication channel between an application settings wrapper and its settings provider. - + . Such a class contains the basic functionality for storing and retrieving properties. However, you can add additional standardized functionality by implementing the interface in the custom settings provider. This interface contains three methods that primarily enable the settings provider to more intelligently handle application version changes. Typically, the settings provider will store application settings for different versions of an application separately to anticipate the following circumstances: + +- Side-by-side execution of different versions of an application. + +- Retaining application settings when upgrading an application. + +- Resetting the application settings to their default values for the currently used version. + + The class implements the interface. The same set of methods contained by is also found in the class, enabling the establishment of a predefined communication channel between an application settings wrapper and its settings provider. + > [!NOTE] -> This interface is optional. If a provider does not implement this interface, the settings infrastructure will fail without notification if it attempts to access any of the methods defined by this interface. - +> This interface is optional. If a provider does not implement this interface, the settings infrastructure will fail without notification if it attempts to access any of the methods defined by this interface. + ]]> - Application Settings Architecture + Application Settings Architecture @@ -90,11 +90,11 @@ Returns the value of the specified settings property for the previous version of the same application. A containing the value of the specified property setting as it was last set in the previous version of the application; or if the setting cannot be found. - method in conjunction with the method to migrate application settings during or after the installation of a new version of an application. - + method in conjunction with the method to migrate application settings during or after the installation of a new version of an application. + ]]> @@ -136,13 +136,13 @@ A describing the current application usage. Resets the application settings associated with the specified application to their default values. - method reinitializes the stored values of the specified application settings group. In contrast, supplies a default value for a single settings property during property initialization, if it has no stored value. - - The settings provider determines what reasonable defaults are for the specified group of application settings. For example, the implementation in resets user-scoped settings to their shared values in the `application.exe.config` file; in contrast, it leaves the application-scoped settings unchanged. - + method reinitializes the stored values of the specified application settings group. In contrast, supplies a default value for a single settings property during property initialization, if it has no stored value. + + The settings provider determines what reasonable defaults are for the specified group of application settings. For example, the implementation in resets user-scoped settings to their shared values in the `application.exe.config` file; in contrast, it leaves the application-scoped settings unchanged. + ]]> @@ -185,15 +185,15 @@ A containing the settings property group whose values are to be retrieved. Indicates to the provider that the application has been upgraded. This offers the provider an opportunity to upgrade its stored settings as appropriate. - method, implemented in a class derived from . - - You can use the method in conjunction with the method to migrate application settings during or after the installation of a new version of an application. - - This method should be suppressed for every application setting that has the is applied to it, or to the entire settings wrapper class, derived from . - + method, implemented in a class derived from . + + You can use the method in conjunction with the method to migrate application settings during or after the installation of a new version of an application. + + This method should be suppressed for every application setting that has the is applied to it, or to the entire settings wrapper class, derived from . + ]]> diff --git a/xml/System.Configuration/IPersistComponentSettings.xml b/xml/System.Configuration/IPersistComponentSettings.xml index 8ae71245a2d..abba951bd0b 100644 --- a/xml/System.Configuration/IPersistComponentSettings.xml +++ b/xml/System.Configuration/IPersistComponentSettings.xml @@ -30,15 +30,15 @@ Defines standard functionality for controls or libraries that store and retrieve application settings. - , and then add special properties to this class. However, this approach does not sufficiently encapsulate application settings for a control so that its container is shielded from the details. The interface provides an application with a standard interface for communicating application settings state change requests to a control, component, or library module. Design-time tools also depend on this interface to properly manage controls and components. - + , and then add special properties to this class. However, this approach does not sufficiently encapsulate application settings for a control so that its container is shielded from the details. The interface provides an application with a standard interface for communicating application settings state change requests to a control, component, or library module. Design-time tools also depend on this interface to properly manage controls and components. + ]]> - Application Settings for Custom Controls + Application Settings for Custom Controls @@ -72,15 +72,15 @@ Reads the control's application settings into their corresponding properties and updates the control's state. - method performs two essential operations: - -- It causes each application settings instance contained by the control to refresh the values of its application settings properties, typically by calling their methods. - -- As required, it updates those general properties that depend on these reloaded settings properties. For example, if the settings class contained a `location` settings property, should ensure that the control's property is updated to reflect this reloaded setting. - + method performs two essential operations: + +- It causes each application settings instance contained by the control to refresh the values of its application settings properties, typically by calling their methods. + +- As required, it updates those general properties that depend on these reloaded settings properties. For example, if the settings class contained a `location` settings property, should ensure that the control's property is updated to reflect this reloaded setting. + ]]> @@ -119,11 +119,11 @@ Resets the control's application settings properties to their default values. - method typically calls the method on each instance of an application settings class it contains. - + method typically calls the method on each instance of an application settings class it contains. + ]]> @@ -161,14 +161,14 @@ Persists the control's application settings properties. - method writes the values of the control's application settings properties to the associated data store. The data store and serialization technique the method uses is determined by the settings provider associated with each settings class through the . You can override the choice of the settings provider by using the interface. - + method writes the values of the control's application settings properties to the associated data store. The data store and serialization technique the method uses is determined by the settings provider associated with each settings class through the . You can override the choice of the settings provider by using the interface. + > [!NOTE] -> If the property is `true`, the control should call in its own method so that the control's configuration data is stored automatically before the application ends. - +> If the property is `true`, the control should call in its own method so that the control's configuration data is stored automatically before the application ends. + ]]> @@ -212,40 +212,40 @@ if the control should automatically persist its state; otherwise, . - method or sometimes implicitly when the control's method is invoked. The property determines whether a control automatically persists its configuration data when it is disposed. - - The default value of depends on the implementation of the control. The documentation for the control should indicate whether it uses application settings, what data is persisted, and what the default value of the property is. - - - -## Examples - The following code example shows the proper way for a control to check the value of the property before it attempts to automatically persist its configuration data. - - `protected override void Dispose( bool disposing ) {` - - `if(disposing) {` - - `try {` - - `if (SaveSettings) {` - - `SaveComponentSettings();` - - `}` - - `}` - - `finally {` - - `//...` - - `}` - - `}` - + method or sometimes implicitly when the control's method is invoked. The property determines whether a control automatically persists its configuration data when it is disposed. + + The default value of depends on the implementation of the control. The documentation for the control should indicate whether it uses application settings, what data is persisted, and what the default value of the property is. + + + +## Examples + The following code example shows the proper way for a control to check the value of the property before it attempts to automatically persist its configuration data. + + `protected override void Dispose( bool disposing ) {` + + `if(disposing) {` + + `try {` + + `if (SaveSettings) {` + + `SaveComponentSettings();` + + `}` + + `}` + + `finally {` + + `//...` + + `}` + + `}` + ]]> @@ -283,26 +283,26 @@ Gets or sets the value of the application settings key for the current instance of the control. A containing the settings key for the current instance of the control. - property to disambiguate groups of application settings properties when there are multiple instances of the same wrapper class. For example, if a control contains an associated wrapper class, then placing multiple instances of the same control in the same application will typically result in multiple instances of the wrapper class. A settings key is required only when the configuration data differs on a per-instance basis; for example, the location of dynamically positioned controls. - - The following general rules apply to the use of : - -- A control, like any class, may contain zero or more application settings classes, derived from . Each settings class contains its own property, which helps disambiguate multiple instances of that class. - -- A control should separate its per-instance data and its shared data into different settings classes. - -- For a control with any per-instance configuration data, the `get` accessor of the property should default to the of the control. In most cases the name of the control will be unique within an application. If the control contains only shared configuration data, `get` should default to `null`. - -- The `set` accessor for this property should be implemented to distinguish between settings classes containing per-instance and shared configuration data. For each settings class containing per-instance data, `set` should just pass-through to the property of the settings class. For settings classes containing shared data, `set` should perform no action for that settings class. - + property to disambiguate groups of application settings properties when there are multiple instances of the same wrapper class. For example, if a control contains an associated wrapper class, then placing multiple instances of the same control in the same application will typically result in multiple instances of the wrapper class. A settings key is required only when the configuration data differs on a per-instance basis; for example, the location of dynamically positioned controls. + + The following general rules apply to the use of : + +- A control, like any class, may contain zero or more application settings classes, derived from . Each settings class contains its own property, which helps disambiguate multiple instances of that class. + +- A control should separate its per-instance data and its shared data into different settings classes. + +- For a control with any per-instance configuration data, the `get` accessor of the property should default to the of the control. In most cases the name of the control will be unique within an application. If the control contains only shared configuration data, `get` should default to `null`. + +- The `set` accessor for this property should be implemented to distinguish between settings classes containing per-instance and shared configuration data. For each settings class containing per-instance data, `set` should just pass-through to the property of the settings class. For settings classes containing shared data, `set` should perform no action for that settings class. + ]]> - Application Settings for Custom Controls + Application Settings for Custom Controls diff --git a/xml/System.Configuration/ISettingsProviderService.xml b/xml/System.Configuration/ISettingsProviderService.xml index 68c9d06ae47..5c87f43207a 100644 --- a/xml/System.Configuration/ISettingsProviderService.xml +++ b/xml/System.Configuration/ISettingsProviderService.xml @@ -30,13 +30,13 @@ Provides an interface for defining an alternate application settings provider. - interface enables controls and components hosted in an application to persist their application settings in a manner largely transparent to the application. However, in some cases, the application or environment may need to override the settings provider natively used by a component with one of its own choosing. The interface enables the creation of a lightweight service that communicates such an alternate settings provider, typically offered through the owning . - - is commonly used by design-time tools and debuggers that provide special support for application settings. To make such an arrangement function seamlessly, the class contains constructors that take a reference to the owning component. These constructors automatically query for compatible settings providers. - + interface enables controls and components hosted in an application to persist their application settings in a manner largely transparent to the application. However, in some cases, the application or environment may need to override the settings provider natively used by a component with one of its own choosing. The interface enables the creation of a lightweight service that communicates such an alternate settings provider, typically offered through the owning . + + is commonly used by design-time tools and debuggers that provide special support for application settings. To make such an arrangement function seamlessly, the class contains constructors that take a reference to the owning component. These constructors automatically query for compatible settings providers. + ]]> @@ -44,7 +44,7 @@ - Application Settings for Custom Controls + Application Settings for Custom Controls @@ -82,11 +82,11 @@ Returns the settings provider compatible with the specified settings property. If found, the that can persist the specified settings property; otherwise, . - method enables an to offer its serialization services to any sited component. This method determines if the associated settings provider can persist the specified application settings property type. If it can, this method returns a reference to that settings provider; otherwise it returns `null`. - + method enables an to offer its serialization services to any sited component. This method determines if the associated settings provider can persist the specified application settings property type. If it can, this method returns a reference to that settings provider; otherwise it returns `null`. + ]]> diff --git a/xml/System.Configuration/LocalFileSettingsProvider.xml b/xml/System.Configuration/LocalFileSettingsProvider.xml index 73e5b5858f2..6027402b57d 100644 --- a/xml/System.Configuration/LocalFileSettingsProvider.xml +++ b/xml/System.Configuration/LocalFileSettingsProvider.xml @@ -36,19 +36,19 @@ Provides persistence for application settings classes. - , which stores configuration data to the local file system. An application settings property or group of properties are associated to a specific settings provider through the use of the . - - Typically, the client program does not explicitly access this class; rather, the application settings architecture automatically invokes the appropriate settings provider when its services are required. For example, many of the members of delegate their work to the associated settings provider. - - persists settings to configuration files that have the extension `.config`. The contents of configuration files are structured as XML documents. Depending on whether the setting is scoped at either the application-level or user-level, the configuration data is stored as elements within an `` or a `` section group, respectively. Each of these section groups is represented by a corresponding or , respectively. Each section object is owned and administered by a configuration section handler, which is an object of type . - - Application-scoped settings and the default user-scoped settings are stored in a file named `application.exe.config`, which is created in the same directory as the executable file. Application configuration settings are read-only. Specific user data is stored in a file named `user.config`, stored under the user's home directory. If roaming profiles are enabled, two versions of the user configuration file could exist. In such a case, the entries in the roaming version take precedence over duplicated entries in the local user configuration file. - - For more information about application settings, see [Application Settings for Windows Forms](/dotnet/framework/winforms/advanced/application-settings-for-windows-forms). - + , which stores configuration data to the local file system. An application settings property or group of properties are associated to a specific settings provider through the use of the . + + Typically, the client program does not explicitly access this class; rather, the application settings architecture automatically invokes the appropriate settings provider when its services are required. For example, many of the members of delegate their work to the associated settings provider. + + persists settings to configuration files that have the extension `.config`. The contents of configuration files are structured as XML documents. Depending on whether the setting is scoped at either the application-level or user-level, the configuration data is stored as elements within an `` or a `` section group, respectively. Each of these section groups is represented by a corresponding or , respectively. Each section object is owned and administered by a configuration section handler, which is an object of type . + + Application-scoped settings and the default user-scoped settings are stored in a file named `application.exe.config`, which is created in the same directory as the executable file. Application configuration settings are read-only. Specific user data is stored in a file named `user.config`, stored under the user's home directory. If roaming profiles are enabled, two versions of the user configuration file could exist. In such a case, the entries in the roaming version take precedence over duplicated entries in the local user configuration file. + + For more information about application settings, see [Application Settings for Windows Forms](/dotnet/desktop/winforms/advanced/application-settings-for-windows-forms). + ]]> @@ -57,7 +57,7 @@ - Application Settings Architecture + Application Settings Architecture @@ -87,11 +87,11 @@ Initializes a new instance of the class. - property to . - + property to . + ]]> @@ -138,11 +138,11 @@ Gets or sets the name of the currently running application. A string that contains the application's display name. - and properties help to disambiguate similarly named setting properties in different applications. - + and properties help to disambiguate similarly named setting properties in different applications. + ]]> @@ -188,11 +188,11 @@ Returns the value of the named settings property for the previous version of the same application. A representing the application setting if found; otherwise, . - method is often used in conjunction with the method when migrating application settings during the installation of a new version of an application. For more information, see the method. - + method is often used in conjunction with the method when migrating application settings during the installation of a new version of an application. For more information, see the method. + ]]> @@ -238,14 +238,14 @@ Returns the collection of setting property values for the specified application instance and settings property group. A containing the values for the specified settings property group. - method also manages the special application settings type . Connection strings are stored in a special section of the configuration file delimited by the element ``. - + method also manages the special application settings type . Connection strings are stored in a special section of the configuration file delimited by the element ``. + > [!CAUTION] -> does not use encryption to persist any settings. Therefore, do not store plain text passwords or other sensitive information using this provider without taking additional precautions, such as separately encrypting the information within the configuration file. For more information, see [Encrypting Configuration Information Using Protected Configuration](https://learn.microsoft.com/previous-versions/aspnet/53tyfkaw(v=vs.100)). - +> does not use encryption to persist any settings. Therefore, do not store plain text passwords or other sensitive information using this provider without taking additional precautions, such as separately encrypting the information within the configuration file. For more information, see [Encrypting Configuration Information Using Protected Configuration](https://learn.microsoft.com/previous-versions/aspnet/53tyfkaw(v=vs.100)). + ]]> A user-scoped setting was encountered but the current configuration only supports application-scoped settings. @@ -330,17 +330,17 @@ A describing the current application usage. Resets all application settings properties associated with the specified application to their default values. - method restores the stored values of the specified application settings group. The action of depends on the scope of the application settings property: - -- Application-scoped settings are not affected. - -- User-scoped settings are reset to the default values that are stored as read-only entries in the application configuration file, `application.exe.config`. If roaming profiles are being used, any application settings values in the roaming profile take precedence over duplicates found in the local profile. - - Notice that if roaming profiles are used, there can be two `user.config` files, one for the local settings and one for the roaming profile. - + method restores the stored values of the specified application settings group. The action of depends on the scope of the application settings property: + +- Application-scoped settings are not affected. + +- User-scoped settings are reset to the default values that are stored as read-only entries in the application configuration file, `application.exe.config`. If roaming profiles are being used, any application settings values in the roaming profile take precedence over duplicates found in the local profile. + + Notice that if roaming profiles are used, there can be two `user.config` files, one for the local settings and one for the roaming profile. + ]]> A user-scoped setting was encountered but the current configuration only supports application-scoped settings. @@ -387,32 +387,32 @@ A representing the group of property settings to set. Sets the values of the specified group of property settings. - , contains the method, which is called to persist the values of all of its settings properties. This method enumerates through all the settings providers associated with its settings properties, and calls the method for each to perform the actual serialization operation. - - individually serializes each user-scoped application settings property to its corresponding application setting in the appropriate `user.config` configuration file. - - By default, the method uses the following logical sequence to determine the serialization scheme, depending on type of the settings property: - -1. If the type has an associated with a method implementation, this conversion is used. - -2. XML serialization is used. - - However, you can specify a preferred serialization mechanism by using the . does not support binary serialization in Visual Studio 2005. - - If a user-scoped settings property is set back to its default value explicitly, then the local file settings provider will remove the entry for the associated setting from the user configuration file. The next read access for this property will simply use the default value. - + , contains the method, which is called to persist the values of all of its settings properties. This method enumerates through all the settings providers associated with its settings properties, and calls the method for each to perform the actual serialization operation. + + individually serializes each user-scoped application settings property to its corresponding application setting in the appropriate `user.config` configuration file. + + By default, the method uses the following logical sequence to determine the serialization scheme, depending on type of the settings property: + +1. If the type has an associated with a method implementation, this conversion is used. + +2. XML serialization is used. + + However, you can specify a preferred serialization mechanism by using the . does not support binary serialization in Visual Studio 2005. + + If a user-scoped settings property is set back to its default value explicitly, then the local file settings provider will remove the entry for the associated setting from the user configuration file. The next read access for this property will simply use the default value. + > [!CAUTION] -> does not use encryption to persist any settings. Therefore, do not store plain text passwords or other sensitive information using this provider without taking additional precautions, such as separately encrypting the information within the configuration file. For more information, see [Encrypting Configuration Information Using Protected Configuration](https://learn.microsoft.com/previous-versions/aspnet/53tyfkaw(v=vs.100)). - +> does not use encryption to persist any settings. Therefore, do not store plain text passwords or other sensitive information using this provider without taking additional precautions, such as separately encrypting the information within the configuration file. For more information, see [Encrypting Configuration Information Using Protected Configuration](https://learn.microsoft.com/previous-versions/aspnet/53tyfkaw(v=vs.100)). + ]]> - A user-scoped setting was encountered but the current configuration only supports application-scoped settings. - - -or- - + A user-scoped setting was encountered but the current configuration only supports application-scoped settings. + + -or- + There was a general failure saving the settings to the configuration file. @@ -459,27 +459,27 @@ A containing the settings property group whose values are to be retrieved. Attempts to migrate previous user-scoped settings from a previous version of the same application. - migrates the local and roaming settings in separate operations. - - The method is suppressed for every application setting that has the applied to it, or to the entire settings wrapper class, derived from . - - This way this method is called depends on the type of application that is being upgraded: - -- Each version of a ClickOnce application is stored in its own isolated installation directory. After a new version of a ClickOnce application is installed, and when the new version is first run, internal logic will automatically call to migrate all common application settings to the new version. For more information, see [ClickOnce and Application Settings](/visualstudio/deployment/clickonce-and-application-settings). - -- Standard Windows Forms and console applications must manually call , because there is not a general, automatic way to determine when such an application is first run. The two common ways to do this are either from the installation program or using from the application itself, using a persisted property, often named something like `IsFirstRun`. - - Note that for the newer version to migrate application settings, it must be able to also load and read the older version of the application settings. Therefore, it must contain wrapper classes compatible with both the new and previous versions of the application. - + migrates the local and roaming settings in separate operations. + + The method is suppressed for every application setting that has the applied to it, or to the entire settings wrapper class, derived from . + + This way this method is called depends on the type of application that is being upgraded: + +- Each version of a ClickOnce application is stored in its own isolated installation directory. After a new version of a ClickOnce application is installed, and when the new version is first run, internal logic will automatically call to migrate all common application settings to the new version. For more information, see [ClickOnce and Application Settings](/visualstudio/deployment/clickonce-and-application-settings). + +- Standard Windows Forms and console applications must manually call , because there is not a general, automatic way to determine when such an application is first run. The two common ways to do this are either from the installation program or using from the application itself, using a persisted property, often named something like `IsFirstRun`. + + Note that for the newer version to migrate application settings, it must be able to also load and read the older version of the application settings. Therefore, it must contain wrapper classes compatible with both the new and previous versions of the application. + ]]> - A user-scoped setting was encountered but the current configuration only supports application-scoped settings. - - -or- - + A user-scoped setting was encountered but the current configuration only supports application-scoped settings. + + -or- + The previous version of the configuration file could not be accessed. diff --git a/xml/System.Configuration/SettingsManageabilityAttribute.xml b/xml/System.Configuration/SettingsManageabilityAttribute.xml index 7747a4a588c..d8212fad312 100644 --- a/xml/System.Configuration/SettingsManageabilityAttribute.xml +++ b/xml/System.Configuration/SettingsManageabilityAttribute.xml @@ -38,18 +38,18 @@ Specifies special services for application settings properties. This class cannot be inherited. - indicates that special, predefined services are to be provided to individual application settings properties and property groups. Most of these services will be provided by the Windows operating system. - - For more information about application settings properties and their use, see [Application Settings for Windows Forms](/dotnet/framework/winforms/advanced/application-settings-for-windows-forms). - + indicates that special, predefined services are to be provided to individual application settings properties and property groups. Most of these services will be provided by the Windows operating system. + + For more information about application settings properties and their use, see [Application Settings for Windows Forms](/dotnet/desktop/winforms/advanced/application-settings-for-windows-forms). + ]]> - Application Settings for Windows Forms + Application Settings for Windows Forms @@ -89,11 +89,11 @@ A value that enumerates the services being requested. Initializes a new instance of the class. - enumeration with the logical `OR` operator. - + enumeration with the logical `OR` operator. + ]]> @@ -136,11 +136,11 @@ Gets the set of special services that have been requested. A value that results from using the logical operator to combine all the enumeration values corresponding to the requested services. - constructor. - + constructor. + ]]> diff --git a/xml/System.Configuration/SettingsProvider.xml b/xml/System.Configuration/SettingsProvider.xml index 572b5d37b6d..ad2b73f58eb 100644 --- a/xml/System.Configuration/SettingsProvider.xml +++ b/xml/System.Configuration/SettingsProvider.xml @@ -32,25 +32,25 @@ Acts as a base class for deriving custom settings providers in the application settings architecture. - , which stores configuration data to the local file system. However, you can create alternate storage mechanisms by deriving from the abstract class. The provider that a wrapper class uses is determined by decorating the wrapper class with the . If this attribute is not provided, the default, , is used. - - When you create a custom settings provider, at minimum, you must provide implementations for the three methods of this class: , and . - - For client applications, you can add more standardized functionality to a custom provider by also implementing the interface. This interface mirrors methods found in the class, which mainly enables versioning support. - - Typically, you should design settings providers to be single-instanced to avoid storage resource contention. Providers should also be thread-safe because they can be called simultaneously from multiple wrapper instances in a single application domain or from multiple applications in different domains. - - At minimum, a settings provider must recognize three attributes - , , and . For a full listing of attributes that can be applied to application settings, see [Application Settings Attributes](/dotnet/framework/winforms/advanced/application-settings-attributes). A custom setting provider should resolve attributes applied to settings properties in the following manner: - -1. If the provider can fulfill the request implied by the attribute, obviously it should do so. - -2. If the provider cannot fulfill the request, it should ignore it silently. - -3. If two or more properties conflict; for example, a property being decorated with both and ; the provider should throw a . - + , which stores configuration data to the local file system. However, you can create alternate storage mechanisms by deriving from the abstract class. The provider that a wrapper class uses is determined by decorating the wrapper class with the . If this attribute is not provided, the default, , is used. + + When you create a custom settings provider, at minimum, you must provide implementations for the three methods of this class: , and . + + For client applications, you can add more standardized functionality to a custom provider by also implementing the interface. This interface mirrors methods found in the class, which mainly enables versioning support. + + Typically, you should design settings providers to be single-instanced to avoid storage resource contention. Providers should also be thread-safe because they can be called simultaneously from multiple wrapper instances in a single application domain or from multiple applications in different domains. + + At minimum, a settings provider must recognize three attributes - , , and . For a full listing of attributes that can be applied to application settings, see [Application Settings Attributes](/dotnet/desktop/winforms/advanced/application-settings-attributes). A custom setting provider should resolve attributes applied to settings properties in the following manner: + +1. If the provider can fulfill the request implied by the attribute, obviously it should do so. + +2. If the provider cannot fulfill the request, it should ignore it silently. + +3. If two or more properties conflict; for example, a property being decorated with both and ; the provider should throw a . + ]]> @@ -58,8 +58,8 @@ - Application Settings Architecture - Application Settings Attributes + Application Settings Architecture + Application Settings Attributes @@ -95,17 +95,17 @@ Initializes an instance of the class. - method typically performs all initialization. - - Client code typically does not directly instantiate a settings provider; instead, you use the following procedure to find a settings provider for a particular settings property: - -1. Call the method on the current or to return a reference to the current . - -2. Call the method of the retrieved in the first step to return the settings provider. - + method typically performs all initialization. + + Client code typically does not directly instantiate a settings provider; instead, you use the following procedure to find a settings provider for a particular settings property: + +1. Call the method on the current or to return a reference to the current . + +2. Call the method of the retrieved in the first step to return the settings provider. + ]]> @@ -144,11 +144,11 @@ Gets or sets the name of the currently running application. A that contains the application's shortened name, which does not contain a full path or extension, for example, SimpleAppSettings. - and properties help to disambiguate similarly named setting properties in different applications. - + and properties help to disambiguate similarly named setting properties in different applications. + ]]> @@ -191,11 +191,11 @@ Returns the collection of settings property values for the specified application instance and settings property group. A containing the values for the specified settings property group. - method must be implemented to handle special settings, those marked with , as well as reconcile application and user settings. - + method must be implemented to handle special settings, those marked with , as well as reconcile application and user settings. + ]]> @@ -238,17 +238,17 @@ A representing the group of property settings to set. Sets the values of the specified group of property settings. - contains the method, which is called to persist the values of all of its settings properties. This method enumerates through all the settings providers associated with its settings properties, and calls the method for each to perform the actual serialization operation. - - The method should be implemented with security in mind: - -- Only fully trusted code should be allowed to update application settings. Partially trusted code should be allowed to update only user application settings. Untrusted code is not typically allowed to update application settings. - -- Usage quotas should be considered to guard against resource attacks by partially trusted applications. - + contains the method, which is called to persist the values of all of its settings properties. This method enumerates through all the settings providers associated with its settings properties, and calls the method for each to perform the actual serialization operation. + + The method should be implemented with security in mind: + +- Only fully trusted code should be allowed to update application settings. Partially trusted code should be allowed to update only user application settings. Untrusted code is not typically allowed to update application settings. + +- Usage quotas should be considered to guard against resource attacks by partially trusted applications. + ]]> diff --git a/xml/System.Configuration/SettingsProviderAttribute.xml b/xml/System.Configuration/SettingsProviderAttribute.xml index d728071b564..60daf355fef 100644 --- a/xml/System.Configuration/SettingsProviderAttribute.xml +++ b/xml/System.Configuration/SettingsProviderAttribute.xml @@ -38,23 +38,23 @@ Specifies the settings provider used to provide storage for the current application settings class or property. This class cannot be inherited. - - that actually provides the storage mechanism. - - The specifies the settings provider used to provide storage for application settings properties. This attribute can be applied to the entire application settings class or individual application settings properties. A set at the property level will override the class-level attribute. If a settings provider is not explicitly specified, the default provider is used. For client applications, the default provider is . - - Setting providers cannot be determined at run time. Any run-time determination of storage methods must be coded into the settings provider class itself. - + - that actually provides the storage mechanism. + + The specifies the settings provider used to provide storage for application settings properties. This attribute can be applied to the entire application settings class or individual application settings properties. A set at the property level will override the class-level attribute. If a settings provider is not explicitly specified, the default provider is used. For client applications, the default provider is . + + Setting providers cannot be determined at run time. Any run-time determination of storage methods must be coded into the settings provider class itself. + > [!CAUTION] -> Using custom settings providers from arbitrary third parties is inherently unsafe because these providers have full read/write access to your application's configuration information. A settings provider should be thoroughly vetted before it is adopted for general use. - +> Using custom settings providers from arbitrary third parties is inherently unsafe because these providers have full read/write access to your application's configuration information. A settings provider should be thoroughly vetted before it is adopted for general use. + ]]> - Application Settings Architecture + Application Settings Architecture @@ -94,14 +94,14 @@ A containing the name of the settings provider. Initializes an instance of the class. - , that is being specified as the settings provider. - + , that is being specified as the settings provider. + > [!CAUTION] -> Using custom settings providers from arbitrary third parties is inherently unsafe because these providers have full read/write access to your application's configuration information. A settings provider should be thoroughly vetted before it is adopted for general use. - +> Using custom settings providers from arbitrary third parties is inherently unsafe because these providers have full read/write access to your application's configuration information. A settings provider should be thoroughly vetted before it is adopted for general use. + ]]> @@ -178,11 +178,11 @@ Gets the type name of the settings provider. A containing the name of the settings provider. - property is set in the for the class. - + property is set in the for the class. + ]]> diff --git a/xml/System.Configuration/UserScopedSettingAttribute.xml b/xml/System.Configuration/UserScopedSettingAttribute.xml index 093efcd284b..4b88fdf7eb2 100644 --- a/xml/System.Configuration/UserScopedSettingAttribute.xml +++ b/xml/System.Configuration/UserScopedSettingAttribute.xml @@ -62,7 +62,7 @@ - Application Settings Architecture + Application Settings Architecture diff --git a/xml/System.Diagnostics.SymbolStore/ISymbolDocumentWriter.xml b/xml/System.Diagnostics.SymbolStore/ISymbolDocumentWriter.xml index 3f389f84546..aca47bb5bcb 100644 --- a/xml/System.Diagnostics.SymbolStore/ISymbolDocumentWriter.xml +++ b/xml/System.Diagnostics.SymbolStore/ISymbolDocumentWriter.xml @@ -48,23 +48,22 @@ Represents a document referenced by a symbol store. - [!NOTE] -> This interface is the managed counterpart of the `ISymUnmanagedDocumentWriter` interface, which is one of the unmanaged symbol store interfaces that provide an alternate way to read and write debug symbol information. - - +> This interface is the managed counterpart of the `ISymUnmanagedDocumentWriter` interface, which is one of the unmanaged symbol store interfaces that provide an alternate way to read and write debug symbol information. + + + +## Examples + The following code example demonstrates how an can be obtained when calling . -## Examples - The following code example demonstrates how an can be obtained when calling . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics.SymbolStore/ISymbolDocumentWriter/Overview/modulebuilder_definedocument.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineDocument/VB/modulebuilder_definedocument.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineDocument/VB/modulebuilder_definedocument.vb" id="Snippet1"::: + ]]> @@ -116,11 +115,11 @@ The checksum. Sets checksum information. - @@ -167,11 +166,11 @@ The document source represented as unsigned bytes. Stores the raw source for a document in the symbol store. - diff --git a/xml/System.Diagnostics.SymbolStore/SymDocumentType.xml b/xml/System.Diagnostics.SymbolStore/SymDocumentType.xml index b8d996122fa..023c478d51a 100644 --- a/xml/System.Diagnostics.SymbolStore/SymDocumentType.xml +++ b/xml/System.Diagnostics.SymbolStore/SymDocumentType.xml @@ -50,15 +50,14 @@ Holds the public GUIDs for document types to be used with the symbol store. - is used when calling the method. -## Examples - The following example demonstrates how is used when calling the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics.SymbolStore/ISymbolDocumentWriter/Overview/modulebuilder_definedocument.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineDocument/VB/modulebuilder_definedocument.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineDocument/VB/modulebuilder_definedocument.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Diagnostics.SymbolStore/SymLanguageType.xml b/xml/System.Diagnostics.SymbolStore/SymLanguageType.xml index 68d64ded499..bb6ee29ef0c 100644 --- a/xml/System.Diagnostics.SymbolStore/SymLanguageType.xml +++ b/xml/System.Diagnostics.SymbolStore/SymLanguageType.xml @@ -50,15 +50,14 @@ Holds the public GUIDs for language types to be used with the symbol store. - is used when calling . -## Examples - The following code example demonstrates how is used when calling . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics.SymbolStore/ISymbolDocumentWriter/Overview/modulebuilder_definedocument.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineDocument/VB/modulebuilder_definedocument.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineDocument/VB/modulebuilder_definedocument.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Diagnostics.SymbolStore/SymLanguageVendor.xml b/xml/System.Diagnostics.SymbolStore/SymLanguageVendor.xml index 19ffd014fda..5bcd5a5148a 100644 --- a/xml/System.Diagnostics.SymbolStore/SymLanguageVendor.xml +++ b/xml/System.Diagnostics.SymbolStore/SymLanguageVendor.xml @@ -50,15 +50,14 @@ Holds the public GUIDs for language vendors to be used with the symbol store. - is used when calling . -## Examples - The following code example demonstrates how is used when calling . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ModuleBuilder_DefineDocument/CPP/modulebuilder_definedocument.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics.SymbolStore/ISymbolDocumentWriter/Overview/modulebuilder_definedocument.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineDocument/VB/modulebuilder_definedocument.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ModuleBuilder_DefineDocument/VB/modulebuilder_definedocument.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Diagnostics/BooleanSwitch.xml b/xml/System.Diagnostics/BooleanSwitch.xml index 92abe692fa8..96ec953a8fa 100644 --- a/xml/System.Diagnostics/BooleanSwitch.xml +++ b/xml/System.Diagnostics/BooleanSwitch.xml @@ -55,56 +55,54 @@ Provides a simple on/off switch that controls debugging and tracing output. - property to get the current value of the switch. - + property to get the current value of the switch. + You can create a in your code and set the property directly to instrument a specific section of code. -For .NET Framework apps only, you can also enable or disable a through the application configuration file and then use the configured value in your application. To configure a , edit the configuration file that corresponds to the name of your application. Within this file, you can add or remove a switch, set a switch's value, or clear all the switches previously set by the application. The configuration file should be formatted like the following example. - -```xml - - - - - - - -``` - - This example configuration section defines a with the property set to `mySwitch` and the value set to `true`. Within your .NET Framework application, you can use the configured switch value by creating a with the same name, as shown in the following code example. +For .NET Framework apps only, you can also enable or disable a through the application configuration file and then use the configured value in your application. To configure a , edit the configuration file that corresponds to the name of your application. Within this file, you can add or remove a switch, set a switch's value, or clear all the switches previously set by the application. The configuration file should be formatted like the following example. + +```xml + + + + + + + +``` + + This example configuration section defines a with the property set to `mySwitch` and the value set to `true`. Within your .NET Framework application, you can use the configured switch value by creating a with the same name, as shown in the following code example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/remarks.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/BooleanSwitch/Overview/remarks.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/VB/remarks.vb" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/VB/remarks.vb" id="Snippet2"::: For .NET Core and .NET 5+ apps, the property of the new switch is set to `false` by default. -For .NET Framework apps, the property is set using the value specified in the configuration file. Configure the switch with a value of 0 to set the property to `false`; configure the switch with a nonzero value to set the property to `true`. If the constructor cannot find initial switch settings in the configuration file, the property of the new switch is set to `false`. - - You must enable tracing or debugging to use a switch. The following syntax is compiler specific. If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler. - -- To enable debugging in C#, add the `/d:DEBUG` flag to the compiler command line when you compile your code, or you can add `#define DEBUG` to the top of your file. In Visual Basic, add the `/d:DEBUG=True` flag to the compiler command line. - -- To enable tracing in C#, add the `/d:TRACE` flag to the compiler command line when you compile your code, or add `#define TRACE` to the top of your file. In Visual Basic, add the `/d:TRACE=True` flag to the compiler command line. - +For .NET Framework apps, the property is set using the value specified in the configuration file. Configure the switch with a value of 0 to set the property to `false`; configure the switch with a nonzero value to set the property to `true`. If the constructor cannot find initial switch settings in the configuration file, the property of the new switch is set to `false`. + + You must enable tracing or debugging to use a switch. The following syntax is compiler specific. If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler. + +- To enable debugging in C#, add the `/d:DEBUG` flag to the compiler command line when you compile your code, or you can add `#define DEBUG` to the top of your file. In Visual Basic, add the `/d:DEBUG=True` flag to the compiler command line. + +- To enable tracing in C#, add the `/d:TRACE` flag to the compiler command line when you compile your code, or add `#define TRACE` to the top of your file. In Visual Basic, add the `/d:TRACE=True` flag to the compiler command line. + > [!NOTE] -> These debug and trace compiler switches are not required when using the class in isolation. They are only required in conjunction with or methods that are conditionally compiled. - - For more information on instrumenting your application, see and . For more information about configuring and using trace switches, see [Trace Switches](/dotnet/framework/debug-trace-profile/trace-switches). - +> These debug and trace compiler switches are not required when using the class in isolation. They are only required in conjunction with or methods that are conditionally compiled. + + For more information on instrumenting your application, see and . For more information about configuring and using trace switches, see [Trace Switches](/dotnet/framework/debug-trace-profile/trace-switches). + > [!NOTE] > To improve performance, you can make members `static` in your class. - -## Examples - The following example creates a and uses the switch to determine whether to print an error message. You create the switch at the class level. The `Main` method passes its location to `MyMethod`, which prints an error message and where the error occurred. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following example creates a and uses the switch to determine whether to print an error message. You create the switch at the class level. The `Main` method passes its location to `MyMethod`, which prints an error message and where the error occurred. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/BooleanSwitch/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -179,36 +177,35 @@ For .NET Framework apps, the The description of the switch. Initializes a new instance of the class with the specified display name and description. - , the `displayName` parameter is used to find the initial switch settings for .NET Framework apps in the application configuration file. If the constructor cannot find initial settings, or for .NET Core and .NET 5+ apps, the property is set to `false` (disabled). - - To set the level of your in a .NET Framework app, edit the configuration file corresponding to the name of your application. Within this file, you can add a switch and set its value, remove a switch, or clear all switches previously set by the application. The configuration file should be formatted like the following example: - -```xml - - - - - - - - - - -``` - + , the `displayName` parameter is used to find the initial switch settings for .NET Framework apps in the application configuration file. If the constructor cannot find initial settings, or for .NET Core and .NET 5+ apps, the property is set to `false` (disabled). + + To set the level of your in a .NET Framework app, edit the configuration file corresponding to the name of your application. Within this file, you can add a switch and set its value, remove a switch, or clear all switches previously set by the application. The configuration file should be formatted like the following example: + +```xml + + + + + + + + + + +``` + > [!NOTE] > The switches you created should be `static`. - -## Examples - The following example creates a and uses the switch to determine whether to print an error message. The switch is created at the class level. The `Main` method passes its location to `MyMethod`, which prints an error message and where the error occurred. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following example creates a and uses the switch to determine whether to print an error message. The switch is created at the class level. The `Main` method passes its location to `MyMethod`, which prints an error message and where the error occurred. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/BooleanSwitch/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BooleanSwitch.BooleanSwitch Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -317,18 +314,17 @@ For .NET Framework apps, the if the switch is enabled; otherwise, . The default is . - . - -## Examples - The following code example creates a and uses the switch to determine whether to print an error message. The switch is created at the class level. The `Main` method passes its location to `MyMethod`, which prints an error message and the location where the error occurred. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic BooleanSwitch.Enabled Example/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following code example creates a and uses the switch to determine whether to print an error message. The switch is created at the class level. The `Main` method passes its location to `MyMethod`, which prints an error message and the location where the error occurred. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/BooleanSwitch/Enabled/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BooleanSwitch.Enabled Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic BooleanSwitch.Enabled Example/VB/source.vb" id="Snippet1"::: + ]]> The caller does not have the correct permission. @@ -377,11 +373,11 @@ For .NET Framework apps, the Determines whether the new value of the property can be parsed as a Boolean value. - method determines whether the new value is a valid string representation of a Boolean value ("false" or "true"). If so, the method sets the property to 0 or 1. Otherwise, the base method is called, which converts the string value to an integer value, which is then used to set the property. - + method determines whether the new value is a valid string representation of a Boolean value ("false" or "true"). If so, the method sets the property to 0 or 1. Otherwise, the base method is called, which converts the string value to an integer value, which is then used to set the property. + ]]> diff --git a/xml/System.Diagnostics/CorrelationManager.xml b/xml/System.Diagnostics/CorrelationManager.xml index 50136e61ac0..cee2e150bd5 100644 --- a/xml/System.Diagnostics/CorrelationManager.xml +++ b/xml/System.Diagnostics/CorrelationManager.xml @@ -49,25 +49,24 @@ Correlates traces that are part of a logical transaction. - class provides methods used to store a logical operation identity in a thread-bound context and automatically tag each trace event generated by the thread with the stored identity. - - Logical operations can also be nested. The property exposes the stack of nested logical operation identities. Each call to the method pushes a new logical operation identity onto the stack. Each call to the method pops a logical operation identity off the stack. - + class provides methods used to store a logical operation identity in a thread-bound context and automatically tag each trace event generated by the thread with the stored identity. + + Logical operations can also be nested. The property exposes the stack of nested logical operation identities. Each call to the method pushes a new logical operation identity onto the stack. Each call to the method pops a logical operation identity off the stack. + > [!NOTE] -> Logical operation identities are objects, allowing the use of a type for a logical operation identity. - - - -## Examples - The following code example demonstrates the use of the class by identifying the logical operation associated with a traced event. Two logical operations are started, one in the main thread and the other in a worker thread. An error event is logged in both logical operations. +> Logical operation identities are objects, allowing the use of a type for a logical operation identity. + + + +## Examples + The following code example demonstrates the use of the class by identifying the logical operation associated with a traced event. Two logical operations are started, one in the main thread and the other in a worker thread. An error event is logged in both logical operations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/cpp/correlationmanager.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CorrelationManager/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/vb/module1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/vb/module1.vb" id="Snippet1"::: + ]]> @@ -110,11 +109,11 @@ Gets or sets the identity for a global activity. A structure that identifies the global activity. - property gets and sets the global activity identity in the for the thread. The is used for trace transfer operations in trace listeners that override the method, such as the class. - + property gets and sets the global activity identity in the for the thread. The is used for trace transfer operations in trace listeners that override the method, such as the class. + ]]> @@ -163,11 +162,11 @@ Gets the logical operation stack from the call context. A object that represents the logical operation stack for the call context. - method pushes a new logical operation identity onto the property's stack. Each call to the method pops a logical operation identity from the stack. - + method pushes a new logical operation identity onto the property's stack. Each call to the method pops a logical operation identity from the stack. + ]]> @@ -220,11 +219,11 @@ Starts a logical operation on a thread. - @@ -270,19 +269,19 @@ An object identifying the operation. Starts a logical operation with the specified identity on a thread. - that allows the operation to be identified for tracing purposes. The object represented by `operationId` is added to the property. - - - -## Examples - The following code example demonstrates the use of the method by initializing a logical operation to be associated with the main thread. For the complete code example, see the class. - + that allows the operation to be identified for tracing purposes. The object represented by `operationId` is added to the property. + + + +## Examples + The following code example demonstrates the use of the method by initializing a logical operation to be associated with the main thread. For the complete code example, see the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CorrelationManager/Overview/program.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/vb/module1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.CorrelationManager/vb/module1.vb" id="Snippet2"::: + ]]> The parameter is . @@ -326,11 +325,11 @@ Stops the current logical operation. - property. - + property. + ]]> The property is an empty stack. diff --git a/xml/System.Diagnostics/CounterCreationData.xml b/xml/System.Diagnostics/CounterCreationData.xml index 728787578af..67c7267b590 100644 --- a/xml/System.Diagnostics/CounterCreationData.xml +++ b/xml/System.Diagnostics/CounterCreationData.xml @@ -52,15 +52,14 @@ Defines the counter type, name, and Help string for a custom counter. - class to define custom counters. This example creates counters that display how many items are processed in an operation. The example initializes the counters, collects information from them, and then calculates and displays the results to the console. -## Examples - The following code example demonstrates how to use the class to define custom counters. This example creates counters that display how many items are processed in an operation. The example initializes the counters, collects information from them, and then calculates and displays the results to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -105,15 +104,14 @@ Initializes a new instance of the class, to a counter of type , and with empty name and help strings. - class. Because the example does not pass in any parameters, the , , and properties are not specified and must be defined later. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp" id="Snippet3"::: + class. Because the example does not pass in any parameters, the , , and properties are not specified and must be defined later. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/.ctor/diagnostics_countercreationdata.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diagnostics_CounterCreationData/VB/diagnostics_countercreationdata.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diagnostics_CounterCreationData/VB/diagnostics_countercreationdata.vb" id="Snippet3"::: + ]]> @@ -157,15 +155,14 @@ A that identifies the counter's behavior. Initializes a new instance of the class, to a counter of the specified type, using the specified counter name and Help strings. - class, and pass in parameters to set the , and properties of the object when it is initialized. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp" id="Snippet2"::: + class, and pass in parameters to set the , and properties of the object when it is initialized. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/.ctor/diagnostics_countercreationdata.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diagnostics_CounterCreationData/VB/diagnostics_countercreationdata.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diagnostics_CounterCreationData/VB/diagnostics_countercreationdata.vb" id="Snippet2"::: + ]]> You have specified a value for that is not a member of the enumeration. @@ -222,15 +219,14 @@ Gets or sets the custom counter's description. The text that describes the counter's behavior. - property. This example creates two counters and sets their property by using different techniques. When the first counter is initialized, the data is passed to the constructor, whereas the second counter sets the property explicitly. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp" id="Snippet5"::: + property. This example creates two counters and sets their property by using different techniques. When the first counter is initialized, the data is passed to the constructor, whereas the second counter sets the property explicitly. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/.ctor/diagnostics_countercreationdata.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diagnostics_CounterCreationData/VB/diagnostics_countercreationdata.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diagnostics_CounterCreationData/VB/diagnostics_countercreationdata.vb" id="Snippet5"::: + ]]> The specified value is . @@ -297,15 +293,14 @@ Gets or sets the name of the custom counter. A name for the counter, which is unique in its category. - property. This example creates two counters and sets their property by using different techniques. When the first counter is initialized, the data is passed to the constructor, whereas the second counter sets the property explicitly. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp" id="Snippet4"::: + property. This example creates two counters and sets their property by using different techniques. When the first counter is initialized, the data is passed to the constructor, whereas the second counter sets the property explicitly. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/.ctor/diagnostics_countercreationdata.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diagnostics_CounterCreationData/VB/diagnostics_countercreationdata.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diagnostics_CounterCreationData/VB/diagnostics_countercreationdata.vb" id="Snippet4"::: + ]]> The specified value is . @@ -361,15 +356,14 @@ Gets or sets the performance counter type of the custom counter. A that defines the behavior of the performance counter. - property. This example creates two counters and sets their property by using different techniques. When the first counter is initialized, the data is passed to the constructor, whereas the second counter sets the property explicitly. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diagnostics_CounterCreationData/CPP/diagnostics_countercreationdata.cpp" id="Snippet6"::: + property. This example creates two counters and sets their property by using different techniques. When the first counter is initialized, the data is passed to the constructor, whereas the second counter sets the property explicitly. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/.ctor/diagnostics_countercreationdata.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diagnostics_CounterCreationData/VB/diagnostics_countercreationdata.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diagnostics_CounterCreationData/VB/diagnostics_countercreationdata.vb" id="Snippet6"::: + ]]> You have specified a type that is not a member of the enumeration. diff --git a/xml/System.Diagnostics/CounterCreationDataCollection.xml b/xml/System.Diagnostics/CounterCreationDataCollection.xml index 02e961188b5..b45a6cda23a 100644 --- a/xml/System.Diagnostics/CounterCreationDataCollection.xml +++ b/xml/System.Diagnostics/CounterCreationDataCollection.xml @@ -40,15 +40,14 @@ Provides a strongly typed collection of objects. - class. The example creates a new instance of the class and uses several methods to add statements to the collection, return their index, and add or remove attributes at a specific index point. + class. The example creates a new instance of the class and uses several methods to add statements to the collection, return their index, and add or remove attributes at a specific index point. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -130,15 +129,14 @@ An array of instances with which to initialize this . Initializes a new instance of the class by using the specified array of instances. - object by using a array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationData/CPP/countercreationdatacollection_ctor.cpp" id="Snippet1"::: + object by using a array. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationData/VB/countercreationdatacollection_ctor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationData/VB/countercreationdatacollection_ctor.vb" id="Snippet1"::: + ]]> @@ -177,15 +175,14 @@ A that holds instances with which to initialize this . Initializes a new instance of the class by using the specified collection of instances. - object by using objects from another . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationDataCollection/CPP/countercreationdatacollection_ctor.cpp" id="Snippet1"::: + object by using objects from another . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/.ctor/countercreationdatacollection_ctor_countercreationdatacollection.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationDataCollection/VB/countercreationdatacollection_ctor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_CounterCreationDataCollection/VB/countercreationdatacollection_ctor.vb" id="Snippet1"::: + ]]> @@ -228,15 +225,14 @@ Adds an instance of the class to the collection. The index of the new object. - method to add a object to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: + method to add a object to a . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -328,15 +324,14 @@ A collection of instances to append to the existing collection. Adds the specified collection of instances to the collection. - method overload to add objects from one to another . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_AddRange/CPP/countercreationdatacollection_addrange.cpp" id="Snippet2"::: + method overload to add objects from one to another . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/AddRange/countercreationdatacollection_addrange.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_AddRange/VB/countercreationdatacollection_addrange.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_AddRange/VB/countercreationdatacollection_addrange.vb" id="Snippet2"::: + ]]> @@ -380,15 +375,14 @@ if the specified object exists in the collection; otherwise, . - method to find a object in a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Contains/CPP/countercreationdatacollection_contains.cpp" id="Snippet1"::: + method to find a object in a . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/Contains/countercreationdatacollection_contains.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_Contains/VB/countercreationdatacollection_contains.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_Contains/VB/countercreationdatacollection_contains.vb" id="Snippet1"::: + ]]> @@ -473,15 +467,14 @@ Returns the index of a object in the collection. The zero-based index of the specified , if it is found, in the collection; otherwise, -1. - entries from a and uses the method to display their names and indexes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/CPP/countercreationdatacollection_insert_indexof.cpp" id="Snippet1"::: + entries from a and uses the method to display their names and indexes. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/IndexOf/countercreationdatacollection_insert_indexof.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/VB/countercreationdatacollection_insert_indexof.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/VB/countercreationdatacollection_insert_indexof.vb" id="Snippet1"::: + ]]> @@ -523,15 +516,14 @@ The to insert into the collection. Inserts a object into the collection, at the specified index. - method to insert a object into a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/CPP/countercreationdatacollection_insert_indexof.cpp" id="Snippet1"::: + method to insert a object into a . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/IndexOf/countercreationdatacollection_insert_indexof.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/VB/countercreationdatacollection_insert_indexof.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_Insert_IndexOf/VB/countercreationdatacollection_insert_indexof.vb" id="Snippet1"::: + ]]> @@ -539,10 +531,10 @@ is not a object. - is less than 0. - - -or- - + is less than 0. + + -or- + is greater than the number of items in the collection. @@ -583,10 +575,10 @@ The collection index, which is used to access individual elements of the collection. To be added. - is less than 0. - - -or- - + is less than 0. + + -or- + is equal to or greater than the number of items in the collection. @@ -619,7 +611,7 @@ [!NOTE] > This override of the OnInsert method is not implemented in the .NET Framework version 2.0 and later. @@ -663,11 +655,11 @@ The object that will be validated. Checks the specified object to determine whether it is a valid type. - method determines whether the object specified in the `value` parameter is a instance. If not, it throws an . - + method determines whether the object specified in the `value` parameter is a instance. If not, it throws an . + ]]> @@ -711,24 +703,23 @@ The to remove from the collection. Removes a object from the collection. - method to delete a object from the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CounterCreationDataCollection_Contains/CPP/countercreationdatacollection_contains.cpp" id="Snippet2"::: + method to delete a object from the . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationDataCollection/Contains/countercreationdatacollection_contains.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_Contains/VB/countercreationdatacollection_contains.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterCreationDataCollection_Contains/VB/countercreationdatacollection_contains.vb" id="Snippet2"::: + ]]> is . - is not a object. - - -or- - + is not a object. + + -or- + does not exist in the collection. diff --git a/xml/System.Diagnostics/CounterSample.xml b/xml/System.Diagnostics/CounterSample.xml index 5b4ce83e25d..8c96543c8f3 100644 --- a/xml/System.Diagnostics/CounterSample.xml +++ b/xml/System.Diagnostics/CounterSample.xml @@ -48,15 +48,14 @@ Defines a structure that holds the raw data for a performance counter. - class to display data for a performance counter. -## Examples - The following example demonstrates the use of the class to display data for a performance counter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -114,11 +113,11 @@ A object that indicates the type of the counter for which this sample is a snapshot. Initializes a new instance of the structure and sets the property to 0 (zero). - method for the first time. - + method for the first time. + ]]> @@ -175,23 +174,21 @@ The time at which the sample was taken. Initializes a new instance of the structure and sets the property to the value that is passed in. - method. - - - -## Examples - The following example demonstrates how to initialize a new structure, passing in values for the `rawValue`, `baseValue`, `counterFrequency`, `systemFrequency`, `timeStamp`, `timeStamp100nSec`, `counterType`, and `counterTimeStamp` parameters. After creating the structure, the example displays the property values for the in the console window. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CounterSample_Ctor_2/CPP/countersample_ctor_2.cpp" id="Snippet1"::: + method. + + + +## Examples + The following example demonstrates how to initialize a new structure, passing in values for the `rawValue`, `baseValue`, `counterFrequency`, `systemFrequency`, `timeStamp`, `timeStamp100nSec`, `counterType`, and `counterTimeStamp` parameters. After creating the structure, the example displays the property values for the in the console window. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterSample/.ctor/countersample_ctor_2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterSample_Ctor_2/VB/countersample_ctor_2.vb" id="Snippet1"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CounterSample_Ctor_2/CPP/countersample_ctor_2.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterSample_Ctor_2/VB/countersample_ctor_2.vb" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterSample/.ctor/countersample_ctor_2.cs" id="Snippet2"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterSample_Ctor_2/VB/countersample_ctor_2.vb" id="Snippet2"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CounterSample_Ctor_2/VB/countersample_ctor_2.vb" id="Snippet2"::: + ]]> @@ -234,15 +231,14 @@ Gets an optional, base raw value for the counter. The base raw value, which is used only if the sample is based on multiple counters. - property for a counter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: + property for a counter. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -372,15 +368,14 @@ Gets the raw counter frequency. The frequency with which the counter is read. - property for a counter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: + property for a counter. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -423,15 +418,14 @@ Gets the counter's time stamp. The time at which the sample was taken. - property for a counter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: + property for a counter. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -559,11 +553,11 @@ if is equal to the current instance; otherwise, . - structures are equal if they have identical property values. - + structures are equal if they have identical property values. + ]]> @@ -604,11 +598,11 @@ if is a structure and is identical to the current instance; otherwise, . - structures are equal if they have identical property values. - + structures are equal if they have identical property values. + ]]> @@ -685,11 +679,11 @@ if and are equal; otherwise, . - structures are equal if they have identical property values. - + structures are equal if they have identical property values. + The equivalent method for this operator is .]]> @@ -732,11 +726,11 @@ if and are not equal; otherwise, . - structures are not equal if any of their property values are different. - + structures are not equal if any of their property values are different. + The equivalent method for this operator is .]]> @@ -779,15 +773,14 @@ Gets the raw value of the counter. The numeric value that is associated with the performance counter sample. - property for a counter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: + property for a counter. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -830,15 +823,14 @@ Gets the raw system frequency. The frequency with which the system reads from the counter. - property for a counter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: + property for a counter. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -881,15 +873,14 @@ Gets the raw time stamp. The system time stamp. - property for a counter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: + property for a counter. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -932,15 +923,14 @@ Gets the raw, high-fidelity time stamp. The system time stamp, represented within 0.1 millisecond. - property for a counter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: + property for a counter. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Diagnostics/CounterSampleCalculator.xml b/xml/System.Diagnostics/CounterSampleCalculator.xml index 2786662ff2b..ca807d9085a 100644 --- a/xml/System.Diagnostics/CounterSampleCalculator.xml +++ b/xml/System.Diagnostics/CounterSampleCalculator.xml @@ -84,23 +84,23 @@ Computes the calculated value of a single raw counter sample. A floating-point representation of the performance counter's calculated value. - method overload returns meaningful results only for performance counters of the following : - -- - -- - -- - -- - -- - - For other counter types, this overload always returns a value of 0 (zero). - + method overload returns meaningful results only for performance counters of the following : + +- + +- + +- + +- + +- + + For other counter types, this overload always returns a value of 0 (zero). + ]]> @@ -143,15 +143,14 @@ Computes the calculated value of two raw counter samples. A floating-point representation of the performance counter's calculated value. - method overload to calculate the value of two raw counter samples. -## Examples - The following example demonstrates the use of the method overload to calculate the value of two raw counter samples. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Diagnostics/DataReceivedEventArgs.xml b/xml/System.Diagnostics/DataReceivedEventArgs.xml index 19b4d5368a8..7330f709035 100644 --- a/xml/System.Diagnostics/DataReceivedEventArgs.xml +++ b/xml/System.Diagnostics/DataReceivedEventArgs.xml @@ -50,22 +50,21 @@ Provides data for the and events. - or stream output of a process, you must create a method that handles the redirected stream output events. The event-handler method is called when the process writes to the redirected stream. The event delegate calls your event handler with an instance of . The property contains the text line that the process wrote to the redirected stream. + + + +## Examples + The following code example illustrates how to perform asynchronous read operations on the redirected stream of the `sort` command. The `sort` command is a console application that reads and sorts text input. + + The example creates an event delegate for the `SortOutputHandler` event handler and associates it with the event. The event handler receives text lines from the redirected stream, formats the text, and writes the text to the screen. -## Remarks - To asynchronously collect the redirected or stream output of a process, you must create a method that handles the redirected stream output events. The event-handler method is called when the process writes to the redirected stream. The event delegate calls your event handler with an instance of . The property contains the text line that the process wrote to the redirected stream. - - - -## Examples - The following code example illustrates how to perform asynchronous read operations on the redirected stream of the `sort` command. The `sort` command is a console application that reads and sorts text input. - - The example creates an event delegate for the `SortOutputHandler` event handler and associates it with the event. The event handler receives text lines from the redirected stream, formats the text, and writes the text to the screen. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/sort_async.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/sort_async.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/sort_async.vb" id="Snippet1"::: + ]]> @@ -120,24 +119,23 @@ Gets the line of characters that was written to a redirected output stream. The line that was written by an associated to its redirected or stream. - or stream of a to your event handler, an event is raised each time the process writes a line to the redirected stream. The property is the line that the wrote to the redirected output stream. Your event handler can use the property to filter process output or write output to an alternate location. For example, you might create an event handler that stores all error output lines into a designated error log file. - - A line is defined as a sequence of characters followed by a line feed ("\n") or a carriage return immediately followed by a line feed ("\r\n"). The line characters are encoded using the default system ANSI code page. The property does not include the terminating carriage return or line feed. - - When the redirected stream is closed, a null line is sent to the event handler. Ensure your event handler checks the property appropriately before accessing it. For example, you can use the static method to validate the property in your event handler. - - - -## Examples - The following code example illustrates a simple event handler associated with the event. The event handler receives text lines from the redirected stream, formats the text, and writes the text to the screen. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/datareceivedevent.cpp" id="Snippet4"::: + or stream of a to your event handler, an event is raised each time the process writes a line to the redirected stream. The property is the line that the wrote to the redirected output stream. Your event handler can use the property to filter process output or write output to an alternate location. For example, you might create an event handler that stores all error output lines into a designated error log file. + + A line is defined as a sequence of characters followed by a line feed ("\n") or a carriage return immediately followed by a line feed ("\r\n"). The line characters are encoded using the default system ANSI code page. The property does not include the terminating carriage return or line feed. + + When the redirected stream is closed, a null line is sent to the event handler. Ensure your event handler checks the property appropriately before accessing it. For example, you can use the static method to validate the property in your event handler. + + + +## Examples + The following code example illustrates a simple event handler associated with the event. The event handler receives text lines from the redirected stream, formats the text, and writes the text to the screen. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/datareceivedevent.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/datareceivedevent.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/datareceivedevent.vb" id="Snippet4"::: + ]]> diff --git a/xml/System.Diagnostics/DataReceivedEventHandler.xml b/xml/System.Diagnostics/DataReceivedEventHandler.xml index 21c29c4b1c5..68d6b14b4f7 100644 --- a/xml/System.Diagnostics/DataReceivedEventHandler.xml +++ b/xml/System.Diagnostics/DataReceivedEventHandler.xml @@ -52,24 +52,23 @@ A that contains the event data. Represents the method that will handle the event or event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + To asynchronously collect the redirected or stream output of a process, add your event handler to the or event. These events are raised each time the process writes a line to the corresponding redirected stream. When the redirected stream is closed, a null line is sent to the event handler. Ensure that your event handler checks for this condition before accessing the property. For example, you can use the `static` method to validate the property in your event handler. + + + +## Examples + The following code example illustrates how to perform asynchronous read operations on the redirected stream of the **sort** command. The **sort** command is a console application that reads and sorts text input. + + The example creates a delegate for the `SortOutputHandler` event handler and associates the delegate with the event. The event handler receives text lines from the redirected stream, formats the text, and writes the text to the screen. -## Remarks - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - To asynchronously collect the redirected or stream output of a process, add your event handler to the or event. These events are raised each time the process writes a line to the corresponding redirected stream. When the redirected stream is closed, a null line is sent to the event handler. Ensure that your event handler checks for this condition before accessing the property. For example, you can use the `static` method to validate the property in your event handler. - - - -## Examples - The following code example illustrates how to perform asynchronous read operations on the redirected stream of the **sort** command. The **sort** command is a console application that reads and sorts text input. - - The example creates a delegate for the `SortOutputHandler` event handler and associates the delegate with the event. The event handler receives text lines from the redirected stream, formats the text, and writes the text to the screen. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/sort_async.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/sort_async.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/sort_async.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Diagnostics/Debug.xml b/xml/System.Diagnostics/Debug.xml index 873df186dc7..76e70b78f5c 100644 --- a/xml/System.Diagnostics/Debug.xml +++ b/xml/System.Diagnostics/Debug.xml @@ -109,7 +109,6 @@ For .NET Framework apps, you can set the to indicate the beginning and end of a program's execution. The example also uses and to distinguish the tracing output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug Example/VB/source.vb" id="Snippet1"::: @@ -232,7 +231,6 @@ For .NET Framework apps, you can change the behavior of the to confirm that the index value is valid. If it is not valid, outputs the call stack. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Assert/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Assert Example/VB/source.vb" id="Snippet1"::: @@ -439,7 +437,6 @@ For .NET Framework apps, you can change the behavior of the outputs a message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Assert/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Assert1 Example/VB/source.vb" id="Snippet1"::: @@ -647,7 +644,6 @@ For .NET Framework apps, you can change the behavior of the outputs two messages. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Assert2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Assert/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Assert2 Example/VB/source.vb" id="Snippet1"::: @@ -911,7 +907,6 @@ For .NET Framework apps, you can also set the named `myTextListener`. `myTextListener` uses a called `myOutputWriter` to write to a file named `TestFile.txt`. The example creates the file, stream, and text writer, writes one line of text to the file, and then flushes and closes the output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Close Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Close Example/VB/source.vb" id="Snippet1"::: @@ -1010,13 +1005,11 @@ The following example creates a method to print a message during exception handling. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Fail/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Fail Example/VB/source.vb" id="Snippet1"::: You can also use the method in a switch statement. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Fail/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Fail Example/VB/source.vb" id="Snippet2"::: @@ -1107,13 +1100,11 @@ The following example uses the method to The following example uses the method to print a message during exception handling. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Fail/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/VB/source.vb" id="Snippet1"::: You can also use the method in a switch statement. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Fail/source1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Fail1 Example/VB/source.vb" id="Snippet2"::: @@ -1188,7 +1179,6 @@ You can also use the method in a switch The following example creates a named `myTextListener`. `myTextListener` uses a called `myFileStream` to write to a file named `TestFile.txt`. The example creates the stream, opens the file if it exists or creates a new one, writes one line of text to the file, and then flushes and closes the output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Close Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Close Example/VB/source.vb" id="Snippet1"::: @@ -1258,7 +1248,6 @@ The following example creates a property represents the numbe The following example sets the indent level and emits debugging messages. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.IndentLevel Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Indent/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.IndentLevel Example/VB/source.vb" id="Snippet1"::: @@ -1468,7 +1456,6 @@ For .NET Framework apps, you can also set the that outputs to the console screen. The code then adds the new listener to the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Listeners Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Listeners/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Listeners Example/VB/source.vb" id="Snippet1"::: @@ -1703,7 +1690,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Write/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Write Example/VB/source.vb" id="Snippet1"::: @@ -1885,7 +1870,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Write/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Write Example/VB/source.vb" id="Snippet1"::: @@ -1973,7 +1957,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Write/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Write Example/VB/source.vb" id="Snippet1"::: @@ -2061,7 +2044,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.Write Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/Write/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.Write Example/VB/source.vb" id="Snippet1"::: @@ -2232,7 +2214,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs a message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteIf/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteIf1 Example/VB/source.vb" id="Snippet1"::: @@ -2334,7 +2315,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteIf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteIf Example/VB/source.vb" id="Snippet1"::: @@ -2516,7 +2496,6 @@ The following example creates a named `gen Then, if the is set to `Error` or higher, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteIf/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteIf3 Example/VB/source.vb" id="Snippet1"::: @@ -2622,7 +2601,6 @@ The following example creates a named `gen Then, if the is set to `Error` or higher, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteIf2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteIf/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteIf2 Example/VB/source.vb" id="Snippet1"::: @@ -2734,7 +2712,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the name of the object on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteLine/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteLine1 Example/VB/source.vb" id="Snippet1"::: @@ -2819,7 +2796,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteLine/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteLine Example/VB/source.vb" id="Snippet1"::: @@ -2907,7 +2883,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteLine/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteLine3 Example/VB/source.vb" id="Snippet1"::: @@ -3082,7 +3057,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message and the `category` on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLine2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteLine/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteLine2 Example/VB/source.vb" id="Snippet1"::: @@ -3250,7 +3224,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the name of the object on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf1 Example/VB/source.vb" id="Snippet1"::: @@ -3353,7 +3326,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf Example/VB/source.vb" id="Snippet1"::: @@ -3534,7 +3506,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf3 Example/VB/source.vb" id="Snippet1"::: @@ -3640,7 +3611,6 @@ The following example creates a named `gen Then, if the is set to `Verbose`, the example outputs the second error message and the `category` on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Debug/WriteLineIf/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Debug.WriteLineIf2 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Diagnostics/DebuggerBrowsableAttribute.xml b/xml/System.Diagnostics/DebuggerBrowsableAttribute.xml index 94a8bfbf986..585fc2356c7 100644 --- a/xml/System.Diagnostics/DebuggerBrowsableAttribute.xml +++ b/xml/System.Diagnostics/DebuggerBrowsableAttribute.xml @@ -65,25 +65,25 @@ Determines if and how a member is displayed in the debugger variable windows. This class cannot be inherited. - [!NOTE] -> In .NET Framework version 2.0, the class is not supported by Visual Basic. Using C#, you can add expansions for custom data using the , , and . Visual Basic supports the attribute but not the attribute. - - This attribute can be applied only as a single instance to properties and fields. It cannot be applied to assemblies. - - The constructor for this attribute takes one of the enumeration values, which specifies one of the following states: - -- indicates that the member is not displayed in the data window. For example, using this value for the on a field removes the field from the hierarchy; the field is not displayed when you expand the enclosing type by clicking the plus sign (+) for the type instance. - -- indicates that the member is displayed but not expanded by default. This is the default behavior. - -- indicates that the member itself is not shown, but its constituent objects are displayed if it is an array or collection. - - For an example of the use of this attribute and the and attributes, see the example provided for the class. - +> In .NET Framework version 2.0, the class is not supported by Visual Basic. Using C#, you can add expansions for custom data using the , , and . Visual Basic supports the attribute but not the attribute. + + This attribute can be applied only as a single instance to properties and fields. It cannot be applied to assemblies. + + The constructor for this attribute takes one of the enumeration values, which specifies one of the following states: + +- indicates that the member is not displayed in the data window. For example, using this value for the on a field removes the field from the hierarchy; the field is not displayed when you expand the enclosing type by clicking the plus sign (+) for the type instance. + +- indicates that the member is displayed but not expanded by default. This is the default behavior. + +- indicates that the member itself is not shown, but its constituent objects are displayed if it is an array or collection. + + For an example of the use of this attribute and the and attributes, see the example provided for the class. + ]]> @@ -133,20 +133,19 @@ One of the values that specifies how to display the member. Initializes a new instance of the class. - attribute to instruct the debugger to not display the root (property name) of the `Keys` property, but to display the elements of the array that `Keys` gets. This code example is part of a larger example provided for the class. + attribute to instruct the debugger to not display the root (property name) of the `Keys` property, but to display the elements of the array that `Keys` gets. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DebuggerBrowsableAttribute/.ctor/program.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet6"::: + ]]> @@ -196,11 +195,11 @@ Gets the display state for the attribute. One of the values. - constructor uses the value of the `state` parameter to set this value. - + constructor uses the value of the `state` parameter to set this value. + ]]> diff --git a/xml/System.Diagnostics/DebuggerBrowsableState.xml b/xml/System.Diagnostics/DebuggerBrowsableState.xml index 685297602b0..43300c598b6 100644 --- a/xml/System.Diagnostics/DebuggerBrowsableState.xml +++ b/xml/System.Diagnostics/DebuggerBrowsableState.xml @@ -60,20 +60,19 @@ Provides display instructions for the debugger. - is used to simplify the view in the debug window. Use of the attribute using this enumeration can result in a much simpler and more pleasing view in the debug window. See the class for information on the use of this enumeration. + + + +## Examples + The following code example shows the use of the enumeration to instruct the debugger to not display the root (property name) of the `Keys` property, but to display the elements of the array that `Keys` gets. This code example is part of a larger example provided for the class. -## Remarks - is used to simplify the view in the debug window. Use of the attribute using this enumeration can result in a much simpler and more pleasing view in the debug window. See the class for information on the use of this enumeration. - - - -## Examples - The following code example shows the use of the enumeration to instruct the debugger to not display the root (property name) of the `Keys` property, but to display the elements of the array that `Keys` gets. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DebuggerBrowsableAttribute/.ctor/program.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet6"::: + ]]> diff --git a/xml/System.Diagnostics/DebuggerDisplayAttribute.xml b/xml/System.Diagnostics/DebuggerDisplayAttribute.xml index 084ae5776a8..199078b9bb8 100644 --- a/xml/System.Diagnostics/DebuggerDisplayAttribute.xml +++ b/xml/System.Diagnostics/DebuggerDisplayAttribute.xml @@ -69,30 +69,29 @@ Determines how a class or field is displayed in the debugger variable windows. - constructor has a single argument: a string to be displayed in the value column for instances of the type. This string can contain braces ({ and }). The text within a pair of braces is evaluated as the name of a field, property, or method. For example, the following C# code causes "Count = 4" to be displayed when the plus sign (+) is selected to expand the debugger display for an instance of `MyHashtable`. + +```csharp +[DebuggerDisplay("Count = {count}")] +class MyHashtable +{ + public int count = 4; +} +``` + + For information about using this attribute in Visual Studio, see [Using the DebuggerDisplay Attribute](/visualstudio/debugger/using-the-debuggerdisplay-attribute). + + + +## Examples + View the following example in Visual Studio to see the results of applying the . -## Remarks - The constructor has a single argument: a string to be displayed in the value column for instances of the type. This string can contain braces ({ and }). The text within a pair of braces is evaluated as the name of a field, property, or method. For example, the following C# code causes "Count = 4" to be displayed when the plus sign (+) is selected to expand the debugger display for an instance of `MyHashtable`. - -```csharp -[DebuggerDisplay("Count = {count}")] -class MyHashtable -{ - public int count = 4; -} -``` - - For information about using this attribute in Visual Studio, see [Using the DebuggerDisplay Attribute](/visualstudio/debugger/using-the-debuggerdisplay-attribute). - - - -## Examples - View the following example in Visual Studio to see the results of applying the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DebuggerBrowsableAttribute/.ctor/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet1"::: + ]]> @@ -141,28 +140,27 @@ class MyHashtable The string to be displayed in the value column for instances of the type; an empty string ("") causes the value column to be hidden. Initializes a new instance of the class. - property from the inherited class to be displayed when the plus sign (+) is selected to expand the debugger display for an instance of `MyHashtable`. You must run the complete example, which is provided in the class, to see the results. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp" id="Snippet4"::: + property from the inherited class to be displayed when the plus sign (+) is selected to expand the debugger display for an instance of `MyHashtable`. You must run the complete example, which is provided in the class, to see the results. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DebuggerBrowsableAttribute/.ctor/program.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet4"::: + ]]> @@ -211,20 +209,19 @@ class MyTable Gets or sets the name to display in the debugger variable windows. The name to display in the debugger variable windows. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp" id="Snippet3"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DebuggerBrowsableAttribute/.ctor/program.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet3"::: + ]]> @@ -273,11 +270,11 @@ class MyTable Gets or sets the type of the attribute's target. The attribute's target type. - @@ -328,11 +325,11 @@ class MyTable Gets or sets the type name of the attribute's target. The name of the attribute's target type. - @@ -432,11 +429,11 @@ class MyTable Gets the string to display in the value column of the debugger variable windows. The string to display in the value column of the debugger variable. - diff --git a/xml/System.Diagnostics/DebuggerTypeProxyAttribute.xml b/xml/System.Diagnostics/DebuggerTypeProxyAttribute.xml index 5490cca13bd..27a06033dd9 100644 --- a/xml/System.Diagnostics/DebuggerTypeProxyAttribute.xml +++ b/xml/System.Diagnostics/DebuggerTypeProxyAttribute.xml @@ -69,26 +69,25 @@ Specifies the display proxy for a type. - attribute is used to specify a display proxy for a type, allowing a developer to tailor the view for the type. This attribute can be used at the assembly level as well, in which case the property specifies the type for which the proxy will be used. In general, this attribute specifies a private nested type that occurs within the type to which the attribute is applied. An expression evaluator that supports type viewers checks for this attribute when a type is displayed. If the attribute is found, the expression evaluator substitutes the display proxy type for the type the attribute is applied to. + + When the is present, the debugger variable window displays only the public members of the proxy type. Private members are not displayed. The behavior of the data window is not changed by attribute-enhanced views. + + To avoid unnecessary performance penalties, expression evaluators should not examine the attributes on the display proxy of the type unless the type is expanded, either through the user clicking the plus sign (+) next to the type in a data window, or through the application of the attribute. Therefore, it is recommended that no attributes be applied to the display type. Attributes can and should be applied within the body of the display type. + + + +## Examples + The following code example shows the use of the to specify a private nested type to be used as a debugger display proxy. This code example is part of a larger example provided for the class. -## Remarks - **Note** Use this attribute when you need to significantly and fundamentally change the debugging view of a type, but not change the type itself. - - The attribute is used to specify a display proxy for a type, allowing a developer to tailor the view for the type. This attribute can be used at the assembly level as well, in which case the property specifies the type for which the proxy will be used. In general, this attribute specifies a private nested type that occurs within the type to which the attribute is applied. An expression evaluator that supports type viewers checks for this attribute when a type is displayed. If the attribute is found, the expression evaluator substitutes the display proxy type for the type the attribute is applied to. - - When the is present, the debugger variable window displays only the public members of the proxy type. Private members are not displayed. The behavior of the data window is not changed by attribute-enhanced views. - - To avoid unnecessary performance penalties, expression evaluators should not examine the attributes on the display proxy of the type unless the type is expanded, either through the user clicking the plus sign (+) next to the type in a data window, or through the application of the attribute. Therefore, it is recommended that no attributes be applied to the display type. Attributes can and should be applied within the body of the display type. - - - -## Examples - The following code example shows the use of the to specify a private nested type to be used as a debugger display proxy. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DebuggerBrowsableAttribute/.ctor/program.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet5"::: + ]]> Using DebuggerTypeProxy Attribute @@ -155,11 +154,11 @@ The type name of the proxy type. Initializes a new instance of the class using the type name of the proxy. - @@ -214,20 +213,19 @@ The proxy type. Initializes a new instance of the class using the type of the proxy. - constructor to specify a debugger display proxy. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/cpp/program.cpp" id="Snippet5"::: + constructor to specify a debugger display proxy. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DebuggerBrowsableAttribute/.ctor/program.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.DebuggerBrowsableAttribute/VB/module1.vb" id="Snippet5"::: + ]]> @@ -333,11 +331,11 @@ Gets or sets the target type for the attribute. The target type for the attribute. - @@ -388,11 +386,11 @@ Gets or sets the name of the target type. The name of the target type. - diff --git a/xml/System.Diagnostics/EntryWrittenEventArgs.xml b/xml/System.Diagnostics/EntryWrittenEventArgs.xml index 0d4147306c0..75d93066bdf 100644 --- a/xml/System.Diagnostics/EntryWrittenEventArgs.xml +++ b/xml/System.Diagnostics/EntryWrittenEventArgs.xml @@ -33,15 +33,14 @@ Provides data for the event. - constructor. It creates a custom object and writes an entry into it. Then it creates an object using the first entry in the custom . This object is used to notify a message. -## Examples - The following example demonstrates the constructor. It creates a custom object and writes an entry into it. Then it creates an object using the first entry in the custom . This object is used to notify a message. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/CPP/entrywritteneventargs_ctor1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EntryWrittenEventArgs/Overview/entrywritteneventargs_ctor1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/VB/entrywritteneventargs_ctor1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/VB/entrywritteneventargs_ctor1.vb" id="Snippet1"::: + ]]> @@ -92,15 +91,14 @@ Initializes a new instance of the class. - constructor. It creates a custom object and writes an entry into it. Then it creates an object using the first entry in the custom . This object is used to notify a message. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/CPP/entrywritteneventargs_ctor1.cpp" id="Snippet1"::: + constructor. It creates a custom object and writes an entry into it. Then it creates an object using the first entry in the custom . This object is used to notify a message. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EntryWrittenEventArgs/Overview/entrywritteneventargs_ctor1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/VB/entrywritteneventargs_ctor1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EntryWrittenEventArgs_ctor1/VB/entrywritteneventargs_ctor1.vb" id="Snippet1"::: + ]]> @@ -143,15 +141,14 @@ An that represents the entry that was written. Initializes a new instance of the class with the specified event log entry. - constructor. It creates a custom object and writes an entry into it. Then it creates an object using the first entry in the custom . This object is used to notify a message. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/CPP/entrywritteneventargs_ctor2.cpp" id="Snippet1"::: + constructor. It creates a custom object and writes an entry into it. Then it creates an object using the first entry in the custom . This object is used to notify a message. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EntryWrittenEventArgs/.ctor/entrywritteneventargs_ctor2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/VB/entrywritteneventargs_ctor2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/VB/entrywritteneventargs_ctor2.vb" id="Snippet1"::: + ]]> @@ -194,17 +191,16 @@ Gets the event log entry that was written to the log. An that represents the entry that was written to the event log. - . - - It creates a custom object and writes an entry into it. Then it creates an object using the first entry in the custom EventLog. This object is used to notify a message. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/CPP/entrywritteneventargs_ctor2.cpp" id="Snippet2"::: + . + + It creates a custom object and writes an entry into it. Then it creates an object using the first entry in the custom EventLog. This object is used to notify a message. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EntryWrittenEventArgs/.ctor/entrywritteneventargs_ctor2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/VB/entrywritteneventargs_ctor2.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EntryWrittenEventArgs_ctor2/VB/entrywritteneventargs_ctor2.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Diagnostics/EventInstance.xml b/xml/System.Diagnostics/EventInstance.xml index 3b59f279376..4b33f92df5d 100644 --- a/xml/System.Diagnostics/EventInstance.xml +++ b/xml/System.Diagnostics/EventInstance.xml @@ -32,145 +32,144 @@ Represents language-neutral information for an event log entry. - to write an event log entry with a resource identifier rather than a string value. To write an event log entry, initialize the property and pass the instance to the method. The Event Viewer uses the instance identifier to find and display the corresponding string from the localized resource file based on current language settings. You must register the event source with the corresponding resource file before you write events using resource identifiers. + + When writing events, you can set the property to specify the icon that the Event Viewer displays for the entry. You can also specify a property to specify the category that the Event Viewer displays for the entry. + + The Event Viewer uses the category to filter events written by an event source. The Event Viewer can display the category as a numeric value, or it can use the category as a resource identifier to display a localized category string. + + To display localized category strings in the Event Viewer, you must use an event source configured with a category resource file, and set the to a resource identifier in the category resource file. If the event source does not have a configured category resource file, or the specified does not index a string in the category resource file, and then the Event Viewer displays the numeric category value for that entry. Configure the category resource file, along with the number of category strings in the resource file, using the or the class. + + You must register a source for an event log before using to write an event with the method. The source must be configured for writing localized entries to the log and the source must define at least a message resource file. + + Create the new event source during the installation of your application. This allows time for the operating system to refresh its list of registered event sources and their configurations. If the operating system has not refreshed its list of event sources, and you attempt to write an event with the new source, the write operation will fail. You can configure a new source using an , or using the method. You must have administrative rights on the computer to create a new event source. + + For details about defining event messages and building event log resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. + + + +## Examples + The following code example writes an informational event entry, and then reuses the to write an entry for a warning event to an existing event log. The event message text is specified using a resource identifier in a message resource file. The code example assumes that the corresponding message resource file has been registered for the source. -## Remarks - Use to write an event log entry with a resource identifier rather than a string value. To write an event log entry, initialize the property and pass the instance to the method. The Event Viewer uses the instance identifier to find and display the corresponding string from the localized resource file based on current language settings. You must register the event source with the corresponding resource file before you write events using resource identifiers. - - When writing events, you can set the property to specify the icon that the Event Viewer displays for the entry. You can also specify a property to specify the category that the Event Viewer displays for the entry. - - The Event Viewer uses the category to filter events written by an event source. The Event Viewer can display the category as a numeric value, or it can use the category as a resource identifier to display a localized category string. - - To display localized category strings in the Event Viewer, you must use an event source configured with a category resource file, and set the to a resource identifier in the category resource file. If the event source does not have a configured category resource file, or the specified does not index a string in the category resource file, and then the Event Viewer displays the numeric category value for that entry. Configure the category resource file, along with the number of category strings in the resource file, using the or the class. - - You must register a source for an event log before using to write an event with the method. The source must be configured for writing localized entries to the log and the source must define at least a message resource file. - - Create the new event source during the installation of your application. This allows time for the operating system to refresh its list of registered event sources and their configurations. If the operating system has not refreshed its list of event sources, and you attempt to write an event with the new source, the write operation will fail. You can configure a new source using an , or using the method. You must have administrative rights on the computer to create a new event source. - - For details about defining event messages and building event log resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. - - - -## Examples - The following code example writes an informational event entry, and then reuses the to write an entry for a warning event to an existing event log. The event message text is specified using a resource identifier in a message resource file. The code example assumes that the corresponding message resource file has been registered for the source. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet9"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet9"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> @@ -219,141 +218,140 @@ SVC_UPDATE.EXE A resource identifier that corresponds to a string defined in the category resource file of the event source, or zero to specify no category for the event. Initializes a new instance of the class using the specified resource identifiers for the localized message and category text of the event entry. - and pass it to the method. Set the `instanceId` to the resource identifier of the event message in the corresponding property for the source. Set the `categoryId` to a numeric category value, or the resource identifier of the event category in the property for the source; set the `categoryId` to zero for no event category. The property for the new instance is set to by default. - - The Event Viewer uses the resource identifiers to display the corresponding strings from the localized resource files for the source. You must register the source with the corresponding resource files before you can write events using resource identifiers. - - - -## Examples - The following code example writes an informational event entry, and then reuses the to write an entry for a warning event to an existing event log. The event message text is specified using a resource identifier in a message resource file. The code example assumes that the corresponding message resource file has been registered for the source. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet9"::: + and pass it to the method. Set the `instanceId` to the resource identifier of the event message in the corresponding property for the source. Set the `categoryId` to a numeric category value, or the resource identifier of the event category in the property for the source; set the `categoryId` to zero for no event category. The property for the new instance is set to by default. + + The Event Viewer uses the resource identifiers to display the corresponding strings from the localized resource files for the source. You must register the source with the corresponding resource files before you can write events using resource identifiers. + + + +## Examples + The following code example writes an informational event entry, and then reuses the to write an entry for a warning event to an existing event log. The event message text is specified using a resource identifier in a message resource file. The code example assumes that the corresponding message resource file has been registered for the source. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet9"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet9"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> - The parameter is a negative value or a value larger than UInt32.MaxValue. - - -or- - + The parameter is a negative value or a value larger than UInt32.MaxValue. + + -or- + The parameter is a negative value or a value larger than UInt16.MaxValue. @@ -396,146 +394,145 @@ SVC_UPDATE.EXE An value that indicates the event type. Initializes a new instance of the class using the specified resource identifiers for the localized message and category text of the event entry and the specified event log entry type. - and pass it to the method. Set the `instanceId` to the resource identifier of the event message in the corresponding property for the source. Set the `categoryId` to a numeric category value, or the resource identifier of the event category in the property for the source; set the `categoryId` to zero for no event category. - - The Event Viewer uses the resource identifiers to display the corresponding strings from the localized resource files for the source. You must register the source with the corresponding resource files before you can write events using resource identifiers. - - Set the `entryType` to one of the pre-defined entry types. The Event Viewer uses the event type to determine which icon to display in the list view of the event log. - - - -## Examples - The following code example writes two audit event entries to the event log `myNewLog`. The code example creates a new event source and a new event log if they do not exist on the local computer. The event message text is specified using a resource identifier in a resource file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet7"::: + and pass it to the method. Set the `instanceId` to the resource identifier of the event message in the corresponding property for the source. Set the `categoryId` to a numeric category value, or the resource identifier of the event category in the property for the source; set the `categoryId` to zero for no event category. + + The Event Viewer uses the resource identifiers to display the corresponding strings from the localized resource files for the source. You must register the source with the corresponding resource files before you can write events using resource identifiers. + + Set the `entryType` to one of the pre-defined entry types. The Event Viewer uses the event type to determine which icon to display in the list view of the event log. + + + +## Examples + The following code example writes two audit event entries to the event log `myNewLog`. The code example creates a new event source and a new event log if they do not exist on the local computer. The event message text is specified using a resource identifier in a resource file. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet7"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet7"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> is not a valid value. - is a negative value or a value larger than UInt32.MaxValue. - - -or- - + is a negative value or a value larger than UInt32.MaxValue. + + -or- + is a negative value or a value larger than UInt16.MaxValue. @@ -581,143 +578,142 @@ SVC_UPDATE.EXE Gets or sets the resource identifier that specifies the application-defined category of the event entry. A numeric category value or resource identifier that corresponds to a string defined in the category resource file of the event source. The default is zero, which signifies that no category will be displayed for the event entry. - property to specify the category that the Event Viewer displays for the entry. The Event Viewer can display the category as a numeric value, or it can use the as a resource identifier to display a localized category string based on the current language settings. - - To display localized category strings in the Event Viewer, you must use an event source configured with a category resource file, and set the to a resource identifier in the category resource file. If the event source does not have a configured category resource file, or the specified does not index a string in the category resource file, and then the Event Viewer displays the numeric category value for that entry. - - You must register the source with the corresponding resource file before you write event categories using resource identifiers. Configure the category resource file, along with the number of category strings in the resource file, using the or the class. When defining category strings in a resource file, the category resource identifiers must be numbered consecutively starting at 1, up to the configured property value. - - Event categories are optional. If your application does not use categories, do not set the for the event log entry. - - For details about defining event messages and building event resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. For details about defining event categories in resource files, see the "Event Categories" topic in the Platform SDK - - - -## Examples - The following code example writes an informational event entry, and then reuses the to write an entry for a warning event to an existing event log. The event message text is specified using a resource identifier in a message resource file. The code example assumes that the corresponding message resource file has been registered for the source. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet9"::: + property to specify the category that the Event Viewer displays for the entry. The Event Viewer can display the category as a numeric value, or it can use the as a resource identifier to display a localized category string based on the current language settings. + + To display localized category strings in the Event Viewer, you must use an event source configured with a category resource file, and set the to a resource identifier in the category resource file. If the event source does not have a configured category resource file, or the specified does not index a string in the category resource file, and then the Event Viewer displays the numeric category value for that entry. + + You must register the source with the corresponding resource file before you write event categories using resource identifiers. Configure the category resource file, along with the number of category strings in the resource file, using the or the class. When defining category strings in a resource file, the category resource identifiers must be numbered consecutively starting at 1, up to the configured property value. + + Event categories are optional. If your application does not use categories, do not set the for the event log entry. + + For details about defining event messages and building event resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. For details about defining event categories in resource files, see the "Event Categories" topic in the Platform SDK + + + +## Examples + The following code example writes an informational event entry, and then reuses the to write an entry for a warning event to an existing event log. The event message text is specified using a resource identifier in a message resource file. The code example assumes that the corresponding message resource file has been registered for the source. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet9"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet9"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> The property is set to a negative value or to a value larger than UInt16.MaxValue. @@ -764,133 +760,132 @@ SVC_UPDATE.EXE Gets or sets the event type of the event log entry. An value that indicates the event entry type. The default value is . - to write an entry for a warning event to an existing event log. The event message text is specified using a resource identifier in a message resource file. The code example assumes that the corresponding message resource file has been registered for the source. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet9"::: + to write an entry for a warning event to an existing event log. The event message text is specified using a resource identifier in a message resource file. The code example assumes that the corresponding message resource file has been registered for the source. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet9"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet9"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> The property is not set to a valid value. @@ -936,135 +931,134 @@ SVC_UPDATE.EXE Gets or sets the resource identifier that designates the message text of the event entry. A resource identifier that corresponds to a string defined in the message resource file of the event source. - property uniquely identifies an event entry for a configured event source. For events defined in message resource files, the corresponds to the resource identifier compiled from the message definition fields in the message text file. Your application can write localized event log entries by setting the to a resource identifier. The Event Viewer uses the resource identifier to find and display the corresponding string from the localized resource file based on current language settings. You must register the source with the corresponding resource file before you write events using resource identifiers. - - For details about defining event messages and building event log resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. For details about event log identifiers, see the [Event Identifiers](/windows/win32/eventlog/event-categories) article in the Platform SDK documentation. - - - -## Examples - The following code example writes an informational event entry, and then reuses the to write an entry for a warning event to an existing event log. The event message text is specified using a resource identifier in a message resource file. The code example assumes that the corresponding message resource file has been registered for the source. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet9"::: + property uniquely identifies an event entry for a configured event source. For events defined in message resource files, the corresponds to the resource identifier compiled from the message definition fields in the message text file. Your application can write localized event log entries by setting the to a resource identifier. The Event Viewer uses the resource identifier to find and display the corresponding string from the localized resource file based on current language settings. You must register the source with the corresponding resource file before you write events using resource identifiers. + + For details about defining event messages and building event log resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. For details about event log identifiers, see the [Event Identifiers](/windows/win32/eventlog/event-categories) article in the Platform SDK documentation. + + + +## Examples + The following code example writes an informational event entry, and then reuses the to write an entry for a warning event to an existing event log. The event message text is specified using a resource identifier in a message resource file. The code example assumes that the corresponding message resource file has been registered for the source. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet9"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet9"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> The property is set to a negative value or to a value larger than UInt32.MaxValue. diff --git a/xml/System.Diagnostics/EventLog.xml b/xml/System.Diagnostics/EventLog.xml index 6fc19e04de7..39afaaae185 100644 --- a/xml/System.Diagnostics/EventLog.xml +++ b/xml/System.Diagnostics/EventLog.xml @@ -126,9 +126,8 @@ The following example creates the event source `MySource` if it doesn't already exist, and writes an entry to the event log `MyNewLog`. > [!NOTE] -> Starting with Windows Vista, you must run this application as an administrator. +> You must run this application as an administrator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/VB/source.vb" id="Snippet1"::: @@ -204,7 +203,6 @@ ## Examples The following example creates the source `MySource` if it does not already exist, and writes an entry to the event log `MyNewLog`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/VB/source.vb" id="Snippet1"::: @@ -280,7 +278,6 @@ ## Examples The following example reads entries in the event log, "myNewLog", on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.EventLog1 Example/VB/source.vb" id="Snippet1"::: @@ -358,7 +355,6 @@ ## Examples The following example reads entries in the event log, "myNewLog", on the computer "myServer". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/.ctor/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.EventLog2 Example/VB/source.vb" id="Snippet1"::: @@ -433,7 +429,6 @@ ## Examples The following example writes an entry to an event log, "MyNewLog", on the local computer, using the source "MySource". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EventLog3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.EventLog3 Example/VB/source.vb" id="Snippet1"::: @@ -548,7 +543,6 @@ > [!CAUTION] > Because Application, System, Security, and other non-custom logs can contain crucial information; be sure to specify a custom log before executing this example code. This example deletes the custom log `myNewLog`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Clear Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Clear/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.Clear Example/VB/source.vb" id="Snippet1"::: @@ -690,7 +684,6 @@ ## Examples The following example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: @@ -930,7 +923,6 @@ SVC_UPDATE.EXE ## Examples The following example creates the source `MySource` if it does not already exist, and writes an entry to the event log `MyNewLog`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/VB/source.vb" id="Snippet1"::: @@ -1065,7 +1057,6 @@ SVC_UPDATE.EXE ## Examples The following example creates the source `MySource` on the computer `MyServer`, and writes an entry to the event log `MyNewLog`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/CreateEventSource/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/VB/source.vb" id="Snippet1"::: @@ -1185,7 +1176,6 @@ SVC_UPDATE.EXE > [!NOTE] > More than one source might write to an event log. Before deleting a custom log, make sure there are no other sources writing to that log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Delete/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/VB/source.vb" id="Snippet1"::: @@ -1268,7 +1258,6 @@ SVC_UPDATE.EXE > [!NOTE] > More than one source might write to an event log. Before deleting a custom log, make sure there are no other sources writing to that log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Delete/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/VB/source.vb" id="Snippet1"::: @@ -1369,7 +1358,6 @@ SVC_UPDATE.EXE > [!NOTE] > More than one source might write to an event log. Before deleting a custom log, make sure there are no other sources writing to that log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Delete/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/VB/source.vb" id="Snippet1"::: @@ -1446,7 +1434,6 @@ SVC_UPDATE.EXE > [!NOTE] > More than one source might write to an event log. Before deleting a custom log, make sure there are no other sources writing to that log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Delete/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.Delete1 Example/VB/source.vb" id="Snippet1"::: @@ -1584,7 +1571,6 @@ SVC_UPDATE.EXE ## Examples The following example handles an event. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EnableRaisingEvents Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/EnableRaisingEvents/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.EnableRaisingEvents Example/VB/source.vb" id="Snippet1"::: @@ -1708,7 +1694,6 @@ SVC_UPDATE.EXE ## Examples The following example reads entries in the event log, "MyNewLog", on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Entries Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Entries/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.Entries Example/VB/source.vb" id="Snippet1"::: @@ -1773,7 +1758,6 @@ SVC_UPDATE.EXE ## Examples The following example handles an entry written event. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.EntryWritten Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/EntryWritten/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.EntryWritten Example/VB/source.vb" id="Snippet1"::: @@ -1848,7 +1832,6 @@ SVC_UPDATE.EXE ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_Exists_1/CPP/eventlog_exists_1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Exists/eventlog_exists_1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_Exists_1/VB/eventlog_exists_1.vb" id="Snippet1"::: @@ -1985,7 +1968,6 @@ SVC_UPDATE.EXE ## Examples The following example enumerates the event logs defined on the local computer, and displays configuration details for each event log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogProperties/VB/source.vb" id="Snippet2"::: @@ -2050,7 +2032,6 @@ SVC_UPDATE.EXE ## Examples The following example gets a list of logs on the computer "myServer". It then outputs the name of each log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.GetEventLogs1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.GetEventLogs1 Example/VB/source.vb" id="Snippet1"::: @@ -2164,7 +2145,6 @@ SVC_UPDATE.EXE ## Examples The following example reads entries in the event log, "NewEventLog", on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Log Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Log/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.Log Example/VB/source.vb" id="Snippet1"::: @@ -2231,7 +2211,6 @@ SVC_UPDATE.EXE ## Examples The following example enumerates the event logs defined on the local computer and displays the for each event log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogProperties/VB/source.vb" id="Snippet2"::: @@ -2294,7 +2273,6 @@ SVC_UPDATE.EXE > [!NOTE] > More than one source might write to an event log. Before deleting a custom log, make sure there are no other sources writing to that log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Delete/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.DeleteEventSource Example/VB/source.vb" id="Snippet1"::: @@ -2377,7 +2355,6 @@ SVC_UPDATE.EXE ## Examples The following example reads entries in the event log, "NewEventLog", on a specified computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.MachineName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/MachineName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.MachineName Example/VB/source.vb" id="Snippet1"::: @@ -2456,7 +2433,6 @@ SVC_UPDATE.EXE ## Examples The following example enumerates the event logs defined on the local computer, and displays configuration details for each event log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogProperties/VB/source.vb" id="Snippet2"::: @@ -2523,7 +2499,6 @@ SVC_UPDATE.EXE ## Examples The following example enumerates the event logs defined on the local computer, and displays configuration details for each event log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogProperties/VB/source.vb" id="Snippet2"::: @@ -2602,7 +2577,6 @@ SVC_UPDATE.EXE ## Examples The following example displays the configured overflow policy for a specified event log, and allows the user to select a new overflow policy setting for the event log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source1.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogProperties/VB/source.vb" id="Snippet3"::: @@ -2679,7 +2653,6 @@ SVC_UPDATE.EXE ## Examples The following example enumerates the event logs defined on the local computer, and displays configuration details for each event log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogProperties/VB/source.vb" id="Snippet2"::: @@ -2750,7 +2723,6 @@ SVC_UPDATE.EXE ## Examples The following example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: @@ -2977,7 +2949,6 @@ SVC_UPDATE.EXE ## Examples The following example creates the source `MySource` if it does not already exist, and writes an entry to the event log `MyNewLog`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Source Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Source/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.Source Example/VB/source.vb" id="Snippet1"::: @@ -3067,7 +3038,6 @@ SVC_UPDATE.EXE ## Examples The following example creates the source `MySource` if it does not already exist, and writes an entry to the event log `MyNewLog`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.Source Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Source/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.Source Example/VB/source.vb" id="Snippet1"::: @@ -3152,7 +3122,6 @@ SVC_UPDATE.EXE ## Examples The following example creates the source `MySource` on the computer `MyServer`, and writes an entry to the event log `MyNewLog`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/CreateEventSource/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.SourceExists1 Example/VB/source.vb" id="Snippet1"::: @@ -3317,7 +3286,6 @@ SVC_UPDATE.EXE ## Examples The following example creates the source `MySource` if it does not already exist, and writes an entry to the event log `MyNewLog`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.CreateEventSource Example/VB/source.vb" id="Snippet1"::: @@ -3427,7 +3395,6 @@ SVC_UPDATE.EXE ## Examples The following example writes a warning entry to an event log, "MyNewLog", on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/WriteEntry/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry2 Example/VB/source.vb" id="Snippet1"::: @@ -3525,7 +3492,6 @@ SVC_UPDATE.EXE ## Examples The following example creates the source `MySource` if it does not already exist, and writes an entry to the event log `MyNewLog`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/WriteEntry/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry1 Example/VB/source.vb" id="Snippet1"::: @@ -3635,7 +3601,6 @@ SVC_UPDATE.EXE ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_1_3/CPP/eventlog_writeentry_1_3.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/WriteEntry/eventlog_writeentry_1_3.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_WriteEntry_1_3/VB/eventlog_writeentry_1_3.vb" id="Snippet3"::: @@ -3741,7 +3706,6 @@ SVC_UPDATE.EXE ## Examples The following example writes a warning entry to an event log, "MyNewLog", on the local computer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/WriteEntry/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLog.WriteEntry3 Example/VB/source.vb" id="Snippet1"::: @@ -3863,7 +3827,6 @@ SVC_UPDATE.EXE ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_1_3/CPP/eventlog_writeentry_1_3.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/WriteEntry/eventlog_writeentry_1_3.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_WriteEntry_1_3/VB/eventlog_writeentry_1_3.vb" id="Snippet3"::: @@ -3971,7 +3934,6 @@ SVC_UPDATE.EXE ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_4/CPP/eventlog_writeentry_4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/WriteEntry/eventlog_writeentry_4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_WriteEntry_4/VB/eventlog_writeentry_4.vb" id="Snippet1"::: @@ -4095,7 +4057,6 @@ SVC_UPDATE.EXE ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_5/CPP/eventlog_writeentry_5.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/WriteEntry/eventlog_writeentry_5.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_WriteEntry_5/VB/eventlog_writeentry_5.vb" id="Snippet1"::: @@ -4211,7 +4172,6 @@ SVC_UPDATE.EXE ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_1_3/CPP/eventlog_writeentry_1_3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/WriteEntry/eventlog_writeentry_1_3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_WriteEntry_1_3/VB/eventlog_writeentry_1_3.vb" id="Snippet1"::: @@ -4321,7 +4281,6 @@ SVC_UPDATE.EXE ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_WriteEntry_1_3/CPP/eventlog_writeentry_1_3.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/WriteEntry/eventlog_writeentry_1_3.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_WriteEntry_1_3/VB/eventlog_writeentry_1_3.vb" id="Snippet2"::: @@ -4440,7 +4399,6 @@ SVC_UPDATE.EXE ## Examples The following example writes two audit entries to the event log `myNewLog`. The example creates a new event source and a new event log if they do not exist on the local computer. The event message text is specified using a resource identifier in a resource file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet7"::: @@ -4673,7 +4631,6 @@ SVC_UPDATE.EXE ## Examples The following example writes two audit entries to the event log `myNewLog`. The example creates a new event source and a new event log if they do not exist on the local computer. The event message text is specified using a resource identifier in a resource file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet7"::: @@ -4892,7 +4849,6 @@ SVC_UPDATE.EXE ## Examples The following example writes an informational event entry and a warning event entry to an existing event log. The event message text is specified using a resource identifier in a resource file. The example assumes the corresponding resource file has been registered for the source. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet8"::: @@ -5111,7 +5067,6 @@ SVC_UPDATE.EXE ## Examples The following example writes an informational event entry and a warning event entry to an existing event log. The event message text is specified using a resource identifier in a resource file. The example assumes the corresponding resource file has been registered for the source. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet8"::: diff --git a/xml/System.Diagnostics/EventLogEntry.xml b/xml/System.Diagnostics/EventLogEntry.xml index d7cb0323dc1..3f0e5f33842 100644 --- a/xml/System.Diagnostics/EventLogEntry.xml +++ b/xml/System.Diagnostics/EventLogEntry.xml @@ -52,23 +52,22 @@ Encapsulates a single record in the event log. This class cannot be inherited. - directly when working with the class. The member of the class contains a collection of instances, which you iterate over when reading by using the class index member. - + directly when working with the class. The member of the class contains a collection of instances, which you iterate over when reading by using the class index member. + > [!IMPORTANT] -> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - - +> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + + + +## Examples + The following code example demonstrates the use of the class. In this example, a `switch` statement uses console input to search for event log entries for the specified event type. If a match is found, log entry source information is displayed at the console. -## Examples - The following code example demonstrates the use of the class. In this example, a `switch` statement uses console input to search for event log entries for the specified event type. If a match is found, log entry source information is displayed at the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Source/CPP/eventlogentry_source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogEntry/Overview/eventlogentry_source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_Source/VB/eventlogentry_source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_Source/VB/eventlogentry_source.vb" id="Snippet1"::: + ]]> @@ -114,11 +113,11 @@ Gets the text associated with the property for this entry. The application-specific category text. - The space could not be allocated for one of the insertion strings associated with the category. @@ -164,11 +163,11 @@ Gets the category number of the event log entry. The application-specific category number for this entry. - property. The Event Viewer can display the category as a numeric value, or it can use the category as a resource identifier to display a localized category string. For more information, see . - + property. The Event Viewer can display the category as a numeric value, or it can use the category as a resource identifier to display a localized category string. For more information, see . + ]]> @@ -214,11 +213,11 @@ Gets the binary data associated with the entry. An array of bytes that holds the binary data associated with the entry. - @@ -261,20 +260,19 @@ Gets the event type of this entry. The event type that is associated with the entry in the event log. - property. In this example, a `switch` statement uses console input to search for event log entries for the specified . If a match is found, log entry source information is displayed at the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Source/CPP/eventlogentry_source.cpp" id="Snippet1"::: + property. In this example, a `switch` statement uses console input to search for event log entries for the specified . If a match is found, log entry source information is displayed at the console. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogEntry/Overview/eventlogentry_source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_Source/VB/eventlogentry_source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_Source/VB/eventlogentry_source.vb" id="Snippet1"::: + ]]> @@ -318,11 +316,11 @@ if the objects are identical; otherwise, . - instances refer to the same object. - + instances refer to the same object. + ]]> @@ -377,13 +375,13 @@ Gets the application-specific event identifier for the current event entry. The application-specific identifier for the event message. - property for an event log entry represents the full 32-bit resource identifier for the event in the message resource file for the event source. Two event log entries from the same source can have matching values, but have different values due to differences in the top two bits of the event identifier. - - If the application wrote the event entry using one of the methods, the property matches the optional `eventId` parameter. If the application wrote the event using or the Windows API `ReportEvent`, the property matches the resource identifier for the event, with the top two bits masked off. - + property for an event log entry represents the full 32-bit resource identifier for the event in the message resource file for the event source. Two event log entries from the same source can have matching values, but have different values due to differences in the top two bits of the event identifier. + + If the application wrote the event entry using one of the methods, the property matches the optional `eventId` parameter. If the application wrote the event using or the Windows API `ReportEvent`, the property matches the resource identifier for the event, with the top two bits masked off. + ]]> @@ -427,11 +425,11 @@ Gets the index of this entry in the event log. The index of this entry in the event log. - @@ -477,24 +475,23 @@ Gets the resource identifier that designates the message text of the event entry. A resource identifier that corresponds to a string definition in the message resource file of the event source. - property uniquely identifies an event entry for a configured event source. The for an event log entry represents the full 32-bit resource identifier for the event in the message resource file for the event source. The property equals the with the top two bits masked off. Two event log entries from the same source can have matching values, but have different values due to differences in the top two bits of the resource identifier. - - If the application wrote the event entry using one of the methods, the property matches the optional `eventId` parameter. If the application wrote the event using , the property matches the resource identifier specified in the of the `instance` parameter. If the application wrote the event using the Windows API `ReportEvent`, the property matches the resource identifier specified in the `dwEventID` parameter. - - For details about defining event messages and building event log resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. For details about event log identifiers, see the [Event Identifiers](/windows/win32/eventlog/event-categories) article in the Platform SDK documentation. - - - -## Examples - The following code example searches an event log for entries with a particular resource identifier. The code example displays the event message for each matching entry, and counts the total number of matching entries in the log. The message text for each entry may or may not be the same; each event message depends on the event source message file, insertion strings, and parameters used when it was written. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet10"::: + property uniquely identifies an event entry for a configured event source. The for an event log entry represents the full 32-bit resource identifier for the event in the message resource file for the event source. The property equals the with the top two bits masked off. Two event log entries from the same source can have matching values, but have different values due to differences in the top two bits of the resource identifier. + + If the application wrote the event entry using one of the methods, the property matches the optional `eventId` parameter. If the application wrote the event using , the property matches the resource identifier specified in the of the `instance` parameter. If the application wrote the event using the Windows API `ReportEvent`, the property matches the resource identifier specified in the `dwEventID` parameter. + + For details about defining event messages and building event log resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. For details about event log identifiers, see the [Event Identifiers](/windows/win32/eventlog/event-categories) article in the Platform SDK documentation. + + + +## Examples + The following code example searches an event log for entries with a particular resource identifier. The code example displays the event message for each matching entry, and counts the total number of matching entries in the log. The message text for each entry may or may not be the same; each event message depends on the event source message file, insertion strings, and parameters used when it was written. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet10"::: + ]]> @@ -591,11 +588,11 @@ Gets the localized message associated with this event entry. The formatted, localized text for the message. This includes associated replacement strings. - The space could not be allocated for one of the insertion strings associated with the message. @@ -641,22 +638,22 @@ Gets the replacement strings associated with the event log entry. An array that holds the replacement strings stored in the event entry. - property. - - The property contains the localized versions of replacement strings that are used in the event log entry. If you provide resource files that contain strings in each target language for your application, you can emit event log messages in the language that is used on that computer. To do that, create an instance of the class for the resource assembly that contains your replacement strings. The first parameter of the constructor identifies the resource assembly to be used. Use the method of that instance to supply localized messages for log events. The following code automatically sets the message to the language for the current culture. - -```csharp -ResourceManager LocRM = new ResourceManager("ReplacementStrings.TestStrings", - typeof(Program).Assembly); -EventLog e1 = new EventLog("LocTest", "MyMachine", "LocTest"); -// Get the string associated with the current culture. -e1.WriteEntry(LocRM.GetString("strMessage"), - EventLogEntryType.Information); -``` - + property. + + The property contains the localized versions of replacement strings that are used in the event log entry. If you provide resource files that contain strings in each target language for your application, you can emit event log messages in the language that is used on that computer. To do that, create an instance of the class for the resource assembly that contains your replacement strings. The first parameter of the constructor identifies the resource assembly to be used. Use the method of that instance to supply localized messages for log events. The following code automatically sets the message to the language for the current culture. + +```csharp +ResourceManager LocRM = new ResourceManager("ReplacementStrings.TestStrings", + typeof(Program).Assembly); +EventLog e1 = new EventLog("LocTest", "MyMachine", "LocTest"); +// Get the string associated with the current culture. +e1.WriteEntry(LocRM.GetString("strMessage"), + EventLogEntryType.Information); +``` + ]]> @@ -701,20 +698,19 @@ e1.WriteEntry(LocRM.GetString("strMessage"), Gets the name of the application that generated this event. The name registered with the event log as the source of this event. - property. In this example, a `switch` statement uses console input to search for event log entries for the specified . If a match is found, the property information is displayed at the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Source/CPP/eventlogentry_source.cpp" id="Snippet1"::: + property. In this example, a `switch` statement uses console input to search for event log entries for the specified . If a match is found, the property information is displayed at the console. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogEntry/Overview/eventlogentry_source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_Source/VB/eventlogentry_source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_Source/VB/eventlogentry_source.vb" id="Snippet1"::: + ]]> @@ -800,13 +796,13 @@ e1.WriteEntry(LocRM.GetString("strMessage"), Gets the local time at which this event was generated. The local time at which this event was generated. - property. - - There is usually a lag between the time that an event is generated and the time it is logged. It is more important to know when the event was generated, unless you want to see if there is a significant lag in logging. That can happen if your log files are on a different server and you are experiencing a bottleneck. - + property. + + There is usually a lag between the time that an event is generated and the time it is logged. It is more important to know when the event was generated, unless you want to see if there is a significant lag in logging. That can happen if your log files are on a different server and you are experiencing a bottleneck. + ]]> @@ -850,11 +846,11 @@ e1.WriteEntry(LocRM.GetString("strMessage"), Gets the local time at which this event was written to the log. The local time at which this event was written to the log. - property. - + property. + ]]> @@ -898,11 +894,11 @@ e1.WriteEntry(LocRM.GetString("strMessage"), Gets the name of the user who is responsible for this event. The security identifier (SID) that uniquely identifies a user or group. - Account information could not be obtained for the user's SID. diff --git a/xml/System.Diagnostics/EventLogEntryCollection.xml b/xml/System.Diagnostics/EventLogEntryCollection.xml index 5268c7a6036..8cf70c468fb 100644 --- a/xml/System.Diagnostics/EventLogEntryCollection.xml +++ b/xml/System.Diagnostics/EventLogEntryCollection.xml @@ -40,22 +40,21 @@ Defines size and enumerators for a collection of instances. - class when reading the entries associated with an instance. The property of the class is a collection of all the entries in the event log. + + Because new entries are appended to the existing list, stepping through the collection enables you to access the entries that were created after you originally created the . However, after you view the entire list, it is not updated with new entries. + + + +## Examples + The following example demonstrates how to obtain event log information from an object. -## Remarks - Use the class when reading the entries associated with an instance. The property of the class is a collection of all the entries in the event log. - - Because new entries are appended to the existing list, stepping through the collection enables you to access the entries that were created after you originally created the . However, after you view the entire list, it is not updated with new entries. - - - -## Examples - The following example demonstrates how to obtain event log information from an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogEntry_CopyTo/CPP/eventlogentry_copyto.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogEntryCollection/Overview/eventlogentry_copyto.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_CopyTo/VB/eventlogentry_copyto.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_CopyTo/VB/eventlogentry_copyto.vb" id="Snippet1"::: + ]]> @@ -99,19 +98,19 @@ The zero-based index in the array at which copying begins. Copies the elements of the to an array of instances, starting at a particular array index. - . An array of instances is fixed at the time it is instantiated. Therefore, you cannot read new entries by using the array that is returned by the method. - - - -## Examples - The following example creates an array and uses the method to copy the contents of an into it. - + . An array of instances is fixed at the time it is instantiated. Therefore, you cannot read new entries by using the array that is returned by the method. + + + +## Examples + The following example creates an array and uses the method to copy the contents of an into it. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogEntryCollection/Overview/eventlogentry_copyto.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_CopyTo/VB/eventlogentry_copyto.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_CopyTo/VB/eventlogentry_copyto.vb" id="Snippet2"::: + ]]> @@ -152,20 +151,19 @@ Gets the number of entries in the event log (that is, the number of elements in the collection). The number of entries currently in the event log. - represents a dynamic list of all the entries in a log. Therefore, the property can change during the lifetime of the instance that you create. It is usually best to work with the property directly instead of assigning its value to a variable. - - - -## Examples - The following example demonstrates how to use the property to iterate through an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Item/CPP/eventlogentry_item.cpp" id="Snippet1"::: + represents a dynamic list of all the entries in a log. Therefore, the property can change during the lifetime of the instance that you create. It is usually best to work with the property directly instead of assigning its value to a variable. + + + +## Examples + The following example demonstrates how to use the property to iterate through an object. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogEntryCollection/Count/eventlogentry_item.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_Item/VB/eventlogentry_item.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_Item/VB/eventlogentry_item.vb" id="Snippet1"::: + ]]> @@ -207,14 +205,14 @@ Supports a simple iteration over the object. An object that can be used to iterate over the collection. - method is a wrapper for the class that implements the enumerator. - + method is a wrapper for the class that implements the enumerator. + > [!NOTE] -> If the collection is changed during the iteration, the iteration is terminated. To avoid this possibility, see the property for an alternative technique for iterating through a collection. - +> If the collection is changed during the iteration, the iteration is terminated. To avoid this possibility, see the property for an alternative technique for iterating through a collection. + ]]> @@ -255,24 +253,23 @@ Gets an entry in the event log, based on an index that starts at 0 (zero). The event log entry at the location that is specified by the parameter. - objects are indexed by the event log system according to the chronological order in which they arrived in the event log. Use the property to select a specific event log entry whose index in the collection is known. - - Iterating through the instance steps through each object sequentially. The collection is dynamic and the number of entries may not be immutable when you enter the loop. Therefore, you should use a `for each...next` loop instead of a `for(int i=0; i instance to examine the entire set of entries. - - Because new entries are appended to the existing list, stepping through the collection enables you to access the entries that were created after you originally created the . - - - -## Examples - The following example demonstrates how to display information for the items in an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogEntry_Item/CPP/eventlogentry_item.cpp" id="Snippet2"::: + objects are indexed by the event log system according to the chronological order in which they arrived in the event log. Use the property to select a specific event log entry whose index in the collection is known. + + Iterating through the instance steps through each object sequentially. The collection is dynamic and the number of entries may not be immutable when you enter the loop. Therefore, you should use a `for each...next` loop instead of a `for(int i=0; i instance to examine the entire set of entries. + + Because new entries are appended to the existing list, stepping through the collection enables you to access the entries that were created after you originally created the . + + + +## Examples + The following example demonstrates how to display information for the items in an object. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogEntryCollection/Count/eventlogentry_item.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_Item/VB/eventlogentry_item.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntry_Item/VB/eventlogentry_item.vb" id="Snippet2"::: + ]]> @@ -318,11 +315,11 @@ The zero-based index in at which copying begins. Copies the elements of the collection to an , starting at a particular index. - method of the class to copy all or part of the collection to an array. - + method of the class to copy all or part of the collection to an array. + ]]> @@ -362,11 +359,11 @@ if access to the collection is not synchronized (thread-safe). - class, the method always returns `false`. - + class, the method always returns `false`. + ]]> @@ -405,11 +402,11 @@ Gets an object that can be used to synchronize access to the object. An object that can be used to synchronize access to the collection. - class, the property always returns the current . - + class, the property always returns the current . + ]]> diff --git a/xml/System.Diagnostics/EventLogEntryType.xml b/xml/System.Diagnostics/EventLogEntryType.xml index 6a6b2eaad3f..b141d1aecbd 100644 --- a/xml/System.Diagnostics/EventLogEntryType.xml +++ b/xml/System.Diagnostics/EventLogEntryType.xml @@ -36,22 +36,21 @@ Specifies the event type of an event log entry. - class to add information about triggered events to a log file. In this example, a `switch` statement is used to determine the event type. Each `case` statement uses the to specify the event type, gets the message and ID, and then writes the information to the log. -## Remarks - The type of an event log entry provides additional information for the entry. Applications set the entry type when they write the entry to the event log. - - Each event must be of a single type; the event types cannot be combined for an entry. The Event Viewer uses this type to determine which icon to display in the list view of the log. - - - -## Examples - The following code example demonstrates how to use the class to add information about triggered events to a log file. In this example, a `switch` statement is used to determine the event type. Each `case` statement uses the to specify the event type, gets the message and ID, and then writes the information to the log. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogEntryType_6/CPP/eventlogentrytype_6.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogEntryType/Overview/eventlogentrytype_6.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntryType_6/VB/eventlogentrytype_6.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogEntryType_6/VB/eventlogentrytype_6.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Diagnostics/EventLogInstaller.xml b/xml/System.Diagnostics/EventLogInstaller.xml index ef7a3034deb..b72b47e46b1 100644 --- a/xml/System.Diagnostics/EventLogInstaller.xml +++ b/xml/System.Diagnostics/EventLogInstaller.xml @@ -55,7 +55,6 @@ ## Examples The following code example sets the installation properties for a new event source. The code example sets the source name and the event log name, and adds the to the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogInstaller/CPP/eventloginstaller.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogInstaller/Overview/eventloginstaller.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogInstaller/VB/eventloginstaller.vb" id="Snippet1"::: @@ -125,7 +124,6 @@ ## Examples The following code example sets the installation properties for a new event source. The code example sets the event source name, event log name, and resource file for localized event text. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlogInstaller_Resources/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogInstaller/CategoryCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlogInstaller_Resources/VB/source.vb" id="Snippet1"::: @@ -305,7 +303,6 @@ SVC_UPDATE.EXE ## Examples The following code example sets the installation properties for a new event source. The code example sets the event source name, event log name, and resource file for localized event text. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlogInstaller_Resources/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogInstaller/CategoryCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlogInstaller_Resources/VB/source.vb" id="Snippet1"::: @@ -664,7 +661,6 @@ SVC_UPDATE.EXE ## Examples The following code example sets the installation properties for a new event source. The code example sets the event source name, event log name, and resource file for localized event text. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlogInstaller_Resources/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogInstaller/CategoryCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlogInstaller_Resources/VB/source.vb" id="Snippet1"::: @@ -868,7 +864,6 @@ TRIGGER.EXE ## Examples The following code example sets the installation properties for a new event source. The code example sets the event source name, event log name, and resource file for localized event text. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlogInstaller_Resources/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogInstaller/CategoryCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlogInstaller_Resources/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Diagnostics/EventLogTraceListener.xml b/xml/System.Diagnostics/EventLogTraceListener.xml index 30374c82840..e49304c6990 100644 --- a/xml/System.Diagnostics/EventLogTraceListener.xml +++ b/xml/System.Diagnostics/EventLogTraceListener.xml @@ -32,48 +32,47 @@ Provides a simple listener that directs tracing or debugging output to an . - can be added to the , , or collections to send output from tracing or debugging to an . You can add the instance in your code or, for a .NET Framework app, specify it in the application configuration file. -To add an using a .NET Framework application configuration file, edit the file that corresponds to the name of your application. In this file, insert an element for a type. The following example adds a object named `myListener` to the collection. The `initializeData` parameter specifies the name of the event log source that is to be passed to the constructor. - -```xml - - - - - - - - - +To add an using a .NET Framework application configuration file, edit the file that corresponds to the name of your application. In this file, insert an element for a type. The following example adds a object named `myListener` to the collection. The `initializeData` parameter specifies the name of the event log source that is to be passed to the constructor. + +```xml + + + + + + + + + ``` - + > [!NOTE] -> If the for the event log that is associated with the instance does not exist, a new event source is created. To create an event source in Windows Vista, Windows XP Professional, or Windows Server 2003, you must have administrative privileges. -> -> The reason for this requirement is that all event logs, including security, must be searched to determine whether the event source is unique. In Windows Vista, users do not have permission to access the security log; therefore, a is thrown. -> -> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses the security log, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - - The class provides the property to get or set the event log that receives the tracing or debugging output, and the property to hold the name of the . - - The method closes the event log so it no longer receives tracing or debugging output. The and methods write a message to the event log. - +> If the for the event log that is associated with the instance does not exist, a new event source is created. To create an event source in Windows Vista, Windows XP Professional, or Windows Server 2003, you must have administrative privileges. +> +> The reason for this requirement is that all event logs, including security, must be searched to determine whether the event source is unique. In Windows Vista, users do not have permission to access the security log; therefore, a is thrown. +> +> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses the security log, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. + + The class provides the property to get or set the event log that receives the tracing or debugging output, and the property to hold the name of the . + + The method closes the event log so it no longer receives tracing or debugging output. The and methods write a message to the event log. + > [!NOTE] > To avoid the possibility of writing large amounts of data to the event log, the does not output the optional trace data specified by the property. + +## Examples + The following example creates a trace listener that sends output to an event log. First, the code creates a new that uses the source `myEventLogSource`. Next, `myTraceListener` is added to the collection. Finally, the example sends a line of output to the object. -## Examples - The following example creates a trace listener that sends output to an event log. First, the code creates a new that uses the source `myEventLogSource`. Next, `myTraceListener` is added to the collection. Finally, the example sends a line of output to the object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic EventLogTraceListener Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLogTraceListener/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLogTraceListener Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic EventLogTraceListener Example/VB/source.vb" id="Snippet1"::: + ]]> This type is thread safe. @@ -397,11 +396,11 @@ To add an using a .NET Framework Gets or sets the name of this . The name of this trace listener. - @@ -471,27 +470,27 @@ To add an using a .NET Framework A data object to write to the output file or stream. Writes trace information, a data object, and event information to the event log. - [!IMPORTANT] -> The methods are not intended to be called by application code. They are called by methods of the , , and classes to output trace data. - - The method, like the method is intended for automated tools but also allows the attaching of additional objects, for example an exception instance, to the trace. - - The `eventCache` and `source` parameters are used to determine if the event should be traced. `id` is used to create an object and the is equated to an for the property. The is written to the event log with the `data` object, formatted as a string, using the method. - +> The methods are not intended to be called by application code. They are called by methods of the , , and classes to output trace data. + + The method, like the method is intended for automated tools but also allows the attaching of additional objects, for example an exception instance, to the trace. + + The `eventCache` and `source` parameters are used to determine if the event should be traced. `id` is used to create an object and the is equated to an for the property. The is written to the event log with the `data` object, formatted as a string, using the method. + > [!NOTE] -> The maximum value of the `id` parameter is 65,535. If the `id` value specified is greater than 65,535, the maximum value is used. - +> The maximum value of the `id` parameter is 65,535. If the `id` value specified is greater than 65,535, the maximum value is used. + ]]> - is not specified. - - -or- - + is not specified. + + -or- + The log entry string exceeds 32,766 characters. @@ -550,29 +549,29 @@ To add an using a .NET Framework An array of data objects. Writes trace information, an array of data objects, and event information to the event log. - [!IMPORTANT] -> The methods are not intended to be called by application code. They are called by methods of the , , and classes to output trace data. - - The method, like the method is intended for automated tools but also allows the attaching of additional objects, for example an exception instance, to the trace. - - The `severity` and `id` parameter data is used to create an object, which is written to the event log with the data from the array of data objects. - - The `eventCache` and `source` parameters are used to determine if the event should be traced. `id` is used to create an object and the is equated to an for the property. The is written to the event log with the `data` object array, formatted as a string array, using the method. - +> The methods are not intended to be called by application code. They are called by methods of the , , and classes to output trace data. + + The method, like the method is intended for automated tools but also allows the attaching of additional objects, for example an exception instance, to the trace. + + The `severity` and `id` parameter data is used to create an object, which is written to the event log with the data from the array of data objects. + + The `eventCache` and `source` parameters are used to determine if the event should be traced. `id` is used to create an object and the is equated to an for the property. The is written to the event log with the `data` object array, formatted as a string array, using the method. + > [!NOTE] -> The maximum value of the `id` parameter is 65,535. If the `id` value specified is greater than 65,535, the maximum value is used. - +> The maximum value of the `id` parameter is 65,535. If the `id` value specified is greater than 65,535, the maximum value is used. + ]]> - is not specified. - - -or- - + is not specified. + + -or- + The log entry string exceeds 32,766 characters. @@ -633,27 +632,27 @@ To add an using a .NET Framework The trace message. Writes trace information, a message, and event information to the event log. - [!IMPORTANT] -> The methods are not intended to be called by application code. These methods are called by methods of the , , and classes to write trace data. - - The method is intended to trace events that can be processed automatically by tools. For example a monitoring tool can notify an administrator if a specific event is traced by a specific source. - - The `eventCache` and `source` parameters are used to determine if the event should be traced. `id` is used to create an object and the is equated to an for the property. The is written to the event log with the `message` data using the method. - +> The methods are not intended to be called by application code. These methods are called by methods of the , , and classes to write trace data. + + The method is intended to trace events that can be processed automatically by tools. For example a monitoring tool can notify an administrator if a specific event is traced by a specific source. + + The `eventCache` and `source` parameters are used to determine if the event should be traced. `id` is used to create an object and the is equated to an for the property. The is written to the event log with the `message` data using the method. + > [!NOTE] -> The maximum value of the `id` parameter is 65,535. If the `id` value specified is greater than 65,535, the maximum value is used. - +> The maximum value of the `id` parameter is 65,535. If the `id` value specified is greater than 65,535, the maximum value is used. + ]]> - is not specified. - - -or- - + is not specified. + + -or- + The log entry string exceeds 32,766 characters. @@ -714,27 +713,27 @@ To add an using a .NET Framework An array containing zero or more objects to format. Writes trace information, a formatted array of objects, and event information to the event log. - [!IMPORTANT] -> The methods are not intended to be called by application code. These methods are called by methods of the , , and classes to write trace data. - - The method is intended to trace events that can be processed automatically by tools. For example a monitoring tool can notify an administrator if a specific event is traced by a specific source. - - The `eventCache` and `source` parameters are used to determine if the event should be traced. `id` is used to create an object and the is equated to an for the property. The is written to the event log, using the method, with the message obtained from the `format` and `args` parameters. The `args` object array is converted to a string using the method, passing the `format` string and `args` array to format the string as the message for the event log. - +> The methods are not intended to be called by application code. These methods are called by methods of the , , and classes to write trace data. + + The method is intended to trace events that can be processed automatically by tools. For example a monitoring tool can notify an administrator if a specific event is traced by a specific source. + + The `eventCache` and `source` parameters are used to determine if the event should be traced. `id` is used to create an object and the is equated to an for the property. The is written to the event log, using the method, with the message obtained from the `format` and `args` parameters. The `args` object array is converted to a string using the method, passing the `format` string and `args` array to format the string as the message for the event log. + > [!NOTE] -> The maximum value of the `id` parameter is 65,535. If the `id` value specified is greater than 65,535, the maximum value is used. - +> The maximum value of the `id` parameter is 65,535. If the `id` value specified is greater than 65,535, the maximum value is used. + ]]> - is not specified. - - -or- - + is not specified. + + -or- + The log entry string exceeds 32,766 characters. diff --git a/xml/System.Diagnostics/EventSchemaTraceListener.xml b/xml/System.Diagnostics/EventSchemaTraceListener.xml index d8956b56261..3eb87370d79 100644 --- a/xml/System.Diagnostics/EventSchemaTraceListener.xml +++ b/xml/System.Diagnostics/EventSchemaTraceListener.xml @@ -101,7 +101,6 @@ You can create an object in y ## Examples The following code example demonstrates how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.EventSchemaTraceListener/CPP/eventschematracelistener.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventSchemaTraceListener/Overview/program.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.EventSchemaTraceListener/vb/program.vb" id="Snippet1"::: diff --git a/xml/System.Diagnostics/EventSourceCreationData.xml b/xml/System.Diagnostics/EventSourceCreationData.xml index b04ac35d295..33755d50cb9 100644 --- a/xml/System.Diagnostics/EventSourceCreationData.xml +++ b/xml/System.Diagnostics/EventSourceCreationData.xml @@ -32,38 +32,37 @@ Represents the configuration settings used to create an event log source on the local computer or a remote computer. - class to configure a new source for writing localized entries to an event log. It is not necessary to use this class to read from an event log. + + This class defines the configuration settings for a new event source and its associated event log. The associated event log can be on the local computer or a remote computer. To create a new source for a new or existing event log on the local computer, set the and properties of an and call the method. This method creates the event source you specify in the property and registers it for the event log specified in . This behavior is similar to using the class to register an event source for an event log. + + Use the and methods to write events to an event log. You must specify an event source to write events; you must create and configure the event source before writing the first entry with the source. + + Create the new event source during the installation of your application. This allows time for the operating system to refresh its list of registered event sources and their configurations. If the operating system has not refreshed its list of event sources, and you attempt to write an event with the new source, the write operation will fail. You can configure a new source using an , or using the method. You must have administrative rights on the computer to create a new event source. + + You can create an event source for an existing event log or a new event log. When you create a new source for a new event log, the system registers the source for that log, but the log is not created until the first entry is written to it. + + Each source can only write to one event log at a time; however, your application can use multiple sources to write to multiple event logs. For example, your application might need multiple sources configured for different event logs or different resource files. + + To change the configuration details of an existing source, you must delete the source and then create it with the new configuration. If other applications or components use the existing source, create a new source with the updated configuration rather than deleting the existing source. + + You can register the event source with localized resources for your event category and message strings. Your application can write event log entries using resource identifiers, rather than specifying the actual string. The Event Viewer uses the resource identifier to find and display the corresponding string from the localized resource file based on current language settings. You can register a separate file for event categories, messages, and parameter insertion strings, or you can register the same resource file for all three types of strings. Use the , , , and properties to configure the source to write localized entries to the event log. If your application writes string values directly to the event log, you do not need to set these properties. + + The source must be configured either for writing localized entries or for writing direct strings. The method writes the given string directly to the event log; it does not use a localizable message resource file. Use the method to write events using a localized message resource file. + + If your application writes entries using both resource identifiers and string values, you must register two separate sources. For example, configure one source with resource files, and then use that source in the method to write entries using resource identifiers to the event log. Then create a different source without resource files and use that source in the method to write strings directly to the event log using that source. + + + +## Examples + The following code example sets the configuration properties for an event source from command-line arguments. The input arguments specify the event source name, event log name, computer name, and event message resource file. The code example verifies that the source does not conflict with an existing event source, and then creates the new event source for the specified event log. -## Remarks - Use the class to configure a new source for writing localized entries to an event log. It is not necessary to use this class to read from an event log. - - This class defines the configuration settings for a new event source and its associated event log. The associated event log can be on the local computer or a remote computer. To create a new source for a new or existing event log on the local computer, set the and properties of an and call the method. This method creates the event source you specify in the property and registers it for the event log specified in . This behavior is similar to using the class to register an event source for an event log. - - Use the and methods to write events to an event log. You must specify an event source to write events; you must create and configure the event source before writing the first entry with the source. - - Create the new event source during the installation of your application. This allows time for the operating system to refresh its list of registered event sources and their configurations. If the operating system has not refreshed its list of event sources, and you attempt to write an event with the new source, the write operation will fail. You can configure a new source using an , or using the method. You must have administrative rights on the computer to create a new event source. - - You can create an event source for an existing event log or a new event log. When you create a new source for a new event log, the system registers the source for that log, but the log is not created until the first entry is written to it. - - Each source can only write to one event log at a time; however, your application can use multiple sources to write to multiple event logs. For example, your application might need multiple sources configured for different event logs or different resource files. - - To change the configuration details of an existing source, you must delete the source and then create it with the new configuration. If other applications or components use the existing source, create a new source with the updated configuration rather than deleting the existing source. - - You can register the event source with localized resources for your event category and message strings. Your application can write event log entries using resource identifiers, rather than specifying the actual string. The Event Viewer uses the resource identifier to find and display the corresponding string from the localized resource file based on current language settings. You can register a separate file for event categories, messages, and parameter insertion strings, or you can register the same resource file for all three types of strings. Use the , , , and properties to configure the source to write localized entries to the event log. If your application writes string values directly to the event log, you do not need to set these properties. - - The source must be configured either for writing localized entries or for writing direct strings. The method writes the given string directly to the event log; it does not use a localizable message resource file. Use the method to write events using a localized message resource file. - - If your application writes entries using both resource identifiers and string values, you must register two separate sources. For example, configure one source with resource files, and then use that source in the method to write entries using resource identifiers to the event log. Then create a different source without resource files and use that source in the method to write strings directly to the event log using that source. - - - -## Examples - The following code example sets the configuration properties for an event source from command-line arguments. The input arguments specify the event source name, event log name, computer name, and event message resource file. The code example verifies that the source does not conflict with an existing event source, and then creates the new event source for the specified event log. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventSourceCreationData/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/VB/source.vb" id="Snippet1"::: + ]]> @@ -103,149 +102,148 @@ The name of the log to which entries from the source are written. Initializes a new instance of the class with a specified event source and event log name. - instance, configure the instance properties for your application, and call the method. After the source is registered, you can write entries from the source using the or methods. - - You can register the event source with localized resources for your event category and message strings. Your application can write event log entries using resource identifiers, rather than specifying the actual string. The Event Viewer uses the resource identifier to find and display the corresponding string from the localized resource file based on current language settings. You can register a separate file for event categories, messages, and parameter insertion strings, or you can register the same resource file for all three types of strings. Use the , , , and properties to configure the source to write localized entries to the event log. If your application writes string values directly to the event log, you do not need to set these properties. - - The source must be configured either for writing localized entries or for writing direct strings. If your application writes entries using both resource identifiers and string values, you must register two separate sources. For example, configure one source with resource files, and then use that source in the method to write entries using resource identifiers to the event log. Then create a different source without resource files and use that source in the method to write strings directly to the event log. - - The following table shows initial property values for an . - -|Property|Initial Value| -|--------------|-------------------| -||The `source` parameter.| -||The `logName` parameter.| -||The local computer (".").| -||Zero| -||`null` (`Nothing` in Visual Basic).| -||`null` (`Nothing` in Visual Basic).| -||`null` (`Nothing` in Visual Basic).| - - - -## Examples - The following code example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the code example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet6"::: + instance, configure the instance properties for your application, and call the method. After the source is registered, you can write entries from the source using the or methods. + + You can register the event source with localized resources for your event category and message strings. Your application can write event log entries using resource identifiers, rather than specifying the actual string. The Event Viewer uses the resource identifier to find and display the corresponding string from the localized resource file based on current language settings. You can register a separate file for event categories, messages, and parameter insertion strings, or you can register the same resource file for all three types of strings. Use the , , , and properties to configure the source to write localized entries to the event log. If your application writes string values directly to the event log, you do not need to set these properties. + + The source must be configured either for writing localized entries or for writing direct strings. If your application writes entries using both resource identifiers and string values, you must register two separate sources. For example, configure one source with resource files, and then use that source in the method to write entries using resource identifiers to the event log. Then create a different source without resource files and use that source in the method to write strings directly to the event log. + + The following table shows initial property values for an . + +|Property|Initial Value| +|--------------|-------------------| +||The `source` parameter.| +||The `logName` parameter.| +||The local computer (".").| +||Zero| +||`null` (`Nothing` in Visual Basic).| +||`null` (`Nothing` in Visual Basic).| +||`null` (`Nothing` in Visual Basic).| + + + +## Examples + The following code example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the code example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> @@ -289,137 +287,136 @@ SVC_UPDATE.EXE Gets or sets the number of categories in the category resource file. The number of categories in the category resource file. The default value is zero. - and properties to write events with localized category strings. The Event Viewer displays the category for an event entry if you supply a category when you write the event. Event log categories are application-defined strings that help filter events, or provide further information on the event. For example, your application can define separate categories for different components or different operations. - - Event categories are optional; if your application does not use categories, do not set the and properties. - - For details about defining event messages and building event resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. - - - -## Examples - The following code example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the code example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet6"::: + and properties to write events with localized category strings. The Event Viewer displays the category for an event entry if you supply a category when you write the event. Event log categories are application-defined strings that help filter events, or provide further information on the event. For example, your application can define separate categories for different components or different operations. + + Event categories are optional; if your application does not use categories, do not set the and properties. + + For details about defining event messages and building event resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. + + + +## Examples + The following code example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the code example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> The property is set to a negative value or to a value larger than UInt16.MaxValue. @@ -469,137 +466,136 @@ SVC_UPDATE.EXE Gets or sets the path of the resource file that contains category strings for the source. The path of the category resource file. The default is an empty string (""). - and properties to write events with localized category strings. The Event Viewer displays the category for an event entry if you supply a category when you write the event. Event log categories are application-defined strings that help filter events, or provide further information on the event. For example, your application can define separate categories for different components or different operations. - - Event categories are optional; if your application does not use categories, do not set the and properties. - - For details about defining event messages and building event resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. - - - -## Examples - The following code example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the code example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet6"::: + and properties to write events with localized category strings. The Event Viewer displays the category for an event entry if you supply a category when you write the event. Event log categories are application-defined strings that help filter events, or provide further information on the event. For example, your application can define separate categories for different components or different operations. + + Event categories are optional; if your application does not use categories, do not set the and properties. + + For details about defining event messages and building event resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. + + + +## Examples + The following code example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the code example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> @@ -647,27 +643,26 @@ SVC_UPDATE.EXE Gets or sets the name of the event log to which the source writes entries. The name of the event log. This can be Application, System, or a custom log name. The default value is "Application." - property to identify the event log that your application writes entries to using the new source. The event log can be a new log or an existing log. Applications and services should write to the Application log or a custom log. Device drivers should write to the System log. If you do not explicitly set the property, the event log defaults to the Application log. - + property to identify the event log that your application writes entries to using the new source. The event log can be a new log or an existing log. Applications and services should write to the Application log or a custom log. Device drivers should write to the System log. If you do not explicitly set the property, the event log defaults to the Application log. + > [!NOTE] -> The Security log is read-only. - - To target an existing log for the new source, set the property to the existing event log name. To create a new event log for the source, you must set the property. Event log names must consist of printable characters, and cannot include the characters '*', '?', or '\\'. The first 8 characters of the event log name must be different from the first 8 characters of existing names of event logs on the specified computer. - - The operating system stores event logs as files. When you use or the method to create a new event log, the associated file is stored in the %SystemRoot%\System32\Config directory on the specified computer. The file name is set by appending the first 8 characters of the property with the ".evt" file name extension. - - - -## Examples - The following code example sets the configuration properties for an event source from command-line arguments. The input arguments specify the event source name, event log name, computer name, and event message resource file. This example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/CPP/source.cpp" id="Snippet2"::: +> The Security log is read-only. + + To target an existing log for the new source, set the property to the existing event log name. To create a new event log for the source, you must set the property. Event log names must consist of printable characters, and cannot include the characters '*', '?', or '\\'. The first 8 characters of the event log name must be different from the first 8 characters of existing names of event logs on the specified computer. + + The operating system stores event logs as files. When you use or the method to create a new event log, the associated file is stored in the %SystemRoot%\System32\Config directory on the specified computer. The file name is set by appending the first 8 characters of the property with the ".evt" file name extension. + + + +## Examples + The following code example sets the configuration properties for an event source from command-line arguments. The input arguments specify the event source name, event log name, computer name, and event message resource file. This example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventSourceCreationData/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/VB/source.vb" id="Snippet2"::: + ]]> @@ -715,22 +710,21 @@ SVC_UPDATE.EXE Gets or sets the name of the computer on which to register the event source. The name of the system on which to register the event source. The default is the local computer ("."). - value cannot be an empty string. If the machine name is not explicitly set, it defaults to the local computer ("."). - - When registering a source on a remote computer, you must have administrative rights on that computer to write the registry values with sufficient permissions. - - - -## Examples - The following code example sets the configuration properties for an event source from command-line arguments. The input arguments specify the event source name, event log name, computer name, and event message resource file. This example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/CPP/source.cpp" id="Snippet2"::: + value cannot be an empty string. If the machine name is not explicitly set, it defaults to the local computer ("."). + + When registering a source on a remote computer, you must have administrative rights on that computer to write the registry values with sufficient permissions. + + + +## Examples + The following code example sets the configuration properties for an event source from command-line arguments. The input arguments specify the event source name, event log name, computer name, and event message resource file. This example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventSourceCreationData/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/VB/source.vb" id="Snippet2"::: + ]]> The computer name is invalid. @@ -780,141 +774,140 @@ SVC_UPDATE.EXE Gets or sets the path of the message resource file that contains message formatting strings for the source. The path of the message resource file. The default is an empty string (""). - property to configure an event log source to write localized event messages. Event messages are application-defined strings that describe the event to the user. - - Your application can write event log entries using resource identifiers. A resource identifier indexes a message located in the . The Event Viewer uses the resource identifier to find and display the corresponding string from the localized message resource file based on current language settings. - - The event source must be configured either for writing localized entries or for writing direct strings. Use the method to write localized entries for a source configured with a message resource file. - - If your application writes event message strings directly, rather than using a resource identifier in a localized resource file, do not set the property. - - For details about defining event messages and building event resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. - - - -## Examples - The following code example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the code example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet6"::: + property to configure an event log source to write localized event messages. Event messages are application-defined strings that describe the event to the user. + + Your application can write event log entries using resource identifiers. A resource identifier indexes a message located in the . The Event Viewer uses the resource identifier to find and display the corresponding string from the localized message resource file based on current language settings. + + The event source must be configured either for writing localized entries or for writing direct strings. Use the method to write localized entries for a source configured with a message resource file. + + If your application writes event message strings directly, rather than using a resource identifier in a localized resource file, do not set the property. + + For details about defining event messages and building event resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. + + + +## Examples + The following code example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the code example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> @@ -961,164 +954,163 @@ SVC_UPDATE.EXE Gets or sets the path of the resource file that contains message parameter strings for the source. The path of the parameter resource file. The default is an empty string (""). - property to configure an event log source to write localized event messages with inserted parameter strings. Each localized event message specified in the property can contain placeholders for insertion strings. These placeholders are used to specify the position and resource identifier for a language-independent string within the event message. The Event Viewer fills in the placeholders using the corresponding strings from the and formats the event log message for the localized event entry. - - For example, the following section of a message text file defines a string with a parameter placeholder: - -``` - -MessageId = 1501 -Severity = Success -Facility = Application -SymbolicName = COMPONENT_STARTING -Language=English -Component %%6050 is starting. -. -``` - - Within the parameter resource file, the insertion string must be defined with the resource identifier that corresponds to the placeholder, as shown below: - -``` -MessageId = 6050 -Severity = Success -Facility = Application -SymbolicName = COMPONENT_NAME_MSGID -Language=English -TRIGGER.EXE -. -``` - - The event source must be configured either for writing localized entries or for writing direct strings. Use the method to write localized entries for a source configured with a message resource file. - - If your application writes event message strings directly to the event log, or if your property does not contain messages with parameter insertion placeholders, do not set the property. - - For details about defining event messages and building event resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. - - - -## Examples - The following code example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the code example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventlog_WriteEvent/CPP/source.cpp" id="Snippet6"::: + property to configure an event log source to write localized event messages with inserted parameter strings. Each localized event message specified in the property can contain placeholders for insertion strings. These placeholders are used to specify the position and resource identifier for a language-independent string within the event message. The Event Viewer fills in the placeholders using the corresponding strings from the and formats the event log message for the localized event entry. + + For example, the following section of a message text file defines a string with a parameter placeholder: + +``` + +MessageId = 1501 +Severity = Success +Facility = Application +SymbolicName = COMPONENT_STARTING +Language=English +Component %%6050 is starting. +. +``` + + Within the parameter resource file, the insertion string must be defined with the resource identifier that corresponds to the placeholder, as shown below: + +``` +MessageId = 6050 +Severity = Success +Facility = Application +SymbolicName = COMPONENT_NAME_MSGID +Language=English +TRIGGER.EXE +. +``` + + The event source must be configured either for writing localized entries or for writing direct strings. Use the method to write localized entries for a source configured with a message resource file. + + If your application writes event message strings directly to the event log, or if your property does not contain messages with parameter insertion placeholders, do not set the property. + + For details about defining event messages and building event resource files, see the [Message Compiler](/windows/win32/wes/message-compiler--mc-exe-) article in the Platform SDK documentation. + + + +## Examples + The following code example determines whether the event source named `SampleApplicationSource` is registered on the local computer. If the event source does not exist, the example sets the message resource file for the source and creates the new event source. Finally, the code example sets the localized display name for the event log, using the resource identifier value in `DisplayNameMsgId` and the resource file path in `messageFile`. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventInstance/Overview/source.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: - - The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. Specifically, the message defined for resource identifier 1004 uses a placeholder for a parameter string defined for resource identifier 5002. - -``` -; // EventLogMsgs.mc -; // ******************************************************** - -; // Use the following commands to build this file: - -; // mc -s EventLogMsgs.mc -; // rc EventLogMsgs.rc -; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res -; // ******************************************************** - -; // - Event categories - -; // Categories must be numbered consecutively starting at 1. -; // ******************************************************** - -MessageId=0x1 -Severity=Success -SymbolicName=INSTALL_CATEGORY -Language=English -Installation -. - -MessageId=0x2 -Severity=Success -SymbolicName=QUERY_CATEGORY -Language=English -Database Query -. - -MessageId=0x3 -Severity=Success -SymbolicName=REFRESH_CATEGORY -Language=English -Data Refresh -. - -; // - Event messages - -; // ********************************* - -MessageId = 1000 -Severity = Success -Facility = Application -SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 -Language=English -My application message text, in English, for message id 1000, called from %1. -. - -MessageId = 1001 -Severity = Warning -Facility = Application -SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 -Language=English -My application message text, in English, for message id 1001, called from %1. -. - -MessageId = 1002 -Severity = Success -Facility = Application -SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 -Language=English -My generic information message in English, for message id 1002. -. - -MessageId = 1003 -Severity = Warning -Facility = Application -SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 -Language=English -My generic warning message in English, for message id 1003, called from %1. -. - -MessageId = 1004 -Severity = Success -Facility = Application -SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 -Language=English -The update cycle is complete for %%5002. -. - -MessageId = 1005 -Severity = Warning -Facility = Application -SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 -Language=English -The refresh operation did not complete because the connection to server %1 could not be established. -. - -; // - Event log display name - -; // ******************************************************** - -MessageId = 5001 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID -Language=English -Sample Event Log -. - -; // - Event message parameters - -; // Language independent insertion strings -; // ******************************************************** - -MessageId = 5002 -Severity = Success -Facility = Application -SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID -Language=English -SVC_UPDATE.EXE -. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventlog_WriteEvent/VB/source.vb" id="Snippet6"::: + + The code example uses the following message text file, built into the resource library EventLogMsgs.dll. A message text file is the source from which the message resource file is created. The message text file defines the resource identifiers and text for the category, event message, and parameter insertion strings. Specifically, the message defined for resource identifier 1004 uses a placeholder for a parameter string defined for resource identifier 5002. + +``` +; // EventLogMsgs.mc +; // ******************************************************** + +; // Use the following commands to build this file: + +; // mc -s EventLogMsgs.mc +; // rc EventLogMsgs.rc +; // link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res +; // ******************************************************** + +; // - Event categories - +; // Categories must be numbered consecutively starting at 1. +; // ******************************************************** + +MessageId=0x1 +Severity=Success +SymbolicName=INSTALL_CATEGORY +Language=English +Installation +. + +MessageId=0x2 +Severity=Success +SymbolicName=QUERY_CATEGORY +Language=English +Database Query +. + +MessageId=0x3 +Severity=Success +SymbolicName=REFRESH_CATEGORY +Language=English +Data Refresh +. + +; // - Event messages - +; // ********************************* + +MessageId = 1000 +Severity = Success +Facility = Application +SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000 +Language=English +My application message text, in English, for message id 1000, called from %1. +. + +MessageId = 1001 +Severity = Warning +Facility = Application +SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001 +Language=English +My application message text, in English, for message id 1001, called from %1. +. + +MessageId = 1002 +Severity = Success +Facility = Application +SymbolicName = GENERIC_INFO_MESSAGE_ID_1002 +Language=English +My generic information message in English, for message id 1002. +. + +MessageId = 1003 +Severity = Warning +Facility = Application +SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003 +Language=English +My generic warning message in English, for message id 1003, called from %1. +. + +MessageId = 1004 +Severity = Success +Facility = Application +SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004 +Language=English +The update cycle is complete for %%5002. +. + +MessageId = 1005 +Severity = Warning +Facility = Application +SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005 +Language=English +The refresh operation did not complete because the connection to server %1 could not be established. +. + +; // - Event log display name - +; // ******************************************************** + +MessageId = 5001 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID +Language=English +Sample Event Log +. + +; // - Event message parameters - +; // Language independent insertion strings +; // ******************************************************** + +MessageId = 5002 +Severity = Success +Facility = Application +SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID +Language=English +SVC_UPDATE.EXE +. +``` + ]]> @@ -1165,24 +1157,23 @@ SVC_UPDATE.EXE Gets or sets the name to register with the event log as an event source. The name to register with the event log as a source of entries. The default is an empty string (""). - method uses the , , and properties to create registry values on the target computer for the new source and its associated event log. A new source name cannot match an existing source name or an existing event log name on the target computer. - - After the registry values for the source are created, your application can use the source to write entries to the configured event log. - - Each source can only write to one event log at a time; however, your application can use multiple sources to write to multiple event logs. For example, your application might require multiple sources configured for different event logs or different resource files. - - - -## Examples - The following code example sets the configuration properties for an event source from command-line arguments. The input arguments specify the event source name, event log name, computer name, and event message resource file. This example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/CPP/source.cpp" id="Snippet2"::: + method uses the , , and properties to create registry values on the target computer for the new source and its associated event log. A new source name cannot match an existing source name or an existing event log name on the target computer. + + After the registry values for the source are created, your application can use the source to write entries to the configured event log. + + Each source can only write to one event log at a time; however, your application can use multiple sources to write to multiple event logs. For example, your application might require multiple sources configured for different event logs or different resource files. + + + +## Examples + The following code example sets the configuration properties for an event source from command-line arguments. The input arguments specify the event source name, event log name, computer name, and event message resource file. This example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventSourceCreationData/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLog_EventSourceCreation_Properties/VB/source.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Diagnostics/FileVersionInfo.xml b/xml/System.Diagnostics/FileVersionInfo.xml index 444ed189f73..6f4bf2a706e 100644 --- a/xml/System.Diagnostics/FileVersionInfo.xml +++ b/xml/System.Diagnostics/FileVersionInfo.xml @@ -51,37 +51,36 @@ Provides version information for a physical file on disk. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - Use the method of this class to get a containing information about a file, then look at the properties for information about the file. The property provides version information about the file. The , , , , and properties provide version information for the product that the specified file is a part of. Call to get a partial list of properties and their values for this file. - - The properties are based on version resource information built into the file. Version resources are often built into binary files such as .exe or .dll files; text files do not have version resource information. - - Version resources are typically specified in a Win32 resource file, or in assembly attributes. For example the property reflects the `VS_FF_DEBUG` flag value in the file's `VS_FIXEDFILEINFO` block, which is built from the `VERSIONINFO` resource in a Win32 resource file. For more information about specifying version resources in a Win32 resource file, see "About Resource Files" and "VERSIONINFO Resource" in the Platform SDK. For more information about specifying version resources in a .NET module, see the [Setting Assembly Attributes](/dotnet/standard/assembly/set-attributes) topic. - + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + Use the method of this class to get a containing information about a file, then look at the properties for information about the file. The property provides version information about the file. The , , , , and properties provide version information for the product that the specified file is a part of. Call to get a partial list of properties and their values for this file. + + The properties are based on version resource information built into the file. Version resources are often built into binary files such as .exe or .dll files; text files do not have version resource information. + + Version resources are typically specified in a Win32 resource file, or in assembly attributes. For example the property reflects the `VS_FF_DEBUG` flag value in the file's `VS_FIXEDFILEINFO` block, which is built from the `VERSIONINFO` resource in a Win32 resource file. For more information about specifying version resources in a Win32 resource file, see "About Resource Files" and "VERSIONINFO Resource" in the Platform SDK. For more information about specifying version resources in a .NET module, see the [Setting Assembly Attributes](/dotnet/standard/assembly/set-attributes) topic. + > [!NOTE] -> This class makes a link demand at the class level that applies to all members. A is thrown when the immediate caller does not have full trust permission. For details about link demands, see [Link Demands](/dotnet/framework/misc/link-demands). +> This class makes a link demand at the class level that applies to all members. A is thrown when the immediate caller does not have full trust permission. For details about link demands, see [Link Demands](/dotnet/framework/misc/link-demands). + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the file description and version number to the console. - - -## Examples - The following example calls to get the for the Notepad. Then it prints the file description and version number to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -135,20 +134,19 @@ Gets the comments associated with the file. The comments associated with the file or if the file did not contain version information. - to get the for the Notepad. Then it prints the comments in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/Classic FileVersionInfo.Comments Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it prints the comments in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/Comments/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/Classic FileVersionInfo.Comments Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/Classic FileVersionInfo.Comments Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -200,15 +198,14 @@ Gets the name of the company that produced the file. The name of the company that produced the file or if the file did not contain version information. - to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.CompanyName Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/CompanyName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.CompanyName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.CompanyName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -259,30 +256,29 @@ Gets the build number of the file. A value representing the build number of the file or if the file did not contain version information. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - This property gets the third set of 16 bits. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileBuildPart Example/CPP/source.cpp" id="Snippet1"::: + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + This property gets the third set of 16 bits. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/FileBuildPart/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileBuildPart Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileBuildPart Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -339,15 +335,14 @@ Gets the description of the file. The description of the file or if the file did not contain version information. - to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileDescription Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/FileDescription/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileDescription Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileDescription Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -398,30 +393,29 @@ Gets the major part of the version number. A value representing the major part of the version number or 0 (zero) if the file did not contain version information. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - This property gets the first set of 16 bits. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMajorPart Example/CPP/source.cpp" id="Snippet1"::: + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + This property gets the first set of 16 bits. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/FileMajorPart/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMajorPart Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMajorPart Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -476,30 +470,29 @@ Gets the minor part of the version number of the file. A value representing the minor part of the version number of the file or 0 (zero) if the file did not contain version information. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - This property gets the second set of 16 bits. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMinorPart Example/CPP/source.cpp" id="Snippet1"::: + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + This property gets the second set of 16 bits. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/FileMinorPart/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMinorPart Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileMinorPart Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -554,15 +547,14 @@ Gets the name of the file that this instance of describes. The name of the file described by this instance of . - to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileName Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/FileName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FileName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -613,30 +605,29 @@ Gets the file private part number. A value representing the file private part number or if the file did not contain version information. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - This property gets the last set of 16 bits. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.FilePrivatePart Example/CPP/source.cpp" id="Snippet1"::: + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + This property gets the last set of 16 bits. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/FilePrivatePart/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FilePrivatePart Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.FilePrivatePart Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -693,28 +684,27 @@ Gets the file version number. The version number of the file or if the file did not contain version information. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the file description and version number in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/CPP/source.cpp" id="Snippet1"::: + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the file description and version number in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -768,15 +758,14 @@ Returns a representing the version information associated with the specified file. A containing information about the file. If the file did not contain version information, the contains only the name of the file requested. - to get the for Notepad and displays the file description and version number in the console window. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/CPP/source.cpp" id="Snippet1"::: + to get the for Notepad and displays the file description and version number in the console window. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo Example/VB/source.vb" id="Snippet1"::: + ]]> The file specified cannot be found. @@ -855,15 +844,14 @@ Gets the internal name of the file, if one exists. The internal name of the file. If none exists, this property will contain the original name of the file without the extension. - to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.InternalName Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/InternalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.InternalName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.InternalName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -909,22 +897,21 @@ if the file contains debugging information or is compiled with debugging features enabled; otherwise, . - properties are based on version resource information built into the file. Version resources are often built into binary files such as .exe or .dll files; text files do not have version resource information. - - Version resources are typically specified in a Win32 resource file, or in assembly attributes. The property reflects the `VS_FF_DEBUG` flag value in the file's `VS_FIXEDFILEINFO` block, which is built from the `VERSIONINFO` resource in a Win32 resource file. For more information about specifying version resources in a Win32 resource file, see the Platform SDK `About Resource Files` topic and `VERSIONINFO Resource` topic topics. - - - -## Examples - The following example calls to get the for the Notepad. Then it displays the state of the Boolean in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsDebug Example/CPP/source.cpp" id="Snippet1"::: + properties are based on version resource information built into the file. Version resources are often built into binary files such as .exe or .dll files; text files do not have version resource information. + + Version resources are typically specified in a Win32 resource file, or in assembly attributes. The property reflects the `VS_FF_DEBUG` flag value in the file's `VS_FIXEDFILEINFO` block, which is built from the `VERSIONINFO` resource in a Win32 resource file. For more information about specifying version resources in a Win32 resource file, see the Platform SDK `About Resource Files` topic and `VERSIONINFO Resource` topic topics. + + + +## Examples + The following example calls to get the for the Notepad. Then it displays the state of the Boolean in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/IsDebug/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsDebug Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsDebug Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -970,15 +957,14 @@ if the file is patched; otherwise, . - to get the for the Notepad. Then it displays the state of the Boolean in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPatched Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it displays the state of the Boolean in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/IsPatched/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPatched Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPatched Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1024,15 +1010,14 @@ if the file is prerelease; otherwise, . - to get the for the Notepad. Then it displays whether this version is a prerelease version in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPreRelease Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it displays whether this version is a prerelease version in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/IsPreRelease/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPreRelease Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPreRelease Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1078,20 +1063,19 @@ if the file is a private build; if the file was built using standard release procedures or if the file did not contain version information. - will describe how this version of the file differs from the standard version. - - - -## Examples - The following example calls to get the for the Notepad. Then it displays the private build information in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPrivateBuild Example/CPP/source.cpp" id="Snippet1"::: + will describe how this version of the file differs from the standard version. + + + +## Examples + The following example calls to get the for the Notepad. Then it displays the private build information in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/IsPrivateBuild/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPrivateBuild Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsPrivateBuild Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1138,20 +1122,19 @@ if the file is a special build; otherwise, . - property must specify how this file differs from the standard version. - - - -## Examples - The following example calls to get the for the Notepad. Then it displays whether this version is a special build version in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsSpecialBuild Example/CPP/source.cpp" id="Snippet1"::: + property must specify how this file differs from the standard version. + + + +## Examples + The following example calls to get the for the Notepad. Then it displays whether this version is a special build version in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/IsSpecialBuild/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsSpecialBuild Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.IsSpecialBuild Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1253,20 +1236,19 @@ Gets all copyright notices that apply to the specified file. The copyright notices that apply to the specified file. - to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalCopyright Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/LegalCopyright/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalCopyright Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalCopyright Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1318,20 +1300,19 @@ Gets the trademarks and registered trademarks that apply to the file. The trademarks and registered trademarks that apply to the file or if the file did not contain version information. - to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalTrademarks Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/LegalTrademarks/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalTrademarks Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.LegalTrademarks Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1383,20 +1364,19 @@ Gets the name the file was created with. The name the file was created with or if the file did not contain version information. - to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.OriginalFilename Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/OriginalFilename/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.OriginalFilename Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.OriginalFilename Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1448,20 +1428,19 @@ Gets information about a private version of the file. Information about a private version of the file or if the file did not contain version information. - is `true`. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the private build information in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.PrivateBuild Example/CPP/source.cpp" id="Snippet1"::: + is `true`. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the private build information in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/PrivateBuild/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.PrivateBuild Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.PrivateBuild Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1513,30 +1492,29 @@ Gets the build number of the product this file is associated with. A value representing the build number of the product this file is associated with or if the file did not contain version information. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - This property gets the third set of 16 bits. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductBuildPart Example/CPP/source.cpp" id="Snippet1"::: + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + This property gets the third set of 16 bits. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/ProductBuildPart/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductBuildPart Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductBuildPart Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1591,30 +1569,29 @@ Gets the major part of the version number for the product this file is associated with. A value representing the major part of the product version number or if the file did not contain version information. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - This property gets the first set of 16 bits. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMajorPart Example/CPP/source.cpp" id="Snippet1"::: + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + This property gets the first set of 16 bits. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/ProductMajorPart/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMajorPart Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMajorPart Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1668,30 +1645,29 @@ Gets the minor part of the version number for the product the file is associated with. A value representing the minor part of the product version number or if the file did not contain version information. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - This property gets the second set of 16 bits. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMinorPart Example/CPP/source.cpp" id="Snippet1"::: + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + This property gets the second set of 16 bits. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/ProductMinorPart/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMinorPart Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductMinorPart Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1746,15 +1722,14 @@ Gets the name of the product this file is distributed with. The name of the product this file is distributed with or if the file did not contain version information. - to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductName Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/ProductName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1805,30 +1780,29 @@ Gets the private part number of the product this file is associated with. A value representing the private part number of the product this file is associated with or if the file did not contain version information. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - This property gets the last set of 16 bits. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductPrivatePart Example/CPP/source.cpp" id="Snippet1"::: + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + This property gets the last set of 16 bits. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/ProductPrivatePart/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductPrivatePart Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductPrivatePart Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1884,28 +1858,27 @@ Gets the version of the product this file is distributed with. The version of the product this file is distributed with or if the file did not contain version information. - number. - -- The next 16 bits are the number. - -- The third set of 16 bits are the number. - -- The last 16 bits are the number. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductVersion Example/CPP/source.cpp" id="Snippet1"::: + number. + +- The next 16 bits are the number. + +- The third set of 16 bits are the number. + +- The last 16 bits are the number. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/ProductVersion/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductVersion Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ProductVersion Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1961,20 +1934,19 @@ Gets the special build information for the file. The special build information for the file or if the file did not contain version information. - is `true`, must specify how this file differs from the standard version of the file. - - - -## Examples - The following example calls to get the for the Notepad. Then it prints the special build information in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.SpecialBuild Example/CPP/source.cpp" id="Snippet1"::: + is `true`, must specify how this file differs from the standard version of the file. + + + +## Examples + The following example calls to get the for the Notepad. Then it prints the special build information in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/SpecialBuild/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.SpecialBuild Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.SpecialBuild Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2019,23 +1991,22 @@ Returns a partial list of properties in the and their values. - A list of the following properties in this class and their values: - - , , , , , , , , , , , , - - . - + A list of the following properties in this class and their values: + + , , , , , , , , , , , , + + . + If the file did not contain version information, this list will contain only the name of the requested file. Boolean values will be , and all other entries will be . - to get the for the Notepad. Then it calls to print a list of the file version information in a text box. This code assumes `textBox1` has been instantiated. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileVersionInfo.ToString Example/CPP/source.cpp" id="Snippet1"::: + to get the for the Notepad. Then it calls to print a list of the file version information in a text box. This code assumes `textBox1` has been instantiated. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/FileVersionInfo/ToString/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ToString Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileVersionInfo.ToString Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Diagnostics/InstanceData.xml b/xml/System.Diagnostics/InstanceData.xml index e41c3c906af..208c658b11c 100644 --- a/xml/System.Diagnostics/InstanceData.xml +++ b/xml/System.Diagnostics/InstanceData.xml @@ -33,15 +33,14 @@ Holds instance data associated with a performance counter sample. - objects that exist in a particular on the local computer. It first displays a numbered list of categories. After the user enters the number of one of the categories, the sample displays, for each in the , the instance data associated with each instance of the . -## Examples - The following code example displays the contents of the objects that exist in a particular on the local computer. It first displays a numbered list of categories. After the user enters the number of one of the categories, the sample displays, for each in the , the instance data associated with each instance of the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/CPP/instdatacopyto.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/InstanceData/Overview/instdatacopyto.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/VB/instdatacopyto.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/VB/instdatacopyto.vb" id="Snippet1"::: + ]]> @@ -86,14 +85,14 @@ A taken from the instance specified by the parameter. Initializes a new instance of the InstanceData class, using the specified sample and performance counter instance. - and displays the values of some of its fields. - + and displays the values of some of its fields. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/InstanceData/Overview/instdatacopyto.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/VB/instdatacopyto.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/VB/instdatacopyto.vb" id="Snippet3"::: + ]]> @@ -136,14 +135,14 @@ Gets the instance name associated with this instance data. The name of an instance associated with the performance counter. - and displays the value of its property and other properties. - + and displays the value of its property and other properties. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/InstanceData/Overview/instdatacopyto.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/VB/instdatacopyto.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/VB/instdatacopyto.vb" id="Snippet3"::: + ]]> @@ -180,14 +179,14 @@ Gets the raw data value associated with the performance counter sample. The raw value read by the performance counter sample associated with the property. - and displays the value of its property and other properties. - + and displays the value of its property and other properties. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/InstanceData/Overview/instdatacopyto.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/VB/instdatacopyto.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/VB/instdatacopyto.vb" id="Snippet3"::: + ]]> @@ -230,14 +229,14 @@ Gets the performance counter sample that generated this data. A taken from the instance specified by the property. - and gets the value of its property, which is a reference to a . The example then displays the fields of the . - + and gets the value of its property, which is a reference to a . The example then displays the fields of the . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/InstanceData/Overview/instdatacopyto.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/VB/instdatacopyto.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.InstanceData.CopyTo/VB/instdatacopyto.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Diagnostics/OverflowAction.xml b/xml/System.Diagnostics/OverflowAction.xml index 583a46739b5..3b6a28b9b6f 100644 --- a/xml/System.Diagnostics/OverflowAction.xml +++ b/xml/System.Diagnostics/OverflowAction.xml @@ -31,16 +31,16 @@ Specifies how to handle entries in an event log that has reached its maximum file size. - method to set the overflow behavior for an . Check the current configured behavior of an through its property. + + Use the method to set the overflow behavior for an . Check the current configured behavior of an through its property. > [!WARNING] > The `OverwriteOlder` behavior is deprecated. Using this value might cause the Event Log to behave as if the `DoNotOverwrite` value was used instead, which will cause events to be discarded when the log is full. @@ -49,10 +49,9 @@ The following example enumerates the event logs defined on the local computer and displays configuration details for each event log. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/EventLogProperties/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/EventLog/GetEventLogs/source1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogProperties/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/EventLogProperties/VB/source.vb" id="Snippet2"::: + ]]> @@ -152,7 +151,7 @@ The following example enumerates the event logs defined on the local computer an This field is deprecated. - [!WARNING] > Do not use this value. Doing so might cause the Event Log to behave as if the `DoNotOverwrite` value was used instead. diff --git a/xml/System.Diagnostics/PerformanceCounter.xml b/xml/System.Diagnostics/PerformanceCounter.xml index d5b0e3c9cd0..c9281fb13f1 100644 --- a/xml/System.Diagnostics/PerformanceCounter.xml +++ b/xml/System.Diagnostics/PerformanceCounter.xml @@ -55,47 +55,46 @@ Represents a Windows NT performance counter component. - component can be used for both reading existing predefined or custom counters and publishing (writing) performance data to custom counters. - - There are numerous predefined counters listed in the Windows Performance Monitor's [Add Counters dialog box](/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc749266(v=ws.11)). To learn about the .NET Framework performance counters, see [Performance Counters](/dotnet/framework/debug-trace-profile/performance-counters). - - This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - + component can be used for both reading existing predefined or custom counters and publishing (writing) performance data to custom counters. + + There are numerous predefined counters listed in the Windows Performance Monitor's [Add Counters dialog box](/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc749266(v=ws.11)). To learn about the .NET Framework performance counters, see [Performance Counters](/dotnet/framework/debug-trace-profile/performance-counters). + + This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + > [!IMPORTANT] -> In versions 1.0 and 1.1 of .NET Framework, this class requires immediate callers to be fully trusted. Starting with .NET Framework version 2.0, this class requires for specific actions. It is strongly recommended that not be granted to semi-trusted code. The ability to read and write performance counters allows code to perform actions such as enumerating executing processes and obtaining information about them. -> -> In addition, passing a object to less-trusted code can create a security issue. Never pass performance counter objects, such as a or , to less trusted code. - - To read from a performance counter, create an instance of the class, set the , , and, optionally, the or properties, and then call the method to take a performance counter reading. - - To publish performance counter data, create one or more custom counters using the method, create an instance of the class, set the , and, optionally, or properties, and then call the , , or methods, or set the property to change the value of your custom counter. - +> In versions 1.0 and 1.1 of .NET Framework, this class requires immediate callers to be fully trusted. Starting with .NET Framework version 2.0, this class requires for specific actions. It is strongly recommended that not be granted to semi-trusted code. The ability to read and write performance counters allows code to perform actions such as enumerating executing processes and obtaining information about them. +> +> In addition, passing a object to less-trusted code can create a security issue. Never pass performance counter objects, such as a or , to less trusted code. + + To read from a performance counter, create an instance of the class, set the , , and, optionally, the or properties, and then call the method to take a performance counter reading. + + To publish performance counter data, create one or more custom counters using the method, create an instance of the class, set the , and, optionally, or properties, and then call the , , or methods, or set the property to change the value of your custom counter. + > [!NOTE] -> The , , and methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data. - - The counter is the mechanism by which performance data is collected. The registry stores the names of all the counters, each of which is related to a specific area of system functionality. Examples include a processor's busy time, memory usage, or the number of bytes received over a network connection. - - Each counter is uniquely identified through its name and its location. In the same way that a file path includes a drive, a directory, one or more subdirectories, and a file name, counter information consists of four elements: the computer, the category, the category instance, and the counter name. - - The counter information must include the category, or performance object, that the counter measures data for. A computer's categories include physical components, such as processors, disks, and memory. There are also system categories, such as processes and threads. Each category is related to a functional element within the computer and has a set of standard counters assigned to it. These objects are listed in the Performance object drop-down list of the Add Counters dialog box within the Windows 2000 System Monitor, and you must include them in the counter path. Performance data is grouped by the category to which is it related. - - In certain cases, several copies of the same category can exist. For example, several processes and threads run simultaneously, and some computers contain more than one processor. The category copies are called category instances, and each instance has a set of standard counters assigned to it. If a category can have more than one instance, an instance specification must be included in the counter information. - - To obtain performance data for counters that required an initial or previous value for performing the necessary calculation, call the method twice and use the information returned as your application requires. - +> The , , and methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data. + + The counter is the mechanism by which performance data is collected. The registry stores the names of all the counters, each of which is related to a specific area of system functionality. Examples include a processor's busy time, memory usage, or the number of bytes received over a network connection. + + Each counter is uniquely identified through its name and its location. In the same way that a file path includes a drive, a directory, one or more subdirectories, and a file name, counter information consists of four elements: the computer, the category, the category instance, and the counter name. + + The counter information must include the category, or performance object, that the counter measures data for. A computer's categories include physical components, such as processors, disks, and memory. There are also system categories, such as processes and threads. Each category is related to a functional element within the computer and has a set of standard counters assigned to it. These objects are listed in the Performance object drop-down list of the Add Counters dialog box within the Windows 2000 System Monitor, and you must include them in the counter path. Performance data is grouped by the category to which is it related. + + In certain cases, several copies of the same category can exist. For example, several processes and threads run simultaneously, and some computers contain more than one processor. The category copies are called category instances, and each instance has a set of standard counters assigned to it. If a category can have more than one instance, an instance specification must be included in the counter information. + + To obtain performance data for counters that required an initial or previous value for performing the necessary calculation, call the method twice and use the information returned as your application requires. + > [!NOTE] > Performance counter categories installed with the .NET Framework 2.0 use separate shared memory, with each performance counter category having its own memory. You can specify the size of separate shared memory by creating a DWORD named FileMappingSize in the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\\*\*\Performance. The FileMappingSize value is set to the shared memory size of the category. The default size is 131072 decimal. If the FileMappingSize value is not present, the `fileMappingSize` attribute value for the `performanceCounters` element specified in the Machine.config file is used, causing additional overhead for configuration file processing. You can realize a performance improvement for application startup by setting the file mapping size in the registry. For more information about the file mapping size, see [<performanceCounters>](/dotnet/framework/configure-apps/file-schema/trace-debug/performancecounters-element). + +## Examples + The following code example demonstrates the use of the class to create and use an counter type. The example creates categories, sets up counters, collects data from the counters, and calls the class to interpret the performance counter data. The intermediate and final results are displayed in the console window. For additional examples of other performance counter types, see the enumeration. -## Examples - The following code example demonstrates the use of the class to create and use an counter type. The example creates categories, sets up counters, collects data from the counters, and calls the class to interpret the performance counter data. The intermediate and final results are displayed in the console window. For additional examples of other performance counter types, see the enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> @@ -142,23 +141,22 @@ Initializes a new, read-only instance of the class, without associating the instance with any system or custom performance counter. - , , and properties to empty strings (""), and sets the property to the local computer, ("."). - - This constructor does not initialize the performance counter, so it does not associate the instance with an existing counter on the local computer. To point to a specific performance counter, set the , , and, optionally, the and properties before reading any other properties or attempting to read from a counter. To write to a performance counter, set the property to `false`. - + , , and properties to empty strings (""), and sets the property to the local computer, ("."). + + This constructor does not initialize the performance counter, so it does not associate the instance with an existing counter on the local computer. To point to a specific performance counter, set the , , and, optionally, the and properties before reading any other properties or attempting to read from a counter. To write to a performance counter, set the property to `false`. + > [!NOTE] > The attribute applied to this member has the following property value: | . The does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the class or [SQL Server Programming and Host Protection Attributes](/dotnet/framework/performance/sql-server-programming-and-host-protection-attributes). - -## Examples - The following code example creates a default instance of the class. After the instance is created, the , , and property values are set, and the results of a call to the method are displayed. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerfCounter/CPP/perfcounter.cpp" id="Snippet1"::: + +## Examples + The following code example creates a default instance of the class. After the instance is created, the , , and property values are set, and the results of a call to the method are displayed. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounter/.ctor/perfcounter.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter/VB/perfcounter.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter/VB/perfcounter.vb" id="Snippet1"::: + ]]> @@ -203,43 +201,43 @@ The name of the performance counter. Initializes a new, read-only instance of the class and associates it with the specified system or custom performance counter on the local computer. This constructor requires that the category have a single instance. - instance to a category that contains multiple instances, the constructor throws an exception. This overload can access any read-only or read/write counter, but does so in a read-only mode. A instance created using this overload cannot write to the counter, even if the counter itself is read/write. - - This overload of the constructor sets the and properties to the values you pass in, sets the property to the local computer, ".", and sets the property to an empty string (""). - - This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the local computer. The values that you pass in for the and properties must point to an existing performance counter on the local computer. - + instance to a category that contains multiple instances, the constructor throws an exception. This overload can access any read-only or read/write counter, but does so in a read-only mode. A instance created using this overload cannot write to the counter, even if the counter itself is read/write. + + This overload of the constructor sets the and properties to the values you pass in, sets the property to the local computer, ".", and sets the property to an empty string (""). + + This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the local computer. The values that you pass in for the and properties must point to an existing performance counter on the local computer. + > [!NOTE] -> To read performance counters from a non-interactive logon session in Windows Vista and later, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. -> -> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. -> -> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - +> To read performance counters from a non-interactive logon session in Windows Vista and later, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. +> +> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. +> +> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. + ]]> - is an empty string (""). - - -or- - - is an empty string (""). - - -or- - - The category specified does not exist. - - -or- - - The category specified is marked as multi-instance and requires the performance counter to be created with an instance name. - - -or- - + is an empty string (""). + + -or- + + is an empty string (""). + + -or- + + The category specified does not exist. + + -or- + + The category specified is marked as multi-instance and requires the performance counter to be created with an instance name. + + -or- + and have been localized into different languages. or is . @@ -290,56 +288,55 @@ to access the counter in read-only mode (although the counter itself could be read/write); to access the counter in read/write mode. Initializes a new, read-only or read/write instance of the class and associates it with the specified system or custom performance counter on the local computer. This constructor requires that the category contain a single instance. - instance to a category that contains multiple instances, the constructor throws an exception. - - This overload of the constructor sets the , , and properties to the values you pass in, sets the property to the local computer, ".", and sets the property to an empty string (""). - - This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the local computer. The values that you pass in for the and properties must point to an existing performance counter on the local computer. If the performance counter instance that you point to is not valid, calling the constructor throws an exception. - + instance to a category that contains multiple instances, the constructor throws an exception. + + This overload of the constructor sets the , , and properties to the values you pass in, sets the property to the local computer, ".", and sets the property to an empty string (""). + + This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the local computer. The values that you pass in for the and properties must point to an existing performance counter on the local computer. If the performance counter instance that you point to is not valid, calling the constructor throws an exception. + > [!NOTE] -> You can use this overload to connect to a system counter, but you cannot write to a system counter. Therefore, setting `readOnly` to `false` when connecting to a system counter causes the constructor to throw an exception. - +> You can use this overload to connect to a system counter, but you cannot write to a system counter. Therefore, setting `readOnly` to `false` when connecting to a system counter causes the constructor to throw an exception. + > [!NOTE] -> To read performance counters from a non-interactive logon session in Windows Vista and later, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. -> -> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. -> +> To read performance counters from a non-interactive logon session in Windows Vista and later, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. +> +> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. +> > In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - -## Examples - The following code example creates an instance of the class. The example passes in category names, counter names, and a flag value indicating that the counter is not read-only. This code example is part of a larger example for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet2"::: + +## Examples + The following code example creates an instance of the class. The example passes in category names, counter names, and a flag value indicating that the counter is not read-only. This code example is part of a larger example for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet2"::: + ]]> - The is an empty string (""). - - -or- - - The is an empty string (""). - - -or- - - The category specified does not exist. (if is ). - - -or- - - The category specified is not a .NET Framework custom category (if is ). - - -or- - - The category specified is marked as multi-instance and requires the performance counter to be created with an instance name. - - -or- - + The is an empty string (""). + + -or- + + The is an empty string (""). + + -or- + + The category specified does not exist. (if is ). + + -or- + + The category specified is not a .NET Framework custom category (if is ). + + -or- + + The category specified is marked as multi-instance and requires the performance counter to be created with an instance name. + + -or- + and have been localized into different languages. or is . @@ -389,49 +386,49 @@ The name of the performance counter category instance, or an empty string (""), if the category contains a single instance. Initializes a new, read-only instance of the class and associates it with the specified system or custom performance counter and category instance on the local computer. - , , and properties to the values you pass in, and sets the property to the local computer, ".". - - This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the local computer. The values that you pass in for the , , and properties must point to an existing performance counter on the local computer. If the performance counter instance you point to is not valid, calling the constructor throws an exception. - - This overload can access any read-only or read/write counter, but does so in a read-only mode. A instance created using this overload cannot write to the counter, even if the counter itself is read/write. - - To create a performance category instance, specify an `instanceName` on the constructor. If the category instance specified by `instanceName` already exists the new object will reference the existing category instance. - + , , and properties to the values you pass in, and sets the property to the local computer, ".". + + This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the local computer. The values that you pass in for the , , and properties must point to an existing performance counter on the local computer. If the performance counter instance you point to is not valid, calling the constructor throws an exception. + + This overload can access any read-only or read/write counter, but does so in a read-only mode. A instance created using this overload cannot write to the counter, even if the counter itself is read/write. + + To create a performance category instance, specify an `instanceName` on the constructor. If the category instance specified by `instanceName` already exists the new object will reference the existing category instance. + > [!NOTE] -> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. -> -> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. -> -> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - +> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. +> +> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. +> +> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. + ]]> - is an empty string (""). - - -or- - - is an empty string (""). - - -or- - - The category specified is not valid. - - -or- - - The category specified is marked as multi-instance and requires the performance counter to be created with an instance name. - - -or- - - is longer than 127 characters. - - -or- - + is an empty string (""). + + -or- + + is an empty string (""). + + -or- + + The category specified is not valid. + + -or- + + The category specified is marked as multi-instance and requires the performance counter to be created with an instance name. + + -or- + + is longer than 127 characters. + + -or- + and have been localized into different languages. or is . @@ -478,60 +475,60 @@ to access a counter in read-only mode; to access a counter in read/write mode. Initializes a new, read-only or read/write instance of the class and associates it with the specified system or custom performance counter and category instance on the local computer. - , , and properties to the values you pass in, it and sets the property to the local computer, ".". - - This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the local computer. The values that you pass in for the , , and properties must point to an existing performance counter on the local computer. If the performance counter instance that you point to is not valid, calling the constructor throws an exception. - + , , and properties to the values you pass in, it and sets the property to the local computer, ".". + + This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the local computer. The values that you pass in for the , , and properties must point to an existing performance counter on the local computer. If the performance counter instance that you point to is not valid, calling the constructor throws an exception. + > [!NOTE] -> You can use this overload to connect to a system counter, but you cannot write to a system counter. Therefore, setting `readOnly` to `false` when connecting to a system counter causes the constructor to throw an exception. - - To create a performance category instance, specify an `instanceName` on the constructor. If the category instance specified by `instanceName` already exists the new object will reference the existing category instance. - +> You can use this overload to connect to a system counter, but you cannot write to a system counter. Therefore, setting `readOnly` to `false` when connecting to a system counter causes the constructor to throw an exception. + + To create a performance category instance, specify an `instanceName` on the constructor. If the category instance specified by `instanceName` already exists the new object will reference the existing category instance. + > [!NOTE] -> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. -> -> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. -> -> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - +> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. +> +> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. +> +> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. + ]]> - is an empty string (""). - - -or- - - is an empty string (""). - - -or- - - The read/write permission setting requested is invalid for this counter. - - -or- - - The category specified does not exist (if is ). - - -or- - - The category specified is not a .NET Framework custom category (if is ). - - -or- - - The category specified is marked as multi-instance and requires the performance counter to be created with an instance name. - - -or- - - is longer than 127 characters. - - -or- - + is an empty string (""). + + -or- + + is an empty string (""). + + -or- + + The read/write permission setting requested is invalid for this counter. + + -or- + + The category specified does not exist (if is ). + + -or- + + The category specified is not a .NET Framework custom category (if is ). + + -or- + + The category specified is marked as multi-instance and requires the performance counter to be created with an instance name. + + -or- + + is longer than 127 characters. + + -or- + and have been localized into different languages. or is . @@ -577,57 +574,57 @@ The computer on which the performance counter and its associated category exist. Initializes a new, read-only instance of the class and associates it with the specified system or custom performance counter and category instance, on the specified computer. - , , , and properties to the values you pass in. - - This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the specified computer. The values that you pass in for the , , and properties must point to an existing performance counter. If the performance counter instance you point to is not valid, calling the constructor throws an exception. This overload can access any read-only or read/write counter, but does so in a read-only mode. A instance created using this overload cannot write to the counter, even if the counter itself is read/write. - + , , , and properties to the values you pass in. + + This constructor initializes the performance counter and associates the instance with an existing counter (either a system or a custom counter) on the specified computer. The values that you pass in for the , , and properties must point to an existing performance counter. If the performance counter instance you point to is not valid, calling the constructor throws an exception. This overload can access any read-only or read/write counter, but does so in a read-only mode. A instance created using this overload cannot write to the counter, even if the counter itself is read/write. + > [!NOTE] -> You cannot write to remote performance counters. There is no overload that allows you to specify a read/write instance of the class that connects to a remote computer. - - To create a performance category instance, specify an `instanceName` on the constructor. If the category instance specified by `instanceName` already exists the new object will reference the existing category instance. - +> You cannot write to remote performance counters. There is no overload that allows you to specify a read/write instance of the class that connects to a remote computer. + + To create a performance category instance, specify an `instanceName` on the constructor. If the category instance specified by `instanceName` already exists the new object will reference the existing category instance. + > [!NOTE] -> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. -> -> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. -> -> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - +> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. +> +> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. +> +> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. + > [!NOTE] -> In Windows Vista, when the remote computer is a member of a workgroup, you may need to disable UAC so that the local user account is not filtered and can be elevated to an administrator account. For security reasons, disabling UAC should be a last resort. For information on disabling UAC, see [User Account Control and WMI](/windows/win32/wmisdk/user-account-control-and-wmi). - +> In Windows Vista, when the remote computer is a member of a workgroup, you may need to disable UAC so that the local user account is not filtered and can be elevated to an administrator account. For security reasons, disabling UAC should be a last resort. For information on disabling UAC, see [User Account Control and WMI](/windows/win32/wmisdk/user-account-control-and-wmi). + ]]> - is an empty string (""). - - -or- - - is an empty string (""). - - -or- - - The read/write permission setting requested is invalid for this counter. - - -or- - - The counter does not exist on the specified computer. - - -or- - - The category specified is marked as multi-instance and requires the performance counter to be created with an instance name. - - -or- - - is longer than 127 characters. - - -or- - + is an empty string (""). + + -or- + + is an empty string (""). + + -or- + + The read/write permission setting requested is invalid for this counter. + + -or- + + The counter does not exist on the specified computer. + + -or- + + The category specified is marked as multi-instance and requires the performance counter to be created with an instance name. + + -or- + + is longer than 127 characters. + + -or- + and have been localized into different languages. The parameter is not valid. @@ -677,11 +674,11 @@ Begins the initialization of a instance used on a form or by another component. The initialization occurs at runtime. - method ends the initialization. Using the and methods prevents the component from being used before it is fully initialized. - + method ends the initialization. Using the and methods prevents the component from being used before it is fully initialized. + ]]> @@ -752,24 +749,23 @@ Gets or sets the name of the performance counter category for this performance counter. The name of the performance counter category (performance object) with which this performance counter is associated. - is displayed in the `Performance Object` field of Performance Counter Manager MMC snap in's `Add Counter` dialog box. - - A performance counter monitors the behavior of a category, or performance object, on a computer. Categories include physical components (such as processors, disks, and memory) and system objects (such as processes and threads). System counters that are related to the same performance object are grouped into a category that indicates their common focus. When you create an instance of the class, you first indicate the category with which the component will interact, and then you choose a counter from that category. - - For example, one Windows counter category is the Memory category. System counters within this category track memory data such as the number of bytes available and the number of bytes cached. If you wanted to work with the bytes cached in your application, you would create an instance of the component, connect it to the Memory category, and then pick the appropriate counter (in this case, Cached Bytes) from that category. - + is displayed in the `Performance Object` field of Performance Counter Manager MMC snap in's `Add Counter` dialog box. + + A performance counter monitors the behavior of a category, or performance object, on a computer. Categories include physical components (such as processors, disks, and memory) and system objects (such as processes and threads). System counters that are related to the same performance object are grouped into a category that indicates their common focus. When you create an instance of the class, you first indicate the category with which the component will interact, and then you choose a counter from that category. + + For example, one Windows counter category is the Memory category. System counters within this category track memory data such as the number of bytes available and the number of bytes cached. If you wanted to work with the bytes cached in your application, you would create an instance of the component, connect it to the Memory category, and then pick the appropriate counter (in this case, Cached Bytes) from that category. + Although your system makes many more counter categories available, the categories that you will probably interact with most frequently are the Cache, Memory, Objects, PhysicalDisk, Process, Processor, Server, System, and Thread categories. - -## Examples - The following code example creates a default instance of the class. After the instance is created, the , , and property values are set, and the results of a call to the method are displayed. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerfCounter/CPP/perfcounter.cpp" id="Snippet1"::: + +## Examples + The following code example creates a default instance of the class. After the instance is created, the , , and property values are set, and the results of a call to the method are displayed. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounter/.ctor/perfcounter.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter/VB/perfcounter.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter/VB/perfcounter.vb" id="Snippet1"::: + ]]> The is . @@ -808,11 +804,11 @@ Closes the performance counter and frees all the resources allocated by this performance counter instance. - instance with a performance counter that resides on the server, the system initializes the instance and allocates memory to contain counter sample information. The method frees the resources allocated by the object. - + instance with a performance counter that resides on the server, the system initializes the instance and allocates memory to contain counter sample information. The method frees the resources allocated by the object. + ]]> @@ -897,29 +893,29 @@ Gets the description for this performance counter. A description of the item or quantity that this performance counter measures. - text when a user selects a counter from the counters list and clicks the Explain button. - - When you create a new counter, use the text to describe what the counter monitors do so the user can determine whether to add the counter to the System Monitor's display. - + text when a user selects a counter from the counters list and clicks the Explain button. + + When you create a new counter, use the text to describe what the counter monitors do so the user can determine whether to add the counter to the System Monitor's display. + > [!NOTE] -> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. - +> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. + > [!NOTE] -> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. -> -> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. -> -> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - +> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. +> +> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. +> +> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. + ]]> - The instance is not associated with a performance counter. - - -or- - + The instance is not associated with a performance counter. + + -or- + The property is set to when using global shared memory. Code that is executing without administrative privileges attempted to read a performance counter. @@ -990,20 +986,19 @@ Gets or sets the name of the performance counter that is associated with this instance. The name of the counter, which generally describes the quantity being counted. This name is displayed in the list of counters of the Performance Counter Manager MMC snap in's Add Counters dialog box. - property to a typical counter name. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerfCounter/CPP/perfcounter.cpp" id="Snippet1"::: + property to a typical counter name. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounter/.ctor/perfcounter.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter/VB/perfcounter.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter/VB/perfcounter.vb" id="Snippet1"::: + ]]> The is . @@ -1051,37 +1046,37 @@ Gets the counter type of the associated performance counter. A that describes both how the counter interacts with a monitoring application and the nature of the values it contains (for example, calculated or uncalculated). - enumeration contains the types of performance counters that you can interact with. Some of the counter types represent calculated values, such as the average of the counter measurements the system has taken. Other types represent raw, or uncalculated, values. The following table shows the counter types that you will interact with most frequently. - -|Counter's Responsibility|PerformanceCounterType Value|Example| -|------------------------------|----------------------------------|-------------| -|Maintain a simple count of items or operations.|`NumberOfItems32`|Tracking the number of orders received as a 32-bit integer.| -|Maintain a higher-capacity simple count.|`NumberOfItems64`|Tracking the number of orders for a site with very high volume, stored as a 64-bit integer.| -|Track the number of items or operations per second.|`RateOfCountsPerSecond32`|Tracking orders received per second on a site.| -|Track a higher-capacity number of items or operations per second.|`RateOfCountsPerSecond64`|Tracking orders received per second on a site with very high volume.| -|Calculate the average time to perform a process or to process an item|`AverageTimer32`|Calculate the average time an order takes to be processed.| - - When you create a counter whose type requires the use of a corresponding base counter, you must declare the counter and the base in the you pass into the method. - + enumeration contains the types of performance counters that you can interact with. Some of the counter types represent calculated values, such as the average of the counter measurements the system has taken. Other types represent raw, or uncalculated, values. The following table shows the counter types that you will interact with most frequently. + +|Counter's Responsibility|PerformanceCounterType Value|Example| +|------------------------------|----------------------------------|-------------| +|Maintain a simple count of items or operations.|`NumberOfItems32`|Tracking the number of orders received as a 32-bit integer.| +|Maintain a higher-capacity simple count.|`NumberOfItems64`|Tracking the number of orders for a site with very high volume, stored as a 64-bit integer.| +|Track the number of items or operations per second.|`RateOfCountsPerSecond32`|Tracking orders received per second on a site.| +|Track a higher-capacity number of items or operations per second.|`RateOfCountsPerSecond64`|Tracking orders received per second on a site with very high volume.| +|Calculate the average time to perform a process or to process an item|`AverageTimer32`|Calculate the average time an order takes to be processed.| + + When you create a counter whose type requires the use of a corresponding base counter, you must declare the counter and the base in the you pass into the method. + > [!NOTE] -> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. - +> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. + > [!NOTE] -> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. -> -> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. -> -> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - +> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. +> +> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. +> +> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. + ]]> - The instance is not correctly associated with a performance counter. - - -or- - + The instance is not correctly associated with a performance counter. + + -or- + The property is set to when using global shared memory. Code that is executing without administrative privileges attempted to read a performance counter. @@ -1120,27 +1115,27 @@ Decrements the associated performance counter by one through an efficient atomic operation. The decremented counter value. - [!NOTE] -> The , , and methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data. - +> The , , and methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data. + > [!NOTE] -> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. - +> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. + ]]> - The counter is read-only, so the application cannot decrement it. - - -or- - - The instance is not correctly associated with a performance counter. - - -or- - + The counter is read-only, so the application cannot decrement it. + + -or- + + The instance is not correctly associated with a performance counter. + + -or- + The property is set to when using global shared memory. An error occurred when accessing a system API. This method is thread safe. @@ -1271,11 +1266,11 @@ Ends the initialization of a instance that is used on a form or by another component. The initialization occurs at runtime. - method starts the initialization. Using the and methods prevents the component from being used before it is fully initialized. - + method starts the initialization. Using the and methods prevents the component from being used before it is fully initialized. + ]]> @@ -1313,27 +1308,27 @@ Increments the associated performance counter by one through an efficient atomic operation. The incremented counter value. - [!NOTE] -> The , , and methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data. - +> The , , and methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data. + > [!NOTE] -> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. - +> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. + ]]> - The counter is read-only, so the application cannot increment it. - - -or- - - The instance is not correctly associated with a performance counter. - - -or- - + The counter is read-only, so the application cannot increment it. + + -or- + + The instance is not correctly associated with a performance counter. + + -or- + The property is set to when using global shared memory. An error occurred when accessing a system API. This method is thread safe. @@ -1381,36 +1376,35 @@ Increments or decrements the value of the associated performance counter by a specified amount through an efficient atomic operation. The new counter value. - [!NOTE] -> The , , and methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data. - +> The , , and methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data. + > [!NOTE] -> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. - - - -## Examples - The following code example demonstrates how to use the method to add increments to a counter. This code example is part of a larger example for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet3"::: +> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. + + + +## Examples + The following code example demonstrates how to use the method to add increments to a counter. This code example is part of a larger example for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet3"::: + ]]> - The counter is read-only, so the application cannot increment it. - - -or- - - The instance is not correctly associated with a performance counter. - - -or- - + The counter is read-only, so the application cannot increment it. + + -or- + + The instance is not correctly associated with a performance counter. + + -or- + The property is set to when using global shared memory. An error occurred when accessing a system API. This method is thread safe. @@ -1457,14 +1451,14 @@ Gets or sets the lifetime of a process. One of the values. The default is . - must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. - + must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. + > [!NOTE] -> If the value of the property is , the value for the performance counter must be . - +> If the value of the property is , the value for the performance counter must be . + ]]> The value set is not a member of the enumeration. @@ -1538,45 +1532,44 @@ Gets or sets an instance name for this performance counter. The name of the performance counter category instance, or an empty string (""), if the counter is a single-instance counter. - [!NOTE] -> Instance names must be shorter than 128 characters in length. - - In some situations, categories are subdivided into instances, which track data about multiple occurrences of the object that a category relates to. Instances apply to the category as whole, rather than to individual counters. Every counter within a category has each instance defined for the category. For example, the Process category contains instances named Idle and System. Every counter within the Process category thus contains data for each instance, showing information about either idle processes or system processes. - - Many categories do not contain multiple instances, so you can leave this property empty to indicate that no instance is associated with the category. - - If this instance points to a noncustom category, you can choose from only the existing category instances. You can create new category instances only in custom categories, which allow you to define as many counters and category instances as you need. - - To create a performance category instance, specify an `instanceName` on the constructor. If the category instance specified by `instanceName` already exists the new object will reference the existing category instance. - +> Instance names must be shorter than 128 characters in length. + + In some situations, categories are subdivided into instances, which track data about multiple occurrences of the object that a category relates to. Instances apply to the category as whole, rather than to individual counters. Every counter within a category has each instance defined for the category. For example, the Process category contains instances named Idle and System. Every counter within the Process category thus contains data for each instance, showing information about either idle processes or system processes. + + Many categories do not contain multiple instances, so you can leave this property empty to indicate that no instance is associated with the category. + + If this instance points to a noncustom category, you can choose from only the existing category instances. You can create new category instances only in custom categories, which allow you to define as many counters and category instances as you need. + + To create a performance category instance, specify an `instanceName` on the constructor. If the category instance specified by `instanceName` already exists the new object will reference the existing category instance. + > [!NOTE] -> Do not use the characters "(", ")", "#", "\\", or "/" in the instance name. If any of these characters are used, the Performance Console (see [Runtime Profiling](/dotnet/framework/debug-trace-profile/runtime-profiling)) may not correctly display the instance values. - - If the instance name is automatically generated and might contain the characters "(", ")", "#", "\\", or "/", use the character mapping in the following table. - -|Character|Mapped character| -|---------------|----------------------| -|(|[| -|)|]| -|#|_| -|\\|_| -|/|_| - - The property of the object obtained from the property is a common source of instance names that can contain invalid characters. - - - -## Examples - The following code example creates a default instance of the class. After the instance is created, the , , and property values are set, and the results of a call to the method are displayed. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerfCounter/CPP/perfcounter.cpp" id="Snippet1"::: +> Do not use the characters "(", ")", "#", "\\", or "/" in the instance name. If any of these characters are used, the Performance Console (see [Runtime Profiling](/dotnet/framework/debug-trace-profile/runtime-profiling)) may not correctly display the instance values. + + If the instance name is automatically generated and might contain the characters "(", ")", "#", "\\", or "/", use the character mapping in the following table. + +|Character|Mapped character| +|---------------|----------------------| +|(|[| +|)|]| +|#|_| +|\\|_| +|/|_| + + The property of the object obtained from the property is a common source of instance names that can contain invalid characters. + + + +## Examples + The following code example creates a default instance of the class. After the instance is created, the , , and property values are set, and the results of a call to the method are displayed. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounter/.ctor/perfcounter.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter/VB/perfcounter.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter/VB/perfcounter.vb" id="Snippet1"::: + ]]> @@ -1635,13 +1628,13 @@ Gets or sets the computer name for this performance counter. The server on which the performance counter and its associated category reside. - property to point to a remote computer, the instance attempts to open the counter on that computer. If the counter does not exist, setting this property throws an exception. - + property to point to a remote computer, the instance attempts to open the counter on that computer. If the counter does not exist, setting this property throws an exception. + ]]> The format is invalid. @@ -1680,36 +1673,35 @@ Obtains a counter sample, and returns the raw, or uncalculated, value for it. A that represents the next raw value that the system obtains for this counter. - [!NOTE] -> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. - +> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. + > [!NOTE] -> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. -> -> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. -> -> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - - - -## Examples - The following code example demonstrates how to use the method to obtain the next uncalculated value of a counter. This code example is part of a larger example for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet3"::: +> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. +> +> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. +> +> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. + + + +## Examples + The following code example demonstrates how to use the method to obtain the next uncalculated value of a counter. This code example is part of a larger example for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet3"::: + ]]> - The instance is not correctly associated with a performance counter. - - -or- - + The instance is not correctly associated with a performance counter. + + -or- + The property is set to when using global shared memory. An error occurred when accessing a system API. Code that is executing without administrative privileges attempted to read a performance counter. @@ -1748,25 +1740,24 @@ Obtains a counter sample and returns the calculated value for it. The next calculated value that the system obtains for this counter. - [!NOTE] -> If the calculated value of a counter depends on two counter reads, the first read operation returns 0.0. Resetting the performance counter properties to specify a different counter is equivalent to creating a new performance counter, and the first read operation using the new properties returns 0.0. The recommended delay time between calls to the method is one second, to allow the counter to perform the next incremental read. - +> If the calculated value of a counter depends on two counter reads, the first read operation returns 0.0. Resetting the performance counter properties to specify a different counter is equivalent to creating a new performance counter, and the first read operation using the new properties returns 0.0. The recommended delay time between calls to the method is one second, to allow the counter to perform the next incremental read. + > [!NOTE] -> To read performance counters, you must have administrative privileges. In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - - - -## Examples - The following code example creates an counter and uses the method to display the counter's values over a time period. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/CPP/elapsedtime.cpp" id="Snippet2"::: +> To read performance counters, you must have administrative privileges. In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. + + + +## Examples + The following code example creates an counter and uses the method to display the counter's values over a time period. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounter/NextValue/elapsedtime.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/VB/elapsedtime.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/VB/elapsedtime.vb" id="Snippet2"::: + ]]> The instance is not correctly associated with a performance counter. @@ -1820,47 +1811,46 @@ Gets or sets the raw, or uncalculated, value of this counter. The raw value of the counter. - property rather than a calculated value can produce significantly better performance in scenarios where the raw value is sufficient. - - If the counter that you are reading is read-only, getting the property samples the counter at the time that the property is called. This action is equivalent to making an initial call to the method. If you subsequently call , you can perform calculations on the values that both calls returned. - - Because system counters are read-only, you can get but not set their raw values. - + property rather than a calculated value can produce significantly better performance in scenarios where the raw value is sufficient. + + If the counter that you are reading is read-only, getting the property samples the counter at the time that the property is called. This action is equivalent to making an initial call to the method. If you subsequently call , you can perform calculations on the values that both calls returned. + + Because system counters are read-only, you can get but not set their raw values. + > [!NOTE] -> The , , and methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data. - +> The , , and methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data. + > [!NOTE] -> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. - +> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. + > [!NOTE] -> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. -> -> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. -> -> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. - - - -## Examples - The following example uses the class to display the value of the property for a counter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/CPP/averagecount32.cpp" id="Snippet1"::: +> To read performance counters in Windows Vista, Windows XP Professional x64 Edition, or Windows Server 2003, you must either be a member of the Performance Monitor Users group or have administrative privileges. +> +> To avoid having to elevate your privileges to access performance counters in Windows Vista, add yourself to the Performance Monitor Users group. +> +> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator. + + + +## Examples + The following example uses the class to display the value of the property for a counter. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/CounterCreationData/Overview/averagecount32.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.AverageCounter64/VB/averagecount32.vb" id="Snippet1"::: + ]]> - You are trying to set the counter's raw value, but the counter is read-only. - - -or- - - The instance is not correctly associated with a performance counter. - - -or- - + You are trying to set the counter's raw value, but the counter is read-only. + + -or- + + The instance is not correctly associated with a performance counter. + + -or- + The property is set to when using global shared memory. An error occurred when accessing a system API. Code that is executing without administrative privileges attempted to read a performance counter. @@ -1917,11 +1907,11 @@ , if the instance is in read-only mode (even if the counter itself is a custom .NET Framework counter); if it is in read/write mode. The default is the value set by the constructor. - should always `true`. You cannot write to a system counter. - + should always `true`. You cannot write to a system counter. + ]]> @@ -1964,29 +1954,29 @@ Deletes the category instance specified by the object property. - [!NOTE] -> To avoid a possible race condition when the performance counter shared memory is released, it is recommended that the method be called from the event handler. - - To create a performance category instance, specify an `instanceName` on the constructor. If the category instance specified by `instanceName` already exists the new object will reference the existing category instance. - +> To avoid a possible race condition when the performance counter shared memory is released, it is recommended that the method be called from the event handler. + + To create a performance category instance, specify an `instanceName` on the constructor. If the category instance specified by `instanceName` already exists the new object will reference the existing category instance. + > [!NOTE] -> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. - +> If the value for the property is and the performance counter category was created with .NET Framework version 1.0 or 1.1, an is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for must be . If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category. + ]]> - This counter is read-only, so any instance that is associated with the category cannot be removed. - - -or- - - The instance is not correctly associated with a performance counter. - - -or- - + This counter is read-only, so any instance that is associated with the category cannot be removed. + + -or- + + The instance is not correctly associated with a performance counter. + + -or- + The property is set to when using global shared memory. An error occurred when accessing a system API. diff --git a/xml/System.Diagnostics/PerformanceCounterCategory.xml b/xml/System.Diagnostics/PerformanceCounterCategory.xml index 9b94c305b65..82b4148b479 100644 --- a/xml/System.Diagnostics/PerformanceCounterCategory.xml +++ b/xml/System.Diagnostics/PerformanceCounterCategory.xml @@ -706,7 +706,6 @@ ## Examples The following code example determines whether a object named "orders" exists. If not, it creates the object by using a object that contains two performance counters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerfCounter_ccd/CPP/ccd.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounterCategory/Create/ccd.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter_ccd/VB/ccd.vb" id="Snippet1"::: @@ -1154,7 +1153,6 @@ ## Examples The following code example determines whether a object named "orders" exists. If not, it creates the object by using a object that contains two performance counters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerfCounter_ccd/CPP/ccd.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounterCategory/Create/ccd.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter_ccd/VB/ccd.vb" id="Snippet1"::: @@ -1224,7 +1222,6 @@ ## Examples The following example determines whether a object named `Orders` exists. If it does not exist, the example creates the object by using a object that contains two performance counters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerfCounter_ccd/CPP/ccd.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounterCategory/Create/ccd.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerfCounter_ccd/VB/ccd.vb" id="Snippet1"::: @@ -1311,7 +1308,6 @@ ## Examples The following code example uses the method to return an array of objects from the local computer or a specified computer. It converts the array into an array of category names, which it sorts and displays for the user. The overload is selected based on whether a computer name was specified. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountergetcat.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounterCategory/GetCategories/perfcountergetcat.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/VB/perfcountercatgetcat.vb" id="Snippet2"::: @@ -1375,7 +1371,6 @@ ## Examples The following code example uses the method to return an array of objects from the local computer or a specified computer. It converts the array into an array of category names, which it sorts and displays for the user. The overload is selected based on whether a computer name was specified. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountergetcat.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounterCategory/GetCategories/perfcountergetcat.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/VB/perfcountercatgetcat.vb" id="Snippet2"::: @@ -1448,7 +1443,6 @@ This overload fails unless it is used with a single-instance category. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetcount.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounterCategory/GetCategories/perfcountercatgetcount.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/VB/perfcountercatgetcount.vb" id="Snippet4"::: @@ -1518,7 +1512,6 @@ This overload fails unless it is used with a category that contains instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetcount.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounterCategory/GetCategories/perfcountercatgetcount.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/VB/perfcountercatgetcount.vb" id="Snippet4"::: @@ -1584,7 +1577,6 @@ ## Examples The following code example gets a list of the objects in a . It first creates a object, using the appropriate constructor based on whether a computer name was specified. It then uses to return the instance names as an array of , which it sorts and displays. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/cpp/perfcountercatgetinst.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounterCategory/GetCategories/perfcountercatgetinst.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.PerformanceCounterCategory.GetMembers/VB/perfcountercatgetinst.vb" id="Snippet6"::: diff --git a/xml/System.Diagnostics/PerformanceCounterInstaller.xml b/xml/System.Diagnostics/PerformanceCounterInstaller.xml index f211e55020d..5a9bbea170b 100644 --- a/xml/System.Diagnostics/PerformanceCounterInstaller.xml +++ b/xml/System.Diagnostics/PerformanceCounterInstaller.xml @@ -18,20 +18,19 @@ Specifies an installer for the component. - *\Performance. The FileMappingSize value is set to the shared memory size of the category. The default size is 131072 decimal. If the FileMappingSize value is not present, the `fileMappingSize` attribute value for the `performanceCounters` element specified in the Machine.config file is used, causing additional overhead for configuration file processing. You can realize a performance improvement for application startup by setting the file mapping size in the registry. + + + +## Examples + The following code example demonstrates how to create a object and add it to an . -## Remarks - The following information might help provide a performance improvement when installing performance counters at application startup. Performance counter categories installed with .NET Framework version 2.0 use separate shared memories, with each performance counter category having its own memory. You can specify the size of separate shared memory by creating a DWORD named FileMappingSize in the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\\*\*\Performance. The FileMappingSize value is set to the shared memory size of the category. The default size is 131072 decimal. If the FileMappingSize value is not present, the `fileMappingSize` attribute value for the `performanceCounters` element specified in the Machine.config file is used, causing additional overhead for configuration file processing. You can realize a performance improvement for application startup by setting the file mapping size in the registry. - - - -## Examples - The following code example demonstrates how to create a object and add it to an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterInstaller/CPP/performancecounterinstaller.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounterInstaller/Overview/performancecounterinstaller.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterInstaller/VB/performancecounterinstaller.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterInstaller/VB/performancecounterinstaller.vb" id="Snippet1"::: + ]]> @@ -162,11 +161,11 @@ Gets or sets the performance counter category type. One of the values. - property specifies whether the performance counter category can have multiple instances. - + property specifies whether the performance counter category can have multiple instances. + ]]> The value is not a . @@ -196,21 +195,21 @@ The component to copy from. Copies all the properties from the specified component that are required at install time for a performance counter. - can only install multiple counters in the same category. - + can only install multiple counters in the same category. + ]]> - The specified component is not a . - - -or- - - The specified is incomplete. - - -or- - + The specified component is not a . + + -or- + + The specified is incomplete. + + -or- + Multiple counters in different categories are trying to be installed. @@ -271,13 +270,13 @@ An that is used to save the information needed to perform a commit, rollback, or uninstall operation. Performs the installation. - [!NOTE] -> When installing both a service and a performance counter with the same name, install the service before installing the performance counter. - +> When installing both a service and a performance counter with the same name, install the service before installing the performance counter. + ]]> diff --git a/xml/System.Diagnostics/Process.xml b/xml/System.Diagnostics/Process.xml index b1cd1f97feb..248185ee78e 100644 --- a/xml/System.Diagnostics/Process.xml +++ b/xml/System.Diagnostics/Process.xml @@ -130,14 +130,12 @@ ## Examples The following example uses an instance of the class to start a process. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process.Start_instance/CPP/processstart.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/Overview/processstart.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/Overview/processstart.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process.Start_instance/VB/processstart.vb" id="Snippet1"::: The following example uses the class itself and a static method to start a process. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/Overview/processstartstatic.cs"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/Overview/processstartstatic.fs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process.Start_static/VB/processstartstatic.vb"::: @@ -285,7 +283,6 @@ ## Examples The following example starts an instance of Notepad. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays the process's exit code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -378,7 +375,6 @@ ## Examples The following example uses the `net view` command to list the available network resources on a remote computer. The user supplies the target computer name as a command-line argument. The user can also supply a file name for error output. The example collects the output of the net command, waits for the process to finish, and then writes the output results to the console. If the user supplies the optional error file, the example writes errors to the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/net_async.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/net_async.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/net_async.vb" id="Snippet2"::: @@ -479,7 +475,6 @@ The example creates an event delegate for the `SortOutputHandler` event handler and associates it with the event. The event handler receives text lines from the redirected stream, formats the text, and writes the text to the screen. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/sort_async.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/sort_async.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/sort_async.vb" id="Snippet1"::: @@ -580,7 +575,6 @@ process.BeginErrorReadLine(); ## Examples The following example starts the `nmake` command with user supplied arguments. The error and output streams are read asynchronously; the collected text lines are displayed to the console as well as written to a log file. If the command output exceeds a specified number of lines, the asynchronous read operations are canceled. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/nmake_async.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/nmake_async.vb" id="Snippet3"::: @@ -673,7 +667,6 @@ process.BeginOutputReadLine(); ## Examples The following example starts the `nmake` command with user supplied arguments. The error and output streams are read asynchronously; the collected text lines are displayed to the console as well as written to a log file. If the command output exceeds a specified number of lines, the asynchronous read operations are canceled. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/nmake_async.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/nmake_async.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/nmake_async.vb" id="Snippet3"::: @@ -740,7 +733,6 @@ process.BeginOutputReadLine(); ## Examples The following example starts an instance of Notepad. It then retrieves the physical memory usage of the associated process at 2-second intervals for a maximum of 10 seconds. The example detects whether the process exits before 10 seconds have elapsed. The example closes the process if it is still running after 10 seconds. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_refresh/CPP/process_refresh.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/Close/process_refresh.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/Close/process_refresh.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_refresh/VB/process_refresh.vb" id="Snippet1"::: @@ -804,7 +796,6 @@ process.BeginOutputReadLine(); ## Examples The following example starts an instance of Notepad. It then retrieves the physical memory usage of the associated process at 2 second intervals for a maximum of 10 seconds. The example detects whether the process exits before 10 seconds have elapsed. The example closes the process if it is still running after 10 seconds. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_refresh/CPP/process_refresh.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/Close/process_refresh.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/Close/process_refresh.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_refresh/VB/process_refresh.vb" id="Snippet1"::: @@ -1111,7 +1102,6 @@ The following code example creates a process that prints a file. It sets the event. The event handler receives text lines from the redirected stream, formats the text, and saves it in an output string that's later shown in the example's console window. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_asyncstreams/CPP/datareceivedevent.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/DataReceivedEventArgs/Overview/datareceivedevent.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/DataReceivedEventArgs/Overview/datareceivedevent.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_asyncstreams/VB/datareceivedevent.vb" id="Snippet4"::: @@ -3560,7 +3538,6 @@ If no main module is found, it could be because the process hasn't finished load ## Examples The following code example starts an instance of the Notepad application, and then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays its exit code and peak memory statistics. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -3700,7 +3677,6 @@ If no main module is found, it could be because the process hasn't finished load ## Examples The following code example starts an instance of the Notepad application. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays its exit code and peak memory statistics. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -3840,7 +3816,6 @@ If no main module is found, it could be because the process hasn't finished load ## Examples The following code example starts an instance of the Notepad application. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays its exit code and peak memory statistics. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -3979,7 +3954,6 @@ If no main module is found, it could be because the process hasn't finished load ## Examples The following code example starts an instance of the Notepad application. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays its exit code and peak memory statistics. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -4132,7 +4106,6 @@ If no main module is found, it could be because the process hasn't finished load ## Examples The following code example starts an instance of the Notepad application. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays its exit code and peak memory statistics. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -4288,7 +4261,6 @@ If no main module is found, it could be because the process hasn't finished load ## Examples The following example starts an instance of Notepad. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays the process's exit code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -4436,7 +4408,6 @@ If no main module is found, it could be because the process hasn't finished load ## Examples The following code example starts an instance of the Notepad application. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays its exit code and peak memory statistics. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -4512,7 +4483,6 @@ If no main module is found, it could be because the process hasn't finished load ## Examples The following example starts an instance of Notepad. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays the process's exit code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -4740,7 +4710,6 @@ If no main module is found, it could be because the process hasn't finished load ## Examples The following example starts an instance of Notepad. It then retrieves the physical memory usage of the associated process at 2 second intervals for a maximum of 10 seconds. The example detects whether the process exits before 10 seconds have elapsed. The example closes the process if it is still running after 10 seconds. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_refresh/CPP/process_refresh.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/Close/process_refresh.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/Close/process_refresh.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_refresh/VB/process_refresh.vb" id="Snippet1"::: @@ -4813,7 +4782,6 @@ If no main module is found, it could be because the process hasn't finished load ## Examples The following example starts an instance of Notepad. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays the process's exit code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -5041,7 +5009,6 @@ You can use asynchronous read operations to avoid these dependencies and their d ## Examples The following example uses the `net use` command together with a user supplied argument to map a network resource. It then reads the standard error stream of the net command and writes it to console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process_StandardError/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/StandardError/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/StandardError/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process_StandardError/VB/source.vb" id="Snippet1"::: @@ -5125,7 +5092,6 @@ You can use asynchronous read operations to avoid these dependencies and their d ## Examples The following example illustrates how to redirect the stream of a process. The example starts the `sort` command with redirected input. It then prompts the user for text, and passes that to the `sort` process by means of the redirected stream. The `sort` results are displayed to the user on the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process_StandardInput/CPP/process_standardinput.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/StandardInput/process_standardinput.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/StandardInput/process_standardinput.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process_StandardInput/VB/process_standardinput.vb" id="Snippet1"::: @@ -5233,7 +5199,6 @@ There is a similar issue when you read all text from both the standard output an ## Examples The following example runs the ipconfig.exe command and redirects its standard output to the example's console window. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process_StandardOutput/CPP/process_standardoutput.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/StandardOutput/process_standardoutput.cs"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/StandardOutput/process_standardoutput.fs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process_StandardOutput/VB/process_standardoutput.vb"::: @@ -5350,7 +5315,6 @@ There is a similar issue when you read all text from both the standard output an ## Examples The following example uses an instance of the class to start a process. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process.Start_instance/CPP/processstart.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/Overview/processstart.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/Overview/processstart.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process.Start_instance/VB/processstart.vb" id="Snippet1"::: @@ -5473,7 +5437,6 @@ The member For additional examples of other uses of this method, refer to the individual properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/Overview/processstartstatic.cs"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/Overview/processstartstatic.fs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process.Start_static/VB/processstartstatic.vb"::: @@ -5600,7 +5563,6 @@ The member ## Examples The following example first spawns an instance of Internet Explorer and displays the contents of the Favorites folder in the browser. It then starts some other instances of Internet Explorer and displays some specific pages or sites. Finally it starts Internet Explorer with the window being minimized while navigating to a specific site. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/Overview/processstartstatic.cs"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/Overview/processstartstatic.fs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process.Start_static/VB/processstartstatic.vb"::: @@ -5768,7 +5730,6 @@ The file specified in the could not be found. could not be found. ## Examples The following example populates a with the file to execute, the action performed on it and whether it should displays a user interface. For additional examples, refer to the reference pages for properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process.Start_instance/CPP/processstart.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/Overview/processstart.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/Overview/processstart.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process.Start_instance/VB/processstart.vb" id="Snippet1"::: @@ -6234,7 +6194,6 @@ The file specified in the could not be found. If the is used inside Visual Studio 2005 in a Windows Forms designer, is automatically set to the control that contains the . For example, if you place a on a designer for `Form1` (which inherits from ) the property of is set to the instance of `Form1`: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/remarks.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/SynchronizingObject/remarks.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/SynchronizingObject/remarks.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process_SynchronizingObject/VB/remarks.vb" id="Snippet2"::: @@ -6244,7 +6203,6 @@ The file specified in the could not be found. ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process_SynchronizingObject/CPP/process_synchronizingobject.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/SynchronizingObject/process_synchronizingobject.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process_SynchronizingObject/VB/process_synchronizingobject.vb" id="Snippet1"::: @@ -6372,7 +6330,6 @@ The file specified in the could not be found. ## Examples The following example starts an instance of Notepad. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays the process's exit code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -6448,7 +6405,6 @@ The file specified in the could not be found. ## Examples The following example starts an instance of Notepad. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays the process's exit code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -6527,7 +6483,6 @@ The file specified in the could not be found. ## Examples The following example starts an instance of Notepad. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays the process's exit code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -6671,7 +6626,6 @@ The file specified in the could not be found. ## Examples The following code example starts an instance of the Notepad application. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays its exit code and peak memory statistics. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: @@ -7234,7 +7188,6 @@ No process is associated with this o ## Examples The following example starts an instance of Notepad. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays the process' exit code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/process_sample/CPP/process_sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/WorkingSet/process_sample.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/WorkingSet/process_sample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/process_sample/VB/process_sample.vb" id="Snippet1"::: @@ -7317,7 +7270,6 @@ No process is associated with this o ## Examples The following code example starts an instance of the Notepad application. The example then retrieves and displays various properties of the associated process. The example detects when the process exits, and displays its exit code and peak memory statistics. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Diag_Process_MemoryProperties64/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/BasePriority/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Diagnostics/Process/BasePriority/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Diag_Process_MemoryProperties64/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Diagnostics/ProcessModule.xml b/xml/System.Diagnostics/ProcessModule.xml index 94a336cdfe5..7bef8b5192b 100644 --- a/xml/System.Diagnostics/ProcessModule.xml +++ b/xml/System.Diagnostics/ProcessModule.xml @@ -69,23 +69,22 @@ Represents a .dll or .exe file that is loaded into a particular process. - [!IMPORTANT] -> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - - +> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + + + +## Examples + The following code sample demonstrates how to use the class to get and display information about all the modules that are used by the Notepad.exe application. -## Examples - The following code sample demonstrates how to use the class to get and display information about all the modules that are used by the Notepad.exe application. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ProcessModule/CPP/processmodule.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ProcessModule/Overview/processmodule.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule/VB/processmodule.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule/VB/processmodule.vb" id="Snippet1"::: + ]]> @@ -136,15 +135,14 @@ Gets the memory address where the module was loaded. The load address of the module. - class to obtain a object for each module in the collection. The and properties are used to display the module name and the memory address where each module was loaded. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ProcessModule_BaseAddress/CPP/processmodule_baseaddress.cpp" id="Snippet1"::: + class to obtain a object for each module in the collection. The and properties are used to display the module name and the memory address where each module was loaded. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ProcessModule/BaseAddress/processmodule_baseaddress.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_BaseAddress/VB/processmodule_baseaddress.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_BaseAddress/VB/processmodule_baseaddress.vb" id="Snippet1"::: + ]]> @@ -195,23 +193,22 @@ Gets the memory address for the function that runs when the system loads and runs the module. The entry point of the module. - [!NOTE] -> Due to changes in the way that Windows loads assemblies, will always return 0 on Windows 8 or Windows 8.1 and should not be relied on for those platforms. - - - -## Examples - The following code example creates a new process for the Notepad.exe application. The code iterates through the class to obtain a object for each module in the collection. The and properties are used to display the name and the entry point address for each module. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ProcessModule_EntryPoint/CPP/processmodule_entrypoint.cpp" id="Snippet1"::: +> Due to changes in the way that Windows loads assemblies, will always return 0 on Windows 8 or Windows 8.1 and should not be relied on for those platforms. + + + +## Examples + The following code example creates a new process for the Notepad.exe application. The code iterates through the class to obtain a object for each module in the collection. The and properties are used to display the name and the entry point address for each module. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ProcessModule/EntryPointAddress/processmodule_entrypoint.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_EntryPoint/VB/processmodule_entrypoint.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_EntryPoint/VB/processmodule_entrypoint.vb" id="Snippet1"::: + ]]> @@ -263,20 +260,19 @@ Gets the full path to the module. The fully qualified path that defines the location of the module. - class to obtain a object for each module in the collection. The and properties are used to display the module name and the full path information for each module. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileName/CPP/processmodule_filename.cpp" id="Snippet1"::: + class to obtain a object for each module in the collection. The and properties are used to display the module name and the full path information for each module. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ProcessModule/FileName/processmodule_filename.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_FileName/VB/processmodule_filename.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_FileName/VB/processmodule_filename.vb" id="Snippet1"::: + ]]> @@ -326,15 +322,14 @@ Gets version information about the module. A that contains the module's version information. - class to obtain a object for each module in the collection. The and properties are used to display the module name and the file version information for each module. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ProcessModule_FileVersionInfo/CPP/processmodule_fileversioninfo.cpp" id="Snippet1"::: + class to obtain a object for each module in the collection. The and properties are used to display the module name and the file version information for each module. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ProcessModule/FileVersionInfo/processmodule_fileversioninfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_FileVersionInfo/VB/processmodule_fileversioninfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_FileVersionInfo/VB/processmodule_fileversioninfo.vb" id="Snippet1"::: + ]]> @@ -385,20 +380,19 @@ Gets the amount of memory that is required to load the module. The size, in bytes, of the memory that the module occupies. - does not include any additional memory allocations that the module makes once it is running; it includes only the size of the static code and data in the module file. - - - -## Examples - The following code example creates a new process for the Notepad.exe application. The code iterates through the class to obtain a object for each module in the collection. The and properties are used to display the module name and the amount of memory needed for each module. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleMemorySize/CPP/processmodule_modulememorysize.cpp" id="Snippet1"::: + does not include any additional memory allocations that the module makes once it is running; it includes only the size of the static code and data in the module file. + + + +## Examples + The following code example creates a new process for the Notepad.exe application. The code iterates through the class to obtain a object for each module in the collection. The and properties are used to display the module name and the amount of memory needed for each module. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ProcessModule/ModuleMemorySize/processmodule_modulememorysize.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_ModuleMemorySize/VB/processmodule_modulememorysize.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_ModuleMemorySize/VB/processmodule_modulememorysize.vb" id="Snippet1"::: + ]]> @@ -450,20 +444,19 @@ Gets the name of the process module. The name of the module. - class to obtain a object for each module in the collection. The property is used to display the name of each module. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ProcessModule_ModuleName/CPP/processmodule_modulename.cpp" id="Snippet1"::: + class to obtain a object for each module in the collection. The property is used to display the name of each module. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ProcessModule/ModuleName/processmodule_modulename.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_ModuleName/VB/processmodule_modulename.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_ModuleName/VB/processmodule_modulename.vb" id="Snippet1"::: + ]]> @@ -509,15 +502,14 @@ Converts the name of the module to a string. The value of the property. - class to obtain a object for each module in the collection. The method is used to display the name for each module. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ProcessModule_ToString/CPP/processmodule_tostring.cpp" id="Snippet1"::: + class to obtain a object for each module in the collection. The method is used to display the name for each module. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ProcessModule/ToString/processmodule_tostring.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_ToString/VB/processmodule_tostring.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessModule_ToString/VB/processmodule_tostring.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Diagnostics/ProcessStartInfo.xml b/xml/System.Diagnostics/ProcessStartInfo.xml index 48ab5aeb0a3..960739fccfb 100644 --- a/xml/System.Diagnostics/ProcessStartInfo.xml +++ b/xml/System.Diagnostics/ProcessStartInfo.xml @@ -78,7 +78,6 @@ ## Examples The following code example demonstrates how to use the class to start Internet Explorer. The destination URLs are provided as arguments. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process.Start_static/CPP/processstartstatic.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/Overview/processstartstatic.cs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process.Start_static/VB/processstartstatic.vb"::: @@ -446,11 +445,9 @@ If you use this property to set command-line arguments, stream. The `sort` results are displayed to the user on the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Process_StandardInput/CPP/process_standardinput.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Process/StandardInput/process_standardinput.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Process_StandardInput/VB/process_standardinput.vb" id="Snippet1"::: @@ -1502,7 +1495,6 @@ There is a similar issue when you read all text from both the standard output an You can use asynchronous read operations to avoid these dependencies and their deadlock potential. Alternately, you can avoid the deadlock condition by creating two threads and reading the output of each stream on a separate thread. ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ProcessOneStream/CPP/stdstr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ProcessStartInfo/RedirectStandardOutput/stdstr.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ProcessOneStream/VB/stdstr.vb" id="Snippet1"::: @@ -1843,7 +1835,6 @@ You can use asynchronous read operations to avoid these dependencies and their d For more information about this API, see Supplemental API remarks for ProcessStartInfo.UseShellExecute. @@ -2080,7 +2071,6 @@ The following code example starts a new process by using the specified verb and class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet1"::: @@ -188,7 +187,6 @@ ## Examples The following example demonstrates the use of the constructor. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet3"::: @@ -248,7 +246,6 @@ ## Examples The following example demonstrates the use of the constructor. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet2"::: @@ -314,7 +311,6 @@ ## Examples The following example demonstrates the use of the constructor. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet5"::: @@ -376,7 +372,6 @@ ## Examples The following example demonstrates the use of the constructor. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet4"::: @@ -444,7 +439,6 @@ ## Examples The following example demonstrates the use of the constructor. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet6"::: @@ -504,7 +498,6 @@ ## Examples The following example demonstrates the use of the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet7"::: @@ -564,7 +557,6 @@ ## Examples The following example demonstrates the use of the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet7"::: @@ -631,7 +623,6 @@ ## Examples The following example demonstrates the use of the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet7"::: @@ -691,7 +682,6 @@ ## Examples The following example demonstrates the use of the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet7"::: @@ -768,7 +758,6 @@ ## Examples The following example demonstrates the use of the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackTraceSample3/CPP/stacktracesample3.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/GetMethod/stacktracesample3.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackTraceSample3/VB/stacktracesample3.vb" id="Snippet6"::: @@ -821,7 +810,6 @@ ## Examples The following example demonstrates the use of the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet7"::: @@ -933,7 +921,6 @@ ## Examples The following example demonstrates the use of the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet3"::: diff --git a/xml/System.Diagnostics/StackTrace.xml b/xml/System.Diagnostics/StackTrace.xml index 8c872860bee..bd8a5bb6f5a 100644 --- a/xml/System.Diagnostics/StackTrace.xml +++ b/xml/System.Diagnostics/StackTrace.xml @@ -77,7 +77,6 @@ ## Examples The following console application demonstrates how to create a simple and iterate through its frames to obtain debugging and diagnostic information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackTraceSample1/CPP/stacktracesample1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackTrace/Overview/stacktracesample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackTraceSample1/VB/stacktracesample1.vb" id="Snippet1"::: @@ -145,7 +144,6 @@ ## Examples The following code example displays the first and last function calls in a stack trace. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet8"::: @@ -203,7 +201,6 @@ ## Examples The following code example demonstrates various constructor methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet4"::: @@ -289,7 +286,6 @@ ## Examples The following code example writes stack trace information to an event log entry. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackTraceSample3/CPP/stacktracesample3.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/GetMethod/stacktracesample3.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackTraceSample3/VB/stacktracesample3.vb" id="Snippet6"::: @@ -510,7 +506,6 @@ ## Examples The following code example demonstrates various constructor methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet4"::: @@ -737,7 +732,6 @@ ## Examples The following code example displays the first and last function calls in a stack trace. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet8"::: @@ -799,7 +793,6 @@ ## Examples The following code example displays the first and last function calls in a stack trace. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackFrameSample1/CPP/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/Overview/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackFrameSample1/VB/source.vb" id="Snippet8"::: @@ -876,7 +869,6 @@ ## Examples The following code example demonstrates enumerating the frames in a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackTraceSample2/CPP/stacktracesample2.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackTrace/GetFrames/stacktracesample2.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackTraceSample2/VB/stacktracesample2.vb" id="Snippet3"::: @@ -987,7 +979,6 @@ ## Examples The following code example writes stack trace information to an event log entry. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StackTraceSample3/CPP/stacktracesample3.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/StackFrame/GetMethod/stacktracesample3.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StackTraceSample3/VB/stacktracesample3.vb" id="Snippet6"::: diff --git a/xml/System.Diagnostics/Stopwatch.xml b/xml/System.Diagnostics/Stopwatch.xml index ef621813905..c66defde220 100644 --- a/xml/System.Diagnostics/Stopwatch.xml +++ b/xml/System.Diagnostics/Stopwatch.xml @@ -64,36 +64,35 @@ Provides a set of methods and properties that you can use to accurately measure elapsed time. - instance can measure elapsed time for one interval, or the total of elapsed time across multiple intervals. In a typical scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. - - A instance is either running or stopped; use to determine the current state of a . Use to begin measuring elapsed time; use to stop measuring elapsed time. Query the elapsed time value through the properties , , or . You can query the elapsed time properties while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. - - By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. - - The measures elapsed time by counting timer ticks in the underlying timer mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the class uses that counter to measure elapsed time. Otherwise, the class uses the system timer to measure elapsed time. Use the and fields to determine the precision and resolution of the timing implementation. - - The class assists the manipulation of timing-related performance counters within managed code. Specifically, the field and method can be used in place of the unmanaged Windows APIs `QueryPerformanceFrequency` and `QueryPerformanceCounter`. - -> [!NOTE] -> On a multiprocessor computer, it does not matter which processor the thread runs on. However, because of bugs in the BIOS or the Hardware Abstraction Layer (HAL), you can get different timing results on different processors. To specify processor affinity for a thread, use the method. - - - -## Examples - The following example demonstrates how to use the class to determine the execution time for an application. - - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.Stopwatch/VB/source.vb" id="Snippet1"::: - - The following example demonstrates the use of the class to calculate performance data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet1"::: - + instance can measure elapsed time for one interval, or the total of elapsed time across multiple intervals. In a typical scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. + + A instance is either running or stopped; use to determine the current state of a . Use to begin measuring elapsed time; use to stop measuring elapsed time. Query the elapsed time value through the properties , , or . You can query the elapsed time properties while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. + + By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. + + The measures elapsed time by counting timer ticks in the underlying timer mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the class uses that counter to measure elapsed time. Otherwise, the class uses the system timer to measure elapsed time. Use the and fields to determine the precision and resolution of the timing implementation. + + The class assists the manipulation of timing-related performance counters within managed code. Specifically, the field and method can be used in place of the unmanaged Windows APIs `QueryPerformanceFrequency` and `QueryPerformanceCounter`. + +> [!NOTE] +> On a multiprocessor computer, it does not matter which processor the thread runs on. However, because of bugs in the BIOS or the Hardware Abstraction Layer (HAL), you can get different timing results on different processors. To specify processor affinity for a thread, use the method. + + + +## Examples + The following example demonstrates how to use the class to determine the execution time for an application. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source1.cs" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.Stopwatch/VB/source.vb" id="Snippet1"::: + + The following example demonstrates the use of the class to calculate performance data. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet1"::: + ]]> @@ -139,21 +138,21 @@ Initializes a new instance of the class. - instance is stopped, and the elapsed time property of the instance is zero. - - Use the method to begin measuring elapsed time with the new instance. Use the method to initialize a new instance and immediately start it. - - - -## Examples - The following example initializes a instance by using a simple class constructor. - - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.Stopwatch/VB/source.vb" id="Snippet1"::: - + instance is stopped, and the elapsed time property of the instance is zero. + + Use the method to begin measuring elapsed time with the new instance. Use the method to initialize a new instance and immediately start it. + + + +## Examples + The following example initializes a instance by using a simple class constructor. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source1.cs" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.Stopwatch/VB/source.vb" id="Snippet1"::: + ]]> @@ -203,25 +202,25 @@ Gets the total elapsed time measured by the current instance. A read-only representing the total elapsed time measured by the current instance. - scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. - - Use the property to retrieve the elapsed time value using methods and properties. For example, you can format the returned instance into a text representation, or pass it to another class that requires a parameter. - - You can query the properties , , and while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. - - By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. - - - -## Examples - The following example demonstrates how to use the property to determine the execution time for an application. - - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.Stopwatch/VB/source.vb" id="Snippet1"::: - + scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. + + Use the property to retrieve the elapsed time value using methods and properties. For example, you can format the returned instance into a text representation, or pass it to another class that requires a parameter. + + You can query the properties , , and while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. + + By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. + + + +## Examples + The following example demonstrates how to use the property to determine the execution time for an application. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source1.cs" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.Stopwatch/VB/source.vb" id="Snippet1"::: + ]]> @@ -273,24 +272,23 @@ Gets the total elapsed time measured by the current instance, in milliseconds. A read-only long integer representing the total number of milliseconds measured by the current instance. - or properties. - - You can query the properties , , and while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. - - By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. - - - -## Examples - The following example uses the class to measure the performance of four different implementations for parsing an integer from a string. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet3"::: - + or properties. + + You can query the properties , , and while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. + + By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. + + + +## Examples + The following example uses the class to measure the performance of four different implementations for parsing an integer from a string. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet3"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet3"::: + ]]> @@ -347,27 +345,26 @@ Gets the total elapsed time measured by the current instance, in timer ticks. A read-only long integer representing the total number of timer ticks measured by the current instance. - timer can measure. Use the field to convert the value into a number of seconds. - - You can query the properties , , and while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. - - By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. - -> [!NOTE] -> ticks are different from . Each tick in the value represents one 100-nanosecond interval. Each tick in the value represents the time interval equal to 1 second divided by the . - - - -## Examples - The following example uses the class to measure the performance of four different implementations for parsing an integer from a string. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet4"::: - + timer can measure. Use the field to convert the value into a number of seconds. + + You can query the properties , , and while the instance is running or stopped. The elapsed time properties steadily increase while the is running; they remain constant when the instance is stopped. + + By default, the elapsed time value of a instance equals the total of all measured time intervals. Each call to begins counting at the cumulative elapsed time; each call to ends the current interval measurement and freezes the cumulative elapsed time value. Use the method to clear the cumulative elapsed time in an existing instance. + +> [!NOTE] +> ticks are different from . Each tick in the value represents one 100-nanosecond interval. Each tick in the value represents the time interval equal to 1 second divided by the . + + + +## Examples + The following example uses the class to measure the performance of four different implementations for parsing an integer from a string. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet4"::: + ]]> @@ -418,24 +415,23 @@ Gets the frequency of the timer as the number of ticks per second. This field is read-only. - value depends on the resolution of the underlying timing mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the value reflects the frequency of that counter. Otherwise, the value is based on the system timer frequency. - - Because the frequency depends on the installed hardware and operating system, the value remains constant while the system is running. - - - -## Examples - The following example displays the frequency and resolution of a timer. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet2"::: - + value depends on the resolution of the underlying timing mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the value reflects the frequency of that counter. Otherwise, the value is based on the system timer frequency. + + Because the frequency depends on the installed hardware and operating system, the value remains constant while the system is running. + + + +## Examples + The following example displays the frequency and resolution of a timer. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet2"::: + ]]> @@ -562,20 +558,19 @@ Gets the current number of ticks in the timer mechanism. A long integer representing the tick counter value of the underlying timer mechanism. - class uses a high-resolution performance counter, returns the current value of that counter. If the class uses the system timer, returns the current property of the instance. - - - -## Examples - The following example illustrates the use of the method to update a performance counter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/CPP/elapsedtime.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounter/NextValue/elapsedtime.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/VB/elapsedtime.vb" id="Snippet2"::: - + class uses a high-resolution performance counter, returns the current value of that counter. If the class uses the system timer, returns the current property of the instance. + + + +## Examples + The following example illustrates the use of the method to update a performance counter. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/PerformanceCounter/NextValue/elapsedtime.cs" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PerformanceCounterType.ElapsedTime/VB/elapsedtime.vb" id="Snippet2"::: + ]]> @@ -624,20 +619,19 @@ Indicates whether the timer is based on a high-resolution performance counter. This field is read-only. - class depends on the system hardware and operating system. is `true` if the timer is based on a high-resolution performance counter. Otherwise, is `false`, which indicates that the timer is based on the system timer. - - - -## Examples - The following example displays the frequency and resolution of a timer. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet2"::: - + class depends on the system hardware and operating system. is `true` if the timer is based on a high-resolution performance counter. Otherwise, is `false`, which indicates that the timer is based on the system timer. + + + +## Examples + The following example displays the frequency and resolution of a timer. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet2"::: + ]]> @@ -694,11 +688,11 @@ if the instance is currently running and measuring elapsed time for an interval; otherwise, . - instance begins running with a call to or . The instance stops running with a call to or . - + instance begins running with a call to or . The instance stops running with a call to or . + ]]> @@ -751,11 +745,11 @@ Stops time interval measurement and resets the elapsed time to zero. - instance calculates and retains the cumulative elapsed time across multiple time intervals, until the instance is reset. Use to stop the current interval measurement and retain the cumulative elapsed time value. Use to stop any interval measurement in progress and clear the elapsed time value. - + instance calculates and retains the cumulative elapsed time across multiple time intervals, until the instance is reset. Use to stop the current interval measurement and retain the cumulative elapsed time value. Use to stop any interval measurement in progress and clear the elapsed time value. + ]]> @@ -807,11 +801,11 @@ Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time. - instance calculates and retains the cumulative elapsed time across multiple time intervals, until the instance is reset or restarted. Use to stop the current interval measurement and retain the cumulative elapsed time value. Use to stop any interval measurement in progress and clear the elapsed time value. Use to stop current interval measurement and start a new interval measurement. - + instance calculates and retains the cumulative elapsed time across multiple time intervals, until the instance is reset or restarted. Use to stop the current interval measurement and retain the cumulative elapsed time value. Use to stop any interval measurement in progress and clear the elapsed time value. Use to stop current interval measurement and start a new interval measurement. + ]]> @@ -860,23 +854,23 @@ Starts, or resumes, measuring elapsed time for an interval. - scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. - - Once started, a timer measures the current interval, in elapsed timer ticks, until the instance is stopped or reset. Starting a that is already running does not change the timer state or reset the elapsed time properties. - - When a instance measures more than one interval, the method resumes measuring time from the current elapsed time value. A instance calculates and retains the cumulative elapsed time across multiple time intervals, until the instance is reset. Use the method before calling to clear the cumulative elapsed time in a instance. Use the method to and the with a single command. - - - -## Examples - The following example demonstrates how to use the method to start a timer that measures the execution time of an application. - - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.Stopwatch/VB/source.vb" id="Snippet1"::: - + scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. + + Once started, a timer measures the current interval, in elapsed timer ticks, until the instance is stopped or reset. Starting a that is already running does not change the timer state or reset the elapsed time properties. + + When a instance measures more than one interval, the method resumes measuring time from the current elapsed time value. A instance calculates and retains the cumulative elapsed time across multiple time intervals, until the instance is reset. Use the method before calling to clear the cumulative elapsed time in a instance. Use the method to and the with a single command. + + + +## Examples + The following example demonstrates how to use the method to start a timer that measures the execution time of an application. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source1.cs" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.Stopwatch/VB/source.vb" id="Snippet1"::: + ]]> @@ -930,20 +924,19 @@ Initializes a new instance, sets the elapsed time property to zero, and starts measuring elapsed time. A that has just begun measuring elapsed time. - constructor and then calling on the new instance. - - - -## Examples - The following example uses the class to measure the performance of four different implementations for parsing an integer from a string. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StopWatchPerfSample/CPP/source.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet4"::: - + constructor and then calling on the new instance. + + + +## Examples + The following example uses the class to measure the performance of four different implementations for parsing an integer from a string. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source.cs" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StopWatchPerfSample/VB/source.vb" id="Snippet4"::: + ]]> @@ -996,23 +989,23 @@ Stops measuring elapsed time for an interval. - scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. - - The method ends the current time interval measurement. Stopping a that is not running does not change the timer state or reset the elapsed time properties. - - When a instance measures more than one interval, the method is equivalent to pausing the elapsed time measurement. A subsequent call to resumes measuring time from the current elapsed time value. Use the method to clear the cumulative elapsed time in a instance. - - - -## Examples - The following example demonstrates how to use the method to stop a timer that measures the execution time of an application. - - :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.Stopwatch/VB/source.vb" id="Snippet1"::: - + scenario, you call the method, then eventually call the method, and then you check elapsed time using the property. + + The method ends the current time interval measurement. Stopping a that is not running does not change the timer state or reset the elapsed time properties. + + When a instance measures more than one interval, the method is equivalent to pausing the elapsed time measurement. A subsequent call to resumes measuring time from the current elapsed time value. Use the method to clear the cumulative elapsed time in a instance. + + + +## Examples + The following example demonstrates how to use the method to stop a timer that measures the execution time of an application. + + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Stopwatch/Overview/source1.cs" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.Stopwatch/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Diagnostics/Switch.xml b/xml/System.Diagnostics/Switch.xml index 61f5845f186..6c884e029fa 100644 --- a/xml/System.Diagnostics/Switch.xml +++ b/xml/System.Diagnostics/Switch.xml @@ -78,7 +78,6 @@ This example configuration section defines a with the property set to `mySwitch` and the value set to `true`. Within your application, you can use the configured switch value by creating a with the same name, as shown in the following code example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/remarks.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Switch/Overview/remarks.cs" id="Snippet4"::: ## Examples @@ -86,19 +85,16 @@ The first example creates the enumeration used to set the level of the switch. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Switch/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Switch Example/VB/source.vb" id="Snippet1"::: The following example creates the new switch. The code implements a `Level` property to set the value of the new switch. `Level` calls the protected property that assigns the value to the new switch. This example also implements two assessor properties to get the assigned value of the switch. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Switch/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Switch Example/VB/source.vb" id="Snippet2"::: The following example creates a new switch in `Main`. It creates a new switch and assigns it a value. Then, depending on the switch settings, it outputs debugging messages for entering and leaving the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Switch Example/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Switch/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Switch Example/VB/source.vb" id="Snippet3"::: diff --git a/xml/System.Diagnostics/TextWriterTraceListener.xml b/xml/System.Diagnostics/TextWriterTraceListener.xml index 0648552db0d..b9524b3313e 100644 --- a/xml/System.Diagnostics/TextWriterTraceListener.xml +++ b/xml/System.Diagnostics/TextWriterTraceListener.xml @@ -51,51 +51,50 @@ Directs tracing or debugging output to a or to a , such as . - class provides the property to get or set the text writer that receives the tracing or debugging output. - + class provides the property to get or set the text writer that receives the tracing or debugging output. + > [!IMPORTANT] -> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - - This class also provides methods to the so that it no longer receives tracing or debugging output, to the output buffer for the , and to a message to the . - - You must enable tracing or debugging to use a trace listener. The following syntax is compiler specific. If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler. - -- To enable debugging in C#, add the `/d:DEBUG` flag to the compiler command line when you compile your code, or you can add `#define DEBUG` to the top of your file. In Visual Basic, add the `/d:DEBUG=True` flag to the compiler command line. - -- To enable tracing in C#, add the `/d:TRACE` flag to the compiler command line when you compile your code, or add `#define TRACE` to the top of your file. In Visual Basic, add the `/d:TRACE=True` flag to the compiler command line. - - To add a trace listener in a .NET Framework app, edit the configuration file that corresponds to the name of your application. Within this file, you can add a listener, set its type and set its parameter, remove a listener, or clear all the listeners previously set by the application. The configuration file should be formatted like the following example. - -```xml - - - - - - - - - - -``` - +> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + + This class also provides methods to the so that it no longer receives tracing or debugging output, to the output buffer for the , and to a message to the . + + You must enable tracing or debugging to use a trace listener. The following syntax is compiler specific. If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler. + +- To enable debugging in C#, add the `/d:DEBUG` flag to the compiler command line when you compile your code, or you can add `#define DEBUG` to the top of your file. In Visual Basic, add the `/d:DEBUG=True` flag to the compiler command line. + +- To enable tracing in C#, add the `/d:TRACE` flag to the compiler command line when you compile your code, or add `#define TRACE` to the top of your file. In Visual Basic, add the `/d:TRACE=True` flag to the compiler command line. + + To add a trace listener in a .NET Framework app, edit the configuration file that corresponds to the name of your application. Within this file, you can add a listener, set its type and set its parameter, remove a listener, or clear all the listeners previously set by the application. The configuration file should be formatted like the following example. + +```xml + + + + + + + + + + +``` + > [!NOTE] > If an attempt is made to write to a file that is in use or unavailable, the file name is automatically prefixed by a GUID. + +## Examples + The following example implements an instance of the class that uses a called `myOutputWriter` to write to a file named `TestFile.txt`. First the example creates a file for output. Then it creates the for the first text writer, assigns it the output file, and adds it to the . Then, the code outputs one line of text to the file. Finally, the example flushes the output buffer. + + After running this sample, you can open the `TestFile.txt` file to see the output. -## Examples - The following example implements an instance of the class that uses a called `myOutputWriter` to write to a file named `TestFile.txt`. First the example creates a file for output. Then it creates the for the first text writer, assigns it the output file, and adds it to the . Then, the code outputs one line of text to the file. Finally, the example flushes the output buffer. - - After running this sample, you can open the `TestFile.txt` file to see the output. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -160,20 +159,19 @@ Initializes a new instance of the class with as the output recipient. - stream as the recipient of the tracing or debugging output. Its property is initialized to an empty string ("", or ). - - - -## Examples - The following example creates a using the constructor. It sets the property to console output, and then adds the to the . It writes a message in two segments, and then closes the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/CPP/source.cpp" id="Snippet1"::: + stream as the recipient of the tracing or debugging output. Its property is initialized to an empty string ("", or ). + + + +## Examples + The following example creates a using the constructor. It sets the property to console output, and then adds the to the . It writes a message in two segments, and then closes the . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/.ctor/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -227,19 +225,19 @@ A that represents the stream the writes to. Initializes a new instance of the class, using the stream as the recipient of the debugging and tracing output. - property to an empty string (""). - - - -## Examples - The following code example creates a using the constructor and adds it to the . The example then writes two messages to this , and writes a message to all objects in the . Finally, it flushes and closes the . - + property to an empty string (""). + + + +## Examples + The following code example creates a using the constructor and adds it to the . The example then writes two messages to this , and writes a message to all objects in the . Finally, it flushes and closes the . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/.ctor/twtlconstream.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TextWriterTraceListener.Ctor/VB/twtlconstream.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TextWriterTraceListener.Ctor/VB/twtlconstream.vb" id="Snippet1"::: + ]]> The stream is . @@ -294,20 +292,19 @@ A that receives the output from the . Initializes a new instance of the class using the specified writer as recipient of the tracing or debugging output. - property to an empty string (""). - - - -## Examples - The following code example creates a using the constructor. The example creates a , then references the when it creates the , which it then adds to the . The example writes a message to all objects in the , then closes this . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/CPP/source.cpp" id="Snippet1"::: + property to an empty string (""). + + + +## Examples + The following code example creates a using the constructor. The example creates a , then references the when it creates the , which it then adds to the . The example writes a message to all objects in the , then closes this . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/VB/source.vb" id="Snippet1"::: + ]]> The writer is . @@ -368,19 +365,19 @@ The name of the file the writes to. Initializes a new instance of the class, using the file as the recipient of the debugging and tracing output. - property to an empty string (""). - - - -## Examples - The following code example creates a using the constructor, then adds it to the . The example writes two messages to this , then writes a message to all objects in the . Finally, it flushes and closes the . - + property to an empty string (""). + + + +## Examples + The following code example creates a using the constructor, then adds it to the . The example writes two messages to this , then writes a message to all objects in the . Finally, it flushes and closes the . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/.ctor/twtlconstring.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TextWriterTraceListener.Ctor/VB/twtlconstring.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TextWriterTraceListener.Ctor/VB/twtlconstring.vb" id="Snippet3"::: + ]]> The file is . @@ -445,19 +442,19 @@ The name of the new instance. Initializes a new instance of the class with the specified name, using the stream as the recipient of the debugging and tracing output. - property to the `name` parameter or to an empty string (""), if the `name` parameter is `null`. - - - -## Examples - The following code example creates a using the constructor and adds it to the . The example then writes two messages to this and writes a message to all objects in the . Finally, it flushes and closes the . - + property to the `name` parameter or to an empty string (""), if the `name` parameter is `null`. + + + +## Examples + The following code example creates a using the constructor and adds it to the . The example then writes two messages to this and writes a message to all objects in the . Finally, it flushes and closes the . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/.ctor/twtlconstreamname.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TextWriterTraceListener.Ctor/VB/twtlconstreamname.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TextWriterTraceListener.Ctor/VB/twtlconstreamname.vb" id="Snippet2"::: + ]]> The stream is . @@ -522,14 +519,14 @@ The name of the new instance. Initializes a new instance of the class with the specified name, using the specified writer as recipient of the tracing or debugging output. - using the constructor. The example creates a , then references the when it creates the , which it then adds to the . The example writes two messages to this , then writes a message to all objects in the . Finally, it flushes and closes the . - + using the constructor. The example creates a , then references the when it creates the , which it then adds to the . The example writes two messages to this , then writes a message to all objects in the . Finally, it flushes and closes the . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/.ctor/twtlconwritername.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TextWriterTraceListener.Ctor/VB/twtlconwritername.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TextWriterTraceListener.Ctor/VB/twtlconwritername.vb" id="Snippet5"::: + ]]> The writer is . @@ -592,19 +589,19 @@ The name of the new instance. Initializes a new instance of the class with the specified name, using the file as the recipient of the debugging and tracing output. - property to the `name` parameter or to an empty string (""), if the `name` parameter is `null`. - - - -## Examples - The following code example creates a using the constructor, then adds it to the . The example writes two messages to this , then writes a message to all objects in the . Finally, it flushes and closes the . - + property to the `name` parameter or to an empty string (""), if the `name` parameter is `null`. + + + +## Examples + The following code example creates a using the constructor, then adds it to the . The example writes two messages to this , then writes a message to all objects in the . Finally, it flushes and closes the . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/.ctor/twtlconstringname.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TextWriterTraceListener.Ctor/VB/twtlconstringname.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TextWriterTraceListener.Ctor/VB/twtlconstringname.vb" id="Snippet4"::: + ]]> The stream is . @@ -658,20 +655,19 @@ Closes the so that it no longer receives tracing or debugging output. - or method after calling automatically reopens the stream. - - - -## Examples - The following example implements a named `myTextListener`, which uses a called `myOutputWriter` to write to a file named `TestFile.txt`. The example creates the file, stream, and text writer, writes one line of text to the file, and then flushes and closes the stream. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/CPP/source.cpp" id="Snippet1"::: + or method after calling automatically reopens the stream. + + + +## Examples + The following example implements a named `myTextListener`, which uses a called `myOutputWriter` to write to a file named `TestFile.txt`. The example creates the file, stream, and text writer, writes one line of text to the file, and then flushes and closes the stream. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -729,11 +725,11 @@ to release managed resources; if , has no effect. Disposes this object. - method of the class to release the managed resources of a object. - + method of the class to release the managed resources of a object. + ]]> @@ -778,15 +774,14 @@ Flushes the output buffer for the . - named `myTextListener`, which uses a called `myOutputWriter` to write to a file named `TestFile.txt`. The example creates the file, stream, and text writer, writes one line of text to the file, and then flushes and closes the stream. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/CPP/source.cpp" id="Snippet1"::: + named `myTextListener`, which uses a called `myOutputWriter` to write to a file named `TestFile.txt`. The example creates the file, stream, and text writer, writes one line of text to the file, and then flushes and closes the stream. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Close Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -844,15 +839,14 @@ A message to write. Writes a message to this instance's . - named `myWriter` to write to the console screen. The example writes two lines to the console screen. Note the second write appears on the same line as the first write. The example then flushes and closes the stream. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Write Example/CPP/source.cpp" id="Snippet1"::: + named `myWriter` to write to the console screen. The example writes two lines to the console screen. Note the second write appears on the same line as the first write. The example then flushes and closes the stream. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/Write/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Write Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Write Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -910,15 +904,14 @@ A message to write. Writes a message to this instance's followed by a line terminator. The default line terminator is a carriage return followed by a line feed (\r\n). - named `myWriter` to write to the console screen. The example writes two lines to the console screen. Note the second write appears on the same line as the first write. The example then flushes and closes the stream. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/CPP/source.cpp" id="Snippet1"::: + named `myWriter` to write to the console screen. The example writes two lines to the console screen. Note the second write appears on the same line as the first write. The example then flushes and closes the stream. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/.ctor/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.WriteLine Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -979,15 +972,14 @@ Gets or sets the text writer that receives the tracing or debugging output. A that represents the writer that receives the tracing or debugging output. - that writes to the console screen. Then the code adds the new trace listener to the in the trace class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Writer Example/CPP/source.cpp" id="Snippet1"::: + that writes to the console screen. Then the code adds the new trace listener to the in the trace class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TextWriterTraceListener/Writer/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Writer Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TextWriterTraceListener.Writer Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Diagnostics/Trace.xml b/xml/System.Diagnostics/Trace.xml index c33ac03aef6..6aea8fb4087 100644 --- a/xml/System.Diagnostics/Trace.xml +++ b/xml/System.Diagnostics/Trace.xml @@ -97,7 +97,6 @@ In .NET Framework apps, you can set the to indicate the beginning and the end of a program's execution. The example also uses the and methods to distinguish the tracing output. For a more complete example of the use of , see [How to: Add Trace Statements to Application Code](/dotnet/framework/debug-trace-profile/how-to-add-trace-statements-to-application-code). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace Example/VB/source.vb" id="Snippet1"::: @@ -214,7 +213,6 @@ For .NET Framework apps, you can change the behavior of the to verify the index value is valid. If it is not valid, the outputs the call stack. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Assert/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Assert Example/VB/source.vb" id="Snippet1"::: @@ -326,7 +324,6 @@ For .NET Framework apps, you can change the behavior of the outputs a message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Assert/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Assert1 Example/VB/source.vb" id="Snippet1"::: @@ -431,7 +428,6 @@ For .NET Framework apps, you can change the behavior of the outputs a message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Assert2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Assert/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Assert2 Example/VB/source.vb" id="Snippet1"::: @@ -573,7 +569,6 @@ For .NET Framework apps, you can change the behavior of the named `myTextListener`. `myTextListener` uses a called `myOutputWriter` to write to a file named `TestFile.txt`. The example creates the file, stream and text writer, writes one line of text to the file, and then flushes and closes the output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Flush Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Flush Example/VB/source.vb" id="Snippet1"::: @@ -725,13 +720,11 @@ For .NET Framework apps, you can change the behavior of the method to print a message during exception handling. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Fail/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Fail Example/VB/source.vb" id="Snippet1"::: You can also use the method in a switch statement. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Fail/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Fail Example/VB/source.vb" id="Snippet2"::: @@ -817,13 +810,11 @@ For .NET Framework apps, you can change the behavior of the method to print a message during exception handling. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Fail/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/VB/source.vb" id="Snippet1"::: You can also use the method in a switch statement. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Fail/source1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/VB/source.vb" id="Snippet2"::: @@ -894,7 +885,6 @@ For .NET Framework apps, you can change the behavior of the named `myTextListener`. `myTextListener` uses a called `myOutputWriter` to write to a file named `TestFile.txt`. The example creates the file, stream and text writer, writes one line of text to the file, and then flushes and closes the output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Flush Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Flush Example/VB/source.vb" id="Snippet1"::: @@ -960,7 +950,6 @@ For .NET Framework apps, you can change the behavior of the that outputs to the console screen. The code then adds the new listener to the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Listeners/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/VB/source.vb" id="Snippet1"::: @@ -1805,7 +1792,6 @@ End of list of errors ## Examples The following example increments and decrements the indent level and emits tracing messages. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.IndentLevel Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Indent/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.IndentLevel Example/VB/source.vb" id="Snippet1"::: @@ -1967,7 +1953,6 @@ End of list of errors Then, if the is set to `Verbose`, the example outputs a message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Write/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Write1 Example/VB/source.vb" id="Snippet1"::: @@ -2053,7 +2038,6 @@ End of list of errors Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. A line terminator follows the second message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Write/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Write Example/VB/source.vb" id="Snippet1"::: @@ -2143,7 +2127,6 @@ End of list of errors Then, if the is set to `Error` or higher, the example outputs the second error message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Write/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Write3 Example/VB/source.vb" id="Snippet1"::: @@ -2233,7 +2216,6 @@ End of list of errors Then, if the is set to `Error` or higher, the example outputs the second error message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Write/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Write2 Example/VB/source.vb" id="Snippet1"::: @@ -2327,7 +2309,6 @@ End of list of errors Then, if the is set to `Verbose`, the example outputs a message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteIf/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteIf1 Example/VB/source.vb" id="Snippet1"::: @@ -2427,7 +2408,6 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteIf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/VB/source.vb" id="Snippet1"::: @@ -2531,7 +2511,6 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); Then, if the is set to `Error` or higher, the example outputs the second error message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteIf/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteIf3 Example/VB/source.vb" id="Snippet1"::: @@ -2635,7 +2614,6 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); Then, if the is set to `Error` or higher, the example outputs the second error message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteIf/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteIf2 Example/VB/source.vb" id="Snippet1"::: @@ -2742,7 +2720,6 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); Then, if the is set to `Verbose`, the example outputs the name of the object on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteLine/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLine1 Example/VB/source.vb" id="Snippet1"::: @@ -2823,7 +2800,6 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Write Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Write/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Write Example/VB/source.vb" id="Snippet1"::: @@ -2908,7 +2884,6 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteLine/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLine3 Example/VB/source.vb" id="Snippet1"::: @@ -2993,7 +2968,6 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); Then, if the is set to `Verbose`, the example outputs the second error message and the `category` on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLine2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteLine/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLine2 Example/VB/source.vb" id="Snippet1"::: @@ -3087,7 +3061,6 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); Then, if the is set to `Verbose`, the example outputs the name of the object on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteLineIf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf1 Example/VB/source.vb" id="Snippet1"::: @@ -3187,7 +3160,6 @@ Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range") Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteIf/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/VB/source.vb" id="Snippet1"::: @@ -3291,7 +3263,6 @@ Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range") Then, if the is set to `Verbose`, the example outputs the second error message on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteLineIf/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf3 Example/VB/source.vb" id="Snippet1"::: @@ -3395,7 +3366,6 @@ Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range") Then, if the is set to `Verbose`, the example outputs the second error message and the `category` on the same line as the first message. The second message is followed by a line terminator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/WriteLineIf/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf2 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Diagnostics/TraceFilter.xml b/xml/System.Diagnostics/TraceFilter.xml index 1371a2ed97e..6dd4ee0e42e 100644 --- a/xml/System.Diagnostics/TraceFilter.xml +++ b/xml/System.Diagnostics/TraceFilter.xml @@ -44,13 +44,13 @@ Provides the base class for trace filter implementations. - property. Trace switches determine if a trace is to be sent to the trace listeners. Trace filters allow the individual trace listeners to determine whether or not the trace is to be written to the associated output medium. For example, as determined by each trace filter, a trace may be written to the console by a , but not to the event log by a . - - Filters that inherit from the class can be used by trace listeners that inherit from the class to perform filtering of events being traced. contains a single method, , which takes event data and returns a flag indicating whether the event should be traced. - + property. Trace switches determine if a trace is to be sent to the trace listeners. Trace filters allow the individual trace listeners to determine whether or not the trace is to be written to the associated output medium. For example, as determined by each trace filter, a trace may be written to the console by a , but not to the event log by a . + + Filters that inherit from the class can be used by trace listeners that inherit from the class to perform filtering of events being traced. contains a single method, , which takes event data and returns a flag indicating whether the event should be traced. + ]]> @@ -171,30 +171,29 @@ to trace the specified event; otherwise, . - method to indicate tracing should occur when the trace event type of the event is equal to . -## Examples - The following code example shows how to override the method to indicate tracing should occur when the trace event type of the event is equal to . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.diagnostics.tracefilter/cpp/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceFilter/ShouldTrace/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.diagnostics.tracefilter/vb/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.diagnostics.tracefilter/vb/source.vb" id="Snippet2"::: + ]]> - Implementations of this method should return if the event specified by the passed parameters should be traced. Otherwise the method should return . For example, a filter that allows only error events to pass through to the listener should inspect the parameter and return if the trace event type level is set to or greater; otherwise, it should return . - - Implementations of the method should be prepared to handle in the following parameters: , , , , and . If the parameter value is , the parameter is not part of the event. For example, if the parameter is , it means that the event does not have any arguments. If the parameter is , then there are either one or no data objects. If there is one data object, it will be found in the parameter. The reason for the distinction between a single data object and an array of data objects is for performance. There is no reason to create an object array if only one object is traced, as is normally the case. If the parameter is not , the parameter must also not be . - - It is guaranteed that the parameter is not and not an empty string (""). - - Implementations of the method can optionally throw the following exceptions: - -- if is . - -- if is not one of the values. - + Implementations of this method should return if the event specified by the passed parameters should be traced. Otherwise the method should return . For example, a filter that allows only error events to pass through to the listener should inspect the parameter and return if the trace event type level is set to or greater; otherwise, it should return . + + Implementations of the method should be prepared to handle in the following parameters: , , , , and . If the parameter value is , the parameter is not part of the event. For example, if the parameter is , it means that the event does not have any arguments. If the parameter is , then there are either one or no data objects. If there is one data object, it will be found in the parameter. The reason for the distinction between a single data object and an array of data objects is for performance. There is no reason to create an object array if only one object is traced, as is normally the case. If the parameter is not , the parameter must also not be . + + It is guaranteed that the parameter is not and not an empty string (""). + + Implementations of the method can optionally throw the following exceptions: + +- if is . + +- if is not one of the values. + - Exceptions unrelated to the implementation of the method. For example, a . diff --git a/xml/System.Diagnostics/TraceListenerCollection.xml b/xml/System.Diagnostics/TraceListenerCollection.xml index 4f8928dc51a..c1d4f100e24 100644 --- a/xml/System.Diagnostics/TraceListenerCollection.xml +++ b/xml/System.Diagnostics/TraceListenerCollection.xml @@ -78,7 +78,6 @@ ## Examples The following example creates a that writes to the console screen. The code then adds the new listener to the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/Trace/Listeners/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/VB/source.vb" id="Snippet1"::: @@ -141,7 +140,6 @@ ## Examples The following example creates a that outputs to the console screen. The code then adds the new listener to the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceListenerCollection.Add Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceListenerCollection/Add/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceListenerCollection.Add Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Diagnostics/TraceSource.xml b/xml/System.Diagnostics/TraceSource.xml index 8d410d9d9c0..8345d671c10 100644 --- a/xml/System.Diagnostics/TraceSource.xml +++ b/xml/System.Diagnostics/TraceSource.xml @@ -50,85 +50,84 @@ Provides a set of methods and properties that enable applications to trace the execution of code and associate trace messages with their source. - class is used by applications to produce traces that can be associated with the application. provides tracing methods that allow you to easily trace events, trace data, and issue informational traces. - -In .NET Framework apps, trace output from can be controlled by configuration file settings. The configuration file is located in the folder with the application executable and has the name of the application with the .config extension added. For example, the name of the configuration file for TraceSourceSample.exe is TraceSourceSample.exe.config. The configuration file can be used to specify where the trace information is to be sent and what levels of activity are to be traced. The following example shows the contents of a sample .NET Framework application configuration file. - -```xml - - - - - - - - - - - - - - - - - - - - - - - - - - -``` - - The class is identified by the name of a source, typically the name of the application. The trace messages coming from a particular component can be initiated by a particular trace source, allowing all messages coming from that component to be easily identified. - - defines tracing methods but does not actually provide any specific mechanism for generating and storing tracing data. The tracing data is produced by trace listeners, which are plug-ins that can be loaded by trace sources. - + +In .NET Framework apps, trace output from can be controlled by configuration file settings. The configuration file is located in the folder with the application executable and has the name of the application with the .config extension added. For example, the name of the configuration file for TraceSourceSample.exe is TraceSourceSample.exe.config. The configuration file can be used to specify where the trace information is to be sent and what levels of activity are to be traced. The following example shows the contents of a sample .NET Framework application configuration file. + +```xml + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + + The class is identified by the name of a source, typically the name of the application. The trace messages coming from a particular component can be initiated by a particular trace source, allowing all messages coming from that component to be easily identified. + + defines tracing methods but does not actually provide any specific mechanism for generating and storing tracing data. The tracing data is produced by trace listeners, which are plug-ins that can be loaded by trace sources. + > [!NOTE] -> You should not call the tracing methods during finalization. Doing so can result in an being thrown. - +> You should not call the tracing methods during finalization. Doing so can result in an being thrown. + You can customize the tracing output's target by adding or removing instances to or from the collection stored in the property. By default, trace output is produced using an instance of the class. -The preceding .NET Framework app configuration file example demonstrates removing the and adding a to produce the trace output for the trace source. For more information, see [\](/dotnet/framework/configure-apps/file-schema/trace-debug/listeners-element-for-source) and [\](/dotnet/framework/configure-apps/file-schema/trace-debug/sharedlisteners-element). - +The preceding .NET Framework app configuration file example demonstrates removing the and adding a to produce the trace output for the trace source. For more information, see [\](/dotnet/framework/configure-apps/file-schema/trace-debug/listeners-element-for-source) and [\](/dotnet/framework/configure-apps/file-schema/trace-debug/sharedlisteners-element). + > [!NOTE] -> Adding a trace listener to the collection can cause an exception to be thrown while tracing, if a resource used by the trace listener is not available. The conditions and the exception thrown depend on the trace listener and cannot be enumerated in this topic. It may be useful to place calls to the methods in `try`/`catch` blocks to detect and handle any exceptions from trace listeners. - - The class provides the means to dynamically control the tracing output. For .NET Framework apps, the preceding configuration file example shows how you can turn off tracing from a trace source and control the level at which tracing occurs. You can modify the value of the source switch without recompiling your application. For information on using the configuration file to set a switch, see and [How to: Create, Initialize and Configure Trace Switches](/dotnet/framework/debug-trace-profile/how-to-create-initialize-and-configure-trace-switches). - +> Adding a trace listener to the collection can cause an exception to be thrown while tracing, if a resource used by the trace listener is not available. The conditions and the exception thrown depend on the trace listener and cannot be enumerated in this topic. It may be useful to place calls to the methods in `try`/`catch` blocks to detect and handle any exceptions from trace listeners. + + The class provides the means to dynamically control the tracing output. For .NET Framework apps, the preceding configuration file example shows how you can turn off tracing from a trace source and control the level at which tracing occurs. You can modify the value of the source switch without recompiling your application. For information on using the configuration file to set a switch, see and [How to: Create, Initialize and Configure Trace Switches](/dotnet/framework/debug-trace-profile/how-to-create-initialize-and-configure-trace-switches). + > [!NOTE] -> If you modify a configuration file while an application is executing, the application must be stopped and restarted or the method must be called before the new settings take effect. - - The enumeration is used to define the event type of the trace message. Trace filters use the to determine if a trace listener should produce the trace message. - - The trace listeners can optionally have an additional layer of filtering through a trace filter. If a trace listener has an associated filter, the listener calls the method on that filter to determine whether or not to produce the trace information. - - The trace listeners use the values of the class properties , , and to format trace output. In .NET Framework apps, you can use configuration file attributes to set the , , and properties. The following example sets the property to `false` and the property to 3. - -```xml - - - - - +> If you modify a configuration file while an application is executing, the application must be stopped and restarted or the method must be called before the new settings take effect. + + The enumeration is used to define the event type of the trace message. Trace filters use the to determine if a trace listener should produce the trace message. + + The trace listeners can optionally have an additional layer of filtering through a trace filter. If a trace listener has an associated filter, the listener calls the method on that filter to determine whether or not to produce the trace information. + + The trace listeners use the values of the class properties , , and to format trace output. In .NET Framework apps, you can use configuration file attributes to set the , , and properties. The following example sets the property to `false` and the property to 3. + +```xml + + + + + ``` + +## Examples + The following code example shows the use of the class to forward traces to listeners. The example also demonstrates switch and filter usage. -## Examples - The following code example shows the use of the class to forward traces to listeners. The example also demonstrates switch and filter usage. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/CPP/tracesource2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SwitchAttribute/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet1"::: + ]]> This type is thread safe. @@ -190,22 +189,22 @@ The preceding .NET Framework app configuration file example demonstrates removin The name of the source (typically, the name of the application). Initializes a new instance of the class, using the specified name for the source. - to determine whether a trace listener should produce the trace. The recommended practice is to use the name of the application for the source name. - + to determine whether a trace listener should produce the trace. The recommended practice is to use the name of the application for the source name. + > [!NOTE] -> It is not necessary to create a new instance for each trace request. Create one instance and use it for all trace requests for the application. - - - -## Examples - The following code example shows the use of the constructor to create a new object. This code example is part of a larger example provided for the class. - +> It is not necessary to create a new instance for each trace request. Create one instance and use it for all trace requests for the application. + + + +## Examples + The following code example shows the use of the constructor to create a new object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SwitchAttribute/Overview/program.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet9"::: + ]]> @@ -255,14 +254,14 @@ The preceding .NET Framework app configuration file example demonstrates removin A bitwise combination of the enumeration values that specifies the default source level at which to trace. Initializes a new instance of the class, using the specified name for the source and the default source level at which tracing is to occur. - to determine if tracing is to occur and by a to determine whether to produce the trace. The default source level is used by an to determine if tracing is to occur based on the source level of the message to be traced. - + to determine if tracing is to occur and by a to determine whether to produce the trace. The default source level is used by an to determine if tracing is to occur based on the source level of the message to be traced. + > [!NOTE] -> It is not necessary to create a new instance for each trace request. Create one instance and use it for all trace requests for the application. - +> It is not necessary to create a new instance for each trace request. Create one instance and use it for all trace requests for the application. + ]]> @@ -309,30 +308,30 @@ The preceding .NET Framework app configuration file example demonstrates removin Gets the custom switch attributes defined in the application configuration file. A containing the custom attributes for the trace switch. - property identifies the custom attributes referenced in the application's configuration file. Unreferenced custom attributes are not enumerated. Classes that inherit from the class can add custom attributes by overriding the method and returning a string array of custom attribute names. - - The following is a sample of a trace source element specifying the custom attribute `SecondTraceSourceAttribute`: - -```xml - - - - -``` - - - -## Examples - The following code sample shows how to display the custom attributes for a . This code example is part of a larger example provided for the class. - + property identifies the custom attributes referenced in the application's configuration file. Unreferenced custom attributes are not enumerated. Classes that inherit from the class can add custom attributes by overriding the method and returning a string array of custom attribute names. + + The following is a sample of a trace source element specifying the custom attribute `SecondTraceSourceAttribute`: + +```xml + + + + +``` + + + +## Examples + The following code sample shows how to display the custom attributes for a . This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SwitchAttribute/Overview/program.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet14"::: + ]]> @@ -376,19 +375,19 @@ The preceding .NET Framework app configuration file example demonstrates removin Closes all the trace listeners in the trace listener collection. - method calls the method of each trace listener in the collection. - - - -## Examples - The following code example shows how you can use the method to close all the listeners in the collection. This code example is part of a larger example provided for the class. - + method calls the method of each trace listener in the collection. + + + +## Examples + The following code example shows how you can use the method to close all the listeners in the collection. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SwitchAttribute/Overview/program.cs" id="Snippet33"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet33"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet33"::: + ]]> @@ -459,19 +458,19 @@ The preceding .NET Framework app configuration file example demonstrates removin Flushes all the trace listeners in the trace listener collection. - method calls the method of each trace listener in the collection. - - - -## Examples - The following code example shows how you can use the method to flush all the listeners in the collection. This code example is part of a larger example provided for the class. - + method calls the method of each trace listener in the collection. + + + +## Examples + The following code example shows how you can use the method to flush all the listeners in the collection. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SwitchAttribute/Overview/program.cs" id="Snippet33"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet33"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet33"::: + ]]> An attempt was made to trace an event during finalization. @@ -527,19 +526,19 @@ The preceding .NET Framework app configuration file example demonstrates removin Gets the custom attributes supported by the trace source. A string array naming the custom attributes supported by the trace source, or if there are no custom attributes. - returns `null`. - - - -## Examples - The following code example shows an override of the method to identify the custom attributes for the `MyTraceSource` class. - + returns `null`. + + + +## Examples + The following code example shows an override of the method to identify the custom attributes for the `MyTraceSource` class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SourceFilter/.ctor/program.cs" id="Snippet33"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource/VB/program.vb" id="Snippet33"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource/VB/program.vb" id="Snippet33"::: + ]]> @@ -618,11 +617,11 @@ The preceding .NET Framework app configuration file example demonstrates removin Gets the collection of trace listeners for the trace source. A that contains the active trace listeners associated with the source. - @@ -672,30 +671,30 @@ The preceding .NET Framework app configuration file example demonstrates removin Gets the name of the trace source. The name of the trace source. - - - - - - - - +You can refer to the trace source by using the `name` attribute in the configuration file of a .NET Framework app. The following XML element shows how to refer to a trace source in the configuration file of a .NET Framework app. + +```xml + + + + + + + + ``` - -## Examples - The following code sample shows how to name a trace source in the constructor call. This code example is part of a larger example provided for the class. - + +## Examples + The following code sample shows how to name a trace source in the constructor call. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SwitchAttribute/Overview/program.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet9"::: + ]]> @@ -739,13 +738,13 @@ You can refer to the trace source by using the `name` attribute in the configura Gets or sets the source switch value. A object representing the source switch value. - property allows the filtering of messages before the trace source calls the listeners. - - The switch is used to check whether trace calls should be generated or ignored. Each trace method calls the method of the to determine whether to proceed with the trace. If the call returns `true`, the listeners are called. - + property allows the filtering of messages before the trace source calls the listeners. + + The switch is used to check whether trace calls should be generated or ignored. Each trace method calls the method of the to determine whether to proceed with the trace. If the call returns `true`, the listeners are called. + ]]> @@ -815,24 +814,24 @@ You can refer to the trace source by using the `name` attribute in the configura The trace data. Writes trace data to the trace listeners in the collection using the specified event type, event identifier, and trace data. - method, like the method, is intended for automated tools, but it also allows the attaching of an additional object, such as an exception instance, to the trace. - - The method calls the method of the object returned by the property. If returns `true`, calls the corresponding method on all listeners. Otherwise, returns without calling the listeners' methods. - + method, like the method, is intended for automated tools, but it also allows the attaching of an additional object, such as an exception instance, to the trace. + + The method calls the method of the object returned by the property. If returns `true`, calls the corresponding method on all listeners. Otherwise, returns without calling the listeners' methods. + > [!NOTE] -> The object is limited to a maximum `id` value of 65,535. If the `id` value specified is greater than 65,535, the object uses 65,535. - - - -## Examples - The following code example shows the use of the method to filter and forward a trace message to the listeners. This code example is part of a larger example provided for the class. - +> The object is limited to a maximum `id` value of 65,535. If the `id` value specified is greater than 65,535, the object uses 65,535. + + + +## Examples + The following code example shows the use of the method to filter and forward a trace message to the listeners. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SwitchAttribute/Overview/program.cs" id="Snippet28"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet28"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet28"::: + ]]> An attempt was made to trace an event during finalization. @@ -898,16 +897,16 @@ You can refer to the trace source by using the `name` attribute in the configura An object array containing the trace data. Writes trace data to the trace listeners in the collection using the specified event type, event identifier, and trace data array. - method, like the method, is intended for automated tools, but it also allows the attaching of additional objects, such as an exception instance and a stack trace, to the trace. - - The method calls the method of the object returned by the property. If returns `true`, calls the corresponding method on all listeners. Otherwise, returns without calling the listeners' methods. - + method, like the method, is intended for automated tools, but it also allows the attaching of additional objects, such as an exception instance and a stack trace, to the trace. + + The method calls the method of the object returned by the property. If returns `true`, calls the corresponding method on all listeners. Otherwise, returns without calling the listeners' methods. + > [!NOTE] -> The object is limited to a maximum `id` value of 65,535. If the `id` value specified is greater than 65,535, the object uses 65,535. - +> The object is limited to a maximum `id` value of 65,535. If the `id` value specified is greater than 65,535, the object uses 65,535. + ]]> An attempt was made to trace an event during finalization. @@ -973,26 +972,26 @@ You can refer to the trace source by using the `name` attribute in the configura A numeric identifier for the event. Writes a trace event message to the trace listeners in the collection using the specified event type and event identifier. - method is intended to trace events that can be processed automatically by tools. For example, a monitoring tool can notify an administrator if a specific event is traced by a specific source. - - The method calls the method of the object returned by the property. If returns `true`, calls the corresponding method of each listener. Otherwise, returns without calling the listeners' methods. - - The trace content is listener specific. If the method is not overridden by the listener implementation, the default output is the name of the trace source, its numeric identity, and the event type. Additional trace content is dependent upon the listener's property value. - + method is intended to trace events that can be processed automatically by tools. For example, a monitoring tool can notify an administrator if a specific event is traced by a specific source. + + The method calls the method of the object returned by the property. If returns `true`, calls the corresponding method of each listener. Otherwise, returns without calling the listeners' methods. + + The trace content is listener specific. If the method is not overridden by the listener implementation, the default output is the name of the trace source, its numeric identity, and the event type. Additional trace content is dependent upon the listener's property value. + > [!NOTE] -> The object is limited to a maximum `id` value of 65,535. If the `id` value specified is greater than 65,535, the uses 65,535. - - - -## Examples - The following code example shows the use of the method to pass a trace event to the listeners. This code example is part of a larger example provided for the class. - +> The object is limited to a maximum `id` value of 65,535. If the `id` value specified is greater than 65,535, the uses 65,535. + + + +## Examples + The following code example shows the use of the method to pass a trace event to the listeners. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SwitchAttribute/Overview/program.cs" id="Snippet17"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet17"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet17"::: + ]]> An attempt was made to trace an event during finalization. @@ -1051,26 +1050,26 @@ You can refer to the trace source by using the `name` attribute in the configura The trace message to write. Writes a trace event message to the trace listeners in the collection using the specified event type, event identifier, and message. - method is intended to trace events that can be processed automatically by tools. For example, a monitoring tool can notify an administrator if a specific event is traced by a specific source. - - The method calls the method of the object returned by the property. If returns `true`, calls the corresponding method of each listener. Otherwise, returns without calling the listeners' methods. - - The trace content is listener specific. If the method is not overridden by the listener implementation, the default output is the name of the trace source, its numeric identity, the event type, and the message. Additional trace content is dependent upon the listener's property value. - + method is intended to trace events that can be processed automatically by tools. For example, a monitoring tool can notify an administrator if a specific event is traced by a specific source. + + The method calls the method of the object returned by the property. If returns `true`, calls the corresponding method of each listener. Otherwise, returns without calling the listeners' methods. + + The trace content is listener specific. If the method is not overridden by the listener implementation, the default output is the name of the trace source, its numeric identity, the event type, and the message. Additional trace content is dependent upon the listener's property value. + > [!NOTE] -> The object is limited to a maximum `id` value of 65,535. If the `id` value specified is greater than 65,535, the object uses 65,535. - - - -## Examples - The following code example shows the use of the method to pass a trace event to the listeners. This code example is part of a larger example provided for the class. - +> The object is limited to a maximum `id` value of 65,535. If the `id` value specified is greater than 65,535, the object uses 65,535. + + + +## Examples + The following code example shows the use of the method to pass a trace event to the listeners. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SwitchAttribute/Overview/program.cs" id="Snippet18"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet18"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet18"::: + ]]> An attempt was made to trace an event during finalization. @@ -1146,37 +1145,37 @@ You can refer to the trace source by using the `name` attribute in the configura An array containing zero or more objects to format. Writes a trace event to the trace listeners in the collection using the specified event type, event identifier, and argument array and format. - method is intended to trace events that can be processed automatically by tools. For example, a monitoring tool can notify an administrator if a specific event is traced by a specific source. - - The method calls the method of the object returned by the property. If returns `true`, calls the corresponding method of each listener. Otherwise, returns without calling the listeners' methods. - - The trace content is listener specific. The default method writes the source name, event type, and numeric identity in the trace header, then calls the method, passing the `format` string and `args` array and using the property to format the string as the message output. - + method is intended to trace events that can be processed automatically by tools. For example, a monitoring tool can notify an administrator if a specific event is traced by a specific source. + + The method calls the method of the object returned by the property. If returns `true`, calls the corresponding method of each listener. Otherwise, returns without calling the listeners' methods. + + The trace content is listener specific. The default method writes the source name, event type, and numeric identity in the trace header, then calls the method, passing the `format` string and `args` array and using the property to format the string as the message output. + > [!NOTE] -> The object is limited to a maximum `id` value of 65,535. If the `id` value specified is greater than 65,535, the object uses 65,535. - - - -## Examples - The following code example shows the use of the method to pass a trace event to the listeners. This code example is part of a larger example provided for the class. - +> The object is limited to a maximum `id` value of 65,535. If the `id` value specified is greater than 65,535, the object uses 65,535. + + + +## Examples + The following code example shows the use of the method to pass a trace event to the listeners. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/SwitchAttribute/Overview/program.cs" id="Snippet24"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet24"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Diagnostics.TraceSource2/VB/program.vb" id="Snippet24"::: + ]]> is . - is invalid. - - -or- - + is invalid. + + -or- + The number that indicates an argument to format is less than zero, or greater than or equal to the number of specified objects to format. An attempt was made to trace an event during finalization. Composite Formatting @@ -1251,13 +1250,13 @@ You can refer to the trace source by using the `name` attribute in the configura The informative message to write. Writes an informational message to the trace listeners in the collection using the specified message. - method provides an informational message intended to be read by users and not by tools. - - calls the method, setting `eventType` to and passing the informative message as the message string. The method in turn calls the method of each trace listener. - + method provides an informational message intended to be read by users and not by tools. + + calls the method, setting `eventType` to and passing the informative message as the message string. The method in turn calls the method of each trace listener. + ]]> An attempt was made to trace an event during finalization. @@ -1333,24 +1332,24 @@ You can refer to the trace source by using the `name` attribute in the configura An array containing zero or more objects to format. Writes an informational message to the trace listeners in the collection using the specified object array and formatting information. - method provides an informational message intended to be read by users and not by tools. - - calls the method, setting `eventType` to and passing the message content as an object array with formatting information. The method in turn calls the method of each trace listener. - + method provides an informational message intended to be read by users and not by tools. + + calls the method, setting `eventType` to and passing the message content as an object array with formatting information. The method in turn calls the method of each trace listener. + ]]> is . - is invalid. - - -or- - + is invalid. + + -or- + The number that indicates an argument to format is less than zero, or greater than or equal to the number of specified objects to format. An attempt was made to trace an event during finalization. Composite Formatting @@ -1414,13 +1413,13 @@ You can refer to the trace source by using the `name` attribute in the configura A structure that identifies the related activity. Writes a trace transfer message to the trace listeners in the collection using the specified numeric identifier, message, and related activity identifier. - method calls the method of each trace listener in the property to write the trace information. The default method in the base class calls the method to process the call, setting `eventType` to and appending a string representation of the `relatedActivityId` GUID to `message`. - - is intended to be used with the logical operations of a . The `relatedActivityId` parameter relates to the property of a object. If a logical operation begins in one activity and transfers to another, the second activity logs the transfer by calling the method. The call relates the new activity identity to the previous identity. The most likely consumer of this functionality is a trace viewer that can report logical operations that span multiple activities. - + method calls the method of each trace listener in the property to write the trace information. The default method in the base class calls the method to process the call, setting `eventType` to and appending a string representation of the `relatedActivityId` GUID to `message`. + + is intended to be used with the logical operations of a . The `relatedActivityId` parameter relates to the property of a object. If a logical operation begins in one activity and transfers to another, the second activity logs the transfer by calling the method. The call relates the new activity identity to the previous identity. The most likely consumer of this functionality is a trace viewer that can report logical operations that span multiple activities. + ]]> diff --git a/xml/System.Diagnostics/TraceSwitch.xml b/xml/System.Diagnostics/TraceSwitch.xml index cb4f256641c..f9422b920fd 100644 --- a/xml/System.Diagnostics/TraceSwitch.xml +++ b/xml/System.Diagnostics/TraceSwitch.xml @@ -55,61 +55,59 @@ Provides a multilevel switch to control tracing and debug output without recompiling your code. - class provides the , , , and properties to test the level of the switch. The property gets or sets the switch's . You can create a in your code and set the level directly to instrument a specific section of code. -In .NET Framework apps only, you can also set the level of a through the application configuration file and then use the configured level in your application. In the application configuration file, you can add or remove a switch, set a switch's value, or clear all the switches previously set by the application. The configuration file should be formatted like the following example: - -```xml - - - - - - - -``` - - This configuration section defines a with the set to `mySwitch`, and the set to 1, which corresponds to the enumeration value . - +In .NET Framework apps only, you can also set the level of a through the application configuration file and then use the configured level in your application. In the application configuration file, you can add or remove a switch, set a switch's value, or clear all the switches previously set by the application. The configuration file should be formatted like the following example: + +```xml + + + + + + + +``` + + This configuration section defines a with the set to `mySwitch`, and the set to 1, which corresponds to the enumeration value . + > [!NOTE] -> You can also use text to specify the value for a switch. For example, `true` for a , or the text representing an enumeration value, such as `Error` for a . The line `` is equivalent to ``. - - In your application, you can use the configured switch level by creating a with the same name, as shown in the following example: +> You can also use text to specify the value for a switch. For example, `true` for a , or the text representing an enumeration value, such as `Error` for a . The line `` is equivalent to ``. + + In your application, you can use the configured switch level by creating a with the same name, as shown in the following example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/remarks.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceSwitch/Overview/remarks.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/remarks.vb" id="Snippet3"::: In .NET Core and .NET 5+ apps, the of the new switch defaults to . In .NET Framework apps, the switch property defaults to the value specified in the configuration file. If the constructor cannot find initial switch settings in the configuration file, of the new switch defaults to . - - You must enable tracing or debugging to use a switch. The following syntax is compiler specific. If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler. - -- To enable debugging in C#, add the `/d:DEBUG` flag to the compiler command line when you compile your code, or add `#define DEBUG` to the top of your file. In Visual Basic, add the `/d:DEBUG=True` flag to the compiler command line. - -- To enable tracing in C#, add the `/d:TRACE` flag to the compiler command line when you compile your code, or add `#define TRACE` to the top of your file. In Visual Basic, add the `/d:TRACE=True` flag to the compiler command line. - + + You must enable tracing or debugging to use a switch. The following syntax is compiler specific. If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler. + +- To enable debugging in C#, add the `/d:DEBUG` flag to the compiler command line when you compile your code, or add `#define DEBUG` to the top of your file. In Visual Basic, add the `/d:DEBUG=True` flag to the compiler command line. + +- To enable tracing in C#, add the `/d:TRACE` flag to the compiler command line when you compile your code, or add `#define TRACE` to the top of your file. In Visual Basic, add the `/d:TRACE=True` flag to the compiler command line. + > [!NOTE] -> These debug and trace compiler switches are not required when using the class in isolation. They are only required in conjunction with or methods that are conditionally compiled. - - For more information on instrumenting your application, see and . For more information about configuring and using trace switches, see [Trace Switches](/dotnet/framework/debug-trace-profile/trace-switches). - +> These debug and trace compiler switches are not required when using the class in isolation. They are only required in conjunction with or methods that are conditionally compiled. + + For more information on instrumenting your application, see and . For more information about configuring and using trace switches, see [Trace Switches](/dotnet/framework/debug-trace-profile/trace-switches). + > [!NOTE] > To improve performance, you can make members `static` in your class. - -## Examples - The following code example creates a new and uses the switch to determine whether to print error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message if the is less than . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following code example creates a new and uses the switch to determine whether to print error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message if the is less than . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceSwitch/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -185,44 +183,42 @@ In .NET Framework apps, the switch The description of the switch. Initializes a new instance of the class, using the specified display name and description. - , edit the configuration file that corresponds to the name of your application. In this file, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. The configuration file should be formatted like the following example: + +```xml + + + + + + + +``` + +You can also use text to specify the value for a switch. For example, `true` for a or the text representing an enumeration value, such as `Error` for a . The line `` is equivalent to ``. + + In your application, you can use the configured switch level by creating a with the same name, as shown in the following example: -For .NET Framework apps, to set the level of your , edit the configuration file that corresponds to the name of your application. In this file, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. The configuration file should be formatted like the following example: - -```xml - - - - - - - -``` - -You can also use text to specify the value for a switch. For example, `true` for a or the text representing an enumeration value, such as `Error` for a . The line `` is equivalent to ``. - - In your application, you can use the configured switch level by creating a with the same name, as shown in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/remarks.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceSwitch/Overview/remarks.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/remarks.vb" id="Snippet3"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/remarks.vb" id="Snippet3"::: This constructor sets the property of the new switch to . Or, for .NET Framework apps, the switch settings are obtained from the configuration file, if available. - - The class provides the , , , and properties to test the of the switch. The property gets or sets the switch's . - + + The class provides the , , , and properties to test the of the switch. The property gets or sets the switch's . + > [!NOTE] > To improve performance, you can make members `static` in your class. - -## Examples - The following code example creates a new and uses the switch to determine whether to print error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message if the is less than . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following code example creates a new and uses the switch to determine whether to print error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message if the is less than . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceSwitch/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -289,11 +285,11 @@ This constructor sets the property o The default value of the switch. Initializes a new instance of the class, using the specified display name, description, and default value for the switch. - property, the `description` parameter is use to set the value of the property, and the `defaultSwitchValue` parameter is saved as a field and used to initialize the property on first reference. See the constructor for more information and a code example. - + property, the `description` parameter is use to set the value of the property, and the `defaultSwitchValue` parameter is saved as a field and used to initialize the property on first reference. See the constructor for more information and a code example. + ]]> @@ -338,38 +334,37 @@ This constructor sets the property o Gets or sets the trace level that determines the messages the switch allows. One of the values that specifies the level of messages that are allowed by the switch. - , edit the configuration file that corresponds to the name of your application. In this file, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. The configuration file should be formatted like the following example: + +```xml + + + + + + + + + + +``` + +You can also use text to specify the value for a switch. For example, `true` for a or the text representing an enumeration value, such as `Error` for a . The line `` is equivalent to ``. + +The default value of the property is . Or, for .NET Framework apps, the level is obtained from the configuration file, if available. -For .NET Framework apps, to set the level of your , edit the configuration file that corresponds to the name of your application. In this file, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. The configuration file should be formatted like the following example: - -```xml - - - - - - - - - - -``` - -You can also use text to specify the value for a switch. For example, `true` for a or the text representing an enumeration value, such as `Error` for a . The line `` is equivalent to ``. - -The default value of the property is . Or, for .NET Framework apps, the level is obtained from the configuration file, if available. - Setting this property updates the , , , and properties to reflect the new value. - -## Examples - The following code example creates a new and uses the switch to determine whether to print error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message if the is less than . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.Level Example/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following code example creates a new and uses the switch to determine whether to print error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message if the is less than . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceSwitch/Level/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.Level Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.Level Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -421,13 +416,13 @@ The default value of the property is Updates and corrects the level for this switch. - method is used by the .NET framework to validate and correct the value of a switch initialized via a configuration file. A message is written to all trace listeners if the switch value specified in the configuration file is not defined by the enumeration and the switch is set to a defined value. - - If you attempt in your code to set the property to a value that is not defined by the enumeration, an exception is thrown. - + method is used by the .NET framework to validate and correct the value of a switch initialized via a configuration file. A message is written to all trace listeners if the switch value specified in the configuration file is not defined by the enumeration and the switch is set to a defined value. + + If you attempt in your code to set the property to a value that is not defined by the enumeration, an exception is thrown. + ]]> @@ -475,11 +470,11 @@ The default value of the property is Sets the property to the integer equivalent of the property. - property of the switch changes. The method ensures that the properties relating to the switch's value reflect the new value. - + property of the switch changes. The method ensures that the properties relating to the switch's value reflect the new value. + ]]> @@ -528,20 +523,19 @@ The default value of the property is if the property is set to , , , or ; otherwise, . - , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to the highest importance, , , only error-handling messages are emitted. - - - -## Examples - The following code example creates a new and uses the switch to determine whether to emit error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message if the is less than . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp" id="Snippet1"::: + , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to the highest importance, , , only error-handling messages are emitted. + + + +## Examples + The following code example creates a new and uses the switch to determine whether to emit error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message if the is less than . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceSwitch/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -592,20 +586,19 @@ The default value of the property is if the property is set to or ; otherwise, . - , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to , informational messages, warnings, and error-handling messages are emitted. - - - -## Examples - The following code example creates a new and uses the switch to determine whether to emit error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message if the is less than . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceInfo Example/CPP/source.cpp" id="Snippet1"::: + , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to , informational messages, warnings, and error-handling messages are emitted. + + + +## Examples + The following code example creates a new and uses the switch to determine whether to emit error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message if the is less than . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceSwitch/TraceInfo/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceInfo Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceInfo Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -656,20 +649,19 @@ The default value of the property is if the property is set to ; otherwise, . - , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to , all debugging and tracing messages are transmitted. - - - -## Examples - The following code example creates a new and uses the switch to determine whether to emit error messages. The switch is created at the class level. `MyMethod` writes both error messages when the property is set to . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/CPP/source.cpp" id="Snippet1"::: + , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to , all debugging and tracing messages are transmitted. + + + +## Examples + The following code example creates a new and uses the switch to determine whether to emit error messages. The switch is created at the class level. `MyMethod` writes both error messages when the property is set to . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceSwitch/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceError Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -720,20 +712,19 @@ The default value of the property is if the property is set to , , or ; otherwise, . - , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to , warnings and error-handling messages are emitted. - - - -## Examples - The following code example creates a new and uses the switch to determine whether to emit error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message when the is less than . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceWarning Example/CPP/source.cpp" id="Snippet1"::: + , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to , warnings and error-handling messages are emitted. + + + +## Examples + The following code example creates a new and uses the switch to determine whether to emit error messages. The switch is created at the class level. `MyMethod` writes the first error message if the property is set to or higher. However, `MyMethod` does not write the second error message when the is less than . + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/TraceSwitch/TraceWarning/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceWarning Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TraceSwitch.TraceWarning Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.DirectoryServices/PropertyCollection.xml b/xml/System.DirectoryServices/PropertyCollection.xml index 64ff2eb97d6..954d7851e23 100644 --- a/xml/System.DirectoryServices/PropertyCollection.xml +++ b/xml/System.DirectoryServices/PropertyCollection.xml @@ -471,7 +471,6 @@ Dim myCollection As New ICollection() ## Examples The following example shows how to implement the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet9"::: @@ -520,7 +519,6 @@ Dim myCollection As New ICollection() ## Examples The following example demonstrates how to implement the method. This example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet8"::: @@ -566,7 +564,6 @@ Dim myCollection As New ICollection() ## Examples The following example demonstrates how to implement the method. This example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet5"::: @@ -615,7 +612,6 @@ Dim myCollection As New ICollection() ## Examples The following example demonstrates how to implement the property. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet6"::: @@ -660,7 +656,6 @@ Dim myCollection As New ICollection() ## Examples The following example shows how to implement the property. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet4"::: @@ -717,7 +712,6 @@ Dim myCollection As New ICollection() ## Examples The following example shows how to implement the property. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet13"::: @@ -769,7 +763,6 @@ Dim myCollection As New ICollection() ## Examples The following example shows how to implement the property. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet10"::: @@ -813,7 +806,6 @@ Dim myCollection As New ICollection() ## Examples The following example shows how to implement the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dictionary/cpp/Dictionary.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Collections/DictionaryEntry/Key/Dictionary.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dictionary/VB/Dictionary.vb" id="Snippet7"::: diff --git a/xml/System.Globalization/Calendar.xml b/xml/System.Globalization/Calendar.xml index 0c842bcb7d5..7d7e918487d 100644 --- a/xml/System.Globalization/Calendar.xml +++ b/xml/System.Globalization/Calendar.xml @@ -139,7 +139,6 @@ ## Examples The following code example demonstrates the members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -210,7 +209,6 @@ ## Examples The following example demonstrates the members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -288,7 +286,6 @@ ## Examples The following code example demonstrates the members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -374,7 +371,6 @@ ## Examples The following code example demonstrates the members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -460,7 +456,6 @@ ## Examples The following code example demonstrates the members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -546,7 +541,6 @@ ## Examples The following code example demonstrates the members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -636,7 +630,6 @@ ## Examples The following code example demonstrates the members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -722,7 +715,6 @@ ## Examples The following code example demonstrates the members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -810,7 +802,6 @@ ## Examples The following code example demonstrates the members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -900,7 +891,6 @@ ## Examples The following code example demonstrates the members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -1202,7 +1192,6 @@ The and when the Heisei era (1989-2019) was the current era. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/CPP/yslin_japanesecalendar_eras.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Eras/yslin_japanesecalendar_eras.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/VB/yslin_japanesecalendar_eras.vb" id="Snippet1"::: @@ -1264,7 +1253,6 @@ The and class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -1341,7 +1329,6 @@ The and class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -1419,7 +1406,6 @@ The and class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -1508,7 +1494,6 @@ The and class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetDaysInMonth/calendar_compare.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/VB/calendar_compare.vb" id="Snippet1"::: @@ -1672,7 +1657,6 @@ The and class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetDaysInMonth/calendar_compare.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/VB/calendar_compare.vb" id="Snippet1"::: @@ -1814,7 +1798,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -1888,7 +1871,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -2102,7 +2084,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -2174,7 +2155,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -2251,7 +2231,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -2338,7 +2317,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetDaysInMonth/calendar_compare.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/VB/calendar_compare.vb" id="Snippet1"::: @@ -2475,7 +2453,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -2594,7 +2571,6 @@ 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 language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetWeekOfYear/yslin_calendar_getweekofyear.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb" id="Snippet1"::: @@ -2678,7 +2654,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar/CPP/calendar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Overview/calendar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar/VB/calendar.vb" id="Snippet1"::: @@ -2772,7 +2747,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetDaysInMonth/calendar_compare.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/VB/calendar_compare.vb" id="Snippet1"::: @@ -2956,7 +2930,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetDaysInMonth/calendar_compare.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/VB/calendar_compare.vb" id="Snippet1"::: @@ -3124,7 +3097,6 @@ Only the and the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/CPP/calendar_compare.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetDaysInMonth/calendar_compare.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar_Compare/VB/calendar_compare.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/CalendarAlgorithmType.xml b/xml/System.Globalization/CalendarAlgorithmType.xml index 04f7b00d181..5a84f00194a 100644 --- a/xml/System.Globalization/CalendarAlgorithmType.xml +++ b/xml/System.Globalization/CalendarAlgorithmType.xml @@ -48,22 +48,21 @@ Specifies whether a calendar is solar-based, lunar-based, or lunisolar-based. - , , and classes are solar-based, the and classes are lunar-based,.and the and classes are lunisolar-based, thus using solar calculations for the year and lunar calculations for the month and day. + + A value, which is returned by a calendar member such as the property, specifies the foundation for a particular calendar. + + + +## Examples + The following code example demonstrates the property and the enumeration. -## Remarks - A date calculation for a particular calendar depends on whether the calendar is solar-based, lunar-based, or lunisolar-based. For example, the , , and classes are solar-based, the and classes are lunar-based,.and the and classes are lunisolar-based, thus using solar calculations for the year and lunar calculations for the month and day. - - A value, which is returned by a calendar member such as the property, specifies the foundation for a particular calendar. - - - -## Examples - The following code example demonstrates the property and the enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.calendartype/CPP/caltype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CalendarAlgorithmType/Overview/caltype.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.calendartype/VB/caltype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.calendartype/VB/caltype.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Globalization/CharUnicodeInfo.xml b/xml/System.Globalization/CharUnicodeInfo.xml index a1aea2b0953..d2d6c54393d 100644 --- a/xml/System.Globalization/CharUnicodeInfo.xml +++ b/xml/System.Globalization/CharUnicodeInfo.xml @@ -102,7 +102,6 @@ When using this class in your applications, keep in mind the following programmi ## Examples The following code example shows the values returned by each method for different types of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CharUnicodeInfo/Overview/charunicodeinfo_char.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/VB/charunicodeinfo_char.vb" id="Snippet1"::: @@ -198,7 +197,6 @@ Each version of the Unicode standard includes information on changes to the Unic ## Examples The following code example shows the values returned by each method for different types of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CharUnicodeInfo/Overview/charunicodeinfo_char.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/VB/charunicodeinfo_char.vb" id="Snippet1"::: @@ -269,7 +267,6 @@ Each version of the Unicode standard includes information on changes to the Unic ## Examples The following code example shows the values returned by each method for different types of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/CPP/charunicodeinfo_string.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CharUnicodeInfo/GetDecimalDigitValue/charunicodeinfo_string.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/VB/charunicodeinfo_string.vb" id="Snippet1"::: @@ -352,7 +349,6 @@ Each version of the Unicode standard includes information on changes to the Unic ## Examples The following code example shows the values returned by each method for different types of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CharUnicodeInfo/Overview/charunicodeinfo_char.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/VB/charunicodeinfo_char.vb" id="Snippet1"::: @@ -423,7 +419,6 @@ Each version of the Unicode standard includes information on changes to the Unic ## Examples The following code example shows the values returned by each method for different types of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/CPP/charunicodeinfo_string.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CharUnicodeInfo/GetDecimalDigitValue/charunicodeinfo_string.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/VB/charunicodeinfo_string.vb" id="Snippet1"::: @@ -517,7 +512,6 @@ Each version of the Unicode standard includes information on changes to the Unic ## Examples The following code example shows the values returned by each method for different types of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CharUnicodeInfo/Overview/charunicodeinfo_char.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/VB/charunicodeinfo_char.vb" id="Snippet1"::: @@ -599,7 +593,6 @@ Each version of the Unicode standard includes information on changes to the Unic ## Examples The following code example shows the values returned by each method for different types of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/CPP/charunicodeinfo_string.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CharUnicodeInfo/GetDecimalDigitValue/charunicodeinfo_string.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/VB/charunicodeinfo_string.vb" id="Snippet1"::: @@ -691,7 +684,6 @@ Each version of the Unicode standard includes information on changes to the Unic ## Examples The following code example shows the values returned by each method for different types of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/CPP/charunicodeinfo_char.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CharUnicodeInfo/Overview/charunicodeinfo_char.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_Char/VB/charunicodeinfo_char.vb" id="Snippet1"::: @@ -814,7 +806,6 @@ Each version of the Unicode standard includes information on changes to the Unic ## Examples The following code example shows the values returned by each method for different types of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/CPP/charunicodeinfo_string.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CharUnicodeInfo/GetDecimalDigitValue/charunicodeinfo_string.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CharUnicodeInfo_String/VB/charunicodeinfo_string.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/CompareInfo.xml b/xml/System.Globalization/CompareInfo.xml index 8437963362c..c4bafbcadb2 100644 --- a/xml/System.Globalization/CompareInfo.xml +++ b/xml/System.Globalization/CompareInfo.xml @@ -97,7 +97,6 @@ The following example shows how the object associated with a object affects string comparison. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Overview/CompareInfo.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompareInfo/VB/CompareInfo.vb" id="Snippet1"::: @@ -206,13 +205,11 @@ - object associated with the Spanish (Spain) culture with traditional sort - object associated with the - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/CPP/comparestrstr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Compare/comparestrstr.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/VB/comparestrstr.vb" id="Snippet1"::: The following example demonstrates calling the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Overview/CompareInfo.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompareInfo/VB/CompareInfo.vb" id="Snippet1"::: @@ -366,13 +363,11 @@ ## Examples The following example compares two strings using different settings. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStrOpt/CPP/comparestrstropt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Compare/comparestrstropt.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStrOpt/VB/comparestrstropt.vb" id="Snippet1"::: The following example demonstrates calling the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Overview/CompareInfo.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompareInfo/VB/CompareInfo.vb" id="Snippet1"::: @@ -483,7 +478,6 @@ - object associated with the - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrInt/CPP/comparestrintstrint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Compare/comparestrintstrint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrInt/VB/comparestrintstrint.vb" id="Snippet1"::: @@ -597,7 +591,6 @@ ## Examples The following example compares portions of two strings using different settings. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrIntOpt/CPP/comparestrintstrintopt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Compare/comparestrintstrintopt.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntStrIntOpt/VB/comparestrintstrintopt.vb" id="Snippet1"::: @@ -722,7 +715,6 @@ - object associated with the - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntInt/CPP/comparestrintintstrintint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Compare/comparestrintintstrintint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntInt/VB/comparestrintintstrintint.vb" id="Snippet1"::: @@ -854,7 +846,6 @@ ## Examples The following example compares portions of two strings using different settings. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntIntOpt/CPP/comparestrintintstrintintopt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Compare/comparestrintintstrintintopt.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrIntIntStrIntIntOpt/VB/comparestrintintstrintintopt.vb" id="Snippet1"::: @@ -1024,7 +1015,6 @@ - object associated with the - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/CPP/comparestrstr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Compare/comparestrstr.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/VB/comparestrstr.vb" id="Snippet1"::: @@ -1097,7 +1087,6 @@ - object associated with the - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/CPP/comparestrstr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Compare/comparestrstr.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.CompareStrStr/VB/comparestrstr.vb" id="Snippet1"::: @@ -1761,7 +1750,6 @@ Use and are searching in different portions of the string, even with the same `startIndex` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/IndexOf/indexofint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/VB/indexofint.vb" id="Snippet1"::: @@ -2215,7 +2200,6 @@ Use and are searching in different portions of the string, even with the same `startIndex` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/IndexOf/indexofint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/VB/indexofint.vb" id="Snippet1"::: @@ -2465,7 +2448,6 @@ This method has greater overhead than other and are searching in different portions of the string, even with the same `startIndex` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/IndexOf/indexofint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/VB/indexofint.vb" id="Snippet1"::: @@ -2561,7 +2543,6 @@ This method has greater overhead than other and are searching in different portions of the string, even with the same `startIndex` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/IndexOf/indexofint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/VB/indexofint.vb" id="Snippet1"::: @@ -2766,7 +2746,6 @@ This method has greater overhead than other . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffixOpt/CPP/isprefixsuffixopt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/IsPrefix/isprefixsuffixopt.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffixOpt/VB/isprefixsuffixopt.vb" id="Snippet1"::: @@ -3622,7 +3597,6 @@ This method has greater overhead than other . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffixOpt/CPP/isprefixsuffixopt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/IsPrefix/isprefixsuffixopt.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IsPrefixSuffixOpt/VB/isprefixsuffixopt.vb" id="Snippet1"::: @@ -3915,7 +3888,6 @@ This method has greater overhead than other and are searching in different portions of the string, even with the same `startIndex` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/IndexOf/indexofint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/VB/indexofint.vb" id="Snippet1"::: @@ -4380,7 +4349,6 @@ This method has greater overhead than other and are searching in different portions of the string, even with the same `startIndex` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/IndexOf/indexofint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/VB/indexofint.vb" id="Snippet1"::: @@ -4628,7 +4595,6 @@ This method has greater overhead than other and are searching in different portions of the string, even with the same `startIndex` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/IndexOf/indexofint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/VB/indexofint.vb" id="Snippet1"::: @@ -4724,7 +4690,6 @@ This method has greater overhead than other and are searching in different portions of the string, even with the same `startIndex` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/CPP/indexofint.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/IndexOf/indexofint.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareInfo.IndexOfInt/VB/indexofint.vb" id="Snippet1"::: @@ -4929,7 +4893,6 @@ This method has greater overhead than other property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Overview/CompareInfo.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompareInfo/VB/CompareInfo.vb" id="Snippet1"::: @@ -5312,7 +5272,6 @@ This method has greater overhead than other property is used to display the name of each culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompareInfo/cpp/CompareInfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareInfo/Overview/CompareInfo.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompareInfo/VB/CompareInfo.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/CultureAndRegionInfoBuilder.xml b/xml/System.Globalization/CultureAndRegionInfoBuilder.xml index 6866c6cb222..f011368654d 100644 --- a/xml/System.Globalization/CultureAndRegionInfoBuilder.xml +++ b/xml/System.Globalization/CultureAndRegionInfoBuilder.xml @@ -66,7 +66,6 @@ @@ -333,7 +332,6 @@ The following code example creates a custom culture with a private use prefix, t ## Examples The following code example creates a custom culture with a private use prefix, then lists a set of its properties. The first property lists the name of the culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.carib1/CPP/carib.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureAndRegionInfoBuilder/.ctor/carib.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.carib1/VB/carib.vb" id="Snippet1"::: @@ -375,7 +373,6 @@ The following code example creates a custom culture with a private use prefix, t ## Examples The following code example creates a custom culture with a private use prefix, then lists a set of its properties. The first property lists the name of the culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.carib1/CPP/carib.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureAndRegionInfoBuilder/.ctor/carib.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.carib1/VB/carib.vb" id="Snippet1"::: @@ -417,7 +414,6 @@ The following code example creates a custom culture with a private use prefix, t ## Examples The following code example creates a custom culture with a private use prefix, then lists a set of its properties. The first property lists the name of the culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.carib1/CPP/carib.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureAndRegionInfoBuilder/.ctor/carib.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.carib1/VB/carib.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/CultureAndRegionModifiers.xml b/xml/System.Globalization/CultureAndRegionModifiers.xml index 9a03452d218..87e5a584266 100644 --- a/xml/System.Globalization/CultureAndRegionModifiers.xml +++ b/xml/System.Globalization/CultureAndRegionModifiers.xml @@ -22,35 +22,34 @@ Specifies constants that define a object. - values as an argument to the constructor. You use the resulting object to create a custom culture. - - A custom culture can have a combination of these characteristics: - -- A custom culture can be a specific culture or a neutral culture. - - A specific culture specifies a language and a region, while a neutral culture specifies a language but no region. - -- A custom culture can be a replacement culture or a supplemental culture. - - A replacement culture replaces a culture that ships with the .NET Framework or a locale that ships with Windows. - - A supplemental culture is anything other than a replacement culture. A supplemental culture can be entirely new, or can extend an existing .NET Framework culture or Windows locale. - + values as an argument to the constructor. You use the resulting object to create a custom culture. + + A custom culture can have a combination of these characteristics: + +- A custom culture can be a specific culture or a neutral culture. + + A specific culture specifies a language and a region, while a neutral culture specifies a language but no region. + +- A custom culture can be a replacement culture or a supplemental culture. + + A replacement culture replaces a culture that ships with the .NET Framework or a locale that ships with Windows. + + A supplemental culture is anything other than a replacement culture. A supplemental culture can be entirely new, or can extend an existing .NET Framework culture or Windows locale. + > [!IMPORTANT] -> Note that the enumeration is found in an assembly named sysglobl.dll. Successfully compiling code that uses this type requires that you add a reference to sysglobl.dll. - - +> Note that the enumeration is found in an assembly named sysglobl.dll. Successfully compiling code that uses this type requires that you add a reference to sysglobl.dll. + + + +## Examples + The following code example creates a custom culture with a private use prefix, then lists a set of its properties. The first property is the name of the culture. -## Examples - The following code example creates a custom culture with a private use prefix, then lists a set of its properties. The first property is the name of the culture. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.carib1/CPP/carib.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureAndRegionInfoBuilder/.ctor/carib.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.carib1/VB/carib.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.carib1/VB/carib.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Globalization/CultureInfo.xml b/xml/System.Globalization/CultureInfo.xml index 51142c64115..b438608fc5f 100644 --- a/xml/System.Globalization/CultureInfo.xml +++ b/xml/System.Globalization/CultureInfo.xml @@ -97,7 +97,6 @@ The following example shows how to create a object for Spanish (Spain) with the international sort and another object with the traditional sort. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/Overview/spanishspain.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/VB/spanishspain.vb" id="Snippet1"::: @@ -677,7 +676,6 @@ If `name` is , the constr ## Examples The following code example shows that CultureInfo.Clone also clones the and instances associated with the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/Clone/yslin_cultureinfo_clone.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/VB/yslin_cultureinfo_clone.vb" id="Snippet1"::: @@ -742,7 +740,6 @@ If `name` is , the constr ## Examples The following code example shows how to create a for Spanish (Spain) with the international sort and another with the traditional sort. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/Overview/spanishspain.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/VB/spanishspain.vb" id="Snippet1"::: @@ -968,7 +965,6 @@ If `name` is , the constr and of the current thread. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CPP/currentculture.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/currentculture.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/VB/currentculture.vb" id="Snippet11"::: ]]> @@ -1042,7 +1038,6 @@ The following example demonstrates how to change the and of the current thread. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/CPP/currentculture.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/CurrentCulture/currentculture.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.CurrentCulture2/VB/currentculture.vb" id="Snippet11"::: ]]> @@ -1120,7 +1115,6 @@ You might choose to override some of the values associated with the current cult and instances associated with the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/Clone/yslin_cultureinfo_clone.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/VB/yslin_cultureinfo_clone.vb" id="Snippet1"::: ]]> @@ -1425,7 +1419,6 @@ csc /resource:GreetingStrings.resources Example1.cs > [!NOTE] > The example displays the `zh-CHS` and `zh-CHT` cultures with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the `zh-Hans` name instead of `zh-CHS` and the `zh-Hant` name instead of zh-CHT. The `zh-Hans` and `zh-Hant` names represent the current standard, and should be used unless you have a reason for using the older names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/DisplayName/getcultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb" id="Snippet1"::: @@ -1504,7 +1497,6 @@ csc /resource:GreetingStrings.resources Example1.cs > [!NOTE] > The example displays the older `zh-CHS` and `zh-CHT` culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the `zh-Hans` name instead of `zh-CHS` and the `zh-Hant` name instead of zh-CHT. The `zh-Hans` and `zh-Hant` names represent the current standard, and should be used unless you have a reason for using the older names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/DisplayName/getcultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb" id="Snippet1"::: @@ -1741,7 +1733,6 @@ csc /resource:GreetingStrings.resources Example1.cs ## Examples The following code example displays the fallback user interface culture associated with a culture object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.ci.getCFUIC/cpp/cfuic.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/GetConsoleFallbackUICulture/cfuic.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.ci.getCFUIC/VB/cfuic.vb" id="Snippet1"::: @@ -2162,7 +2153,6 @@ Setting `predefinedOnly` to `true` will ensure a culture is created only if the > [!NOTE] > The example displays the `zh-CHS` and `zh-CHT` cultures with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the `zh-Hans` name instead of `zh-CHS` and the `zh-Hant` name instead of zh-CHT. The `zh-Hans` and `zh-Hant` names represent the current standard, and should be used unless you have a reason for using the older names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/DisplayName/getcultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb" id="Snippet1"::: @@ -2559,7 +2549,6 @@ Setting `predefinedOnly` to `true` will ensure a culture is created only if the > [!NOTE] > The example displays the older `zh-CHS` and `zh-CHT` culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the `zh-Hans` name instead of `zh-CHS` and the `zh-Hant` name instead of zh-CHT. The `zh-Hans` and `zh-Hant` names represent the current standard, and should be used unless you have a reason for using the older names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/CPP/neutralculture.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/IsNeutralCulture/neutralculture.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.IsNeutralCulture2/VB/neutralculture.vb" id="Snippet1"::: @@ -2623,7 +2612,6 @@ Setting `predefinedOnly` to `true` will ensure a culture is created only if the ## Examples The following code example shows that also helps protect the and instances associated with the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/CPP/yslin_cultureinfo_readonly.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/IsReadOnly/yslin_cultureinfo_readonly.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/VB/yslin_cultureinfo_readonly.vb" id="Snippet1"::: @@ -2749,7 +2737,6 @@ Setting `predefinedOnly` to `true` will ensure a culture is created only if the ## Examples The following code example shows how to create a for Spanish (Spain) with the international sort order and another with the traditional sort order. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/Overview/spanishspain.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/VB/spanishspain.vb" id="Snippet1"::: @@ -2819,7 +2806,6 @@ For a list of predefined culture names and identifiers that the [!NOTE] > The example displays the older `zh-CHS` and `zh-CHT` culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the `zh-Hans` name instead of `zh-CHS` and the `zh-Hant` name instead of zh-CHT. The `zh-Hans` and `zh-Hant` names represent the current standard, and should be used unless you have a reason for using the older names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/DisplayName/getcultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb" id="Snippet1"::: @@ -2962,7 +2948,6 @@ You might choose to override some of the values associated with the current cult and instances associated with the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/CPP/yslin_cultureinfo_clone.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/Clone/yslin_cultureinfo_clone.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Clone/VB/yslin_cultureinfo_clone.vb" id="Snippet1"::: ]]> @@ -3032,7 +3017,6 @@ The following code example shows that CultureInfo.Clone also clones the versions supported by the culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/CPP/gregoriancalendartypes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/OptionalCalendars/gregoriancalendartypes.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/VB/gregoriancalendartypes.vb" id="Snippet1"::: @@ -3106,7 +3090,6 @@ The following code example shows that CultureInfo.Clone also clones the [!NOTE] > The example displays the older `zh-CHS` and `zh-CHT` culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the `zh-Hans` name instead of `zh-CHS` and the `zh-Hant` name instead of zh-CHT. The `zh-Hans` and `zh-Hant` names represent the current standard, and should be used unless you have a reason for using the older names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Parent/CPP/parentculture.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/Parent/parentculture.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.Parent/VB/parentculture.vb" id="Snippet1"::: @@ -3184,7 +3167,6 @@ The following code example shows that CultureInfo.Clone also clones the method helps protect the and instances associated with the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/CPP/yslin_cultureinfo_readonly.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/IsReadOnly/yslin_cultureinfo_readonly.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.ReadOnly/VB/yslin_cultureinfo_readonly.vb" id="Snippet1"::: @@ -3249,7 +3231,6 @@ The following code example shows that CultureInfo.Clone also clones the for Spanish (Spain) with the international sort order and another with the traditional sort order. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/CPP/spanishspain.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/Overview/spanishspain.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo_esES/VB/spanishspain.vb" id="Snippet1"::: @@ -3322,7 +3303,6 @@ The following code example shows that CultureInfo.Clone also clones the [!NOTE] > The example displays the older `zh-CHS` and `zh-CHT` culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the `zh-Hans` name instead of `zh-CHS` and the `zh-Hant` name instead of zh-CHT. The `zh-Hans` and `zh-Hant` names represent the current standard, and should be used unless you have a reason for using the older names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/DisplayName/getcultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb" id="Snippet1"::: @@ -3400,7 +3380,6 @@ The following code example shows that CultureInfo.Clone also clones the [!NOTE] > The example displays the older `zh-CHS` and `zh-CHT` culture names with the 0x0004 and 0x7C04 culture identifiers, respectively. However, your Windows Vista applications should use the `zh-Hans` name instead of zh-CHS and the `zh-Hant` name instead of zh-CHT. The `zh-Hans` and `zh-Hant` names represent the current standard, and should be used unless you have a reason for using the older names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/DisplayName/getcultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/CultureTypes.xml b/xml/System.Globalization/CultureTypes.xml index 6d0656495f1..faca7081668 100644 --- a/xml/System.Globalization/CultureTypes.xml +++ b/xml/System.Globalization/CultureTypes.xml @@ -89,7 +89,6 @@ The following example demonstrates the `CultureTypes.AllCultures` enumeration me The following example displays several properties of the neutral cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/CPP/getcultures.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/DisplayName/getcultures.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CultureInfo.GetCultures/VB/getcultures.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/DateTimeFormatInfo.xml b/xml/System.Globalization/DateTimeFormatInfo.xml index 2d1a1ac6c80..c2872a7f969 100644 --- a/xml/System.Globalization/DateTimeFormatInfo.xml +++ b/xml/System.Globalization/DateTimeFormatInfo.xml @@ -965,7 +965,6 @@ This property is affected if the value of the for a few cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.FullDateTimePattern/CPP/dtfi_fulldatetimepattern.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/FullDateTimePattern/dtfi_fulldatetimepattern.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.FullDateTimePattern/VB/dtfi_fulldatetimepattern.vb" id="Snippet1"::: @@ -1368,7 +1367,6 @@ This property is affected if the value of the ignores the punctuation in the era name, only if the calendar is Gregorian and the culture uses the era name "A.D.". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/CPP/gregorian_getera.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/GetEra/gregorian_getera.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/VB/gregorian_getera.vb" id="Snippet1"::: @@ -2072,7 +2069,6 @@ This property is affected if the value of the property for a few cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongDatePattern/CPP/dtfi_longdatepattern.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/LongDatePattern/dtfi_longdatepattern.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongDatePattern/VB/dtfi_longdatepattern.vb" id="Snippet1"::: @@ -2148,7 +2144,6 @@ This property is affected if the value of the for a few cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongTimePattern/CPP/dtfi_longtimepattern.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/LongTimePattern/dtfi_longtimepattern.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.LongTimePattern/VB/dtfi_longtimepattern.vb" id="Snippet1"::: @@ -2222,7 +2217,6 @@ This property is affected if the value of the for a few cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.MonthDayPattern/CPP/dtfi_monthdaypattern.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/MonthDayPattern/dtfi_monthdaypattern.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.MonthDayPattern/VB/dtfi_monthdaypattern.vb" id="Snippet1"::: @@ -2623,7 +2617,6 @@ This property is affected if the value of the for a few cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.ShortTimePattern/CPP/dtfi_shorttimepattern.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/ShortTimePattern/dtfi_shorttimepattern.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.ShortTimePattern/VB/dtfi_shorttimepattern.vb" id="Snippet1"::: @@ -2987,7 +2979,6 @@ The default array starts on Sunday. ## Examples The following example displays the value of for a few cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.SortableDateTimePattern/CPP/dtfi_sortabledatetimepattern.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/SortableDateTimePattern/dtfi_sortabledatetimepattern.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.SortableDateTimePattern/VB/dtfi_sortabledatetimepattern.vb" id="Snippet1"::: @@ -3158,7 +3149,6 @@ If the custom pattern includes the format pattern ":", for a few cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.UniversalSortableDateTimePattern/CPP/dtfi_universalsortabledatetimepattern.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/UniversalSortableDateTimePattern/dtfi_universalsortabledatetimepattern.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.UniversalSortableDateTimePattern/VB/dtfi_universalsortabledatetimepattern.vb" id="Snippet1"::: @@ -3235,7 +3225,6 @@ If the custom pattern includes the format pattern ":", for a few cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.YearMonthPattern/CPP/dtfi_yearmonthpattern.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/YearMonthPattern/dtfi_yearmonthpattern.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.DateTimeFormatInfo.YearMonthPattern/VB/dtfi_yearmonthpattern.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/GregorianCalendar.xml b/xml/System.Globalization/GregorianCalendar.xml index b6dc1cd2bab..0f1b4f17728 100644 --- a/xml/System.Globalization/GregorianCalendar.xml +++ b/xml/System.Globalization/GregorianCalendar.xml @@ -73,41 +73,40 @@ Represents the Gregorian calendar. - class recognizes only the current era (A.D. or C.E.). - + class recognizes only the current era (A.D. or C.E.). + > [!NOTE] -> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). - - A leap year in the Gregorian calendar is defined as a year that is evenly divisible by 4, unless it is divisible by 100. However, years that are divisible by 400 are leap years. For example, the year 1900 was not a leap year, but the year 2000 was. A common year has 365 days and a leap year has 366 days. - - The Gregorian calendar has 12 months with 28 to 31 days each: January (31 days), February (28 or 29 days), March (31 days), April (30 days), May (31 days), June (30 days), July (31 days), August (31 days), September (30 days), October (31 days), November (30 days), and December (31 days). February has 29 days during leap years and 28 during common years. - +> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). + + A leap year in the Gregorian calendar is defined as a year that is evenly divisible by 4, unless it is divisible by 100. However, years that are divisible by 400 are leap years. For example, the year 1900 was not a leap year, but the year 2000 was. A common year has 365 days and a leap year has 366 days. + + The Gregorian calendar has 12 months with 28 to 31 days each: January (31 days), February (28 or 29 days), March (31 days), April (30 days), May (31 days), June (30 days), July (31 days), August (31 days), September (30 days), October (31 days), November (30 days), and December (31 days). February has 29 days during leap years and 28 during common years. + > [!IMPORTANT] -> By default, all and values express dates and times in the Gregorian calendar. - +> By default, all and values express dates and times in the Gregorian calendar. + The Gregorian calendar was developed as a replacement for the Julian calendar (which is represented by the class) and was first introduced in a small number of cultures on October 15, 1582. When working with historic dates that precede a culture's adoption of the Gregorian calendar, you should use the original calendar if it is available in the .NET Framework. For example, Denmark changed from the Julian calendar to the Gregorian calendar on February 19 (in the Julian calendar) or March 1 (in the Gregorian calendar) of 1700. In this case, for dates before the adoption of the Gregorian calendar, you should use the Julian calendar. However, note that no culture offers intrinsic support for the class. You must use the class as a standalone calendar. For more information, see [Working with calendars](/dotnet/standard/datetime/working-with-calendars). - - The following example illustrates that February 18, 1700 in the Julian calendar, which is the last day the Julian calendar was officially used in Denmark, is one day earlier than March 1, 1700 in the Gregorian calendar. - + + The following example illustrates that February 18, 1700 in the Julian calendar, which is the last day the Julian calendar was officially used in Denmark, is one day earlier than March 1, 1700 in the Gregorian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/Overview/minimum1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.gregoriancalendar.class/vb/minimum1.vb" id="Snippet1"::: - - Each supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application can set the property to a new . - - ignores punctuation in abbreviated era names, only if the is selected in and the culture uses "A.D." as the era name, that is, "A.D." is equivalent to "AD". + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.gregoriancalendar.class/vb/minimum1.vb" id="Snippet1"::: + + Each supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application can set the property to a new . + + ignores punctuation in abbreviated era names, only if the is selected in and the culture uses "A.D." as the era name, that is, "A.D." is equivalent to "AD". + + + +## Examples + The following code example shows that ignores the punctuation in the era name, only if the calendar is Gregorian and the culture uses the era name "A.D.". - - -## Examples - The following code example shows that ignores the punctuation in the era name, only if the calendar is Gregorian and the culture uses the era name "A.D.". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/CPP/gregorian_getera.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/DateTimeFormatInfo/GetEra/gregorian_getera.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/VB/gregorian_getera.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar.GetEra/VB/gregorian_getera.vb" id="Snippet1"::: + ]]> @@ -165,20 +164,19 @@ Initializes a new instance of the class using the default value. - value is . If the property of the is set to a that is created with this constructor, the dates and times are localized in the language associated with the . - - - -## Examples - The following code example prints a using a that is localized. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/CPP/gregorianlocalized.cpp" id="Snippet1"::: + value is . If the property of the is set to a that is created with this constructor, the dates and times are localized in the language associated with the . + + + +## Examples + The following code example prints a using a that is localized. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/.ctor/gregorianlocalized.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/VB/gregorianlocalized.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/VB/gregorianlocalized.vb" id="Snippet1"::: + ]]> @@ -283,37 +281,36 @@ Returns a that is the specified number of months away from the specified . The that results from adding the specified number of months to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the `months` parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April. - - If the value of the `months` parameter is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the `months` parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April. + + If the value of the `months` parameter is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: - - - -## Examples - The following code example displays the values of several components of a in terms of the Gregorian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Gregorian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/AddMonths/gregoriancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. - is less than -120000. - - -or- - + is less than -120000. + + -or- + is greater than 120000. @@ -410,29 +407,28 @@ Returns a that is the specified number of years away from the specified . The that results from adding the specified number of years to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, February has 28 days, except during leap years when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of `years` is 1, the resulting date will be the 28th day of February in the following year. - - If `years` is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, February has 28 days, except during leap years when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of `years` is 1, the resulting date will be the 28th day of February in the following year. + + If `years` is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: - - - -## Examples - The following code example displays the values of several components of a in terms of the Gregorian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Gregorian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/AddMonths/gregoriancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. @@ -487,11 +483,11 @@ Represents the current era. This field is constant. - class recognizes only the current era (A.D. or C.E.). This field always returns 1. - + class recognizes only the current era (A.D. or C.E.). This field always returns 1. + ]]> @@ -545,14 +541,14 @@ Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both. Always returns . - type found in the .NET Framework and displays the value of its property. - + type found in the .NET Framework and displays the value of its property. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AlgorithmType/algorithmtype1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: + ]]> @@ -601,15 +597,14 @@ Gets or sets the value that denotes the language version of the current . A value that denotes the language version of the current . - The value specified in a set operation is not a member of the enumeration. @@ -661,11 +656,11 @@ Gets the list of eras in the . An array of integers that represents the eras in the . - class recognizes only the current era (A.D. or C.E.). This property always returns an array with only one element. - + class recognizes only the current era (A.D. or C.E.). This property always returns an array with only one element. + ]]> @@ -720,15 +715,14 @@ Returns the day of the month in the specified . An integer from 1 to 31 that represents the day of the month in . - in terms of the Gregorian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp" id="Snippet1"::: + in terms of the Gregorian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/AddMonths/gregoriancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -788,20 +782,19 @@ Returns the day of the week in the specified . A value that represents the day of the week in . - values are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday. - - - -## Examples - The following code example displays the values of several components of a in terms of the Gregorian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp" id="Snippet1"::: + values are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday. + + + +## Examples + The following code example displays the values of several components of a in terms of the Gregorian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/AddMonths/gregoriancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -862,20 +855,19 @@ Returns the day of the year in the specified . An integer from 1 to 366 that represents the day of the year in . - for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year, which is the same value returned by . - - - -## Examples - The following code example displays the values of several components of a in terms of the Gregorian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp" id="Snippet1"::: + for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year, which is the same value returned by . + + + +## Examples + The following code example displays the values of several components of a in terms of the Gregorian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/AddMonths/gregoriancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -939,31 +931,30 @@ Returns the number of days in the specified month in the specified year in the specified era. The number of days in the specified month in the specified year in the specified era. - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1022,27 +1013,26 @@ Returns the number of days in the specified year in the specified era. The number of days in the specified year in the specified era. - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1099,20 +1089,19 @@ Returns the era in the specified . An integer that represents the era in . - class recognizes only the current era (A.D. or C.E.). - - - -## Examples - The following code example displays the values of several components of a in terms of the Gregorian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp" id="Snippet1"::: + class recognizes only the current era (A.D. or C.E.). + + + +## Examples + The following code example displays the values of several components of a in terms of the Gregorian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/AddMonths/gregoriancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1187,10 +1176,10 @@ Always 0 because the Gregorian calendar does not recognize leap months. To be added. - is less than the Gregorian calendar year 1 or greater than the Gregorian calendar year 9999. - - -or- - + is less than the Gregorian calendar year 1 or greater than the Gregorian calendar year 9999. + + -or- + is not or . @@ -1242,15 +1231,14 @@ Returns the month in the specified . An integer from 1 to 12 that represents the month in . - in terms of the Gregorian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp" id="Snippet1"::: + in terms of the Gregorian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/AddMonths/gregoriancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1316,22 +1304,21 @@ Returns the number of months in the specified year in the specified era. The number of months in the specified year in the specified era. - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1385,9 +1372,9 @@ To be added. is outside the range supported by the calendar. - + -or- - + is not a valid value. @@ -1439,15 +1426,14 @@ Returns the year in the specified . An integer that represents the year in . - in terms of the Gregorian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/CPP/gregoriancalendar_addget.cpp" id="Snippet1"::: + in terms of the Gregorian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/AddMonths/gregoriancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_AddGet/VB/gregoriancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1518,37 +1504,36 @@ if the specified day is a leap day; otherwise, . - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1611,33 +1596,32 @@ Determines whether the specified month in the specified year in the specified era is a leap month. This method always returns , unless overridden by a derived class. - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1698,27 +1682,26 @@ if the specified year is a leap year; otherwise, . - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1776,15 +1759,14 @@ Gets the latest date and time supported by the type. The latest date and time supported by the type, which is the last moment of December 31, 9999 C.E. and is equivalent to DateTime.MaxValue. - @@ -1838,20 +1820,19 @@ Gets the earliest date and time supported by the type. The earliest date and time supported by the type, which is the first moment of January 1, 0001 C.E. and is equivalent to DateTime.MinValue. - property is the first moment of January 1, 0001 C.E., the Gregorian calendar was not introduced until October 15, 1582, and its adoption throughout the European continent and worldwide was slow. Until they adopted the Gregorian calendar, most cultures in the European, American, and Australian continents used the Julian calendar, which is represented by the class. - - - -## Examples - The following code example gets the minimum value and the maximum value of the calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_MinMax/CPP/gregoriancalendar_minmax.cpp" id="Snippet1"::: + property is the first moment of January 1, 0001 C.E., the Gregorian calendar was not introduced until October 15, 1582, and its adoption throughout the European continent and worldwide was slow. Until they adopted the Gregorian calendar, most cultures in the European, American, and Australian continents used the Julian calendar, which is represented by the class. + + + +## Examples + The following code example gets the minimum value and the maximum value of the calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/MaxSupportedDateTime/gregoriancalendar_minmax.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_MinMax/VB/gregoriancalendar_minmax.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendar_MinMax/VB/gregoriancalendar_minmax.vb" id="Snippet1"::: + ]]> @@ -1919,34 +1900,34 @@ The that is set to the specified date and time in the current era. To be added. - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is less than zero or greater than 23. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 59. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is less than zero or greater than 23. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 59. + + -or- + is less than zero or greater than 999. @@ -2004,13 +1985,13 @@ Converts the specified year to a four-digit year by using the property to determine the appropriate century. An integer that contains the four-digit representation of . - is the last year in the 100-year range that can be represented by a two-digit year. The century is determined by finding the sole occurrence of the two-digit `year` within that 100-year range. For example, if is set to 2029, the 100-year range is from 1930 to 2029. Therefore, a 2-digit value of 30 is interpreted as 1930, while a 2-digit value of 29 is interpreted as 2029. - - supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. - + is the last year in the 100-year range that can be represented by a two-digit year. The century is determined by finding the sole occurrence of the two-digit `year` within that 100-year range. For example, if is set to 2029, the 100-year range is from 1930 to 2029. Therefore, a 2-digit value of 30 is interpreted as 1930, while a 2-digit value of 29 is interpreted as 2029. + + supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. + ]]> @@ -2062,21 +2043,21 @@ Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. The last year of a 100-year range that can be represented by a 2-digit year. - . The class does not detect changes in the system settings automatically. - - The application should set this value to 99 to indicate that 2-digit years are to be taken literally. For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. Therefore, a 2-digit value of 30 is interpreted as 30. - + . The class does not detect changes in the system settings automatically. + + The application should set this value to 99 to indicate that 2-digit years are to be taken literally. For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. Therefore, a 2-digit value of 30 is interpreted as 30. + ]]> - The value specified in a set operation is less than 99. - - -or- - + The value specified in a set operation is less than 99. + + -or- + The value specified in a set operation is greater than . In a set operation, the current instance is read-only. diff --git a/xml/System.Globalization/GregorianCalendarTypes.xml b/xml/System.Globalization/GregorianCalendarTypes.xml index 1040c717a41..f2f51bdd6c7 100644 --- a/xml/System.Globalization/GregorianCalendarTypes.xml +++ b/xml/System.Globalization/GregorianCalendarTypes.xml @@ -68,30 +68,28 @@ Defines the different language versions of the Gregorian calendar. - vary depending on the language. If the is selected in , can be used to specify which date and time patterns to use in that . + + For Arabic cultures, more language versions of the Gregorian calendar are available. For example, you can use the French version of using the `MiddleEastFrench` value. + + A culture that supports might not support all language versions of . The and properties specify the calendars supported by that culture. If is supported, can be used to determine which language versions of are supported. + + + +## Examples + The following code example demonstrates how to determine the GregorianCalendar language version supported by the culture. -## Remarks - The date and time patterns associated with the vary depending on the language. If the is selected in , can be used to specify which date and time patterns to use in that . - - For Arabic cultures, more language versions of the Gregorian calendar are available. For example, you can use the French version of using the `MiddleEastFrench` value. - - A culture that supports might not support all language versions of . The and properties specify the calendars supported by that culture. If is supported, can be used to determine which language versions of are supported. - - - -## Examples - The following code example demonstrates how to determine the GregorianCalendar language version supported by the culture. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/CPP/gregoriancalendartypes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/CultureInfo/OptionalCalendars/gregoriancalendartypes.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/VB/gregoriancalendartypes.vb" id="Snippet1"::: - - The following code example prints a using a that is localized. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/CPP/gregorianlocalized.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarTypes/VB/gregoriancalendartypes.vb" id="Snippet1"::: + + The following code example prints a using a that is localized. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/GregorianCalendar/.ctor/gregorianlocalized.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/VB/gregorianlocalized.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.GregorianCalendarLocalized/VB/gregorianlocalized.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Globalization/HebrewCalendar.xml b/xml/System.Globalization/HebrewCalendar.xml index 270e857e139..0b1f7398ff9 100644 --- a/xml/System.Globalization/HebrewCalendar.xml +++ b/xml/System.Globalization/HebrewCalendar.xml @@ -73,51 +73,51 @@ Represents the Hebrew calendar. - class recognizes only the current era (A.M.) and the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - + class recognizes only the current era (A.M.) and the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + > [!NOTE] -> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). - - In every 19-year cycle that ends with a year that is evenly divisible by 19, the 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years are leap years. A common year can have from 353 to 355 days, depending on the placement of Jewish holidays. A leap year can have from 383 to 385 days. - - The Hebrew calendar has 12 months during common years and 13 months during leap years: - -|GetMonth value (common year)|GetMonth value (leap year)|Month|Days in common years|Days in leap years| -|------------------------------------|----------------------------------|-----------|--------------------------|------------------------| -|1|1|תשרי (Tishrei)|30|30| -|2|2|חשון (Cheshvan)|29/30|29/30| -|3|3|כסלו (Kislev)|29/30|29/30| -|4|4|טבת (Tevet)|29|29| -|5|5|שבט (Shevat)|30|30| -|6|-|אדר (Adar)|29|-| -|-|6|אדר א (Adar Alef)|-|30| -|-|7|אדר ב (Adar Beit)|-|29| -|7|8|ניסן (Nissan)|30|30| -|8|9|אייר (Iyar)|29|29| -|9|10|סיון (Sivan)|30|30| -|10|11|תמוז (Tamuz)|29|29| -|11|12|אב (Av)|30|30| -|12|13|אלול (Elul)|29|29| - - The days in Cheshvan and Kislev vary depending on the placement of Jewish holidays. During leap years, Adar is replaced by Adar Alef with 30 days and Adar Beit with 29 days. Adar Alef is considered the leap month. The last day of Adar Alef and all the days in Adar Beit are considered leap days; that is, the method returns `true` for these days. - - The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the sixth day of Tevet in the year 5761 A.M. in the Hebrew calendar. - - Each supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . - - - -## Examples - The following example creates a file that contains the date ranges supported by the class, and displays the number of days in each month of the year 5772. - +> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). + + In every 19-year cycle that ends with a year that is evenly divisible by 19, the 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years are leap years. A common year can have from 353 to 355 days, depending on the placement of Jewish holidays. A leap year can have from 383 to 385 days. + + The Hebrew calendar has 12 months during common years and 13 months during leap years: + +|GetMonth value (common year)|GetMonth value (leap year)|Month|Days in common years|Days in leap years| +|------------------------------------|----------------------------------|-----------|--------------------------|------------------------| +|1|1|תשרי (Tishrei)|30|30| +|2|2|חשון (Cheshvan)|29/30|29/30| +|3|3|כסלו (Kislev)|29/30|29/30| +|4|4|טבת (Tevet)|29|29| +|5|5|שבט (Shevat)|30|30| +|6|-|אדר (Adar)|29|-| +|-|6|אדר א (Adar Alef)|-|30| +|-|7|אדר ב (Adar Beit)|-|29| +|7|8|ניסן (Nissan)|30|30| +|8|9|אייר (Iyar)|29|29| +|9|10|סיון (Sivan)|30|30| +|10|11|תמוז (Tamuz)|29|29| +|11|12|אב (Av)|30|30| +|12|13|אלול (Elul)|29|29| + + The days in Cheshvan and Kislev vary depending on the placement of Jewish holidays. During leap years, Adar is replaced by Adar Alef with 30 days and Adar Beit with 29 days. Adar Alef is considered the leap month. The last day of Adar Alef and all the days in Adar Beit are considered leap days; that is, the method returns `true` for these days. + + The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the sixth day of Tevet in the year 5761 A.M. in the Hebrew calendar. + + Each supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . + + + +## Examples + The following example creates a file that contains the date ranges supported by the class, and displays the number of days in each month of the year 5772. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/Overview/example1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.hebrewcalendar.class/vb/example1.vb" id="Snippet1"::: - - The example instantiates a object and makes it the current calendar of a Hebrew (Israel) object. It then makes Hebrew (Israel) the current culture. This causes the common language runtime to interpret all dates and times in relation to the Hebrew calendar. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.hebrewcalendar.class/vb/example1.vb" id="Snippet1"::: + + The example instantiates a object and makes it the current calendar of a Hebrew (Israel) object. It then makes Hebrew (Israel) the current culture. This causes the common language runtime to interpret all dates and times in relation to the Hebrew calendar. + ]]> @@ -218,31 +218,30 @@ Returns a that is the specified number of months away from the specified . The that results from adding the specified number of months to the specified . - class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - The day part of the resulting is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, if the specified month is Av, which has 30 days, the specified day is the 30th day of that month, and the value of the `months` parameter is 5, the resulting year is one more than the specified year, the resulting month is Tevet, and the resulting day is the 29th day, which is the last day in Tevet. - - If the value of the `months` parameter is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + The day part of the resulting is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, if the specified month is Av, which has 30 days, the specified day is the 30th day of that month, and the value of the `months` parameter is 5, the resulting year is one more than the specified year, the resulting month is Tevet, and the resulting day is the 29th day, which is the last day in Tevet. + + If the value of the `months` parameter is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: - - - -## Examples - The following code example displays the values of several components of a in terms of the Hebrew calendar. + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Hebrew calendar. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/AddMonths/hebrewcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. @@ -308,35 +307,34 @@ Returns a that is the specified number of years away from the specified . The that results from adding the specified number of years to the specified . - class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - The day part of the resulting is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. For example, Cheshvan can have 29 or 30 days, depending on the placement of Jewish holidays. Suppose that Cheshvan has 30 days in the current year and 29 in the following year. If the specified date is the 30th day of Cheshvan in the current year and the value of `years` is 1, the resulting date will be the 29th day of Cheshvan in the following year. - - The month part of the resulting is affected if the resulting month is not a valid month in the resulting year. It is changed to the last valid month in the resulting year. For example, if the month in the `time` parameter is the 13th month of a leap year and the value of `years` is 1, the month in the resulting is the 12th month of the following year, which is a non-leap year. Note that even when the month part does not change, it might still refer to a different month. For example, Adar Beit is the 7th month in leap years, but Nissan is the 7th month in common years. - - This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . - - The time-of-day part of the resulting remains the same as the specified . - - If `years` is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + The day part of the resulting is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. For example, Cheshvan can have 29 or 30 days, depending on the placement of Jewish holidays. Suppose that Cheshvan has 30 days in the current year and 29 in the following year. If the specified date is the 30th day of Cheshvan in the current year and the value of `years` is 1, the resulting date will be the 29th day of Cheshvan in the following year. + + The month part of the resulting is affected if the resulting month is not a valid month in the resulting year. It is changed to the last valid month in the resulting year. For example, if the month in the `time` parameter is the 13th month of a leap year and the value of `years` is 1, the month in the resulting is the 12th month of the following year, which is a non-leap year. Note that even when the month part does not change, it might still refer to a different month. For example, Adar Beit is the 7th month in leap years, but Nissan is the 7th month in common years. + + This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . + + The time-of-day part of the resulting remains the same as the specified . + + If `years` is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: - - - -## Examples - The following code example displays the values of several components of a in terms of the Hebrew calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Hebrew calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/AddMonths/hebrewcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. @@ -391,14 +389,14 @@ Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both. Always returns . - type found in the .NET Framework and displays the value of its property. - + type found in the .NET Framework and displays the value of its property. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AlgorithmType/algorithmtype1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: + ]]> @@ -447,11 +445,11 @@ Gets the list of eras in the . An array of integers that represents the eras in the type. The return value is always an array containing one element equal to . - class recognizes only the current era (A.M.). This property always returns an array with only one element. - + class recognizes only the current era (A.M.). This property always returns an array with only one element. + ]]> @@ -506,15 +504,14 @@ Returns the day of the month in the specified . An integer from 1 to 30 that represents the day of the month in the specified . - in terms of the Hebrew calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp" id="Snippet1"::: + in terms of the Hebrew calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/AddMonths/hebrewcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -574,30 +571,29 @@ Returns the day of the week in the specified . A value that represents the day of the week in the specified . - values are as follows: - -|DayOfWeek value|Day of Week| -|---------------------|-----------------| -|Sunday|יום ראשון (Yom Rishon)| -|Monday|יום שני (Yom Sheni)| -|Tuesday|יום שלישי (Yom Shlishi)| -|Wednesday|יום רביעי (Yom Reviee)| -|Thursday|יום חמישי (Yom Chamishi)| -|Friday|יום שישי (Yom Shishi)| -|Saturday|שבת (Shabat)| - - - -## Examples - The following code example displays the values of several components of a in terms of the Hebrew calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp" id="Snippet1"::: + values are as follows: + +|DayOfWeek value|Day of Week| +|---------------------|-----------------| +|Sunday|יום ראשון (Yom Rishon)| +|Monday|יום שני (Yom Sheni)| +|Tuesday|יום שלישי (Yom Shlishi)| +|Wednesday|יום רביעי (Yom Reviee)| +|Thursday|יום חמישי (Yom Chamishi)| +|Friday|יום שישי (Yom Shishi)| +|Saturday|שבת (Shabat)| + + + +## Examples + The following code example displays the values of several components of a in terms of the Hebrew calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/AddMonths/hebrewcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -658,22 +654,21 @@ Returns the day of the year in the specified . An integer from 1 to 385 that represents the day of the year in the specified . - for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year, which is the same value returned by . - - This implementation of the class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - - -## Examples - The following code example displays the values of several components of a in terms of the Hebrew calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp" id="Snippet1"::: + for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year, which is the same value returned by . + + This implementation of the class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + + +## Examples + The following code example displays the values of several components of a in terms of the Hebrew calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/AddMonths/hebrewcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -739,22 +734,21 @@ Returns the number of days in the specified month in the specified year in the specified era. The number of days in the specified month in the specified year in the specified era. - class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - - -## Examples - The following code example calls `GetDaysInMonth` for the second month in each of five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetDaysInMonth/CPP/hebrewcalendar_getdaysinmonth.cpp" id="Snippet1"::: + class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + + +## Examples + The following code example calls `GetDaysInMonth` for the second month in each of five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/GetDaysInMonth/hebrewcalendar_getdaysinmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetDaysInMonth/VB/hebrewcalendar_getdaysinmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetDaysInMonth/VB/hebrewcalendar_getdaysinmonth.vb" id="Snippet1"::: + ]]> @@ -816,22 +810,21 @@ Returns the number of days in the specified year in the specified era. The number of days in the specified year in the specified era. - class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - - -## Examples - The following code example calls `GetDaysInYear` for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_GetDaysInYear/CPP/hebrewcalendar_getdaysinyear.cpp" id="Snippet1"::: + class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + + +## Examples + The following code example calls `GetDaysInYear` for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/GetDaysInYear/hebrewcalendar_getdaysinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_GetDaysInYear/VB/hebrewcalendar_getdaysinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_GetDaysInYear/VB/hebrewcalendar_getdaysinyear.vb" id="Snippet1"::: + ]]> @@ -891,20 +884,19 @@ Returns the era in the specified . An integer that represents the era in the specified . The return value is always . - class recognizes only the current era (A.M.) and only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - - -## Examples - The following code example displays the values of several components of a in terms of the Hebrew calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp" id="Snippet1"::: + class recognizes only the current era (A.M.) and only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + + +## Examples + The following code example displays the values of several components of a in terms of the Hebrew calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/AddMonths/hebrewcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -972,18 +964,18 @@ Calculates the leap month for a specified year and era. A positive integer that indicates the leap month in the specified year and era. The return value is 7 if the and parameters specify a leap year, or 0 if the year is not a leap year. - method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. - + method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. + ]]> - is not or . - - -or- - + is not or . + + -or- + is less than the Hebrew calendar year 5343 or greater than the Hebrew calendar year 5999. @@ -1035,15 +1027,14 @@ Returns the month in the specified . An integer from 1 to 13 that represents the month in the specified . - in terms of the Hebrew calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp" id="Snippet1"::: + in terms of the Hebrew calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/AddMonths/hebrewcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1111,20 +1102,19 @@ Returns the number of months in the specified year in the specified era. The number of months in the specified year in the specified era. The return value is either 12 in a common year, or 13 in a leap year. - class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - - -## Examples - The following code example calls `GetMonthsInYear` for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetMonthsInYear/CPP/hebrewcalendar_getmonthsinyear.cpp" id="Snippet1"::: + class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + + +## Examples + The following code example calls `GetMonthsInYear` for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/GetMonthsInYear/hebrewcalendar_getmonthsinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetMonthsInYear/VB/hebrewcalendar_getmonthsinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.GetMonthsInYear/VB/hebrewcalendar_getmonthsinyear.vb" id="Snippet1"::: + ]]> @@ -1184,20 +1174,19 @@ Returns the year in the specified value. An integer that represents the year in the specified value. - class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - - -## Examples - The following code example displays the values of several components of a in terms of the Hebrew calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/CPP/hebrewcalendar_addget.cpp" id="Snippet1"::: + class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + + +## Examples + The following code example displays the values of several components of a in terms of the Hebrew calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/AddMonths/hebrewcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_AddGet/VB/hebrewcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1256,13 +1245,13 @@ Represents the current era. This field is constant. - class recognizes only the current era (A.M.). - + class recognizes only the current era (A.M.). + ]]> @@ -1324,24 +1313,23 @@ if the specified day is a leap day; otherwise, . - class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - In every 19-year cycle that ends with a year that is evenly divisible by 19, the 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years are leap years. A common year can have from 353 to 355 days, depending on the placement of Jewish holidays. A leap year can have from 383 to 385 days. - - A leap day is a day that occurs only in a leap year. In the Hebrew calendar, the last day of Adar Alef and all the days in Adar Beit are considered leap days. - - - -## Examples - The following code example calls `IsLeapDay` for the last day of the second month (February) for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapDay/CPP/hebrewcalendar_isleapday.cpp" id="Snippet1"::: + class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + In every 19-year cycle that ends with a year that is evenly divisible by 19, the 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years are leap years. A common year can have from 353 to 355 days, depending on the placement of Jewish holidays. A leap year can have from 383 to 385 days. + + A leap day is a day that occurs only in a leap year. In the Hebrew calendar, the last day of Adar Alef and all the days in Adar Beit are considered leap days. + + + +## Examples + The following code example calls `IsLeapDay` for the last day of the second month (February) for five years in each of the eras. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/IsLeapDay/hebrewcalendar_isleapday.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapDay/VB/hebrewcalendar_isleapday.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapDay/VB/hebrewcalendar_isleapday.vb" id="Snippet1"::: + ]]> @@ -1408,24 +1396,23 @@ if the specified month is a leap month; otherwise, . - class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - In every 19-year cycle that ends with a year that is evenly divisible by 19, the 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years are leap years. A common year can have from 353 to 355 days, depending on the placement of Jewish holidays. A leap year can have from 383 to 385 days. - - A leap month is an entire month that occurs only in a leap year. In the Hebrew calendar, Adar Beit is the only leap month. - - - -## Examples - The following code example calls `IsLeapMonth` for all the months in five years in the current era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapMonth/CPP/hebrewcalendar_isleapmonth.cpp" id="Snippet1"::: + class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + In every 19-year cycle that ends with a year that is evenly divisible by 19, the 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years are leap years. A common year can have from 353 to 355 days, depending on the placement of Jewish holidays. A leap year can have from 383 to 385 days. + + A leap month is an entire month that occurs only in a leap year. In the Hebrew calendar, Adar Beit is the only leap month. + + + +## Examples + The following code example calls `IsLeapMonth` for all the months in five years in the current era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/IsLeapMonth/hebrewcalendar_isleapmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapMonth/VB/hebrewcalendar_isleapmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapMonth/VB/hebrewcalendar_isleapmonth.vb" id="Snippet1"::: + ]]> @@ -1489,22 +1476,21 @@ if the specified year is a leap year; otherwise, . - class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - - In every 19-year cycle that ends with a year that is evenly divisible by 19, the 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years are leap years. A common year can have from 353 to 355 days, depending on the placement of Jewish holidays. A leap year can have from 383 to 385 days. - - - -## Examples - The following code example calls `IsLeapYear` for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapYear/CPP/hebrewcalendar_isleapyear.cpp" id="Snippet1"::: + class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + + In every 19-year cycle that ends with a year that is evenly divisible by 19, the 3rd, 6th, 8th, 11th, 14th, 17th, and 19th years are leap years. A common year can have from 353 to 355 days, depending on the placement of Jewish holidays. A leap year can have from 383 to 385 days. + + + +## Examples + The following code example calls `IsLeapYear` for five years in each of the eras. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/IsLeapYear/hebrewcalendar_isleapyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapYear/VB/hebrewcalendar_isleapyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar.IsLeapYear/VB/hebrewcalendar_isleapyear.vb" id="Snippet1"::: + ]]> @@ -1559,15 +1545,14 @@ Gets the latest date and time supported by the type. The latest date and time supported by the type, which is equivalent to the last moment of September, 29, 2239 C.E. in the Gregorian calendar. - @@ -1615,20 +1600,19 @@ Gets the earliest date and time supported by the type. The earliest date and time supported by the type, which is equivalent to the first moment of January, 1, 1583 C.E. in the Gregorian calendar. - type, which is January 1, 0001 C.E. However, the type does not support that minimum date. Consequently, if you call a method to format the time of day using the current calendar but you do not specify a format specifier, formatting uses the ISO 8601 sortable ("s") date/time pattern format specifier instead of the default general ("G") date/time pattern format specifier. For more information, see [Standard Date and Time Format Strings](/dotnet/standard/base-types/standard-date-and-time-format-strings). - - - -## Examples - The following code example gets the minimum value and the maximum value of the calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_MinMax/CPP/hebrewcalendar_minmax.cpp" id="Snippet1"::: + type, which is January 1, 0001 C.E. However, the type does not support that minimum date. Consequently, if you call a method to format the time of day using the current calendar but you do not specify a format specifier, formatting uses the ISO 8601 sortable ("s") date/time pattern format specifier instead of the default general ("G") date/time pattern format specifier. For more information, see [Standard Date and Time Format Strings](/dotnet/standard/base-types/standard-date-and-time-format-strings). + + + +## Examples + The following code example gets the minimum value and the maximum value of the calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HebrewCalendar/MaxSupportedDateTime/hebrewcalendar_minmax.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_MinMax/VB/hebrewcalendar_minmax.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HebrewCalendar_MinMax/VB/hebrewcalendar_minmax.vb" id="Snippet1"::: + ]]> @@ -1695,32 +1679,32 @@ Returns a that is set to the specified date and time in the specified era. The that is set to the specified date and time in the current era. - method is useful because it can convert any date in the current calendar to a Gregorian calendar date. The Gregorian date can subsequently be used, for example, to compare dates in different calendars or create an equivalent date in a particular calendar. - - This implementation of the class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). - + method is useful because it can convert any date in the current calendar to a Gregorian calendar date. The Gregorian date can subsequently be used, for example, to compare dates in different calendars or create an equivalent date in a particular calendar. + + This implementation of the class recognizes only the Hebrew years 5343 to 5999 (1583 to 2239 in the Gregorian calendar). + ]]> - , , or is outside the range supported by the current object. - - -or- - - is less than 0 or greater than 23. - - -or- - - is less than 0 or greater than 59. - - -or- - - is less than 0 or greater than 59. - - -or- - + , , or is outside the range supported by the current object. + + -or- + + is less than 0 or greater than 23. + + -or- + + is less than 0 or greater than 59. + + -or- + + is less than 0 or greater than 59. + + -or- + is less than 0 or greater than 999. @@ -1778,22 +1762,22 @@ Converts the specified year to a 4-digit year by using the property to determine the appropriate century. If the parameter is a 2-digit year, the return value is the corresponding 4-digit year. If the parameter is a 4-digit year, the return value is the unchanged parameter. - method uses the `year` parameter, the property, and a year to calculate a 4-digit year. The century is determined by finding the sole occurrence of the `year` parameter within that 100-year range. For example, if is set to 5729, the 100-year range is from 5630 to 5729. Therefore, a value of 30 is interpreted as 5630, while a value of 29 is interpreted as 5729. - - If the property has the special value 99, the method ignores the settings in the regional and language options in Control Panel and returns the value of the `year` parameter unchanged. - - supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. - + method uses the `year` parameter, the property, and a year to calculate a 4-digit year. The century is determined by finding the sole occurrence of the `year` parameter within that 100-year range. For example, if is set to 5729, the 100-year range is from 5630 to 5729. Therefore, a value of 30 is interpreted as 5630, while a value of 29 is interpreted as 5729. + + If the property has the special value 99, the method ignores the settings in the regional and language options in Control Panel and returns the value of the `year` parameter unchanged. + + supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. + ]]> - is less than 0. - - -or- - + is less than 0. + + -or- + is less than or greater than . @@ -1842,15 +1826,15 @@ Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. The last year of a 100-year range that can be represented by a 2-digit year. - property allows a 2-digit year to be properly translated to a 4-digit year. For example, if this property is set to 5729, the 100-year range is from 5630 to 5729. Therefore, a 2-digit value of 30 is interpreted as 5630, while a 2-digit value of 29 is interpreted as 5729. - - The initial value of this property is derived from the settings in the regional and language options portion of Control Panel. If the initial system setting changes during the life of your application the class does not automatically detect the change. - - The special value 99 causes the method to ignore the system settings and return the specified year unchanged. - + property allows a 2-digit year to be properly translated to a 4-digit year. For example, if this property is set to 5729, the 100-year range is from 5630 to 5729. Therefore, a 2-digit value of 30 is interpreted as 5630, while a 2-digit value of 29 is interpreted as 5729. + + The initial value of this property is derived from the settings in the regional and language options portion of Control Panel. If the initial system setting changes during the life of your application the class does not automatically detect the change. + + The special value 99 causes the method to ignore the system settings and return the specified year unchanged. + ]]> The current object is read-only. diff --git a/xml/System.Globalization/HijriCalendar.xml b/xml/System.Globalization/HijriCalendar.xml index bf8102760d7..08181997f29 100644 --- a/xml/System.Globalization/HijriCalendar.xml +++ b/xml/System.Globalization/HijriCalendar.xml @@ -73,41 +73,41 @@ Represents the Hijri calendar. - [!NOTE] -> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). - - In every 30-year cycle that ends with a year that is evenly divisible by 30, the 2nd, 5th, 7th, 10th, 13th, 16th, 18th, 21st, 24th, 26th, and 29th years are leap years. A common year has 354 days and a leap year has 355 days. - - The Hijri calendar has 12 months with 29 to 30 days each: - -|GetMonth value|Month|Days in common years|Days in leap years| -|--------------------|-----------|--------------------------|------------------------| -|1|محرم (Muharram)|30|30| -|2|صفر (Safar)|29|29| -|3|‏ربيع الاول (Rabi I)|30|30| -|4|‏ربيع الثاني (Rabi II)|29|29| -|5|جمادى الاولى (Jumada I)|30|30| -|6|جمادى الثانية (Jumada II)|29|29| -|7|رجب (Rajab)|30|30| -|8|شعبان (Shaban)|29|29| -|9|رمضان (Ramadan)|30|30| -|10|شوال (Shawwal)|29|29| -|11|ذو القعدة (Zulkadah)|30|30| -|12|ذو الحجة (Zulhijjah)|29|30| - - Ramadan, the month of fasting in the Muslim world, officially starts and ends according to a decree that is based on the observation of the new moon. Therefore, the number of days in Shaban and the number of days in Ramadan vary. - - The date January 1, 2001 A.D. in the Gregorian calendar is roughly equivalent to the sixth day of Shawwal in the year 1421 A.H. in the Hijri calendar. - - This implementation of the class adjusts the calendar date by adding or subtracting a value from zero to two days to accommodate the variances in the start and the end of Ramadan and to accommodate the date difference between countries/regions. That value is stored in the property. If is not set explicitly, it derives its value from the settings in the regional and language options portion of Control Panel and is stored in the registry value HKEY_CURRENT_USER\Control Panel\International\AddHijriDate. However, that information can change during the life of the . The class does not detect changes in the system settings automatically. - - Each supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . - +> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). + + In every 30-year cycle that ends with a year that is evenly divisible by 30, the 2nd, 5th, 7th, 10th, 13th, 16th, 18th, 21st, 24th, 26th, and 29th years are leap years. A common year has 354 days and a leap year has 355 days. + + The Hijri calendar has 12 months with 29 to 30 days each: + +|GetMonth value|Month|Days in common years|Days in leap years| +|--------------------|-----------|--------------------------|------------------------| +|1|محرم (Muharram)|30|30| +|2|صفر (Safar)|29|29| +|3|‏ربيع الاول (Rabi I)|30|30| +|4|‏ربيع الثاني (Rabi II)|29|29| +|5|جمادى الاولى (Jumada I)|30|30| +|6|جمادى الثانية (Jumada II)|29|29| +|7|رجب (Rajab)|30|30| +|8|شعبان (Shaban)|29|29| +|9|رمضان (Ramadan)|30|30| +|10|شوال (Shawwal)|29|29| +|11|ذو القعدة (Zulkadah)|30|30| +|12|ذو الحجة (Zulhijjah)|29|30| + + Ramadan, the month of fasting in the Muslim world, officially starts and ends according to a decree that is based on the observation of the new moon. Therefore, the number of days in Shaban and the number of days in Ramadan vary. + + The date January 1, 2001 A.D. in the Gregorian calendar is roughly equivalent to the sixth day of Shawwal in the year 1421 A.H. in the Hijri calendar. + + This implementation of the class adjusts the calendar date by adding or subtracting a value from zero to two days to accommodate the variances in the start and the end of Ramadan and to accommodate the date difference between countries/regions. That value is stored in the property. If is not set explicitly, it derives its value from the settings in the regional and language options portion of Control Panel and is stored in the registry value HKEY_CURRENT_USER\Control Panel\International\AddHijriDate. However, that information can change during the life of the . The class does not detect changes in the system settings automatically. + + Each supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . + ]]> @@ -209,37 +209,36 @@ Returns a that is the specified number of months away from the specified . The that results from adding the specified number of months to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, if the specified month is Zulkadah, which has 30 days, the specified day is the 30th day of that month, and the value of the `months` parameter is 3, the resulting year is one more than the specified year, the resulting month is Safar, and the resulting day is the 29th day, which is the last day in Safar. - - If the value of the `months` parameter is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, if the specified month is Zulkadah, which has 30 days, the specified day is the 30th day of that month, and the value of the `months` parameter is 3, the resulting year is one more than the specified year, the resulting month is Safar, and the resulting day is the 29th day, which is the last day in Safar. + + If the value of the `months` parameter is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Hijri calendar. - - -## Examples - The following code example displays the values of several components of a in terms of the Hijri calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/AddMonths/hijricalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: + ]]> The resulting . - is less than -120000. - - -or- - + is less than -120000. + + -or- + is greater than 120000. @@ -301,29 +300,28 @@ Returns a that is the specified number of years away from the specified . The that results from adding the specified number of years to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, Zulhijjah has 29 days, except during leap years when it has 30 days. If the specified date is the 30th day of Zulhijjah in a leap year and the value of `years` is 1, the resulting date will be the 29th day of Zulhijjah in the following year. - - If `years` is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, Zulhijjah has 29 days, except during leap years when it has 30 days. If the specified date is the 30th day of Zulhijjah in a leap year and the value of `years` is 1, the resulting date will be the 29th day of Zulhijjah in the following year. + + If `years` is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: - - - -## Examples - The following code example displays the values of several components of a in terms of the Hijri calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Hijri calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/AddMonths/hijricalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. @@ -384,14 +382,14 @@ Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both. Always returns . - type found in the .NET Framework and displays the value of its property. - + type found in the .NET Framework and displays the value of its property. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AlgorithmType/algorithmtype1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: + ]]> @@ -436,11 +434,11 @@ Gets the number of days in the year that precedes the year that is specified by the property. The number of days in the year that precedes the year specified by . - @@ -489,11 +487,11 @@ Gets the list of eras in the . An array of integers that represents the eras in the . - @@ -548,15 +546,14 @@ Returns the day of the month in the specified . An integer from 1 to 30 that represents the day of the month in the specified . - in terms of the Hijri calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp" id="Snippet1"::: + in terms of the Hijri calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/AddMonths/hijricalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: + ]]> @@ -616,30 +613,29 @@ Returns the day of the week in the specified . A value that represents the day of the week in the specified . - values are as follows: - -|DayOfWeek value|which indicates| -|---------------------|---------------------| -|Sunday|الاحد (Al-Ahad)| -|Monday|الاثنين (Al-Ithnayn)| -|Tuesday|الثلاثاء (At-Thulaathaa')| -|Wednesday|الاربعاء (Al-Arbi'aa')| -|Thursday|الخميس (Al-Khamiis)| -|Friday|الجمعة (Al-Jumu'ah)| -|Saturday|السبت (As-Sabt)| - - - -## Examples - The following code example displays the values of several components of a in terms of the Hijri calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp" id="Snippet1"::: + values are as follows: + +|DayOfWeek value|which indicates| +|---------------------|---------------------| +|Sunday|الاحد (Al-Ahad)| +|Monday|الاثنين (Al-Ithnayn)| +|Tuesday|الثلاثاء (At-Thulaathaa')| +|Wednesday|الاربعاء (Al-Arbi'aa')| +|Thursday|الخميس (Al-Khamiis)| +|Friday|الجمعة (Al-Jumu'ah)| +|Saturday|السبت (As-Sabt)| + + + +## Examples + The following code example displays the values of several components of a in terms of the Hijri calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/AddMonths/hijricalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: + ]]> @@ -700,20 +696,19 @@ Returns the day of the year in the specified . An integer from 1 to 355 that represents the day of the year in the specified . - for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year, which is the same value returned by . - - - -## Examples - The following code example displays the values of several components of a in terms of the Hijri calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp" id="Snippet1"::: + for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year, which is the same value returned by . + + + +## Examples + The following code example displays the values of several components of a in terms of the Hijri calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/AddMonths/hijricalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: + ]]> @@ -777,31 +772,30 @@ Returns the number of days in the specified month of the specified year and era. The number of days in the specified month in the specified year in the specified era. - - is outside the range supported by this calendar. - - -or- - - is outside the range supported by this calendar. - - -or- - + is outside the range supported by this calendar. + + -or- + + is outside the range supported by this calendar. + + -or- + is outside the range supported by this calendar. @@ -860,15 +854,14 @@ Returns the number of days in the specified year and era. The number of days in the specified year and era. The number of days is 354 in a common year or 355 in a leap year. - @@ -928,20 +921,19 @@ Returns the era in the specified . An integer that represents the era in the specified . - in terms of the Hijri calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp" id="Snippet1"::: + in terms of the Hijri calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/AddMonths/hijricalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1015,18 +1007,18 @@ Calculates the leap month for a specified year and era. Always 0 because the type does not support the notion of a leap month. - method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. - + method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. + ]]> - is less than the Hijri calendar year 1 or greater than the year 9666. - - -or- - + is less than the Hijri calendar year 1 or greater than the year 9666. + + -or- + is not or . @@ -1078,15 +1070,14 @@ Returns the month in the specified . An integer from 1 to 12 that represents the month in the specified . - in terms of the Hijri calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp" id="Snippet1"::: + in terms of the Hijri calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/AddMonths/hijricalendar_addget.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1152,22 +1143,21 @@ Returns the number of months in the specified year and era. The number of months in the specified year and era. - - is outside the range supported by this calendar. - - -or- - + is outside the range supported by this calendar. + + -or- + is outside the range supported by this calendar. @@ -1224,15 +1214,14 @@ Returns the year in the specified . An integer that represents the year in the specified . - in terms of the Hijri calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/CPP/hijricalendar_addget.cpp" id="Snippet1"::: + in terms of the Hijri calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/AddMonths/hijricalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_AddGet/VB/hijricalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1298,20 +1287,19 @@ Gets or sets the number of days to add or subtract from the calendar to accommodate the variances in the start and the end of Ramadan and to accommodate the date difference between countries/regions. An integer from -2 to 2 that represents the number of days to add or subtract from the calendar. - class adjusts the calendar date by adding or subtracting a value from zero to two days to accommodate the variances in the start and the end of Ramadan and to accommodate the date difference between countries/regions. That value is stored in the property. If is not set explicitly, it derives its value from the settings in the regional and language options portion of Control Panel and is stored in the registry value HKEY_CURRENT_USER\Control Panel\International\AddHijriDate. However, that information can change during the life of the . The class does not detect changes in the system settings automatically. - - - -## Examples - The following code example shows how affects the date. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.HijriAdjustment/CPP/hijriadjustment.cpp" id="Snippet1"::: + class adjusts the calendar date by adding or subtracting a value from zero to two days to accommodate the variances in the start and the end of Ramadan and to accommodate the date difference between countries/regions. That value is stored in the property. If is not set explicitly, it derives its value from the settings in the regional and language options portion of Control Panel and is stored in the registry value HKEY_CURRENT_USER\Control Panel\International\AddHijriDate. However, that information can change during the life of the . The class does not detect changes in the system settings automatically. + + + +## Examples + The following code example shows how affects the date. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/HijriAdjustment/hijriadjustment.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.HijriAdjustment/VB/hijriadjustment.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.HijriAdjustment/VB/hijriadjustment.vb" id="Snippet1"::: + ]]> The property is being set to an invalid value. @@ -1358,13 +1346,13 @@ Represents the current era. This field is constant. - field is 1. - - The Hijri calendar recognizes one era: A.H. (Latin "Anno Hegirae", which means "the year of the migration," in reference to the migration of Muhammad (PBUH) from Mecca). - + field is 1. + + The Hijri calendar recognizes one era: A.H. (Latin "Anno Hegirae", which means "the year of the migration," in reference to the migration of Muhammad (PBUH) from Mecca). + ]]> @@ -1426,37 +1414,36 @@ if the specified day is a leap day; otherwise, . - - is outside the range supported by this calendar. - - -or- - - is outside the range supported by this calendar. - - -or- - - is outside the range supported by this calendar. - - -or- - + is outside the range supported by this calendar. + + -or- + + is outside the range supported by this calendar. + + -or- + + is outside the range supported by this calendar. + + -or- + is outside the range supported by this calendar. @@ -1519,33 +1506,32 @@ Determines whether the specified month in the specified year and era is a leap month. This method always returns . - - is outside the range supported by this calendar. - - -or- - - is outside the range supported by this calendar. - - -or- - + is outside the range supported by this calendar. + + -or- + + is outside the range supported by this calendar. + + -or- + is outside the range supported by this calendar. @@ -1606,27 +1592,26 @@ if the specified year is a leap year; otherwise, . - - is outside the range supported by this calendar. - - -or- - + is outside the range supported by this calendar. + + -or- + is outside the range supported by this calendar. @@ -1684,20 +1669,19 @@ Gets the latest date and time supported by this calendar. The latest date and time supported by the type, which is equivalent to the last moment of December 31, 9999 C.E. in the Gregorian calendar. - @@ -1751,20 +1735,19 @@ Gets the earliest date and time supported by this calendar. The earliest date and time supported by the type, which is equivalent to the first moment of July 18, 622 C.E. in the Gregorian calendar. - type, which is January 1, 0001 C.E. However, the type does not support that minimum date. Consequently, if you call a method to format the time of day using the current calendar but you do not specify a format specifier, formatting uses the ISO 8601 sortable ("s") date/time pattern format specifier instead of the default general ("G") date/time pattern format specifier. For more information, see [Standard Date and Time Format Strings](/dotnet/standard/base-types/standard-date-and-time-format-strings). - - - -## Examples - The following code example gets the minimum value and the maximum value of the calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_MinMax/CPP/hijricalendar_minmax.cpp" id="Snippet1"::: + type, which is January 1, 0001 C.E. However, the type does not support that minimum date. Consequently, if you call a method to format the time of day using the current calendar but you do not specify a format specifier, formatting uses the ISO 8601 sortable ("s") date/time pattern format specifier instead of the default general ("G") date/time pattern format specifier. For more information, see [Standard Date and Time Format Strings](/dotnet/standard/base-types/standard-date-and-time-format-strings). + + + +## Examples + The following code example gets the minimum value and the maximum value of the calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/MaxSupportedDateTime/hijricalendar_minmax.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_MinMax/VB/hijricalendar_minmax.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar_MinMax/VB/hijricalendar_minmax.vb" id="Snippet1"::: + ]]> @@ -1832,34 +1815,34 @@ The that is set to the specified date and time in the current era. To be added. - is outside the range supported by this calendar. - - -or- - - is outside the range supported by this calendar. - - -or- - - is outside the range supported by this calendar. - - -or- - - is outside the range supported by this calendar. - - -or- - - is less than zero or greater than 23. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 59. - - -or- - + is outside the range supported by this calendar. + + -or- + + is outside the range supported by this calendar. + + -or- + + is outside the range supported by this calendar. + + -or- + + is outside the range supported by this calendar. + + -or- + + is less than zero or greater than 23. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 59. + + -or- + is less than zero or greater than 999. @@ -1917,13 +1900,13 @@ Converts the specified year to a four-digit year by using the property to determine the appropriate century. An integer that contains the four-digit representation of . - is the last year in the 100-year range that can be represented by a two-digit year. The century is determined by finding the sole occurrence of the two-digit `year` within that 100-year range. For example, if is set to 1429, the 100-year range is from 1330 to 1429; therefore, a 2-digit value of 30 is interpreted as 1330, while a 2-digit value of 29 is interpreted as 1429. - - supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. - + is the last year in the 100-year range that can be represented by a two-digit year. The century is determined by finding the sole occurrence of the two-digit `year` within that 100-year range. For example, if is set to 1429, the 100-year range is from 1330 to 1429; therefore, a 2-digit value of 30 is interpreted as 1330, while a 2-digit value of 29 is interpreted as 1429. + + supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. + ]]> @@ -1975,15 +1958,15 @@ Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. The last year of a 100-year range that can be represented by a 2-digit year. - . The class does not detect changes in the system settings automatically. - - The application should set this value to 99 to indicate that 2-digit years are to be taken literally. For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. Therefore, a 2-digit value of 30 is interpreted as 30. - + . The class does not detect changes in the system settings automatically. + + The application should set this value to 99 to indicate that 2-digit years are to be taken literally. For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. Therefore, a 2-digit value of 30 is interpreted as 30. + ]]> This calendar is read-only. diff --git a/xml/System.Globalization/JapaneseCalendar.xml b/xml/System.Globalization/JapaneseCalendar.xml index 95aa3168d2b..e02774b0b24 100644 --- a/xml/System.Globalization/JapaneseCalendar.xml +++ b/xml/System.Globalization/JapaneseCalendar.xml @@ -74,57 +74,57 @@ Represents the Japanese calendar. - [!NOTE] -> For information about using the class and the other calendar classes in .NET, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). - - The Japanese calendar recognizes one era for every emperor's reign. The two most recent eras are the Heisei era, beginning in the Gregorian calendar year 1989, and the Reiwa era, beginning in the Gregorian calendar year 2019. The era name is typically displayed before the year. For example, the Gregorian calendar year 2001 is the Japanese calendar year Heisei 13. Note that the first year of an era is called "Gannen." Therefore, the Gregorian calendar year 1989 was the Japanese calendar year Heisei Gannen. By default, formatting operations with specified date and time format strings, such as "D", "F", and "Y", output Gannen rather than "1" in the result string. +> For information about using the class and the other calendar classes in .NET, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). + + The Japanese calendar recognizes one era for every emperor's reign. The two most recent eras are the Heisei era, beginning in the Gregorian calendar year 1989, and the Reiwa era, beginning in the Gregorian calendar year 2019. The era name is typically displayed before the year. For example, the Gregorian calendar year 2001 is the Japanese calendar year Heisei 13. Note that the first year of an era is called "Gannen." Therefore, the Gregorian calendar year 1989 was the Japanese calendar year Heisei Gannen. By default, formatting operations with specified date and time format strings, such as "D", "F", and "Y", output Gannen rather than "1" in the result string. [!INCLUDE[japanese-era-note](~/includes/calendar-era.md)] - This class assigns numbers to the eras as follows: - -|GetEra value|Era Name|Era Abbreviation|Gregorian Dates| -|------------------|--------------|----------------------|---------------------| + This class assigns numbers to the eras as follows: + +|GetEra value|Era Name|Era Abbreviation|Gregorian Dates| +|------------------|--------------|----------------------|---------------------| |5|令和 (Reiwa)|令和 (R, r)|May 1, 2019 to present| -|4|平成 (Heisei)|平 (H, h)|January 8, 1989 to April 30, 2019| -|3|昭和 (Showa)|昭 (S, s)|December 25, 1926 to January 7, 1989| -|2|大正 (Taisho)|大 (T, t)|July 30, 1912 to December 24, 1926| -|1|明治 (Meiji)|明 (M, m)|September 8, 1868 to July 29, 1912| - - This class handles dates from September 8 in the year Meiji 1 (in the Gregorian calendar, September 8, 1868). Although the Japanese calendar was switched from a lunar calendar to a solar calendar in the year Meiji 6 (1873 of the Gregorian calendar), this implementation is based on the solar calendar only. - - Leap years in the Japanese calendar correspond to the same leap years in the Gregorian calendar. A leap year in the Gregorian calendar is defined as a Gregorian year that is evenly divisible by four, except if it is divisible by 100. However, Gregorian years that are divisible by 400 are leap years. A common year has 365 days and a leap year has 366 days. - - The Japanese calendar has 12 months with 28 to 31 days each: - -|GetMonth value|Month|English|Days in common years|Days in leap years| -|--------------------|-----------|-------------|--------------------------|------------------------| -|1|1月 (Ichigatsu)|January|31|31| -|2|2月 (Nigatsu)|February|28|29| -|3|3月 (Sangatsu)|March|31|31| -|4|4月 (Shigatsu)|April|30|30| -|5|5月 (Gogatsu)|May|31|31| -|6|6月 (Rokugatsu)|June|30|30| -|7|7月 (Shichigatsu)|July|31|31| -|8|8月 (Hachigatsu)|August|31|31| -|9|9月 (Kugatsu)|September|30|30| -|10|10月 (Juugatsu)|October|31|31| -|11|11月 (Juuichigatsu)|November|30|30| -|12|12月 (Juunigatsu)|December|31|31| - - Nigatsu, which is equivalent to the Gregorian calendar month of February, has 29 days during leap years and 28 during common years. - - The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the first day of Ichigatsu in the year Heisei 13 in the Japanese calendar. - +|4|平成 (Heisei)|平 (H, h)|January 8, 1989 to April 30, 2019| +|3|昭和 (Showa)|昭 (S, s)|December 25, 1926 to January 7, 1989| +|2|大正 (Taisho)|大 (T, t)|July 30, 1912 to December 24, 1926| +|1|明治 (Meiji)|明 (M, m)|September 8, 1868 to July 29, 1912| + + This class handles dates from September 8 in the year Meiji 1 (in the Gregorian calendar, September 8, 1868). Although the Japanese calendar was switched from a lunar calendar to a solar calendar in the year Meiji 6 (1873 of the Gregorian calendar), this implementation is based on the solar calendar only. + + Leap years in the Japanese calendar correspond to the same leap years in the Gregorian calendar. A leap year in the Gregorian calendar is defined as a Gregorian year that is evenly divisible by four, except if it is divisible by 100. However, Gregorian years that are divisible by 400 are leap years. A common year has 365 days and a leap year has 366 days. + + The Japanese calendar has 12 months with 28 to 31 days each: + +|GetMonth value|Month|English|Days in common years|Days in leap years| +|--------------------|-----------|-------------|--------------------------|------------------------| +|1|1月 (Ichigatsu)|January|31|31| +|2|2月 (Nigatsu)|February|28|29| +|3|3月 (Sangatsu)|March|31|31| +|4|4月 (Shigatsu)|April|30|30| +|5|5月 (Gogatsu)|May|31|31| +|6|6月 (Rokugatsu)|June|30|30| +|7|7月 (Shichigatsu)|July|31|31| +|8|8月 (Hachigatsu)|August|31|31| +|9|9月 (Kugatsu)|September|30|30| +|10|10月 (Juugatsu)|October|31|31| +|11|11月 (Juuichigatsu)|November|30|30| +|12|12月 (Juunigatsu)|December|31|31| + + Nigatsu, which is equivalent to the Gregorian calendar month of February, has 29 days during leap years and 28 during common years. + + The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the first day of Ichigatsu in the year Heisei 13 in the Japanese calendar. + If the is the current calendar of the Japanese culture, recognizes the era abbreviations in front of the year. The abbreviation is either the single-character case-insensitive Latin alphabet abbreviation or the single-character Kanji abbreviation. also recognizes either "1" or Gannen (元年) as the first year of an era. - + Each object supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , set the property to a new . - + ]]> @@ -227,37 +227,36 @@ Returns a that is the specified number of months away from the specified . The that results from adding the specified number of months to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . The era part of the resulting is affected if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, if the specified month is Juugatsu (October), which has 31 days, the specified day is the 31st day of that month, and `months` is 6, the resulting year is one more than the specified year, the resulting month is Shigatsu (April), and the resulting day is the 30th day, which is the last day in Shigatsu (April). - - If `months` is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . The era part of the resulting is affected if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, if the specified month is Juugatsu (October), which has 31 days, the specified day is the 31st day of that month, and `months` is 6, the resulting year is one more than the specified year, the resulting month is Shigatsu (April), and the resulting day is the 30th day, which is the last day in Shigatsu (April). + + If `months` is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: - - - -## Examples - The following code example displays the values of several components of a in terms of the Japanese calendar. + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Japanese calendar. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/AddMonths/japanesecalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. - is less than -120000. - - -or- - + is less than -120000. + + -or- + is greater than 120000. @@ -319,37 +318,36 @@ Returns a that is the specified number of years away from the specified . The that results from adding the specified number of years to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . The era part of the resulting is affected if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, Nigatsu (February) has 28 days except during leap years when it has 29 days. If the specified date is the 29th day of Nigatsu (February) in a leap year and the value of `years` is 1, the resulting date will be the 28th day of Nigatsu (February) in the following year. - - If `years` is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . The era part of the resulting is affected if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, Nigatsu (February) has 28 days except during leap years when it has 29 days. If the specified date is the 29th day of Nigatsu (February) in a leap year and the value of `years` is 1, the resulting date will be the 28th day of Nigatsu (February) in the following year. + + If `years` is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: - - - -## Examples - The following code example displays the values of several components of a in terms of the Japanese calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Japanese calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/AddMonths/japanesecalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. - is outside the supported range of the type. - - -or- - + is outside the supported range of the type. + + -or- + is less than -10,000 or greater than 10,000. @@ -408,14 +406,14 @@ Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both. Always returns . - type found in the .NET Class Library and displays the value of its property. - + type found in the .NET Class Library and displays the value of its property. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AlgorithmType/algorithmtype1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: + ]]> @@ -464,37 +462,36 @@ Gets the list of eras in the . An array of integers that represents the eras in the . - [!NOTE] -> Should additional eras be added in the future, applications may encounter more than the expected five eras for the Japanese calendar. Your applications should be tested to ensure that they continue to work in such an event; see [Era Handling for the Japanese Calendar](/windows/desktop/Intl/era-handling-for-the-japanese-calendar). - - - -## Examples - The following example displays the values contained in the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/CPP/yslin_japanesecalendar_eras.cpp" id="Snippet1"::: +> Should additional eras be added in the future, applications may encounter more than the expected five eras for the Japanese calendar. Your applications should be tested to ensure that they continue to work in such an event; see [Era Handling for the Japanese Calendar](/windows/desktop/Intl/era-handling-for-the-japanese-calendar). + + + +## Examples + The following example displays the values contained in the property. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/Eras/yslin_japanesecalendar_eras.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/VB/yslin_japanesecalendar_eras.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.Eras/VB/yslin_japanesecalendar_eras.vb" id="Snippet1"::: + ]]> @@ -548,15 +545,14 @@ Returns the day of the month in the specified . An integer from 1 to 31 that represents the day of the month in the specified . - in terms of the Japanese calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp" id="Snippet1"::: + in terms of the Japanese calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/AddMonths/japanesecalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: + ]]> @@ -616,30 +612,29 @@ Returns the day of the week in the specified . A value that represents the day of the week in the specified . - values are as follows: - -|DayOfWeek value|which indicates| -|---------------------|---------------------| -|Sunday|日曜日 (Nichiyoubi)| -|Monday|月曜日 (Getsuyoubi)| -|Tuesday|火曜日 (Kayoubi)| -|Wednesday|水曜日 (Suiyoubi)| -|Thursday|木曜日 (Mokuyoubi)| -|Friday|金曜日 (Kinyoubi)| -|Saturday|土曜日 (Doyoubi)| - - - -## Examples - The following code example displays the values of several components of a in terms of the Japanese calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp" id="Snippet1"::: + values are as follows: + +|DayOfWeek value|which indicates| +|---------------------|---------------------| +|Sunday|日曜日 (Nichiyoubi)| +|Monday|月曜日 (Getsuyoubi)| +|Tuesday|火曜日 (Kayoubi)| +|Wednesday|水曜日 (Suiyoubi)| +|Thursday|木曜日 (Mokuyoubi)| +|Friday|金曜日 (Kinyoubi)| +|Saturday|土曜日 (Doyoubi)| + + + +## Examples + The following code example displays the values of several components of a in terms of the Japanese calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/AddMonths/japanesecalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: + ]]> @@ -700,20 +695,19 @@ Returns the day of the year in the specified . An integer from 1 to 366 that represents the day of the year in the specified . - for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year, which is the same value as that returned by . - - - -## Examples - The following code example displays the values of several components of a in terms of the Japanese calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp" id="Snippet1"::: + for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year, which is the same value as that returned by . + + + +## Examples + The following code example displays the values of several components of a in terms of the Japanese calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/AddMonths/japanesecalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: + ]]> @@ -777,31 +771,30 @@ Returns the number of days in the specified month in the specified year in the specified era. The number of days in the specified month in the specified year in the specified era. - for the second month in each of five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInMonth/CPP/japanesecalendar_getdaysinmonth.cpp" id="Snippet1"::: + for the second month in each of five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/GetDaysInMonth/japanesecalendar_getdaysinmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInMonth/VB/japanesecalendar_getdaysinmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInMonth/VB/japanesecalendar_getdaysinmonth.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -859,27 +852,26 @@ Returns the number of days in the specified year in the specified era. The number of days in the specified year in the specified era. - for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInYear/CPP/japanesecalendar_getdaysinyear.cpp" id="Snippet1"::: + for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/GetDaysInYear/japanesecalendar_getdaysinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInYear/VB/japanesecalendar_getdaysinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetDaysInYear/VB/japanesecalendar_getdaysinyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -935,32 +927,31 @@ Returns the era in the specified . An integer that represents the era in the specified . - class supports dates from September 8 in the year Meiji 1 (September 8, 1868 of the Gregorian calendar), which is the value of the property. However, the method successfully returns the era for dates from January 1 through September 7 in the year Meiji 1 (January 1, 1868 through September 7, 1868 in the Gregorian calendar). For dates earlier than January 1, 1868 in the Gregorian calendar, the method throws an exception. - -## Examples - The following example displays the values of several components of a in terms of the Japanese calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp" id="Snippet1"::: +|4|平成 (Heisei)|平 (H, h)|January 8, 1989 to April 30, 2019| +|3|昭和 (Showa)|昭 (S, s)|December 25, 1926 to January 7, 1989| +|2|大正 (Taisho)|大 (T, t)|July 30, 1912 to December 24, 1926| +|1|明治 (Meiji)|明 (M, m)|September 8, 1868 to July 29, 1912| + + Ordinarily, the class supports dates from September 8 in the year Meiji 1 (September 8, 1868 of the Gregorian calendar), which is the value of the property. However, the method successfully returns the era for dates from January 1 through September 7 in the year Meiji 1 (January 1, 1868 through September 7, 1868 in the Gregorian calendar). For dates earlier than January 1, 1868 in the Gregorian calendar, the method throws an exception. + +## Examples + The following example displays the values of several components of a in terms of the Japanese calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/AddMonths/japanesecalendar_addget.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. @@ -1034,11 +1025,11 @@ Calculates the leap month for a specified year and era. The return value is always 0 because the type does not support the notion of a leap month. - method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. - + method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. + ]]> @@ -1093,15 +1084,14 @@ Returns the month in the specified . An integer from 1 to 12 that represents the month in the specified . - in terms of the Japanese calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp" id="Snippet1"::: + in terms of the Japanese calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/AddMonths/japanesecalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1167,22 +1157,21 @@ Returns the number of months in the specified year in the specified era. The return value is always 12. - for the first five years in each era. Because the class supports only 12-month years, it indicates that there are 12 months in each of the eras supported by the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetMonthsInYear/CPP/japanesecalendar_getmonthsinyear.cpp"::: + for the first five years in each era. Because the class supports only 12-month years, it indicates that there are 12 months in each of the eras supported by the class. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/GetMonthsInYear/japanesecalendar_getmonthsinyear.cs"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetMonthsInYear/VB/japanesecalendar_getmonthsinyear.vb"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.GetMonthsInYear/VB/japanesecalendar_getmonthsinyear.vb"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1247,35 +1236,34 @@ Returns the week of the year that includes the date in the specified . A 1-based integer that represents the week of the year that includes the date in the parameter. - property contains culture-specific values that can be used for the `rule` and `firstDayOfWeek` parameters. - - The property of contains the default value that represents the first day of the week for a specific culture, using the calendar specified in the property of . - - The property of contains the default value that defines a calendar week for a specific culture, using the calendar specified in the property of . - - For example, in , the method for January 1 returns 1. - - - -## Examples - The following code example shows how the result of varies depending on the and values used. If the specified date is the last day of the year, returns the total number of weeks in that year. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp" id="Snippet1"::: + property contains culture-specific values that can be used for the `rule` and `firstDayOfWeek` parameters. + + The property of contains the default value that represents the first day of the week for a specific culture, using the calendar specified in the property of . + + The property of contains the default value that defines a calendar week for a specific culture, using the calendar specified in the property of . + + For example, in , the method for January 1 returns 1. + + + +## Examples + The following code example shows how the result of varies depending on the and values used. If the specified date is the last day of the year, returns the total number of weeks in that year. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetWeekOfYear/yslin_calendar_getweekofyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb" id="Snippet1"::: + ]]> - or is outside the range supported by the calendar. - - -or- - + or is outside the range supported by the calendar. + + -or- + is not a valid value. @@ -1327,15 +1315,14 @@ Returns the year in the specified . An integer that represents the year in the specified . - in terms of the Japanese calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/CPP/japanesecalendar_addget.cpp" id="Snippet1"::: + in terms of the Japanese calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/AddMonths/japanesecalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_AddGet/VB/japanesecalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1406,36 +1393,35 @@ , if the specified day is a leap day; otherwise, . - for the last day of the second month (February) for five years in each of the eras. The current era in the example output is the Reiwa era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapDay/CPP/japanesecalendar_isleapday.cpp"::: +The following example calls for the last day of the second month (February) for five years in each of the eras. The current era in the example output is the Reiwa era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/IsLeapDay/japanesecalendar_isleapday.cs"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapDay/VB/japanesecalendar_isleapday.vb"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapDay/VB/japanesecalendar_isleapday.vb"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1497,31 +1483,30 @@ The following example calls Determines whether the specified month in the specified year in the specified era is a leap month. This method always returns , unless overridden by a derived class. - for all the months in the first five years in the current era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapMonth/CPP/japanesecalendar_isleapmonth.cpp" id="Snippet1"::: + for all the months in the first five years in the current era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/IsLeapMonth/japanesecalendar_isleapmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapMonth/VB/japanesecalendar_isleapmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapMonth/VB/japanesecalendar_isleapmonth.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1581,27 +1566,26 @@ The following example calls , if the specified year is a leap year; otherwise, . - for five years in each of the eras. The current era in the example output is the Reiwa era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapYear/CPP/japanesecalendar_isleapyear.cpp"::: + for five years in each of the eras. The current era in the example output is the Reiwa era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/IsLeapYear/japanesecalendar_isleapyear.cs"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapYear/VB/japanesecalendar_isleapyear.vb"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar.IsLeapYear/VB/japanesecalendar_isleapyear.vb"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1658,15 +1642,14 @@ The following example calls Gets the latest date and time supported by the current object. The latest date and time supported by the type, which is equivalent to the last moment of December 31, 9999 C.E. in the Gregorian calendar. - @@ -1720,20 +1703,19 @@ The following example calls Gets the earliest date and time supported by the current object. The earliest date and time supported by the type, which is equivalent to the first moment of September 8, 1868 C.E. in the Gregorian calendar. - class is September 8, 1868 C.E., in the first year of the Meiji era. Ordinarily, date and time operations that use the class throw an exception for dates before this date. However, some members, such as the method, support dates from January 1, 1868 through September 7 in the year Meiji 1. - - - -## Examples - The following example gets the earliest and latest dates supported by the calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_MinMax/CPP/japanesecalendar_minmax.cpp" id="Snippet1"::: + class is September 8, 1868 C.E., in the first year of the Meiji era. Ordinarily, date and time operations that use the class throw an exception for dates before this date. However, some members, such as the method, support dates from January 1, 1868 through September 7 in the year Meiji 1. + + + +## Examples + The following example gets the earliest and latest dates supported by the calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar/MaxSupportedDateTime/japanesecalendar_minmax.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_MinMax/VB/japanesecalendar_minmax.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JapaneseCalendar_MinMax/VB/japanesecalendar_minmax.vb" id="Snippet1"::: + ]]> @@ -1800,10 +1782,10 @@ The following example calls Returns a that is set to the specified date and time in the specified era. The that is set to the specified date and time in the current era. - method is useful because it can convert any date in the current calendar to a Gregorian calendar date. The Gregorian date can subsequently be used, for example, to compare dates in different calendars or create an equivalent date in a particular calendar. + method is useful because it can convert any date in the current calendar to a Gregorian calendar date. The Gregorian date can subsequently be used, for example, to compare dates in different calendars or create an equivalent date in a particular calendar. Because the supports multiple eras based on the reign of the emperor, you should always call this method and explicitly specify an era to avoid an unintended date and to make the intent of your code clear. The example shows how to instantiate a date that is always in the current era and one that belongs to a specified era. @@ -1812,39 +1794,39 @@ Because the supports multiple eras The following example instantiates two dates. The first is always the first day of the second year in the current era, while the second identifies a specific day in the Taisho era. The output from the example was produced with the Heisei era as the current era. :::code language="csharp" source="~/snippets/csharp/System.Globalization/JapaneseCalendar.ToDateTime/Program.cs"::: -:::code language="vb" source="~/snippets/visualbasic/api/system.globalization/japanesecalendar/todatetime/Program.vb"::: +:::code language="vb" source="~/snippets/visualbasic/api/system.globalization/japanesecalendar/todatetime/Program.vb"::: ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is less than zero or greater than 23. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 999. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is less than zero or greater than 23. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 999. + + -or- + is outside the range supported by the calendar. @@ -1901,15 +1883,15 @@ The following example instantiates two dates. The first is always the first day Converts the specified year to a four-digit year by using the property to determine the appropriate century. An integer that contains the four-digit representation of . - . - - Because the year in the Japanese calendar is typically less than four digits long, this implementation always returns the value of the `year` parameter. - - supports either a two-digit year or a four-digit year. However, a valid year is generally represented as two digits (less than 100). Passing a two-digit year value causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit value, or if it supplies zero or a negative value, throws an exception. - + . + + Because the year in the Japanese calendar is typically less than four digits long, this implementation always returns the value of the `year` parameter. + + supports either a two-digit year or a four-digit year. However, a valid year is generally represented as two digits (less than 100). Passing a two-digit year value causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit value, or if it supplies zero or a negative value, throws an exception. + ]]> @@ -1961,19 +1943,19 @@ The following example instantiates two dates. The first is always the first day Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. The last year of a 100-year range that can be represented by a 2-digit year. - . - - Because the year in the Japanese calendar is typically less than four digits long, this implementation returns 99 by default and does not affect the return value of . - + . + + Because the year in the Japanese calendar is typically less than four digits long, this implementation returns 99 by default and does not affect the return value of . + ]]> - The value specified in a set operation is less than 99. - - -or- - + The value specified in a set operation is less than 99. + + -or- + The value specified in a set operation is greater than 8011 (or ). In a set operation, the current instance is read-only. diff --git a/xml/System.Globalization/JulianCalendar.xml b/xml/System.Globalization/JulianCalendar.xml index e35b0069b72..cfa3ad77ad4 100644 --- a/xml/System.Globalization/JulianCalendar.xml +++ b/xml/System.Globalization/JulianCalendar.xml @@ -73,26 +73,26 @@ Represents the Julian calendar. - [!NOTE] -> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). - - The class recognizes only the current era. - - Unlike the Gregorian calendar, the Julian calendar defines a leap year as a year that is evenly divisible by four with no exceptions. Therefore, the calendar is inaccurate by one day every 128 years. A common year has 365 days and a leap year has 366 days. - - Like the Gregorian calendar, the Julian calendar has 12 months with 28 to 31 days each: January (31 days), February (28 or 29 days), March (31 days), April (30 days), May (31 days), June (30 days), July (31 days), August (31 days), September (30 days), October (31 days), November (30 days), and December (31 days). February has 29 days during leap years and 28 during common years. - - The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the 19th day of December in the year 2000 A.D. in the Julian calendar. - - Currently, the is not used by any of the cultures supported by the class. Therefore, the class can be used only to calculate dates in the Julian calendar. - - Each object supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . - +> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). + + The class recognizes only the current era. + + Unlike the Gregorian calendar, the Julian calendar defines a leap year as a year that is evenly divisible by four with no exceptions. Therefore, the calendar is inaccurate by one day every 128 years. A common year has 365 days and a leap year has 366 days. + + Like the Gregorian calendar, the Julian calendar has 12 months with 28 to 31 days each: January (31 days), February (28 or 29 days), March (31 days), April (30 days), May (31 days), June (30 days), July (31 days), August (31 days), September (30 days), October (31 days), November (30 days), and December (31 days). February has 29 days during leap years and 28 during common years. + + The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the 19th day of December in the year 2000 A.D. in the Julian calendar. + + Currently, the is not used by any of the cultures supported by the class. Therefore, the class can be used only to calculate dates in the Julian calendar. + + Each object supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . + ]]> @@ -194,37 +194,36 @@ Returns a that is the specified number of months away from the specified . The that results from adding the specified number of months to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the `months` parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April. - - If the value of the `months` parameter is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the `months` parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April. + + If the value of the `months` parameter is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: - - - -## Examples - The following code example displays the values of several components of a in terms of the Julian calendar. + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Julian calendar. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/AddMonths/juliancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. - is less than -120000. - - -or- - + is less than -120000. + + -or- + is greater than 120000. @@ -286,29 +285,28 @@ Returns a that is the specified number of years away from the specified . The that results from adding the specified number of years to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, February has 28 days, except during leap years when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of `years` is 1, the resulting date is the 28th day of February in the following year. - - If `years` is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, February has 28 days, except during leap years when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of `years` is 1, the resulting date is the 28th day of February in the following year. + + If `years` is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: - - - -## Examples - The following code example displays the values of several components of a in terms of the Julian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Julian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/AddMonths/juliancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. @@ -369,14 +367,14 @@ Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both. Always returns . - type found in the .NET Framework and displays the value of its property. - + type found in the .NET Framework and displays the value of its property. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AlgorithmType/algorithmtype1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: + ]]> @@ -425,11 +423,11 @@ Gets the list of eras in the . An array of integers that represents the eras in the . - class recognizes only the current era. This property always returns an array with only one element. - + class recognizes only the current era. This property always returns an array with only one element. + ]]> @@ -484,15 +482,14 @@ Returns the day of the month in the specified . An integer from 1 to 31 that represents the day of the month in . - in terms of the Julian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp" id="Snippet1"::: + in terms of the Julian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/AddMonths/juliancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -552,20 +549,19 @@ Returns the day of the week in the specified . A value that represents the day of the week in . - values are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday. - - - -## Examples - The following code example displays the values of several components of a in terms of the Julian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp" id="Snippet1"::: + values are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday. + + + +## Examples + The following code example displays the values of several components of a in terms of the Julian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/AddMonths/juliancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -626,17 +622,16 @@ Returns the day of the year in the specified . An integer from 1 to 366 that represents the day of the year in . - for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year. The total is the same value as that returned by . - - - -## Examples - The following code example displays the values of several components of a in terms of the Julian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp" id="Snippet1"::: + for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year. The total is the same value as that returned by . + + + +## Examples + The following code example displays the values of several components of a in terms of the Julian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/AddMonths/juliancalendar_addget.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: @@ -703,31 +698,30 @@ Returns the number of days in the specified month in the specified year in the specified era. The number of days in the specified month in the specified year in the specified era. - for the second month in each of five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInMonth/CPP/juliancalendar_getdaysinmonth.cpp" id="Snippet1"::: + for the second month in each of five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/GetDaysInMonth/juliancalendar_getdaysinmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInMonth/VB/juliancalendar_getdaysinmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInMonth/VB/juliancalendar_getdaysinmonth.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -786,27 +780,26 @@ Returns the number of days in the specified year in the specified era. The number of days in the specified year in the specified era. - for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInYear/CPP/juliancalendar_getdaysinyear.cpp" id="Snippet1"::: + for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/GetDaysInYear/juliancalendar_getdaysinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInYear/VB/juliancalendar_getdaysinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetDaysInYear/VB/juliancalendar_getdaysinyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -863,20 +856,19 @@ Returns the era in the specified . An integer that represents the era in . - class recognizes only the current era. - - - -## Examples - The following code example displays the values of several components of a in terms of the Julian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp" id="Snippet1"::: + class recognizes only the current era. + + + +## Examples + The following code example displays the values of several components of a in terms of the Julian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/AddMonths/juliancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -950,11 +942,11 @@ Calculates the leap month for a specified year and era. A positive integer that indicates the leap month in the specified year and era. Alternatively, this method returns zero if the calendar does not support a leap month, or if and do not specify a leap year. - method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. - + method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. + ]]> @@ -1007,15 +999,14 @@ Returns the month in the specified . An integer from 1 to 12 that represents the month in . - in terms of the Julian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp" id="Snippet1"::: + in terms of the Julian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/AddMonths/juliancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1081,22 +1072,21 @@ Returns the number of months in the specified year in the specified era. The number of months in the specified year in the specified era. - for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetMonthsInYear/CPP/juliancalendar_getmonthsinyear.cpp" id="Snippet1"::: + for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/GetMonthsInYear/juliancalendar_getmonthsinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetMonthsInYear/VB/juliancalendar_getmonthsinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.GetMonthsInYear/VB/juliancalendar_getmonthsinyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1153,15 +1143,14 @@ Returns the year in the specified . An integer that represents the year in . - in terms of the Julian calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/CPP/juliancalendar_addget.cpp" id="Snippet1"::: + in terms of the Julian calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/AddMonths/juliancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar_AddGet/VB/juliancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1232,37 +1221,36 @@ if the specified day is a leap day; otherwise, . - for the last day of the second month (February) for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapDay/CPP/juliancalendar_isleapday.cpp" id="Snippet1"::: + for the last day of the second month (February) for five years in each of the eras. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/IsLeapDay/juliancalendar_isleapday.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapDay/VB/juliancalendar_isleapday.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapDay/VB/juliancalendar_isleapday.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1325,33 +1313,32 @@ Determines whether the specified month in the specified year in the specified era is a leap month. This method always returns , unless overridden by a derived class. - for all the months in five years in the current era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapMonth/CPP/juliancalendar_isleapmonth.cpp" id="Snippet1"::: + for all the months in five years in the current era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/IsLeapMonth/juliancalendar_isleapmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapMonth/VB/juliancalendar_isleapmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapMonth/VB/juliancalendar_isleapmonth.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1412,27 +1399,26 @@ if the specified year is a leap year; otherwise, . - for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapYear/CPP/juliancalendar_isleapyear.cpp" id="Snippet1"::: + for five years in each of the eras. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/JulianCalendar/IsLeapYear/juliancalendar_isleapyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapYear/VB/juliancalendar_isleapyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.JulianCalendar.IsLeapYear/VB/juliancalendar_isleapyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1482,11 +1468,11 @@ Represents the current era. This field is constant. - class recognizes only the current era. This field always returns 1. - + class recognizes only the current era. This field always returns 1. + ]]> @@ -1542,15 +1528,14 @@ Gets the latest date and time supported by the class. The latest date and time supported by the class, which is equivalent to the last moment of December 31, 9999 C.E. in the Gregorian calendar. - @@ -1604,15 +1589,14 @@ Gets the earliest date and time supported by the class. The earliest date and time supported by the class, which is equivalent to the first moment of January 1, 0001 C.E. in the Gregorian calendar. - @@ -1680,34 +1664,34 @@ The that is set to the specified date and time in the current era. To be added. - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is less than zero or greater than 23. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 999. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is less than zero or greater than 23. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 999. + + -or- + is outside the range supported by the calendar. @@ -1765,13 +1749,13 @@ Converts the specified year to a four-digit year by using the property to determine the appropriate century. An integer that contains the four-digit representation of . - is the last year in the 100-year range that can be represented by a two-digit year. The century is determined by finding the sole occurrence of the specified `year` within that 100-year range. For example, if is set to 2029, the 100-year range is from 1930 to 2029. Therefore, a 2-digit value of 30 is interpreted as 1930, while a 2-digit value of 29 is interpreted as 2029. - - supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. - + is the last year in the 100-year range that can be represented by a two-digit year. The century is determined by finding the sole occurrence of the specified `year` within that 100-year range. For example, if is set to 2029, the 100-year range is from 1930 to 2029. Therefore, a 2-digit value of 30 is interpreted as 1930, while a 2-digit value of 29 is interpreted as 2029. + + supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. + ]]> @@ -1823,21 +1807,21 @@ Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. The last year of a 100-year range that can be represented by a 2-digit year. - class does not detect changes in the system settings. - - The application can set this value to 99 to indicate that 2-digit years are to be taken literally. For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. Therefore, a 2-digit value of 30 is interpreted as 30. - + class does not detect changes in the system settings. + + The application can set this value to 99 to indicate that 2-digit years are to be taken literally. For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. Therefore, a 2-digit value of 30 is interpreted as 30. + ]]> - The value specified in a set operation is less than 99. - - -or- - + The value specified in a set operation is less than 99. + + -or- + The value specified in a set operation is greater than . In a set operation, the current instance is read-only. diff --git a/xml/System.Globalization/KoreanCalendar.xml b/xml/System.Globalization/KoreanCalendar.xml index 35bfb7a7f8c..baf5dfab08e 100644 --- a/xml/System.Globalization/KoreanCalendar.xml +++ b/xml/System.Globalization/KoreanCalendar.xml @@ -74,41 +74,41 @@ Represents the Korean calendar. - [!NOTE] -> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). - - The class recognizes only the current era. - - Leap years in the Korean calendar correspond to the same leap years in the Gregorian calendar. A leap year in the Gregorian calendar is defined as a Gregorian year that is evenly divisible by four, except if it is divisible by 100. However, Gregorian years that are divisible by 400 are leap years. A common year has 365 days and a leap year has 366 days. - - The Korean calendar has 12 months with 28 to 31 days each: - -|GetMonth value|Month|Days in common years|Days in leap years| -|--------------------|-----------|--------------------------|------------------------| -|1|1월 (January)|31|31| -|2|2월 (February)|28|29| -|3|3월 (March)|31|31| -|4|4월 (April)|30|30| -|5|5월 (May)|31|31| -|6|6월 (June)|30|30| -|7|7월 (July)|31|31| -|8|8월 (August)|31|31| -|9|9월 (September)|30|30| -|10|10월 (October)|31|31| -|11|11월 (November)|30|30| -|12|12월 (December)|31|31| - - February has 29 days during leap years and 28 days during common years. - - The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the first day of January in the year 4334 of the current era in the Korean calendar. - - Each object supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . - +> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). + + The class recognizes only the current era. + + Leap years in the Korean calendar correspond to the same leap years in the Gregorian calendar. A leap year in the Gregorian calendar is defined as a Gregorian year that is evenly divisible by four, except if it is divisible by 100. However, Gregorian years that are divisible by 400 are leap years. A common year has 365 days and a leap year has 366 days. + + The Korean calendar has 12 months with 28 to 31 days each: + +|GetMonth value|Month|Days in common years|Days in leap years| +|--------------------|-----------|--------------------------|------------------------| +|1|1월 (January)|31|31| +|2|2월 (February)|28|29| +|3|3월 (March)|31|31| +|4|4월 (April)|30|30| +|5|5월 (May)|31|31| +|6|6월 (June)|30|30| +|7|7월 (July)|31|31| +|8|8월 (August)|31|31| +|9|9월 (September)|30|30| +|10|10월 (October)|31|31| +|11|11월 (November)|30|30| +|12|12월 (December)|31|31| + + February has 29 days during leap years and 28 days during common years. + + The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the first day of January in the year 4334 of the current era in the Korean calendar. + + Each object supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . + ]]> @@ -211,36 +211,35 @@ Returns a that is the specified number of months away from the specified . The that results from adding the specified number of months to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the `months` parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April. - - If the value of the `months` parameter is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the `months` parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April. + + If the value of the `months` parameter is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Korean calendar. - - -## Examples - The following code example displays the values of several components of a in terms of the Korean calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/AddMonths/koreancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: + ]]> - is less than -120000. - - -or- - + is less than -120000. + + -or- + is greater than 120000. @@ -302,29 +301,28 @@ Returns a that is the specified number of years away from the specified . The that results from adding the specified number of years to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, February has 28 days, except during leap years when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of `years` is 1, the resulting date is the 28th day of February in the following year. - - If `years` is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, February has 28 days, except during leap years when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of `years` is 1, the resulting date is the 28th day of February in the following year. + + If `years` is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: - - - -## Examples - The following code example displays the values of several components of a in terms of the Korean calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: + + + +## Examples + The following code example displays the values of several components of a in terms of the Korean calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/AddMonths/koreancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -386,14 +384,14 @@ Gets a value indicating whether the current calendar is solar-based, lunar-based, or a combination of both. Always returns . - type found in the .NET Framework and displays the value of its property. - + type found in the .NET Framework and displays the value of its property. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AlgorithmType/algorithmtype1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: + ]]> @@ -442,11 +440,11 @@ Gets the list of eras in the . An array of integers that represents the eras in the . - class recognizes only the current era. This property always returns an array with only one element. - + class recognizes only the current era. This property always returns an array with only one element. + ]]> @@ -501,15 +499,14 @@ Returns the day of the month in the specified . An integer from 1 to 31 that represents the day of the month in the specified . - in terms of the Korean calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp" id="Snippet1"::: + in terms of the Korean calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/AddMonths/koreancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -569,30 +566,29 @@ Returns the day of the week in the specified . A value that represents the day of the week in the specified . - values are as follows: - -|DayOfWeek value|Which indicates| -|---------------------|---------------------| -|Sunday|일요일| -|Monday|월요일| -|Tuesday|화요일| -|Wednesday|수요일| -|Thursday|목요일| -|Friday|금요일| -|Saturday|토요일| - - - -## Examples - The following code example displays the values of several components of a in terms of the Korean calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp" id="Snippet1"::: + values are as follows: + +|DayOfWeek value|Which indicates| +|---------------------|---------------------| +|Sunday|일요일| +|Monday|월요일| +|Tuesday|화요일| +|Wednesday|수요일| +|Thursday|목요일| +|Friday|금요일| +|Saturday|토요일| + + + +## Examples + The following code example displays the values of several components of a in terms of the Korean calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/AddMonths/koreancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -653,20 +649,19 @@ Returns the day of the year in the specified . An integer from 1 to 366 that represents the day of the year in the specified . - for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year. The total is the same value as that returned by . - - - -## Examples - The following code example displays the values of several components of a in terms of the Korean calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp" id="Snippet1"::: + for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year. The total is the same value as that returned by . + + + +## Examples + The following code example displays the values of several components of a in terms of the Korean calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/AddMonths/koreancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -730,31 +725,30 @@ Returns the number of days in the specified month in the specified year in the specified era. The number of days in the specified month in the specified year in the specified era. - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -813,27 +807,26 @@ Returns the number of days in the specified year in the specified era. The number of days in the specified year in the specified era. - for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInYear/CPP/koreancalendar_getdaysinyear.cpp" id="Snippet1"::: + for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/GetDaysInYear/koreancalendar_getdaysinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInYear/VB/koreancalendar_getdaysinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetDaysInYear/VB/koreancalendar_getdaysinyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -890,20 +883,19 @@ Returns the era in the specified . An integer that represents the era in the specified . - class recognizes only the current era. - - - -## Examples - The following code example displays the values of several components of a in terms of the Korean calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp" id="Snippet1"::: + class recognizes only the current era. + + + +## Examples + The following code example displays the values of several components of a in terms of the Korean calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/AddMonths/koreancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -977,11 +969,11 @@ Calculates the leap month for a specified year and era. The return value is always 0 because the class does not support the notion of a leap month. - method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. - + method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. + ]]> @@ -1034,15 +1026,14 @@ Returns the month in the specified . An integer from 1 to 12 that represents the month in the specified . - in terms of the Korean calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp" id="Snippet1"::: + in terms of the Korean calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/AddMonths/koreancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1108,22 +1099,21 @@ Returns the number of months in the specified year in the specified era. The number of months in the specified year in the specified era. - for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetMonthsInYear/CPP/koreancalendar_getmonthsinyear.cpp" id="Snippet1"::: + for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/GetMonthsInYear/koreancalendar_getmonthsinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetMonthsInYear/VB/koreancalendar_getmonthsinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.GetMonthsInYear/VB/koreancalendar_getmonthsinyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1189,35 +1179,34 @@ Returns the week of the year that includes the date in the specified . A 1-based integer that represents the week of the year that includes the date in the parameter. - contains culture-specific values that can be used for the `rule` and `firstDayOfWeek` parameters. - - The property of contains the default value that represents the first day of the week for a specific culture, using the calendar specified in the property of . - - The property of contains the default value that defines a calendar week for a specific culture, using the calendar specified in the property of . - - For example, in , for January 1 returns 1. - - - -## Examples - The following code example shows how the result of varies depending on the and values used. If the specified date is the last day of the year, returns the total number of weeks in that year. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp" id="Snippet1"::: + contains culture-specific values that can be used for the `rule` and `firstDayOfWeek` parameters. + + The property of contains the default value that represents the first day of the week for a specific culture, using the calendar specified in the property of . + + The property of contains the default value that defines a calendar week for a specific culture, using the calendar specified in the property of . + + For example, in , for January 1 returns 1. + + + +## Examples + The following code example shows how the result of varies depending on the and values used. If the specified date is the last day of the year, returns the total number of weeks in that year. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetWeekOfYear/yslin_calendar_getweekofyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb" id="Snippet1"::: + ]]> - or is outside the range supported by the calendar. - - -or- - + or is outside the range supported by the calendar. + + -or- + is not a valid value. @@ -1269,15 +1258,14 @@ Returns the year in the specified . An integer that represents the year in the specified . - in terms of the Korean calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/CPP/koreancalendar_addget.cpp" id="Snippet1"::: + in terms of the Korean calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/AddMonths/koreancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar_AddGet/VB/koreancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1348,37 +1336,36 @@ if the specified day is a leap day; otherwise, . - for the last day of the second month (February) for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapDay/CPP/koreancalendar_isleapday.cpp" id="Snippet1"::: + for the last day of the second month (February) for five years in each of the eras. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/IsLeapDay/koreancalendar_isleapday.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapDay/VB/koreancalendar_isleapday.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapDay/VB/koreancalendar_isleapday.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1441,33 +1428,32 @@ Determines whether the specified month in the specified year in the specified era is a leap month. This method always returns , unless overridden by a derived class. - for all the months in five years in the current era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapMonth/CPP/koreancalendar_isleapmonth.cpp" id="Snippet1"::: + for all the months in five years in the current era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/IsLeapMonth/koreancalendar_isleapmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapMonth/VB/koreancalendar_isleapmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapMonth/VB/koreancalendar_isleapmonth.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1528,27 +1514,26 @@ if the specified year is a leap year; otherwise, . - for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapYear/CPP/koreancalendar_isleapyear.cpp" id="Snippet1"::: + for five years in each of the eras. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/KoreanCalendar/IsLeapYear/koreancalendar_isleapyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapYear/VB/koreancalendar_isleapyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.KoreanCalendar.IsLeapYear/VB/koreancalendar_isleapyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1599,11 +1584,11 @@ Represents the current era. This field is constant. - class recognizes only the current era. This field always returns 1. - + class recognizes only the current era. This field always returns 1. + ]]> @@ -1659,15 +1644,14 @@ Gets the latest date and time supported by the class. The latest date and time supported by the class, which is equivalent to the last moment of December 31, 9999 C.E. in the Gregorian calendar. - @@ -1721,15 +1705,14 @@ Gets the earliest date and time supported by the class. The earliest date and time supported by the class, which is equivalent to the first moment of January 1, 0001 C.E. in the Gregorian calendar. - @@ -1797,34 +1780,34 @@ The that is set to the specified date and time in the current era. To be added. - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is less than zero or greater than 23. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 999. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is less than zero or greater than 23. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 999. + + -or- + is outside the range supported by the calendar. @@ -1882,13 +1865,13 @@ Converts the specified year to a four-digit year by using the property to determine the appropriate century. An integer that contains the four-digit representation of . - defines the last year in the 100-year range that can be represented by . The century is determined by finding the sole occurrence of the two-digit year within that 100-year range. For example, if is set to 2029, the 100-year range is from 1930 to 2029. Therefore, a two-digit value of 30 is interpreted as 1930, while a two-digit value of 29 is interpreted as 2029. - - supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. - + defines the last year in the 100-year range that can be represented by . The century is determined by finding the sole occurrence of the two-digit year within that 100-year range. For example, if is set to 2029, the 100-year range is from 1930 to 2029. Therefore, a two-digit value of 30 is interpreted as 1930, while a two-digit value of 29 is interpreted as 2029. + + supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. + ]]> @@ -1940,21 +1923,21 @@ Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. The last year of a 100-year range that can be represented by a 2-digit year. - . The class does not detect changes in the system settings automatically. - - The application should set this value to 99 to indicate that 2-digit years are to be taken literally. For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. Therefore, a 2-digit value of 30 is interpreted as 30. - + . The class does not detect changes in the system settings automatically. + + The application should set this value to 99 to indicate that 2-digit years are to be taken literally. For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. Therefore, a 2-digit value of 30 is interpreted as 30. + ]]> - The value specified in a set operation is less than 99. - - -or- - + The value specified in a set operation is less than 99. + + -or- + The value specified in a set operation is greater than . In a set operation, the current instance is read-only. diff --git a/xml/System.Globalization/NumberFormatInfo.xml b/xml/System.Globalization/NumberFormatInfo.xml index 0f7dfa887c8..543fdec0b41 100644 --- a/xml/System.Globalization/NumberFormatInfo.xml +++ b/xml/System.Globalization/NumberFormatInfo.xml @@ -94,7 +94,6 @@ The following example shows how to retrieve a object for a corresponding object, and use the retrieved object to query number formatting information for the particular culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/NumberFormatInfo/cpp/NumberFormatInfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/Overview/NumberFormatInfo.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/NumberFormatInfo/vb/numberformatinfo.vb" id="Snippet1"::: @@ -288,7 +287,6 @@ ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalDigits/CPP/currencydecimaldigits.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/CurrencyDecimalDigits/currencydecimaldigits.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CurrencyDecimalDigits/VB/currencydecimaldigits.vb" id="Snippet1"::: @@ -360,7 +358,6 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CurrencyDecimalSeparator/CPP/currencydecimalseparator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/CurrencyDecimalSeparator/currencydecimalseparator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CurrencyDecimalSeparator/VB/currencydecimalseparator.vb" id="Snippet1"::: @@ -433,7 +430,6 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSeparator/CPP/currencygroupseparator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/CurrencyGroupSeparator/currencygroupseparator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CurrencyGroupSeparator/VB/currencygroupseparator.vb" id="Snippet1"::: @@ -507,7 +503,6 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CurrencyGroupSizes/CPP/currencygroupsizes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/CurrencyGroupSizes/currencygroupsizes.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CurrencyGroupSizes/VB/currencygroupsizes.vb" id="Snippet1"::: @@ -1083,7 +1078,6 @@ The pattern does not support a positive sign. ## Examples The following example displays the default property values of the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.NumberFormatInfo.InvariantInfo/CPP/invariantinfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/InvariantInfo/invariantinfo.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.NumberFormatInfo.InvariantInfo/VB/invariantinfo.vb" id="Snippet1"::: @@ -1265,7 +1259,6 @@ The pattern does not support a positive sign. ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.NFI.nativeDigits/cpp/nd.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/NativeDigits/nd.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.NFI.nativeDigits/vb/nd.vb" id="Snippet1"::: @@ -1463,7 +1456,6 @@ The pattern does not support a positive sign. ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/NumberDecimalDigits/CPP/numberdecimaldigits.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/NumberDecimalDigits/numberdecimaldigits.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/NumberDecimalDigits/VB/numberdecimaldigits.vb" id="Snippet1"::: @@ -1534,7 +1526,6 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/NumberDecimalSeparator/CPP/numberdecimalseparator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/NumberDecimalSeparator/numberdecimalseparator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/NumberDecimalSeparator/VB/numberdecimalseparator.vb" id="Snippet1"::: @@ -1606,7 +1597,6 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/NumberGroupSeparator/CPP/numbergroupseparator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/NumberGroupSeparator/numbergroupseparator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/NumberGroupSeparator/VB/numbergroupseparator.vb" id="Snippet1"::: @@ -1681,13 +1671,11 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/NumberGroupSizes/CPP/numbergroupsizes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/NumberGroupSizes/numbergroupsizes.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/NumberGroupSizes/VB/numbergroupsizes.vb" id="Snippet1"::: The following example prints a value using different arrays. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberGroupSizes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/NumberGroupSizes/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberGroupSizes Example/VB/source.vb" id="Snippet1"::: @@ -1771,7 +1759,6 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example displays a value using different patterns. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberNegativePattern Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/NumberNegativePattern/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NumberFormatInfo.NumberNegativePattern Example/VB/source.vb" id="Snippet1"::: @@ -1840,7 +1827,6 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PercentDecimalDigits/CPP/percentdecimaldigits.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/PercentDecimalDigits/percentdecimaldigits.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PercentDecimalDigits/VB/percentdecimaldigits.vb" id="Snippet1"::: @@ -1910,7 +1896,6 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PercentDecimalSeparator/CPP/percentdecimalseparator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/PercentDecimalSeparator/percentdecimalseparator.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PercentDecimalSeparator/VB/percentdecimalseparator.vb" id="Snippet1"::: @@ -1981,7 +1966,6 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PercentGroupSeparator/CPP/percentgroupseparator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/PercentGroupSeparator/percentgroupseparator.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PercentGroupSeparator/VB/percentgroupseparator.vb" id="Snippet1"::: @@ -2055,7 +2039,6 @@ On Windows, the initial value of this property is derived from the settings in t ## Examples The following example demonstrates the effect of changing the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PercentGroupSizes/CPP/percentgroupsizes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberFormatInfo/PercentGroupSizes/percentgroupsizes.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/PercentGroupSizes/VB/percentgroupsizes.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/NumberStyles.xml b/xml/System.Globalization/NumberStyles.xml index d25e2fe37af..4d828b929e8 100644 --- a/xml/System.Globalization/NumberStyles.xml +++ b/xml/System.Globalization/NumberStyles.xml @@ -95,10 +95,9 @@ The following table lists the composite number styles and indicates which indivi | | (0x1ff) | (0x17f) | (0x0a7) | (0x007) | (0x06f) | (0x203) | (0x403) | ## Examples - + This example shows how to parse a string into a 32-bit integer by using various `NumberStyles` flags. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/NumberStyles/cpp/NumberStyles.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/NumberStyles/Overview/NumberStyles.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/NumberStyles/vb/numberstyles.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/RegionInfo.xml b/xml/System.Globalization/RegionInfo.xml index 4d62e2d4341..a9bf3543a86 100644 --- a/xml/System.Globalization/RegionInfo.xml +++ b/xml/System.Globalization/RegionInfo.xml @@ -84,7 +84,6 @@ The following example demonstrates several members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo/CPP/regioninfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/Overview/regioninfo.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo/VB/regioninfo.vb" id="Snippet1"::: @@ -163,7 +162,6 @@ ## Examples The following code example compares two instances of that were created differently. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/CPP/regioninfo_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/.ctor/regioninfo_equals.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/VB/regioninfo_equals.vb" id="Snippet1"::: @@ -246,13 +244,11 @@ This constructor throws an if `name` is a neutra ## Examples The following code example compares two instances of that were created differently. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/CPP/regioninfo_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/.ctor/regioninfo_equals.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/VB/regioninfo_equals.vb" id="Snippet1"::: The following code example creates instances of using culture names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo.ctorCultureName/CPP/regioninfo_ctorculturename.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/.ctor/regioninfo_ctorculturename.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo.ctorCultureName/VB/regioninfo_ctorculturename.vb" id="Snippet1"::: @@ -327,7 +323,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencyEnglishName/rgn5props.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/VB/rgn5props.vb" id="Snippet1"::: @@ -396,7 +391,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencyEnglishName/rgn5props.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/VB/rgn5props.vb" id="Snippet1"::: @@ -464,7 +458,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example displays the properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencySymbol/regioninfo_properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/VB/regioninfo_properties.vb" id="Snippet1"::: @@ -592,7 +585,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example displays the properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencySymbol/regioninfo_properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/VB/regioninfo_properties.vb" id="Snippet1"::: @@ -663,7 +655,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example displays the properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencySymbol/regioninfo_properties.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/VB/regioninfo_properties.vb" id="Snippet1"::: @@ -741,7 +732,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example compares two instances of that were created differently. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/CPP/regioninfo_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/.ctor/regioninfo_equals.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Equals/VB/regioninfo_equals.vb" id="Snippet1"::: @@ -807,7 +797,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencyEnglishName/rgn5props.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/VB/rgn5props.vb" id="Snippet1"::: @@ -930,7 +919,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example displays the properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencySymbol/regioninfo_properties.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/VB/regioninfo_properties.vb" id="Snippet1"::: @@ -1110,7 +1098,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example displays the properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencySymbol/regioninfo_properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/VB/regioninfo_properties.vb" id="Snippet1"::: @@ -1177,7 +1164,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example displays the properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencySymbol/regioninfo_properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/VB/regioninfo_properties.vb" id="Snippet1"::: @@ -1255,7 +1241,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/cpp/rgn5props.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencyEnglishName/rgn5props.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.glob.regioninfo.rgn5props/VB/rgn5props.vb" id="Snippet1"::: @@ -1321,7 +1306,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example displays the properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencySymbol/regioninfo_properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/VB/regioninfo_properties.vb" id="Snippet1"::: @@ -1390,7 +1374,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example displays the properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencySymbol/regioninfo_properties.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/VB/regioninfo_properties.vb" id="Snippet1"::: @@ -1533,7 +1516,6 @@ This constructor throws an if `name` is a neutra ## Examples The following code example displays the properties of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/CPP/regioninfo_properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/RegionInfo/CurrencySymbol/regioninfo_properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.RegionInfo_Properties/VB/regioninfo_properties.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/SortKey.xml b/xml/System.Globalization/SortKey.xml index 03e78e69eb6..7ce0db169ac 100644 --- a/xml/System.Globalization/SortKey.xml +++ b/xml/System.Globalization/SortKey.xml @@ -67,7 +67,6 @@ when compared with different objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.SortKey.Equals/CPP/sortkey_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/SortKey/Equals/sortkey_equals.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.SortKey.Equals/VB/sortkey_equals.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/StringInfo.xml b/xml/System.Globalization/StringInfo.xml index 24190e65eff..fba1709c4cc 100644 --- a/xml/System.Globalization/StringInfo.xml +++ b/xml/System.Globalization/StringInfo.xml @@ -109,7 +109,6 @@ Each string is parsed once by the and methods of the class to manipulate a string that contains surrogate and combining characters. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StringInfo/cpp/StringInfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/StringInfo/Overview/StringInfo.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StringInfo/vb/stringinfo.vb" id="Snippet1"::: @@ -733,7 +732,6 @@ A grapheme cluster is a sequence of one or more Unicode code points that should ## Examples The following example demonstrates calling the method. This example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StringInfo/cpp/StringInfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/StringInfo/Overview/StringInfo.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StringInfo/vb/stringinfo.vb" id="Snippet1"::: @@ -946,7 +944,6 @@ A grapheme cluster is a sequence of one or more Unicode code points that should ## Examples The following example demonstrates calling the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StringInfo/cpp/StringInfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/StringInfo/Overview/StringInfo.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StringInfo/vb/stringinfo.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/TaiwanCalendar.xml b/xml/System.Globalization/TaiwanCalendar.xml index 7086d203755..f109bb661e2 100644 --- a/xml/System.Globalization/TaiwanCalendar.xml +++ b/xml/System.Globalization/TaiwanCalendar.xml @@ -74,39 +74,39 @@ the Taiwan calendar. - class recognizes only the current era. - + class recognizes only the current era. + > [!NOTE] -> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). - - Leap years in the Taiwan calendar correspond to the same leap years in the Gregorian calendar. A leap year in the Gregorian calendar is defined as a Gregorian year that is evenly divisible by four, except if it is divisible by 100. However, Gregorian years that are divisible by 400 are leap years. A common year has 365 days and a leap year has 366 days. - - The Taiwan calendar has 12 months with 28 to 31 days each: - -|GetMonth value|Month|Days in common years|Days in leap years| -|--------------------|-----------|--------------------------|------------------------| -|1|1月 (January)|31|31| -|2|2月 (February)|28|29| -|3|3月 (March)|31|31| -|4|4月 (April)|30|30| -|5|5月 (May)|31|31| -|6|6月 (June)|30|30| -|7|7月 (July)|31|31| -|8|8月 (August)|31|31| -|9|9月 (September)|30|30| -|10|10月 (October)|31|31| -|11|11月 (November)|30|30| -|12|12月 (December)|31|31| - - February has 29 days during leap years and 28 during common years. - - The date January 1, 2001 C.E. in the Gregorian calendar is equivalent to the first day of January in the year 90 of the current era in the Taiwan calendar. - - Each supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . - +> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). + + Leap years in the Taiwan calendar correspond to the same leap years in the Gregorian calendar. A leap year in the Gregorian calendar is defined as a Gregorian year that is evenly divisible by four, except if it is divisible by 100. However, Gregorian years that are divisible by 400 are leap years. A common year has 365 days and a leap year has 366 days. + + The Taiwan calendar has 12 months with 28 to 31 days each: + +|GetMonth value|Month|Days in common years|Days in leap years| +|--------------------|-----------|--------------------------|------------------------| +|1|1月 (January)|31|31| +|2|2月 (February)|28|29| +|3|3月 (March)|31|31| +|4|4月 (April)|30|30| +|5|5月 (May)|31|31| +|6|6月 (June)|30|30| +|7|7月 (July)|31|31| +|8|8月 (August)|31|31| +|9|9月 (September)|30|30| +|10|10月 (October)|31|31| +|11|11月 (November)|30|30| +|12|12月 (December)|31|31| + + February has 29 days during leap years and 28 during common years. + + The date January 1, 2001 C.E. in the Gregorian calendar is equivalent to the first day of January in the year 90 of the current era in the Taiwan calendar. + + Each supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . + ]]> @@ -212,37 +212,36 @@ Returns a that is the specified number of months away from the specified . The that results from adding the specified number of months to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the `months` parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April. - - If the value of the `months` parameter is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the `months` parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April. + + If the value of the `months` parameter is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: - - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + + + +## Examples + The following code example demonstrates the use of the method. -## Examples - The following code example demonstrates the use of the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/AddMonths/taiwancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. - is less than -120000. - - -or- - + is less than -120000. + + -or- + is greater than 120000. @@ -299,29 +298,28 @@ Returns a that is the specified number of years away from the specified . The that results from adding the specified number of years to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, February has 28 days, except during leap years when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of `years` is 1, the resulting date is the 28th day of February in the following year. - - If `years` is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, February has 28 days, except during leap years when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of `years` is 1, the resulting date is the 28th day of February in the following year. + + If `years` is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: - - - -## Examples - The following code example displays the use of the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: + + + +## Examples + The following code example displays the use of the method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/AddMonths/taiwancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. @@ -376,14 +374,14 @@ Gets a value that indicates whether the current calendar is solar-based, lunar-based, or a combination of both. Always returns . - type found in the .NET Framework and displays the value of its property. - + type found in the .NET Framework and displays the value of its property. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AlgorithmType/algorithmtype1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: + ]]> @@ -432,11 +430,11 @@ Gets the list of eras in the . An array that consists of a single element for which the value is always the current era. - @@ -490,15 +488,14 @@ Returns the day of the month in the specified . An integer from 1 to 31 that represents the day of the month in the specified . - method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp" id="Snippet1"::: + method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/AddMonths/taiwancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -555,30 +552,29 @@ Returns the day of the week in the specified . A value that represents the day of the week in the specified . - values are as follows: - -|DayOfWeek value|which indicates| -|---------------------|---------------------| -|Sunday|星期日| -|Monday|星期一| -|Tuesday|星期二| -|Wednesday|星期三| -|Thursday|星期四| -|Friday|星期五| -|Saturday|星期六| - - - -## Examples - The following code example demonstrates the use of the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp" id="Snippet1"::: + values are as follows: + +|DayOfWeek value|which indicates| +|---------------------|---------------------| +|Sunday|星期日| +|Monday|星期一| +|Tuesday|星期二| +|Wednesday|星期三| +|Thursday|星期四| +|Friday|星期五| +|Saturday|星期六| + + + +## Examples + The following code example demonstrates the use of the method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/AddMonths/taiwancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -636,20 +632,19 @@ Returns the day of the year in the specified . An integer from 1 to 366 that represents the day of the year in the specified . - for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year. The total is the same as the value returned by . - - - -## Examples - The following code example demonstrates the use of the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp" id="Snippet1"::: + for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year. The total is the same as the value returned by . + + + +## Examples + The following code example demonstrates the use of the method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/AddMonths/taiwancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -710,31 +705,30 @@ Returns the number of days in the specified month in the specified year in the specified era. The number of days in the specified month in the specified year in the specified era. - for the second month in each of five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInMonth/CPP/taiwancalendar_getdaysinmonth.cpp" id="Snippet1"::: + for the second month in each of five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/GetDaysInMonth/taiwancalendar_getdaysinmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInMonth/VB/taiwancalendar_getdaysinmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInMonth/VB/taiwancalendar_getdaysinmonth.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -792,27 +786,26 @@ Returns the number of days in the specified year in the specified era. The number of days in the specified year in the specified era. - for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInYear/CPP/taiwancalendar_getdaysinyear.cpp" id="Snippet1"::: + for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/GetDaysInYear/taiwancalendar_getdaysinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInYear/VB/taiwancalendar_getdaysinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetDaysInYear/VB/taiwancalendar_getdaysinyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -868,20 +861,19 @@ Returns the era in the specified . An integer that represents the era in the specified . - class recognizes only the current era. - - - -## Examples - The following code example demonstrates the use of the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp" id="Snippet1"::: + class recognizes only the current era. + + + +## Examples + The following code example demonstrates the use of the method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/AddMonths/taiwancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -945,11 +937,11 @@ Calculates the leap month for a specified year and era. The return value is always 0 because the class does not support the notion of a leap month. - method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. - + method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. + ]]> @@ -1002,15 +994,14 @@ Returns the month in the specified . An integer from 1 to 12 that represents the month in the specified . - method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp" id="Snippet1"::: + method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/AddMonths/taiwancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1067,22 +1058,21 @@ Returns the number of months in the specified year in the specified era. The number of months in the specified year in the specified era. - for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetMonthsInYear/CPP/taiwancalendar_getmonthsinyear.cpp" id="Snippet1"::: + for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/GetMonthsInYear/taiwancalendar_getmonthsinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetMonthsInYear/VB/taiwancalendar_getmonthsinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.GetMonthsInYear/VB/taiwancalendar_getmonthsinyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1147,35 +1137,34 @@ Returns the week of the year that includes the date in the specified . A positive integer that represents the week of the year that includes the date in the parameter. - property contains culture-specific values that can be used for the `rule` and `firstDayOfWeek` parameters. - - The property of contains the default value that represents the first day of the week for a specific culture, using the calendar specified in the property of . - - The property of contains the default value that defines a calendar week for a specific culture, using the calendar specified in the property of . - - For example, in , the method for January 1 returns 1. - - - -## Examples - The following code example shows how the result of varies depending on the and values used. If the specified date is the last day of the year, returns the total number of weeks in that year. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp" id="Snippet1"::: + property contains culture-specific values that can be used for the `rule` and `firstDayOfWeek` parameters. + + The property of contains the default value that represents the first day of the week for a specific culture, using the calendar specified in the property of . + + The property of contains the default value that defines a calendar week for a specific culture, using the calendar specified in the property of . + + For example, in , the method for January 1 returns 1. + + + +## Examples + The following code example shows how the result of varies depending on the and values used. If the specified date is the last day of the year, returns the total number of weeks in that year. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetWeekOfYear/yslin_calendar_getweekofyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb" id="Snippet1"::: + ]]> - or is outside the range supported by the calendar. - - -or- - + or is outside the range supported by the calendar. + + -or- + is not a valid value. @@ -1227,15 +1216,14 @@ Returns the year in the specified . An integer that represents the year in the specified . - method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/CPP/taiwancalendar_addget.cpp" id="Snippet1"::: + method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/AddMonths/taiwancalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_AddGet/VB/taiwancalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1299,37 +1287,36 @@ if the specified day is a leap day; otherwise, . - for the last day of the second month (February) for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapDay/CPP/taiwancalendar_isleapday.cpp" id="Snippet1"::: + for the last day of the second month (February) for five years in each of the eras. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/IsLeapDay/taiwancalendar_isleapday.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapDay/VB/taiwancalendar_isleapday.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapDay/VB/taiwancalendar_isleapday.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1390,33 +1377,32 @@ Determines whether the specified month in the specified year in the specified era is a leap month. This method always returns , unless overridden by a derived class. - for all the months in five years in the current era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapMonth/CPP/taiwancalendar_isleapmonth.cpp" id="Snippet1"::: + for all the months in five years in the current era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/IsLeapMonth/taiwancalendar_isleapmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapMonth/VB/taiwancalendar_isleapmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapMonth/VB/taiwancalendar_isleapmonth.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1475,27 +1461,26 @@ if the specified year is a leap year; otherwise, . - for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapYear/CPP/taiwancalendar_isleapyear.cpp" id="Snippet1"::: + for five years in each of the eras. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/IsLeapYear/taiwancalendar_isleapyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapYear/VB/taiwancalendar_isleapyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar.IsLeapYear/VB/taiwancalendar_isleapyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1551,15 +1536,14 @@ Gets the latest date and time supported by the class. The latest date and time supported by the class, which is equivalent to the last moment of December 31, 9999 C.E. in the Gregorian calendar. - @@ -1613,20 +1597,19 @@ Gets the earliest date and time supported by the class. The earliest date and time supported by the class, which is equivalent to the first moment of January 1, 1912 C.E. in the Gregorian calendar. - , which is January 1, 0001 C.E. However, the class does not support that minimum date. Consequently, if your application calls a method to format the time of day using the current calendar but does not specify a format specifier, formatting uses the ISO 8601 sortable ("s") date/time pattern format specifier instead of the default general ("G") date/time pattern format specifier. For more information, see [Standard Date and Time Format Strings](/dotnet/standard/base-types/standard-date-and-time-format-strings). - - - -## Examples - The following code example gets the minimum value and the maximum value of the calendar. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_MinMax/CPP/taiwancalendar_minmax.cpp" id="Snippet1"::: + , which is January 1, 0001 C.E. However, the class does not support that minimum date. Consequently, if your application calls a method to format the time of day using the current calendar but does not specify a format specifier, formatting uses the ISO 8601 sortable ("s") date/time pattern format specifier instead of the default general ("G") date/time pattern format specifier. For more information, see [Standard Date and Time Format Strings](/dotnet/standard/base-types/standard-date-and-time-format-strings). + + + +## Examples + The following code example gets the minimum value and the maximum value of the calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/TaiwanCalendar/MaxSupportedDateTime/taiwancalendar_minmax.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_MinMax/VB/taiwancalendar_minmax.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TaiwanCalendar_MinMax/VB/taiwancalendar_minmax.vb" id="Snippet1"::: + ]]> @@ -1694,34 +1677,34 @@ The that is set to the specified date and time in the current era. To be added. - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is less than zero or greater than 23. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 999. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is less than zero or greater than 23. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 999. + + -or- + is outside the range supported by the calendar. @@ -1777,15 +1760,15 @@ Converts the specified year to a four-digit year by using the property to determine the appropriate century. An integer that contains the four-digit representation of . - . - - Because the year in the Taiwan calendar is typically less than four digits long, this implementation always returns the value of the `year` parameter. - - supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. - + . + + Because the year in the Taiwan calendar is typically less than four digits long, this implementation always returns the value of the `year` parameter. + + supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. + ]]> @@ -1837,19 +1820,19 @@ Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. The last year of a 100-year range that can be represented by a 2-digit year. - . - - Because the year in the Taiwan calendar is typically less than four digits long, this implementation returns 99 by default and does not affect the return value of . - + . + + Because the year in the Taiwan calendar is typically less than four digits long, this implementation returns 99 by default and does not affect the return value of . + ]]> - The value specified in a set operation is less than 99. - - -or- - + The value specified in a set operation is less than 99. + + -or- + The value specified in a set operation is greater than . In a set operation, the current instance is read-only. diff --git a/xml/System.Globalization/TextElementEnumerator.xml b/xml/System.Globalization/TextElementEnumerator.xml index 24fd7bb927a..57ff215794a 100644 --- a/xml/System.Globalization/TextElementEnumerator.xml +++ b/xml/System.Globalization/TextElementEnumerator.xml @@ -78,42 +78,41 @@ Enumerates the text elements of a string. - value. For example, LATIN CAPITAL LETTER A (U+0041) and LATIN SMALL LETTER AE (U+00E6) are base characters. + +- A combining character sequence, which consists of a base character and one or more combining characters. For example, example, LATIN CAPITAL LETTER A (U+0041) followed by COMBINING MACRON (U+0304) is a combining character sequence. + +- Surrogate pairs, which the [Unicode Standard](https://go.microsoft.com/fwlink/?linkid=37123) defines as a coded character representation for a single abstract character that consists of a sequence of two code units: a high surrogate, and a low surrogate. Surrogate pairs are used to represent characters outside of the Unicode Basic Multilingual Plane as UTF-16 encoded characters. For example, GOTHIC LETTER SAUIL (U+10343) is represented in UTF-16 encoding as a high surrogate whose value is 0xD800 and a low surrogate whose value is 0xDF43. A surrogate pair can represent a base character or a combining character. + + The class allows you to work with the text elements in a string rather than with single objects. + + You instantiate a object that represents a particular string by passing the string to the method. This returns an enumerator that is positioned before the first text element in the string. Calling the method also brings the enumerator back to this position. Because this represents an invalid state, you must call to advance the enumerator to the first text element of the string before reading the value of the property to return the current text element. + + When working with a object, you are responsible for positioning the enumerator. The property returns the same text element until you call either or . The enumerator is in an invalid state if it is positioned before the first text element or after the last text element in the string. When the enumerator is in an invalid state, attempting to retrieve the value of the property throws an exception. You can determine whether the enumerator is in an invalid state by testing whether the return value of the property is `false`. + + The object represents a snapshot of the current state of a string variable or string literal at the moment that the object is instantiated. Note that: + +- Text element enumerators can only be used to read data in a string. They cannot modify the underlying string. + +- An enumerator does not have exclusive access to the string that it represents. A string variable can be modified after the enumerator is created. + +- A object enumerates the text elements present in the string at the time that the object was instantiated. It does not reflect any subsequent changes to the string variable if that variable is modified afterward. + +- Because the class does not override , two objects that represent the same string will be considered unequal. + + + +## Examples + The following example uses the class to enumerate the text elements of a string. -## Remarks - The .NET Framework defines a text element as a unit of text that is displayed as a single character, that is, a grapheme. A text element can be any of the following: - -- A base character, which is represented as a single value. For example, LATIN CAPITAL LETTER A (U+0041) and LATIN SMALL LETTER AE (U+00E6) are base characters. - -- A combining character sequence, which consists of a base character and one or more combining characters. For example, example, LATIN CAPITAL LETTER A (U+0041) followed by COMBINING MACRON (U+0304) is a combining character sequence. - -- Surrogate pairs, which the [Unicode Standard](https://go.microsoft.com/fwlink/?linkid=37123) defines as a coded character representation for a single abstract character that consists of a sequence of two code units: a high surrogate, and a low surrogate. Surrogate pairs are used to represent characters outside of the Unicode Basic Multilingual Plane as UTF-16 encoded characters. For example, GOTHIC LETTER SAUIL (U+10343) is represented in UTF-16 encoding as a high surrogate whose value is 0xD800 and a low surrogate whose value is 0xDF43. A surrogate pair can represent a base character or a combining character. - - The class allows you to work with the text elements in a string rather than with single objects. - - You instantiate a object that represents a particular string by passing the string to the method. This returns an enumerator that is positioned before the first text element in the string. Calling the method also brings the enumerator back to this position. Because this represents an invalid state, you must call to advance the enumerator to the first text element of the string before reading the value of the property to return the current text element. - - When working with a object, you are responsible for positioning the enumerator. The property returns the same text element until you call either or . The enumerator is in an invalid state if it is positioned before the first text element or after the last text element in the string. When the enumerator is in an invalid state, attempting to retrieve the value of the property throws an exception. You can determine whether the enumerator is in an invalid state by testing whether the return value of the property is `false`. - - The object represents a snapshot of the current state of a string variable or string literal at the moment that the object is instantiated. Note that: - -- Text element enumerators can only be used to read data in a string. They cannot modify the underlying string. - -- An enumerator does not have exclusive access to the string that it represents. A string variable can be modified after the enumerator is created. - -- A object enumerates the text elements present in the string at the time that the object was instantiated. It does not reflect any subsequent changes to the string variable if that variable is modified afterward. - -- Because the class does not override , two objects that represent the same string will be considered unequal. - - - -## Examples - The following example uses the class to enumerate the text elements of a string. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextElementEnumerator.Summary/CPP/tee_summary.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/TextElementEnumerator/Overview/tee_summary.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TextElementEnumerator.Summary/VB/tee_summary.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TextElementEnumerator.Summary/VB/tee_summary.vb" id="Snippet1"::: + ]]> @@ -166,15 +165,15 @@ Gets the current text element in the string. An object containing the current text element in the string. - is called, must be called to advance the enumerator to the first text element of the string before reading the value of . Otherwise, is undefined. - - also throws an exception if the last call to returned `false`, which indicates the end of the string. - - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + is called, must be called to advance the enumerator to the first text element of the string before reading the value of . Otherwise, is undefined. + + also throws an exception if the last call to returned `false`, which indicates the end of the string. + + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> The enumerator is positioned before the first text element of the string or after the last text element. @@ -278,11 +277,11 @@ Gets the current text element in the string. A new string containing the current text element in the string being read. - property. - + property. + ]]> The enumerator is positioned before the first text element of the string or after the last text element. @@ -345,15 +344,15 @@ if the enumerator was successfully advanced to the next text element; if the enumerator has passed the end of the string. - is called, the enumerator is positioned before the first text element of the string, and the first call to moves the enumerator over the first text element of the string. - - If the string is modified after this enumerator was created, throws an exception. - - After the end of the string is passed, subsequent calls to return `false` until is called. - + is called, the enumerator is positioned before the first text element of the string, and the first call to moves the enumerator over the first text element of the string. + + If the string is modified after this enumerator was created, throws an exception. + + After the end of the string is passed, subsequent calls to return `false` until is called. + ]]> @@ -413,11 +412,11 @@ Sets the enumerator to its initial position, which is before the first text element in the string. - method moves the enumerator to the beginning of the string, before the first text element. After calling , you must call to advance the enumerator to the first text element of the string before calling to read the value of the first text element. - + method moves the enumerator to the beginning of the string, before the first text element. After calling , you must call to advance the enumerator to the first text element of the string before calling to read the value of the first text element. + ]]> diff --git a/xml/System.Globalization/TextInfo.xml b/xml/System.Globalization/TextInfo.xml index b7003379a04..1fe4364ccc5 100644 --- a/xml/System.Globalization/TextInfo.xml +++ b/xml/System.Globalization/TextInfo.xml @@ -960,7 +960,6 @@ The property always reflects a spec ## Examples The following code example changes the casing of a string based on the English (United States) culture, with the culture name en-US. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/CPP/textinfo_casing.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/TextInfo/ToTitleCase/textinfo_casing.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/VB/textinfo_casing.vb" id="Snippet1"::: @@ -1246,7 +1245,6 @@ The property always reflects a spec ## Examples The following example changes the casing of a string based on the English (United States) culture, with the culture name en-US. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/CPP/textinfo_casing.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/TextInfo/ToTitleCase/textinfo_casing.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/VB/textinfo_casing.vb" id="Snippet1"::: @@ -1277,7 +1275,6 @@ The property always reflects a spec ## Examples The following code example changes the casing of a string based on the English (United States) culture, with the culture name en-US. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/CPP/textinfo_casing.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/TextInfo/ToTitleCase/textinfo_casing.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.TextInfo_casing/VB/textinfo_casing.vb" id="Snippet1"::: diff --git a/xml/System.Globalization/ThaiBuddhistCalendar.xml b/xml/System.Globalization/ThaiBuddhistCalendar.xml index bfedc8c36da..eaa85ccdf8c 100644 --- a/xml/System.Globalization/ThaiBuddhistCalendar.xml +++ b/xml/System.Globalization/ThaiBuddhistCalendar.xml @@ -74,41 +74,41 @@ Represents the Thai Buddhist calendar. - [!NOTE] -> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). - - The class recognizes only the current era. - - Leap years in the Thai Buddhist calendar correspond to the same leap years in the Gregorian calendar. A leap year in the Gregorian calendar is defined as a Gregorian year that is evenly divisible by four, except if it is divisible by 100. However, Gregorian years that are divisible by 400 are leap years. A common year has 365 days and a leap year has 366 days. - - The Thai Buddhist calendar has 12 months with 28 to 31 days each: - -|GetMonth value|Month|Days in common years|Days in leap years| -|--------------------|-----------|--------------------------|------------------------| -|1|มกราคม (January)|31|31| -|2|กุมภาพันธ์ (February)|28|29| -|3|มีนาคม (March)|31|31| -|4|เมษายน (April)|30|30| -|5|พฤษภาคม (May)|31|31| -|6|มิถุนายน (June)|30|30| -|7|กรกฎาคม (July)|31|31| -|8|สิงหาคม (August)|31|31| -|9|กันยายน (September)|30|30| -|10|ตุลาคม (October)|31|31| -|11|พฤศจิกายน (November)|30|30| -|12|ธันวาคม (December)|31|31| - - February has 29 days during leap years and 28 during common years. - - The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the first day of January in the year 2544 of the current era in the Thai Buddhist calendar. - - Each supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . - +> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). + + The class recognizes only the current era. + + Leap years in the Thai Buddhist calendar correspond to the same leap years in the Gregorian calendar. A leap year in the Gregorian calendar is defined as a Gregorian year that is evenly divisible by four, except if it is divisible by 100. However, Gregorian years that are divisible by 400 are leap years. A common year has 365 days and a leap year has 366 days. + + The Thai Buddhist calendar has 12 months with 28 to 31 days each: + +|GetMonth value|Month|Days in common years|Days in leap years| +|--------------------|-----------|--------------------------|------------------------| +|1|มกราคม (January)|31|31| +|2|กุมภาพันธ์ (February)|28|29| +|3|มีนาคม (March)|31|31| +|4|เมษายน (April)|30|30| +|5|พฤษภาคม (May)|31|31| +|6|มิถุนายน (June)|30|30| +|7|กรกฎาคม (July)|31|31| +|8|สิงหาคม (August)|31|31| +|9|กันยายน (September)|30|30| +|10|ตุลาคม (October)|31|31| +|11|พฤศจิกายน (November)|30|30| +|12|ธันวาคม (December)|31|31| + + February has 29 days during leap years and 28 during common years. + + The date January 1, 2001 A.D. in the Gregorian calendar is equivalent to the first day of January in the year 2544 of the current era in the Thai Buddhist calendar. + + Each supports a set of calendars. The property returns the default calendar for the culture, and the property returns an array containing all the calendars supported by the culture. To change the calendar used by a , the application should set the property of to a new . + ]]> @@ -210,37 +210,36 @@ Returns a that is the specified number of months away from the specified . The that results from adding the specified number of months to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the `months` parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April. - - If the value of the `months` parameter is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the `months` parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April. + + If the value of the `months` parameter is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + + + +## Examples + The following example demonstrates the use of the method. - - -## Examples - The following example demonstrates the use of the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/AddMonths/thaibuddhistcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. - is less than -120000. - - -or- - + is less than -120000. + + -or- + is greater than 120000. @@ -296,29 +295,28 @@ Returns a that is the specified number of years away from the specified . The that results from adding the specified number of years to the specified . - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, February has 28 days except during leap years, when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of `years` is 1, the resulting date is the 28th day of February in the following year. - - If `years` is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, February has 28 days except during leap years, when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of `years` is 1, the resulting date is the 28th day of February in the following year. + + If `years` is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: - - - -## Examples - The following example demonstrates the use of the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: + + + +## Examples + The following example demonstrates the use of the method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/AddMonths/thaibuddhistcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: + ]]> The resulting is outside the supported range. @@ -373,14 +371,14 @@ Gets a value indicating whether the current calendar is solar-based, lunar-based, or a combination of both. Always returns . - type found in the .NET Framework and displays the value of its property. - + type found in the .NET Framework and displays the value of its property. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AlgorithmType/algorithmtype1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: + ]]> @@ -429,11 +427,11 @@ Gets the list of eras in the class. An array that consists of a single element having a value that is always the current era. - @@ -488,15 +486,14 @@ Returns the day of the month in the specified . An integer from 1 to 31 that represents the day of the month in the specified . - method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp" id="Snippet1"::: + method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/AddMonths/thaibuddhistcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -553,30 +550,29 @@ Returns the day of the week in the specified . A value that represents the day of the week in the specified . - values are as follows: - -|DayOfWeek value|which indicates| -|---------------------|---------------------| -|Sunday|อาทิตย์| -|Monday|จันทร์| -|Tuesday|อังคาร| -|Wednesday|พุธ| -|Thursday|พฤหัสบดี| -|Friday|ศุกร์| -|Saturday|เสาร์| - - - -## Examples - The following example demonstrates the use of the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp" id="Snippet1"::: + values are as follows: + +|DayOfWeek value|which indicates| +|---------------------|---------------------| +|Sunday|อาทิตย์| +|Monday|จันทร์| +|Tuesday|อังคาร| +|Wednesday|พุธ| +|Thursday|พฤหัสบดี| +|Friday|ศุกร์| +|Saturday|เสาร์| + + + +## Examples + The following example demonstrates the use of the method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/AddMonths/thaibuddhistcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -634,20 +630,19 @@ Returns the day of the year in the specified . An integer from 1 to 366 that represents the day of the year in the specified . - for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year. The total is the same as the value returned by . - - - -## Examples - The following example demonstrates the use of the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp" id="Snippet1"::: + for the first day of the first month returns 1, and for the last day of the last month returns the total number of days in that year. The total is the same as the value returned by . + + + +## Examples + The following example demonstrates the use of the method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/AddMonths/thaibuddhistcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -708,31 +703,30 @@ Returns the number of days in the specified month in the specified year in the specified era. The number of days in the specified month in the specified year in the specified era. - for the second month in each of five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInMonth/CPP/thaibuddhistcalendar_getdaysinmonth.cpp" id="Snippet1"::: + for the second month in each of five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/GetDaysInMonth/thaibuddhistcalendar_getdaysinmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInMonth/VB/thaibuddhistcalendar_getdaysinmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInMonth/VB/thaibuddhistcalendar_getdaysinmonth.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -790,27 +784,26 @@ Returns the number of days in the specified year in the specified era. The number of days in the specified year in the specified era. - for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInYear/CPP/thaibuddhistcalendar_getdaysinyear.cpp" id="Snippet1"::: + for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/GetDaysInYear/thaibuddhistcalendar_getdaysinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInYear/VB/thaibuddhistcalendar_getdaysinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetDaysInYear/VB/thaibuddhistcalendar_getdaysinyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -866,20 +859,19 @@ Returns the era in the specified . An integer that represents the era in the specified . - class recognizes only the current era. - - - -## Examples - The following example demonstrates the use of the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp" id="Snippet1"::: + class recognizes only the current era. + + + +## Examples + The following example demonstrates the use of the method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/AddMonths/thaibuddhistcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -943,11 +935,11 @@ Calculates the leap month for a specified year and era. The return value is always 0 because the class does not support the notion of a leap month. - method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. - + method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. + ]]> @@ -1000,15 +992,14 @@ Returns the month in the specified . An integer from 1 to 12 that represents the month in the specified . - method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp" id="Snippet1"::: + method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/AddMonths/thaibuddhistcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1066,22 +1057,21 @@ Returns the number of months in the specified year in the specified era. The number of months in the specified year in the specified era. - for five years in each era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetMonthsInYear/CPP/thaibuddhistcalendar_getmonthsinyear.cpp" id="Snippet1"::: + for five years in each era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/GetMonthsInYear/thaibuddhistcalendar_getmonthsinyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetMonthsInYear/VB/thaibuddhistcalendar_getmonthsinyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.GetMonthsInYear/VB/thaibuddhistcalendar_getmonthsinyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1146,35 +1136,34 @@ Returns the week of the year that includes the date in the specified . A 1-based positive integer that represents the week of the year that includes the date in the parameter. - contains culture-specific values that can be used for the `rule` and `firstDayOfWeek` parameters. - - The property of contains the default value that represents the first day of the week for a specific culture, using the calendar specified in the property of . - - The property of contains the default value that defines a calendar week for a specific culture, using the calendar specified in the property of . - - For example, in , for January 1 returns 1. - - - -## Examples - The following example shows how the result of the method varies depending on the and values used. If the specified date is the last day of the year, returns the total number of weeks in that year. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/CPP/yslin_calendar_getweekofyear.cpp" id="Snippet1"::: + contains culture-specific values that can be used for the `rule` and `firstDayOfWeek` parameters. + + The property of contains the default value that represents the first day of the week for a specific culture, using the calendar specified in the property of . + + The property of contains the default value that defines a calendar week for a specific culture, using the calendar specified in the property of . + + For example, in , for January 1 returns 1. + + + +## Examples + The following example shows how the result of the method varies depending on the and values used. If the specified date is the last day of the year, returns the total number of weeks in that year. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/GetWeekOfYear/yslin_calendar_getweekofyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.Calendar.GetWeekOfYear/VB/yslin_calendar_getweekofyear.vb" id="Snippet1"::: + ]]> - or is outside the range supported by the calendar. - - -or- - + or is outside the range supported by the calendar. + + -or- + is not a valid value. @@ -1230,15 +1219,14 @@ Returns the year in the specified . An integer that represents the year in the specified . - Method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/CPP/thaibuddhistcalendar_addget.cpp" id="Snippet1"::: + Method. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/AddMonths/thaibuddhistcalendar_addget.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar_AddGet/VB/thaibuddhistcalendar_addget.vb" id="Snippet1"::: + ]]> @@ -1301,37 +1289,36 @@ if the specified day is a leap day; otherwise, . - for the last day of the second month (February) for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapDay/CPP/thaibuddhistcalendar_isleapday.cpp" id="Snippet1"::: + for the last day of the second month (February) for five years in each of the eras. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/IsLeapDay/thaibuddhistcalendar_isleapday.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapDay/VB/thaibuddhistcalendar_isleapday.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapDay/VB/thaibuddhistcalendar_isleapday.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1393,33 +1380,32 @@ Determines whether the specified month in the specified year in the specified era is a leap month. This method always returns , unless overridden by a derived class. - for all the months in five years in the current era. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapMonth/CPP/thaibuddhistcalendar_isleapmonth.cpp" id="Snippet1"::: + for all the months in five years in the current era. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/IsLeapMonth/thaibuddhistcalendar_isleapmonth.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapMonth/VB/thaibuddhistcalendar_isleapmonth.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapMonth/VB/thaibuddhistcalendar_isleapmonth.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1479,27 +1465,26 @@ if the specified year is a leap year; otherwise, . - for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapYear/CPP/thaibuddhistcalendar_isleapyear.cpp" id="Snippet1"::: + for five years in each of the eras. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/ThaiBuddhistCalendar/IsLeapYear/thaibuddhistcalendar_isleapyear.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapYear/VB/thaibuddhistcalendar_isleapyear.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.ThaiBuddhistCalendar.IsLeapYear/VB/thaibuddhistcalendar_isleapyear.vb" id="Snippet1"::: + ]]> - is outside the range supported by the calendar. - - -or- - + is outside the range supported by the calendar. + + -or- + is outside the range supported by the calendar. @@ -1556,15 +1541,14 @@ Gets the latest date and time supported by the class. The latest date and time supported by the class, which is equivalent to the last moment of December 31, 9999 C.E. in the Gregorian calendar. - @@ -1618,15 +1602,14 @@ Gets the earliest date and time supported by the class. The earliest date and time supported by the class, which is equivalent to the first moment of January 1, 0001 C.E. in the Gregorian calendar. - @@ -1673,11 +1656,11 @@ Represents the current era. This field is constant. - class recognizes only the current era. This field always returns 1. - + class recognizes only the current era. This field always returns 1. + ]]> @@ -1747,34 +1730,34 @@ The that is set to the specified date and time in the current era. To be added. - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is outside the range supported by the calendar. - - -or- - - is less than zero or greater than 23. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 999. - - -or- - + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is outside the range supported by the calendar. + + -or- + + is less than zero or greater than 23. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 999. + + -or- + is outside the range supported by the calendar. @@ -1831,13 +1814,13 @@ Converts the specified year to a four-digit year by using the property to determine the appropriate century. An integer that contains the four-digit representation of . - is the last year in the 100-year range that can be represented by a two-digit year. The century is determined by finding the sole occurrence of the two-digit `year` within that 100-year range. For example, if is set to 2029, the 100-year range is from 1930 to 2029. Therefore, a 2-digit value of 30 is interpreted as 1930, while a 2-digit value of 29 is interpreted as 2029. - - supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. - + is the last year in the 100-year range that can be represented by a two-digit year. The century is determined by finding the sole occurrence of the two-digit `year` within that 100-year range. For example, if is set to 2029, the 100-year range is from 1930 to 2029. Therefore, a 2-digit value of 30 is interpreted as 1930, while a 2-digit value of 29 is interpreted as 2029. + + supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. + ]]> @@ -1889,21 +1872,21 @@ Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. The last year of a 100-year range that can be represented by a 2-digit year. - . The class does not detect changes in the system settings automatically. - - The application should set this value to 99 to indicate that 2-digit years are to be taken literally. For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. Therefore, a 2-digit value of 30 is interpreted as 30. - + . The class does not detect changes in the system settings automatically. + + The application should set this value to 99 to indicate that 2-digit years are to be taken literally. For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. Therefore, a 2-digit value of 30 is interpreted as 30. + ]]> - The value specified in a set operation is less than 99. - - -or- - + The value specified in a set operation is less than 99. + + -or- + The value specified in a set operation is greater than . In a set operation, the current instance is read-only. diff --git a/xml/System.Globalization/UmAlQuraCalendar.xml b/xml/System.Globalization/UmAlQuraCalendar.xml index 46c0565d150..501f0806730 100644 --- a/xml/System.Globalization/UmAlQuraCalendar.xml +++ b/xml/System.Globalization/UmAlQuraCalendar.xml @@ -68,20 +68,20 @@ Represents the Saudi Hijri (Um Al Qura) calendar. - class is nearly identical to the class, except the Um Al Qura calendar uses a table-based algorithm licensed from the Saudi government to calculate dates, can express dates to the year 1500 A.H., and does not support the property. - + class is nearly identical to the class, except the Um Al Qura calendar uses a table-based algorithm licensed from the Saudi government to calculate dates, can express dates to the year 1500 A.H., and does not support the property. + > [!NOTE] -> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). - - For the class, each month has either 29 or 30 days, but usually in no discernible order. Whereas the documentation for the Hijri Calendar gives a table that shows the corresponding days in each month, no such general table can be produced for the Um Al Qura calendar. - - For more information about the Hijri calendar, see the class. - - **Note** The class supports only dates from 04/30/1900 00.00.00 (Gregorian date) through 11/16/2077 23:59:59 (Gregorian date). - +> For information about using the class and the other calendar classes in the .NET Framework, see [Working with Calendars](/dotnet/standard/datetime/working-with-calendars). + + For the class, each month has either 29 or 30 days, but usually in no discernible order. Whereas the documentation for the Hijri Calendar gives a table that shows the corresponding days in each month, no such general table can be produced for the Um Al Qura calendar. + + For more information about the Hijri calendar, see the class. + + **Note** The class supports only dates from 04/30/1900 00.00.00 (Gregorian date) through 11/16/2077 23:59:59 (Gregorian date). + ]]> @@ -181,36 +181,36 @@ Calculates a date that is a specified number of months away from a specified initial date. The date yielded by adding the number of months specified by the parameter to the date specified by the parameter. - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, an exception is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, if the specified month is Zulkadah, which has 30 days, the specified day is the 30th day of that month, and the value of the `months` parameter is 3, the resulting year is one more than the specified year, the resulting month is Safar, and the resulting day is the 29th day, which is the last day in Safar. - - If the value of the `months` parameter is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The year part of the resulting is affected if the resulting month is outside the year of the specified . This implementation supports only the current era. Therefore, an exception is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, if the specified month is Zulkadah, which has 30 days, the specified day is the 30th day of that month, and the value of the `months` parameter is 3, the resulting year is one more than the specified year, the resulting month is Safar, and the resulting day is the 29th day, which is the last day in Safar. + + If the value of the `months` parameter is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: - - - -## Examples - The following example instantiates a value and displays the values of several of its components in the Um Al Qura calendar. Next, it calls the and methods to add 2 years and 10 months in the Um Al Qura calendar to the date value. Finally, it again displays the values of these date components in the Um Al Qura calendar. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet5"::: + + + +## Examples + The following example instantiates a value and displays the values of several of its components in the Um Al Qura calendar. Next, it calls the and methods to add 2 years and 10 months in the Um Al Qura calendar to the date value. Finally, it again displays the values of these date components in the Um Al Qura calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/AddMonths/addmonths1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.addmonths/vb/addmonths1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.addmonths/vb/addmonths1.vb" id="Snippet1"::: + ]]> The resulting date is outside the range supported by the class. - is less than -120,000 or greater than 120,000. - - -or- - + is less than -120,000 or greater than 120,000. + + -or- + is outside the range supported by this calendar. @@ -263,36 +263,36 @@ Calculates a date that is a specified number of years away from a specified initial date. The date yielded by adding the number of years specified by the parameter to the date specified by the parameter. - is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, an exception is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . - - For example, Zulhijjah has 29 days, except during leap years when it has 30 days. If the specified date is the 30th day of Zulhijjah in a leap year and the value of the `years` parameter is 1, the resulting date is the 29th day of Zulhijjah in the following year. - - If `years` is negative, the resulting is earlier than the specified . - - The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. - + is affected if the resulting day is not a valid day in the resulting month of the resulting year. It is changed to the last valid day in the resulting month of the resulting year. The month part of the resulting remains the same as the specified . This implementation supports only the current era. Therefore, an exception is thrown if the resulting year is outside the era of the specified . The time-of-day part of the resulting remains the same as the specified . + + For example, Zulhijjah has 29 days, except during leap years when it has 30 days. If the specified date is the 30th day of Zulhijjah in a leap year and the value of the `years` parameter is 1, the resulting date is the 29th day of Zulhijjah in the following year. + + If `years` is negative, the resulting is earlier than the specified . + + The property of the returned value always equals . You can preserve the property of the `time` parameter by calling the method, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AddDays/add1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: - - - -## Examples - The following example instantiates a value and displays the values of several of its components in the Um AL Qura calendar. Next, it calls the and methods to add 2 years and 10 months in the Um Al Qura calendar to the date value. Finally, it again displays the values of these date components in the Um Al Qura calendar. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.addmethods/vb/add1.vb" id="Snippet8"::: + + + +## Examples + The following example instantiates a value and displays the values of several of its components in the Um AL Qura calendar. Next, it calls the and methods to add 2 years and 10 months in the Um Al Qura calendar to the date value. Finally, it again displays the values of these date components in the Um Al Qura calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/AddMonths/addmonths1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.addmonths/vb/addmonths1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.addmonths/vb/addmonths1.vb" id="Snippet1"::: + ]]> The resulting date is outside the range supported by the class. - is less than -10,000 or greater than 10,000. - - -or- - + is less than -10,000 or greater than 10,000. + + -or- + is outside the range supported by this calendar. @@ -337,14 +337,14 @@ Gets a value indicating whether the current calendar is solar-based, lunar-based, or a combination of both. Always returns . - type found in the .NET Framework and displays the value of its property. - + type found in the .NET Framework and displays the value of its property. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/Calendar/AlgorithmType/algorithmtype1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.calendar.algorithmtype/vb/algorithmtype1.vb" id="Snippet1"::: + ]]> @@ -389,11 +389,11 @@ Gets the number of days in the year that precedes the year that is specified by the property. The number of days in the year that precedes the year specified by . - @@ -441,11 +441,11 @@ Gets a list of the eras that are supported by the current . An array that consists of a single element having a value that is . - @@ -497,14 +497,14 @@ Calculates the day of the month on which a specified date occurs. An integer from 1 through 30 that represents the day of the month specified by the parameter. - in terms of the Um Al Qura calendar. - + in terms of the Um Al Qura calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/AddMonths/addmonths1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.addmonths/vb/addmonths1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.addmonths/vb/addmonths1.vb" id="Snippet1"::: + ]]> @@ -559,29 +559,29 @@ Calculates the day of the week on which a specified date occurs. A value that represents the day of the week specified by the parameter. - values are as follows: - -|DayOfWeek value|which indicates| -|---------------------|---------------------| -|Sunday|الاحد (Al-Ahad)| -|Monday|الاثنين (Al-Ithnayn)| -|Tuesday|الثلاثاء (At-Thulaathaa')| -|Wednesday|الاربعاء (Al-Arbi'aa')| -|Thursday|الخميس (Al-Khamiis)| -|Friday|الجمعة (Al-Jumu'ah)| -|Saturday|السبت (As-Sabt)| - - - -## Examples - The following example displays the values of several components of a in terms of the Um Al Qura calendar. - + values are as follows: + +|DayOfWeek value|which indicates| +|---------------------|---------------------| +|Sunday|الاحد (Al-Ahad)| +|Monday|الاثنين (Al-Ithnayn)| +|Tuesday|الثلاثاء (At-Thulaathaa')| +|Wednesday|الاربعاء (Al-Arbi'aa')| +|Thursday|الخميس (Al-Khamiis)| +|Friday|الجمعة (Al-Jumu'ah)| +|Saturday|السبت (As-Sabt)| + + + +## Examples + The following example displays the values of several components of a in terms of the Um Al Qura calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/AddMonths/addmonths1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.addmonths/vb/addmonths1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.addmonths/vb/addmonths1.vb" id="Snippet1"::: + ]]> @@ -637,19 +637,19 @@ Calculates the day of the year on which a specified date occurs. An integer from 1 through 355 that represents the day of the year specified by the parameter. - method returns 1 for the first day of the first month of the year, and the total number of days in the year for the last day of the last month. - - - -## Examples - The following example displays the values of several components of a in terms of the Um Al Qura calendar. - + method returns 1 for the first day of the first month of the year, and the total number of days in the year for the last day of the last month. + + + +## Examples + The following example displays the values of several components of a in terms of the Um Al Qura calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/AddMonths/addmonths1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.addmonths/vb/addmonths1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.addmonths/vb/addmonths1.vb" id="Snippet1"::: + ]]> @@ -708,19 +708,19 @@ Calculates the number of days in the specified month of the specified year and era. The number of days in the specified month in the specified year and era. The return value is 29 in a common year and 30 in a leap year. - method to get the number of days in each month of five consecutive years. - + method to get the number of days in each month of five consecutive years. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/GetDaysInMonth/getdaysinmonth1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getdaysinmonth/vb/getdaysinmonth1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getdaysinmonth/vb/getdaysinmonth1.vb" id="Snippet1"::: + ]]> @@ -776,14 +776,14 @@ Calculates the number of days in the specified year of the specified era. The number of days in the specified year and era. The number of days is 354 in a common year or 355 in a leap year. - method to get the number of days in ten consecutive years in each era supported by the class. - + method to get the number of days in ten consecutive years in each era supported by the class. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/GetDaysInYear/getdaysinyear1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getdaysinyear/vb/getdaysinyear1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getdaysinyear/vb/getdaysinyear1.vb" id="Snippet1"::: + ]]> @@ -838,19 +838,19 @@ Calculates the era in which a specified date occurs. Always returns the value. - @@ -906,18 +906,18 @@ Calculates the leap month for a specified year and era. Always 0 because the class does not support leap months. - method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. - + method returns a number between 1 and 13 that indicates the month associated with a specified date. If there is a leap month between the eighth and ninth months of the year, the method returns 8 for the eighth month, 9 for the leap eighth month, and 10 for the ninth month. + ]]> - is less than 1318 or greater than 1450. - - -or- - + is less than 1318 or greater than 1450. + + -or- + is not or . @@ -968,14 +968,14 @@ Calculates the month in which a specified date occurs. An integer from 1 through 12 that represents the month in the date specified by the parameter. - class in both the Gregorian and Um Al Qura calendars. The method is used to retrieve the month of the minimum and maximum supported dates in the Um Al Qura calendar if it is not the current culture's current calendar. - + class in both the Gregorian and Um Al Qura calendars. The method is used to retrieve the month of the minimum and maximum supported dates in the Um Al Qura calendar if it is not the current culture's current calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/GetMonth/getmonth1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getmonth/vb/getmonth1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getmonth/vb/getmonth1.vb" id="Snippet1"::: + ]]> @@ -1032,14 +1032,14 @@ Calculates the number of months in the specified year of the specified era. Always 12. - method to determine the number of months in four consecutive years, and then calls the method to determine how many days there are in each month. - + method to determine the number of months in four consecutive years, and then calls the method to determine how many days there are in each month. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/GetDaysInMonth/getdaysinmonth1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getdaysinmonth/vb/getdaysinmonth1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getdaysinmonth/vb/getdaysinmonth1.vb" id="Snippet1"::: + ]]> @@ -1095,14 +1095,14 @@ Calculates the year of a date represented by a specified . An integer that represents the year specified by the parameter. - class in both the Gregorian and Um Al Qura calendars. The method is used to retrieve the year of the minimum and maximum supported dates in the Um Al Qura calendar if it is not the current culture's current calendar. - + class in both the Gregorian and Um Al Qura calendars. The method is used to retrieve the year of the minimum and maximum supported dates in the Um Al Qura calendar if it is not the current culture's current calendar. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/GetMonth/getmonth1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getmonth/vb/getmonth1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getmonth/vb/getmonth1.vb" id="Snippet1"::: + ]]> @@ -1163,20 +1163,19 @@ if the specified day is a leap day; otherwise, . The return value is always because the class does not support leap days. - method for the last day of the second month (February) for five years in each of the eras. -## Examples - The following example calls the method for the last day of the second month (February) for five years in each of the eras. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapDay/CPP/hijricalendar_isleapday.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Globalization/HijriCalendar/IsLeapDay/hijricalendar_isleapday.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapDay/VB/hijricalendar_isleapday.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.HijriCalendar.IsLeapDay/VB/hijricalendar_isleapday.vb" id="Snippet1"::: + ]]> @@ -1234,11 +1233,11 @@ Determines whether the specified month in the specified year and era is a leap month. Always because the class does not support leap months. - @@ -1295,19 +1294,19 @@ if the specified year is a leap year; otherwise, . - method to determine which years are leap years. - + method to determine which years are leap years. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/IsLeapYear/isleapyear1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.isleapyear/vb/isleapyear1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.isleapyear/vb/isleapyear1.vb" id="Snippet1"::: + ]]> @@ -1357,21 +1356,21 @@ Gets the latest date and time supported by this calendar. The latest date and time supported by the class, which is equivalent to the last moment of November 16, 2077 C.E. in the Gregorian calendar. - [!NOTE] -> Starting with the .NET Framework 4.5, the value of the property is 11/16/2077. In previous versions of the .NET Framework, its value is the last moment of May 13, 2029 C.E. in the Gregorian calendar. - - - -## Examples - The following example displays the date ranges supported by the class in both the Gregorian and Um Al Qura calendars. - +> Starting with the .NET Framework 4.5, the value of the property is 11/16/2077. In previous versions of the .NET Framework, its value is the last moment of May 13, 2029 C.E. in the Gregorian calendar. + + + +## Examples + The following example displays the date ranges supported by the class in both the Gregorian and Um Al Qura calendars. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/GetMonth/getmonth1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getmonth/vb/getmonth1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getmonth/vb/getmonth1.vb" id="Snippet1"::: + ]]> @@ -1419,14 +1418,14 @@ Gets the earliest date and time supported by this calendar. The earliest date and time supported by the class, which is equivalent to the first moment of April 30, 1900 C.E. in the Gregorian calendar. - class in both the Gregorian and Um Al Qura calendars. - + class in both the Gregorian and Um Al Qura calendars. + :::code language="csharp" source="~/snippets/csharp/System.Globalization/UmAlQuraCalendar/GetMonth/getmonth1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getmonth/vb/getmonth1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.globalization.umalquracalendar.getmonth/vb/getmonth1.vb" id="Snippet1"::: + ]]> @@ -1492,30 +1491,30 @@ Returns a that is set to the specified date, time, and era. The that is set to the specified date and time in the current era. - method is useful because it can convert any date in the current calendar to a Gregorian calendar date. The Gregorian date can subsequently be used, for example, to compare dates in different calendars or create an equivalent date in a particular calendar. - + method is useful because it can convert any date in the current calendar to a Gregorian calendar date. The Gregorian date can subsequently be used, for example, to compare dates in different calendars or create an equivalent date in a particular calendar. + ]]> - , , , or is outside the range supported by the class. - - -or- - - is less than zero or greater than 23. - - -or- - - is less than zero or greater than 59. - - -or- - - is less than zero or greater than 59. - - -or- - + , , , or is outside the range supported by the class. + + -or- + + is less than zero or greater than 23. + + -or- + + is less than zero or greater than 59. + + -or- + + is less than zero or greater than 59. + + -or- + is less than zero or greater than 999. @@ -1566,15 +1565,15 @@ Converts the specified year to a four-digit year by using the property to determine the appropriate century. If the parameter is a 2-digit year, the return value is the corresponding 4-digit year. If the parameter is a 4-digit year, the return value is the unchanged parameter. - method uses the `year` parameter, the property, and a year to calculate a 4-digit year. The century is determined by finding the sole occurrence of the 2-digit `year` parameter within that 100-year range. For example, if is set to 1429, the 100-year range is from 1330 through 1429. Therefore, a 2-digit value of 30 is interpreted as 1330, while a 2-digit value of 29 is interpreted as 1429. - - If the property is the special value 99, the method ignores the settings in the regional and language options in Control Panel and returns the `year` parameter unchanged. - - supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. - + method uses the `year` parameter, the property, and a year to calculate a 4-digit year. The century is determined by finding the sole occurrence of the 2-digit `year` parameter within that 100-year range. For example, if is set to 1429, the 100-year range is from 1330 through 1429. Therefore, a 2-digit value of 30 is interpreted as 1330, while a 2-digit value of 29 is interpreted as 1429. + + If the property is the special value 99, the method ignores the settings in the regional and language options in Control Panel and returns the `year` parameter unchanged. + + supports either a two-digit year or a four-digit year. Passing a two-digit year value (less than 100) causes the method to convert the value to a four-digit value according to the value representing the appropriate century. If the application supplies a four-digit year value that is within the supported calendar range to , the method returns the actual input value. If the application supplies a four-digit value that is outside the supported calendar range, or if it supplies a negative value, the method throws an exception. + ]]> @@ -1625,15 +1624,15 @@ Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. The last year of a 100-year range that can be represented by a 2-digit year. - . The class does not detect changes in the system settings automatically. - - The special value 99 causes the method to ignore the system settings and return the specified year unchanged. - + . The class does not detect changes in the system settings automatically. + + The special value 99 causes the method to ignore the system settings and return the specified year unchanged. + ]]> This calendar is read-only. @@ -1682,13 +1681,13 @@ Represents the current era. This field is constant. - field is 1. - - The Um Al Qura calendar recognizes one era: A.H. (Latin "Anno Hegirae", which means "the year of the migration," in reference to the migration of Muhammad (PBUH) from Mecca). - + field is 1. + + The Um Al Qura calendar recognizes one era: A.H. (Latin "Anno Hegirae", which means "the year of the migration," in reference to the migration of Muhammad (PBUH) from Mecca). + ]]> diff --git a/xml/System.IO.IsolatedStorage/IsolatedStorageFile.xml b/xml/System.IO.IsolatedStorage/IsolatedStorageFile.xml index 076b47f0cbc..84221849b4a 100644 --- a/xml/System.IO.IsolatedStorage/IsolatedStorageFile.xml +++ b/xml/System.IO.IsolatedStorage/IsolatedStorageFile.xml @@ -197,7 +197,6 @@ ## Examples The following code example demonstrates how to use the method. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet10"::: @@ -442,7 +441,6 @@ ## Examples The following code example demonstrates the method. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet7"::: @@ -593,7 +591,6 @@ ## Examples The following code example demonstrates the property. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet5"::: @@ -663,7 +660,6 @@ ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet8"::: @@ -735,7 +731,6 @@ ## Examples The following code example uses the method to delete a number of files in isolated storage. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet6"::: @@ -867,7 +862,6 @@ ## Examples The following code example opens an isolated storage file, uses it to write information to a stream, closes the file, and then uses the method to release all resources. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet10"::: @@ -1183,7 +1177,6 @@ ## Examples The following code example demonstrates the method. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet16"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet16"::: @@ -1390,7 +1383,6 @@ ## Examples The following code example demonstrates the method. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet16"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet16"::: @@ -1602,7 +1594,6 @@ is functionally equivalent to the following code: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp" id="Snippet18"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/remarks.cs" id="Snippet18"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/remarks.vb" id="Snippet18"::: @@ -1673,7 +1664,6 @@ is functionally equivalent to the following code: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp" id="Snippet19"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/remarks.cs" id="Snippet19"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/remarks.vb" id="Snippet19"::: @@ -1739,7 +1729,6 @@ is functionally equivalent to the following code: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/remarks.cs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/remarks.vb" id="Snippet20"::: @@ -1753,7 +1742,6 @@ ## Examples The following code example demonstrates the method. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet10"::: @@ -2168,7 +2156,6 @@ ## Examples The following code example demonstrates the method. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet15"::: @@ -2336,7 +2323,6 @@ is functionally equivalent to the following code: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp" id="Snippet21"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/remarks.cs" id="Snippet21"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/remarks.vb" id="Snippet21"::: @@ -2410,7 +2396,6 @@ is functionally equivalent to the following code: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp" id="Snippet22"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/remarks.cs" id="Snippet22"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/remarks.vb" id="Snippet22"::: @@ -2481,7 +2466,6 @@ is functionally equivalent to the following code: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/remarks.cpp" id="Snippet23"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/remarks.cs" id="Snippet23"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/remarks.vb" id="Snippet23"::: @@ -2495,7 +2479,6 @@ ## Examples The following code example demonstrates the method. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet10"::: @@ -2781,7 +2764,6 @@ ## Examples The following code example demonstrates the property. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet5"::: @@ -3313,7 +3295,6 @@ ## Examples The following code example uses the method to delete the isolated storage file after its contents have been emptied. The [How to: Delete Stores in Isolated Storage](/dotnet/standard/io/how-to-delete-stores-in-isolated-storage) example also demonstrates the use of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet16"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet16"::: diff --git a/xml/System.IO.IsolatedStorage/IsolatedStorageFileStream.xml b/xml/System.IO.IsolatedStorage/IsolatedStorageFileStream.xml index 3627325ef94..fd7e3074051 100644 --- a/xml/System.IO.IsolatedStorage/IsolatedStorageFileStream.xml +++ b/xml/System.IO.IsolatedStorage/IsolatedStorageFileStream.xml @@ -78,7 +78,6 @@ ## Examples The following console application demonstrates how you can use and to write data to an Isolated Storage file. The user is requested to log in. If the user is a new user, a News URL and a Sports URL are recorded as personal preferences in Isolated Storage. If the user is a returning user, the user's current preferences are displayed. The code examples used throughout this namespace are presented in the context of this sample application. You can use the [Storeadm.exe (Isolated Storage Tool)](/dotnet/framework/tools/storeadm-exe-isolated-storage-tool) utility to list and remove the Isolated Storage files that are created with this console application. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet1"::: @@ -280,7 +279,6 @@ ## Examples The following code example demonstrates the use of this constructor. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet11"::: @@ -351,7 +349,6 @@ ## Examples The following code example demonstrates the use of this constructor. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet15"::: @@ -429,7 +426,6 @@ ## Examples The following code example demonstrates the use of this constructor. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet10"::: @@ -576,7 +572,6 @@ ## Examples The following code example demonstrates the use of this constructor. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet11"::: @@ -663,7 +658,6 @@ ## Examples The following code example demonstrates the use of this constructor. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet12"::: @@ -903,7 +897,6 @@ ## Examples The following code example demonstrates how you could use the property, as a check to see whether a stream can be read before calling the or methods. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet11"::: @@ -1012,7 +1005,6 @@ ## Examples The following code example demonstrates how you could use the property, as a check to see whether a stream can be read before calling the or methods. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet13"::: @@ -1525,7 +1517,6 @@ Dim source As New IsolatedStorageFileStream(UserName,FileMode.Open,isoFile) ## Examples The following code example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet4"::: @@ -1584,7 +1575,6 @@ Dim source As New IsolatedStorageFileStream(UserName,FileMode.Open,isoFile) ## Examples The following code example demonstrates how you can use the property to verify that an is synchronous. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet7"::: @@ -1643,7 +1633,6 @@ Dim source As New IsolatedStorageFileStream(UserName,FileMode.Open,isoFile) ## Examples The following code example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet14"::: @@ -1761,7 +1750,6 @@ Dim source As New IsolatedStorageFileStream(UserName,FileMode.Open,isoFile) ## Examples The following code example uses the property to write data to a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet14"::: @@ -2020,7 +2008,6 @@ This method stores in the task it returns all non-usage exceptions that the meth ## Examples The following code example demonstrates how the method can be used to read data from an object. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet14"::: @@ -2506,7 +2493,6 @@ This method stores in the task it returns all non-usage exceptions that the meth ## Examples The following code example demonstrates how the method can be used to read data from an object. For the complete context of this example, see the overview. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet14"::: diff --git a/xml/System.IO.IsolatedStorage/IsolatedStorageScope.xml b/xml/System.IO.IsolatedStorage/IsolatedStorageScope.xml index 912a5b40efd..dbbd252d30b 100644 --- a/xml/System.IO.IsolatedStorage/IsolatedStorageScope.xml +++ b/xml/System.IO.IsolatedStorage/IsolatedStorageScope.xml @@ -58,20 +58,19 @@ Enumerates the levels of isolated storage scope that are supported by . - to specify a degree of scope for an isolated store. You can specify combinations of these levels that are supported by . + + + +## Examples + The following code example demonstrates how the enumeration is used in the methods. -## Remarks - Use to specify a degree of scope for an isolated store. You can specify combinations of these levels that are supported by . - - - -## Examples - The following code example demonstrates how the enumeration is used in the methods. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/CPP/source.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.IO.IsolatedStorage/IsolatedStorageFile/Close/source.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.IsolatedStorage.IsolatedStorage/VB/source.vb" id="Snippet15"::: + ]]> Types of Isolation diff --git a/xml/System.IO.Pipes/AnonymousPipeClientStream.xml b/xml/System.IO.Pipes/AnonymousPipeClientStream.xml index 31bbaf104c6..b6de0e08dcf 100644 --- a/xml/System.IO.Pipes/AnonymousPipeClientStream.xml +++ b/xml/System.IO.Pipes/AnonymousPipeClientStream.xml @@ -50,28 +50,27 @@ Exposes the client side of an anonymous pipe stream, which supports both synchronous and asynchronous read and write operations (without cancellation support on Windows platforms). - class enables a child process to connect to and exchange information with a parent process. - - Anonymous pipes are unnamed, one-way pipes that typically transfer data between parent and child processes. Anonymous pipes are always local; they cannot be used over a network. A value of is not supported because anonymous pipes are defined to be one-way. - - Anonymous pipes do not support the read mode. - - The client side of an anonymous pipe must be created from a pipe handle provided by the server side by calling the method. The string is then passed as a parameter when creating the client process. From the client process, it is passed to the constructor as the `pipeHandleAsString` parameter. + class enables a child process to connect to and exchange information with a parent process. + + Anonymous pipes are unnamed, one-way pipes that typically transfer data between parent and child processes. Anonymous pipes are always local; they cannot be used over a network. A value of is not supported because anonymous pipes are defined to be one-way. + + Anonymous pipes do not support the read mode. + + The client side of an anonymous pipe must be created from a pipe handle provided by the server side by calling the method. The string is then passed as a parameter when creating the client process. From the client process, it is passed to the constructor as the `pipeHandleAsString` parameter. On Windows, asynchronous (overlapped) read and write operations aren't supported by anonymous pipes (see [Anonymous pipe operations](https://learn.microsoft.com/windows/win32/ipc/anonymous-pipe-operations)). The class will still schedule work on the thread pool on Windows platforms so asynchronous operations work, but cancellation of those operations isn't supported. -## Examples +## Examples -The following example sends a string from a parent process to a child process by using anonymous pipes. This example creates an object in a parent process with a value of . It also creates an object in a child process with a value of . The parent process then sends a user-supplied string to the child process. The string is displayed to the console. - - This example is for the client process, which is started by the server process. Name the resulting executable from the client code `pipeClient.exe` and copy it to the same directory as the server executable when you run this example. For the entire code example, including the code for both the pipe client and server, see [How to: Use Anonymous Pipes for Local Interprocess Communication](/dotnet/standard/io/how-to-use-anonymous-pipes-for-local-interprocess-communication). +The following example sends a string from a parent process to a child process by using anonymous pipes. This example creates an object in a parent process with a value of . It also creates an object in a child process with a value of . The parent process then sends a user-supplied string to the child process. The string is displayed to the console. + + This example is for the client process, which is started by the server process. Name the resulting executable from the client code `pipeClient.exe` and copy it to the same directory as the server executable when you run this example. For the entire code example, including the code for both the pipe client and server, see [How to: Use Anonymous Pipes for Local Interprocess Communication](/dotnet/standard/io/how-to-use-anonymous-pipes-for-local-interprocess-communication). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/cpp/program.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeClientStream/Overview/Program.cs"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/vb/program.vb"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/vb/program.vb"::: + ]]> @@ -135,19 +134,19 @@ The following example sends a string from a parent process to a child process by A string that represents the pipe handle. Initializes a new instance of the class with the specified string representation of the pipe handle. - parameter, the default direction is . - - - -## Examples - The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a child process. - + parameter, the default direction is . + + + +## Examples + The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a child process. + :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeClientStream/.ctor/Program.cs" id="Snippet01"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_ctorSample1/vb/program.vb" id="Snippet01"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_ctorSample1/vb/program.vb" id="Snippet01"::: + ]]> @@ -197,25 +196,25 @@ The following example sends a string from a parent process to a child process by - One of the enumeration values that determines the direction of the pipe. - + One of the enumeration values that determines the direction of the pipe. + Anonymous pipes can only be in one direction, so cannot be set to . A safe handle for the pipe that this object will encapsulate. Initializes a new instance of the class from the specified handle. - value of is not supported because anonymous pipes are defined to be one-way. - - - -## Examples - The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a child process with a value of . - + value of is not supported because anonymous pipes are defined to be one-way. + + + +## Examples + The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a child process with a value of . + :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeClientStream/.ctor/Program.cs" id="Snippet01"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_ctorSample1/vb/program.vb" id="Snippet01"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_ctorSample1/vb/program.vb" id="Snippet01"::: + ]]> @@ -224,10 +223,10 @@ The following example sends a string from a parent process to a child process by is . is set to . - An I/O error, such as a disk error, has occurred. - - -or- - + An I/O error, such as a disk error, has occurred. + + -or- + The stream has been closed. @@ -274,26 +273,25 @@ The following example sends a string from a parent process to a child process by - One of the enumeration values that determines the direction of the pipe. - + One of the enumeration values that determines the direction of the pipe. + Anonymous pipes can only be in one direction, so cannot be set to . A string that represents the pipe handle. Initializes a new instance of the class with the specified pipe direction and a string representation of the pipe handle. - value of is not supported because anonymous pipes are defined to be one-way. - - - -## Examples - The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a child process with a value of . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/cpp/program.cpp"::: + value of is not supported because anonymous pipes are defined to be one-way. + + + +## Examples + The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a child process with a value of . + :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeClientStream/Overview/Program.cs"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/vb/program.vb"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/vb/program.vb"::: + ]]> @@ -388,22 +386,21 @@ The following example sends a string from a parent process to a child process by Sets the reading mode for the object. The for the object. - read mode. - - - +Anonymous pipes do not support the read mode. + + + ## Examples -The following example sends a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a child process. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/cpp/program.cpp"::: +The following example sends a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a child process. + :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeClientStream/Overview/Program.cs"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/vb/program.vb"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/vb/program.vb"::: + ]]> The transmission mode is not valid. For anonymous pipes, only is supported. @@ -457,20 +454,19 @@ The following example sends a string from a parent process to a child process by Gets the pipe transmission mode supported by the current pipe. The supported by the current pipe. - read mode. Because the default value of this property is , there is never a reason to set this property in your code. - -## Examples +Anonymous pipes do not support read mode. Because the default value of this property is , there is never a reason to set this property in your code. + +## Examples + +The following example sends a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a child process and the is displayed to the console. -The following example sends a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a child process and the is displayed to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/cpp/program.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeClientStream/Overview/Program.cs"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/vb/program.vb"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeClientStream_Sample/vb/program.vb"::: + ]]> diff --git a/xml/System.IO.Pipes/AnonymousPipeServerStream.xml b/xml/System.IO.Pipes/AnonymousPipeServerStream.xml index 0645c7b2bf9..783d153ae7c 100644 --- a/xml/System.IO.Pipes/AnonymousPipeServerStream.xml +++ b/xml/System.IO.Pipes/AnonymousPipeServerStream.xml @@ -69,7 +69,6 @@ The following example sends a string from a parent process to a child process us This example is for the server process, which uses the class. For the entire code example, including the code for both the pipe client and server, see [How to: Use Anonymous Pipes for Local Interprocess Communication](/dotnet/standard/io/how-to-use-anonymous-pipes-for-local-interprocess-communication). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeServerStream/Overview/Program.cs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/vb/program.vb"::: @@ -272,7 +271,6 @@ The following example sends a string from a parent process to a child process us ## Examples The following example demonstrates a method to send a string from a parent process to a child process using anonymous pipes. In this example, an object is created in a parent process with a value of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeServerStream/Overview/Program.cs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/vb/program.vb"::: @@ -652,7 +650,6 @@ The following example sends a string from a parent process to a child process us ## Examples The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a parent process with a value of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeServerStream/Overview/Program.cs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/vb/program.vb"::: @@ -755,7 +752,6 @@ The following example sends a string from a parent process to a child process us ## Examples The following example demonstrates a way to send a string from a parent process to a child process by using anonymous pipes. In this example, an object is created in a parent process with a value of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeServerStream/Overview/Program.cs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/vb/program.vb"::: @@ -876,7 +872,6 @@ Anonymous pipes do not support the object is created in a parent process and the property is displayed to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/cpp/program.cpp"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/AnonymousPipeServerStream/Overview/Program.cs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.AnonymousPipeServerStream_Sample/vb/program.vb"::: diff --git a/xml/System.IO.Pipes/NamedPipeServerStream.xml b/xml/System.IO.Pipes/NamedPipeServerStream.xml index ea334362f61..cce929e5542 100644 --- a/xml/System.IO.Pipes/NamedPipeServerStream.xml +++ b/xml/System.IO.Pipes/NamedPipeServerStream.xml @@ -1277,7 +1277,6 @@ This example is for the server process, which uses the object in a parent process, which then creates multiple threads that wait for objects to connect. After a client is connected, it supplies a file name to the server and the contents of that file are read and sent back to the client. Because the impersonates the client when opening the file, the client can request only files that it has sufficient permissions to open. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.NamedPipeServerStream_ImpersonationSample1/cpp/program.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/NamedPipeServerStream/GetImpersonationUserName/Program.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.NamedPipeServerStream_ImpersonationSample1/vb/program.vb" id="Snippet01"::: @@ -1404,7 +1403,6 @@ This example is for the server process, which uses the object in a parent process, which then creates multiple threads that wait for objects to connect. After a client is connected, it supplies a file name to the server and the contents of that file are read and sent back to the client. Because the impersonates the client when opening the file, the client can request only files that it has sufficient permissions to open. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Pipes.NamedPipeServerStream_ImpersonationSample1/cpp/program.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Pipes/NamedPipeServerStream/GetImpersonationUserName/Program.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Pipes.NamedPipeServerStream_ImpersonationSample1/vb/program.vb" id="Snippet01"::: diff --git a/xml/System.IO.Pipes/PipeStream.xml b/xml/System.IO.Pipes/PipeStream.xml index 3b8279392b5..31f8bc3409d 100644 --- a/xml/System.IO.Pipes/PipeStream.xml +++ b/xml/System.IO.Pipes/PipeStream.xml @@ -1647,7 +1647,6 @@ The pipe handle has not been set. (Did your Specifies the control protocol used in establishing a serial port communication for a object. - property. + + + +## Examples + The following code example displays the possible values of the enumeration to the console, then prompts the user to choose one. This code example is part of a larger code example provided for the class. -## Remarks - This enumeration is used with the property. - - - -## Examples - The following code example displays the possible values of the enumeration to the console, then prompts the user to choose one. This code example is part of a larger code example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet05"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet05"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet05"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet05"::: + ]]> diff --git a/xml/System.IO.Ports/Parity.xml b/xml/System.IO.Ports/Parity.xml index 980c1811f2e..e6a8927131e 100644 --- a/xml/System.IO.Ports/Parity.xml +++ b/xml/System.IO.Ports/Parity.xml @@ -28,22 +28,21 @@ Specifies the parity bit for a object. - property for a serial port connection. + + Parity is an error-checking procedure in which the number of 1s must always be the same - either even or odd - for each group of bits that is transmitted without error. In modem-to-modem communications, parity is often one of the parameters that must be agreed upon by sending parties and receiving parties before transmission can take place. + + + +## Examples + The following code example displays the possible values of the enumeration to the console, then prompts the user to choose one. This code example is part of a larger code example provided for the class. -## Remarks - Use this enumeration when setting the property for a serial port connection. - - Parity is an error-checking procedure in which the number of 1s must always be the same - either even or odd - for each group of bits that is transmitted without error. In modem-to-modem communications, parity is often one of the parameters that must be agreed upon by sending parties and receiving parties before transmission can take place. - - - -## Examples - The following code example displays the possible values of the enumeration to the console, then prompts the user to choose one. This code example is part of a larger code example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet03"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet03"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet03"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet03"::: + ]]> diff --git a/xml/System.IO.Ports/SerialPort.xml b/xml/System.IO.Ports/SerialPort.xml index 8abc5a1e6d4..5106d9e1cb7 100644 --- a/xml/System.IO.Ports/SerialPort.xml +++ b/xml/System.IO.Ports/SerialPort.xml @@ -51,7 +51,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. Both computers must be executing the program to achieve full functionality of this example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet10"::: @@ -98,7 +97,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -459,13 +457,11 @@ ## Examples The following example shows how to set the property to `9600`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/datareceived.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/datareceived.cs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/datareceived.vb" id="Snippet20"::: The following example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -706,7 +702,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -821,7 +816,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -885,7 +879,6 @@ ## Examples This example adds a to to read all the available data received on the COM1 port. Note that to test this code it is necessary to have hardware attached to COM1 that will send data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/datareceived.cpp" id="Snippet06"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/datareceived.cs" id="Snippet06"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/datareceived.vb" id="Snippet06"::: @@ -1316,7 +1309,6 @@ ## Examples The following code example uses the method to display serial port names to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.Ports.GetPortNames/cpp/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/SerialPort/GetPortNames/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.Ports.GetPortNames/VB/example.vb" id="Snippet1"::: @@ -1379,7 +1371,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -1555,7 +1546,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -1634,7 +1624,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -1803,7 +1792,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -2167,7 +2155,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -2238,7 +2225,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -2458,13 +2444,11 @@ ## Examples The following example shows how to set the property to `One`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/datareceived.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/datareceived.cs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/datareceived.vb" id="Snippet20"::: The following example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -2721,7 +2705,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: @@ -2789,7 +2772,6 @@ ## Examples The following code example demonstrates the use of the class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. This code example is part of a larger code example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet01"::: :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet01"::: diff --git a/xml/System.IO.Ports/StopBits.xml b/xml/System.IO.Ports/StopBits.xml index ef194b0747f..5157910b5d7 100644 --- a/xml/System.IO.Ports/StopBits.xml +++ b/xml/System.IO.Ports/StopBits.xml @@ -28,28 +28,24 @@ Specifies the number of stop bits used on the object. - property on the class. Stop bits separate each unit of data on an asynchronous serial connection. They are also sent continuously when no data is available for transmission. - - The class throws an exception when you set the property to None. - - - -## Examples - The following example shows how to set the property to `One`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/datareceived.cpp" id="Snippet20"::: + property on the class. Stop bits separate each unit of data on an asynchronous serial connection. They are also sent continuously when no data is available for transmission. + + The class throws an exception when you set the property to None. + +## Examples + The following example shows how to set the property to `One`. + :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/datareceived.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/datareceived.vb" id="Snippet20"::: - - The following code example displays the possible values of the enumeration to the console, then prompts the user to choose one. This code example is part of a larger code example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/cpp/serialport.cpp" id="Snippet04"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/datareceived.vb" id="Snippet20"::: + + The following code example displays the possible values of the enumeration to the console, then prompts the user to choose one. This code example is part of a larger code example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.IO.Ports/Handshake/Overview/SerialPort.cs" id="Snippet04"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet04"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Ports.SerialPort/vb/SerialPort.vb" id="Snippet04"::: + ]]> diff --git a/xml/System.IO/BinaryReader.xml b/xml/System.IO/BinaryReader.xml index 1e77216a98f..d0b1eb53c35 100644 --- a/xml/System.IO/BinaryReader.xml +++ b/xml/System.IO/BinaryReader.xml @@ -385,7 +385,6 @@ ## Examples The following code example shows how to read and write `Double` data to memory by using the `BinaryReader` and classes on top of the class. `MemoryStream` only reads and writes `Byte` data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/BaseStream/rwdouble.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: @@ -813,7 +812,6 @@ ## Examples The following example shows how to read and write data using memory as a backing store. This example displays a list of invalid file path characters to the console. Although the code tries to display a list of all invalid file path characters, not all of the characters are within the displayable set of characters. Because the list of invalid characters can vary based on the system, output for this code may also vary. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar2/CPP/rwreadchar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Read/rwreadchar.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Read/rwreadchar.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar2/VB/rwreadchar.vb" id="Snippet1"::: @@ -1092,7 +1090,6 @@ ## Examples The following example shows how to read and write data using memory as a backing store. This example displays a list of invalid file path characters to the console. Although the code tries to display a list of all invalid file path characters, not all of the characters are within the displayable set of characters. Because the list of invalid characters can vary based on the system, output for this code may also vary. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars2/CPP/rwreadchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Read/rwreadchars.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Read/rwreadchars.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars2/VB/rwreadchars.vb" id="Snippet1"::: @@ -1382,7 +1379,6 @@ ## Examples The following code example shows how to write binary data using memory as a backing store, and then verify that the data was written correctly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWByte/CPP/rwbyte.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/ReadByte/rwbyte.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/ReadByte/rwbyte.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWByte/VB/rwbyte.vb" id="Snippet1"::: @@ -1467,7 +1463,6 @@ ## Examples The following code example shows how to write binary data using memory as a backing store, and then verify that the data was written correctly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes1/CPP/rwbytes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/ReadBytes/rwbytes.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/ReadBytes/rwbytes.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes1/VB/rwbytes.vb" id="Snippet1"::: @@ -1559,7 +1554,6 @@ ## Examples The following code example shows how to read and write data using memory as a backing store. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/CPP/rwchar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/ReadChar/rwchar.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/ReadChar/rwchar.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/VB/rwchar.vb" id="Snippet1"::: @@ -1646,7 +1640,6 @@ ## Examples The following code example shows how to read and write data using memory as a backing store. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/CPP/rwchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/ReadChars/rwchars.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/ReadChars/rwchars.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/VB/rwchars.vb" id="Snippet1"::: @@ -1799,7 +1792,6 @@ ## Examples The following code example shows how to read and write `Double` data to memory by using the `BinaryReader` and classes on top of the class. `MemoryStream` only reads and writes `Byte` data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/BaseStream/rwdouble.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: diff --git a/xml/System.IO/BinaryWriter.xml b/xml/System.IO/BinaryWriter.xml index d237f43380d..af4609c9f11 100644 --- a/xml/System.IO/BinaryWriter.xml +++ b/xml/System.IO/BinaryWriter.xml @@ -97,27 +97,27 @@ Writes primitive types in binary to a stream and supports writing strings in a specific encoding. - class provides methods that simplify writing primitive data types to a stream. For example, you can use the method to write a Boolean value to the stream as a one-byte value. The class includes write methods that support different data types. - - When you create a new instance of the class, you provide the stream to write to, and optionally specify the type of encoding and whether to leave the stream open after disposing the object. If you do not specify an encoding type, UTF-8 is used. - + class provides methods that simplify writing primitive data types to a stream. For example, you can use the method to write a Boolean value to the stream as a one-byte value. The class includes write methods that support different data types. + + When you create a new instance of the class, you provide the stream to write to, and optionally specify the type of encoding and whether to leave the stream open after disposing the object. If you do not specify an encoding type, UTF-8 is used. + > [!IMPORTANT] -> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - - A derived class can override the methods of this class to give unique character encodings. - - - -## Examples - The following code example demonstrates how to store and retrieve application settings in a file. - +> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + + A derived class can override the methods of this class to give unique character encodings. + + + +## Examples + The following code example demonstrates how to store and retrieve application settings in a file. + :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source.vb" id="Snippet1"::: + ]]> @@ -182,11 +182,11 @@ Initializes a new instance of the class that writes to a stream. - File and Stream I/O @@ -248,20 +248,20 @@ The output stream. Initializes a new instance of the class based on the specified stream and using UTF-8 encoding. - The stream does not support writing or is already closed. @@ -323,11 +323,11 @@ The character encoding to use. Initializes a new instance of the class based on the specified stream and character encoding. - The stream does not support writing or is already closed. @@ -447,21 +447,20 @@ Gets the underlying stream of the . The underlying stream associated with the . - and `BinaryWriter` classes on top of the class. `MemoryStream` only reads and writes `Byte` data. + and `BinaryWriter` classes on top of the class. `MemoryStream` only reads and writes `Byte` data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/BaseStream/rwdouble.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: + ]]> File and Stream I/O @@ -514,13 +513,13 @@ Closes the current and the underlying stream. - method passing a `true` value. - - Flushing the stream will not flush its underlying encoder unless you explicitly call or `Close`. Setting to `true` means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters. - + method passing a `true` value. + + Flushing the stream will not flush its underlying encoder unless you explicitly call or `Close`. Setting to `true` means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters. + ]]> File and Stream I/O @@ -746,15 +745,15 @@ Clears all buffers for the current writer and causes any buffered data to be written to the underlying device. - . Setting to `true` means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters. - - For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/common-i-o-tasks). - + . Setting to `true` means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters. + + For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/common-i-o-tasks). + ]]> File and Stream I/O @@ -809,11 +808,11 @@ Specifies a with no backing store. - File and Stream I/O @@ -868,11 +867,11 @@ Holds the underlying stream. - File and Stream I/O @@ -934,21 +933,20 @@ Sets the position within the current stream. The position with the current stream. - to move to various locations in the file, and then writes marker bytes by using the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/CPP/source3.cpp" id="Snippet5"::: + to move to various locations in the file, and then writes marker bytes by using the method. + :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source3.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source3.fs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source3.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source3.vb" id="Snippet5"::: + ]]> The file pointer was moved to an invalid location. @@ -1068,20 +1066,20 @@ This member is an explicit interface member implementation. It can be used only The value to write (0 or 1). Writes a one-byte value to the current stream, with 0 representing and 1 representing . - An I/O error occurs. @@ -1148,29 +1146,28 @@ This member is an explicit interface member implementation. It can be used only The unsigned byte to write. Writes an unsigned byte to the current stream and advances the stream position by one byte. - An I/O error occurs. @@ -1231,21 +1228,20 @@ This member is an explicit interface member implementation. It can be used only A byte array containing the data to write. Writes a byte array to the underlying stream. - An I/O error occurs. @@ -1314,31 +1310,30 @@ This member is an explicit interface member implementation. It can be used only The non-surrogate, Unicode character to write. Writes a Unicode character to the current stream and advances the current position of the stream in accordance with the used and the specific characters being written to the stream. - method overload. - - - -## Examples - The following code example shows how to read and write data using memory as a backing store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/CPP/rwchar.cpp" id="Snippet1"::: + method overload. + + + +## Examples + The following code example shows how to read and write data using memory as a backing store. + :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/ReadChar/rwchar.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/ReadChar/rwchar.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/VB/rwchar.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/VB/rwchar.vb" id="Snippet1"::: + ]]> An I/O error occurs. @@ -1402,34 +1397,33 @@ This member is an explicit interface member implementation. It can be used only A character array containing the data to write. Writes a character array to the current stream and advances the current position of the stream in accordance with the used and the specific characters being written to the stream. -


| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - The following code example shows how to read and write data using memory as a backing store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/CPP/rwchars.cpp" id="Snippet1"::: +


| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + The following code example shows how to read and write data using memory as a backing store. + :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/ReadChars/rwchars.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/ReadChars/rwchars.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/VB/rwchars.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/VB/rwchars.vb" id="Snippet1"::: + ]]>
@@ -1493,24 +1487,24 @@ This member is an explicit interface member implementation. It can be used only The decimal value to write. Writes a decimal value to the current stream and advances the stream position by sixteen bytes. -


| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - +


| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + ]]>
An I/O error occurs. @@ -1577,21 +1571,20 @@ This member is an explicit interface member implementation. It can be used only The eight-byte floating-point value to write. Writes an eight-byte floating-point value to the current stream and advances the stream position by eight bytes. - and `BinaryWriter` classes on top of the class. `MemoryStream` only reads and writes `Byte` data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp" id="Snippet1"::: + and `BinaryWriter` classes on top of the class. `MemoryStream` only reads and writes `Byte` data. + :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/BaseStream/rwdouble.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: + ]]> An I/O error occurs. @@ -1639,21 +1632,20 @@ This member is an explicit interface member implementation. It can be used only The two-byte floating-point value to write. Writes a two-byte floating-point value to the current stream and advances the stream position by two bytes. - and `BinaryWriter` classes on top of the class. `MemoryStream` only reads and writes `Byte` data. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp" id="Snippet1"::: + and `BinaryWriter` classes on top of the class. `MemoryStream` only reads and writes `Byte` data. + :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/BaseStream/rwdouble.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: + ]]> An I/O error occurs. @@ -1714,26 +1706,26 @@ This member is an explicit interface member implementation. It can be used only The two-byte signed integer to write. Writes a two-byte signed integer to the current stream and advances the stream position by two bytes. -


| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - +


| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + ]]>
An I/O error occurs. @@ -1794,22 +1786,22 @@ This member is an explicit interface member implementation. It can be used only The four-byte signed integer to write. Writes a four-byte signed integer to the current stream and advances the stream position by four bytes. - An I/O error occurs. @@ -1870,13 +1862,13 @@ This member is an explicit interface member implementation. It can be used only The eight-byte signed integer to write. Writes an eight-byte signed integer to the current stream and advances the stream position by eight bytes. - An I/O error occurs. @@ -2031,11 +2023,11 @@ This member is an explicit interface member implementation. It can be used only The signed byte to write. Writes a signed byte to the current stream and advances the stream position by one byte. - An I/O error occurs. @@ -2102,22 +2094,22 @@ This member is an explicit interface member implementation. It can be used only The four-byte floating-point value to write. Writes a four-byte floating-point value to the current stream and advances the stream position by four bytes. - An I/O error occurs. @@ -2184,24 +2176,24 @@ This member is an explicit interface member implementation. It can be used only The value to write. Writes a length-prefixed string to this stream in the current encoding of the , and advances the current position of the stream in accordance with the encoding used and the specific characters being written to the stream. - instance's current encoding to the stream. This value is written as an unsigned integer. This method then writes that many bytes to the stream. - - For example, the string "A" has a length of 1, but when encoded with UTF-16; the length is 2 bytes, so the value written in the prefix is 2, and 3 bytes are written to the stream, including the prefix. - - For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/common-i-o-tasks). - - - -## Examples - The following code example demonstrates how to store and retrieve application settings in a file. - + instance's current encoding to the stream. This value is written as an unsigned integer. This method then writes that many bytes to the stream. + + For example, the string "A" has a length of 1, but when encoded with UTF-16; the length is 2 bytes, so the value written in the prefix is 2, and 3 bytes are written to the stream, including the prefix. + + For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/common-i-o-tasks). + + + +## Examples + The following code example demonstrates how to store and retrieve application settings in a file. + :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source.vb" id="Snippet1"::: + ]]> An I/O error occurs. @@ -2271,13 +2263,13 @@ This member is an explicit interface member implementation. It can be used only The two-byte unsigned integer to write. Writes a two-byte unsigned integer to the current stream and advances the stream position by two bytes. - An I/O error occurs. @@ -2344,13 +2336,13 @@ This member is an explicit interface member implementation. It can be used only The four-byte unsigned integer to write. Writes a four-byte unsigned integer to the current stream and advances the stream position by four bytes. - An I/O error occurs. @@ -2417,13 +2409,13 @@ This member is an explicit interface member implementation. It can be used only The eight-byte unsigned integer to write. Writes an eight-byte unsigned integer to the current stream and advances the stream position by eight bytes. - An I/O error occurs. @@ -2488,20 +2480,20 @@ This member is an explicit interface member implementation. It can be used only The number of bytes to read from and to write to the stream. Writes a region of a byte array to the current stream. - The buffer length minus is less than . @@ -2571,21 +2563,20 @@ This member is an explicit interface member implementation. It can be used only The number of characters to read from and to write to the stream. Writes a section of a character array to the current stream, and advances the current position of the stream in accordance with the used and perhaps the specific characters being written to the stream. - The buffer length minus is less than . @@ -2656,15 +2647,15 @@ This member is an explicit interface member implementation. It can be used only The 32-bit integer to be written. Writes a 32-bit integer in a compressed format. - The end of the stream is reached. diff --git a/xml/System.IO/BufferedStream.xml b/xml/System.IO/BufferedStream.xml index df243abb082..5d9f10e68f6 100644 --- a/xml/System.IO/BufferedStream.xml +++ b/xml/System.IO/BufferedStream.xml @@ -96,14 +96,12 @@ **Example 1: Code that runs on the client** - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BufferedStream/Overview/client.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BufferedStream/Overview/client.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BufferedStream1/VB/client.vb" id="Snippet1"::: **Example 2: Code that runs on the server** - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream2/CPP/server.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BufferedStream/Overview/server.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BufferedStream/Overview/server.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BufferedStream2/VB/server.vb" id="Snippet1"::: @@ -245,7 +243,6 @@ ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BufferedStream/Overview/client.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BufferedStream/Overview/client.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BufferedStream1/VB/client.vb" id="Snippet2"::: @@ -545,7 +542,6 @@ ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BufferedStream/Overview/client.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BufferedStream/Overview/client.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BufferedStream1/VB/client.vb" id="Snippet5"::: @@ -617,7 +613,6 @@ ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BufferedStream/Overview/client.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BufferedStream/Overview/client.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BufferedStream1/VB/client.vb" id="Snippet3"::: @@ -690,7 +685,6 @@ ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BufferedStream/Overview/client.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BufferedStream/Overview/client.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BufferedStream1/VB/client.vb" id="Snippet4"::: @@ -1169,7 +1163,6 @@ Calling `DisposeAsync` allows the resources used by the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BufferedStream/Overview/client.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BufferedStream/Overview/client.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BufferedStream1/VB/client.vb" id="Snippet6"::: @@ -1494,7 +1487,6 @@ Use for reading primitive data types. ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BufferedStream/Overview/client.cs" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BufferedStream/Overview/client.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BufferedStream1/VB/client.vb" id="Snippet7"::: @@ -2022,7 +2014,6 @@ If the write operation is successful, the position within the buffered stream ad ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BufferedStream1/CPP/client.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BufferedStream/Overview/client.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/BufferedStream/Overview/client.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BufferedStream1/VB/client.vb" id="Snippet6"::: diff --git a/xml/System.IO/Directory.xml b/xml/System.IO/Directory.xml index 22e38ef0653..af30800ba01 100644 --- a/xml/System.IO/Directory.xml +++ b/xml/System.IO/Directory.xml @@ -1962,7 +1962,6 @@ The returned collection is not cached. Each call to the method to return file names from a user-specified location. The example is configured to catch all errors common to this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Recursive file finder/CPP/directorylisting.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/Exists/directorylisting.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/Exists/directorylisting.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Recursive file finder/VB/directorylisting.vb" id="Snippet1"::: @@ -3036,7 +3028,6 @@ The returned collection is not cached. Each call to the method to fill an array of strings with the names of all files and subdirectories in a user-specified location and prints each string in the array to the console. The example is configured to catch all errors common to this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Directory/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/Overview/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/Overview/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Directory/VB/class1.vb" id="Snippet1"::: @@ -3449,7 +3439,6 @@ The returned collection is not cached. Each call to the method to fill an array of strings with the names of all files matching a user-specified filter in a specific location and prints each string in the array to the console. The example is configured to catch all errors common to this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Directory/CPP/class1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/Overview/class1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/Overview/class1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Directory/VB/class1.vb" id="Snippet2"::: @@ -3744,7 +3733,6 @@ The returned collection is not cached. Each call to the method to assign the name of each drive on the calling computer to an array of strings. Each member of this string array is then printed to the console. The example is configured to catch all errors common to this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Directory/CPP/class1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/Overview/class1.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/Overview/class1.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Directory/VB/class1.vb" id="Snippet3"::: @@ -4180,7 +4164,6 @@ The returned collection is not cached. Each call to the method to retrieve the parent directory of a user-specified location, "path". The value returned by the method is then printed to the console. The example is configured to catch all errors common to this method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Directory/CPP/class1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/Overview/class1.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/Overview/class1.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Directory/VB/class1.vb" id="Snippet4"::: @@ -4513,7 +4496,6 @@ There are too many levels of symbolic links.
## Examples The following example illustrates the differences in output when using Coordinated Universal Time (UTC) output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.UTCExample/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/GetCreationTimeUtc/example.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/GetCreationTimeUtc/example.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.UTCExample/VB/example.vb" id="Snippet1"::: @@ -4687,7 +4669,6 @@ There are too many levels of symbolic links.
## Examples The following example illustrates how to set the current directory and display the directory root. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryRoot/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/GetDirectoryRoot/example.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/GetDirectoryRoot/example.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.DirectoryRoot/VB/example.vb" id="Snippet1"::: @@ -4771,7 +4752,6 @@ There are too many levels of symbolic links.
## Examples The following example demonstrates how to use `SetLastAccessTime`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dir_SetLastAccess/CPP/dir_setlastaccess.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/SetLastAccessTime/dir_setlastaccess.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/SetLastAccessTime/dir_setlastaccess.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dir_SetLastAccess/VB/dir_setlastaccess.vb" id="Snippet1"::: @@ -4862,7 +4842,6 @@ There are too many levels of symbolic links.
## Examples The following example illustrates the differences in output when using Coordinated Universal Time (UTC) output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.UTCExample/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/GetCreationTimeUtc/example.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/GetCreationTimeUtc/example.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.UTCExample/VB/example.vb" id="Snippet1"::: @@ -4947,7 +4926,6 @@ There are too many levels of symbolic links.
## Examples The following example demonstrates how to use `SetLastWriteTime`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Dir_SetLastWrite/CPP/dir_setlastwrite.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/SetLastWriteTime/dir_setlastwrite.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/SetLastWriteTime/dir_setlastwrite.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Dir_SetLastWrite/VB/dir_setlastwrite.vb" id="Snippet1"::: @@ -5041,7 +5019,6 @@ There are too many levels of symbolic links.
## Examples The following example illustrates the differences in output when using Coordinated Universal Time (UTC) output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.UTCExample/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Directory/GetCreationTimeUtc/example.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/Directory/GetCreationTimeUtc/example.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.UTCExample/VB/example.vb" id="Snippet1"::: diff --git a/xml/System.IO/DirectoryInfo.xml b/xml/System.IO/DirectoryInfo.xml index c1d9ab0514f..99e28431b3f 100644 --- a/xml/System.IO/DirectoryInfo.xml +++ b/xml/System.IO/DirectoryInfo.xml @@ -99,7 +99,6 @@ ## Examples The following example demonstrates some of the main members of the `DirectoryInfo` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DirInfo Class Example/CPP/dirinfo class example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/Overview/dirinfo class example.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/Overview/dirinfo class example.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DirInfo Class Example/VB/dirinfo class example.vb" id="Snippet1"::: @@ -188,7 +187,6 @@ ## Examples The following example uses this constructor to create the specified directory and subdirectory, and demonstrates that a directory that contains subdirectories cannot be deleted. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DirInfo Ctor/CPP/dirinfo ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/.ctor/dirinfo ctor.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/.ctor/dirinfo ctor.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DirInfo Ctor/VB/dirinfo ctor.vb" id="Snippet1"::: @@ -271,7 +269,6 @@ ## Examples The following example checks whether a specified directory exists, creates the directory if it does not exist, and deletes the directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DirInfo Create/CPP/dirinfo create.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/Create/dirinfo create.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/Create/dirinfo create.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DirInfo Create/VB/dirinfo create.vb" id="Snippet1"::: @@ -437,7 +434,6 @@ namespace ConsoleApp ## Examples The following example demonstrates creating a subdirectory. In this example, the created directories are removed once created. Therefore, to test this sample, comment out the delete lines in the code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/directoryinfocreatesub/CPP/directoryinfocreatesub.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/CreateSubdirectory/directoryinfocreatesub.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/CreateSubdirectory/directoryinfocreatesub.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/directoryinfocreatesub/VB/directoryinfocreatesub.vb" id="Snippet1"::: @@ -607,7 +603,6 @@ namespace ConsoleApp ## Examples The following example throws an exception if you attempt to delete a directory that is not empty. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DirInfo Delete1/CPP/dirinfo delete1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/Delete/dirinfo delete1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/Delete/dirinfo delete1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DirInfo Delete1/VB/dirinfo delete1.vb" id="Snippet1"::: @@ -697,7 +692,6 @@ namespace ConsoleApp ## Examples The following example demonstrates deleting a directory. Because the directory is removed, first comment out the `Delete` line to test that the directory exists. Then uncomment the same line of code to test that the directory was removed successfully. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/directoryinfodelete/CPP/directoryinfodelete.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/Delete/directoryinfodelete.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/Delete/directoryinfodelete.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/directoryinfodelete/VB/directoryinfodelete.vb" id="Snippet1"::: @@ -1998,7 +1992,6 @@ namespace ConsoleApp ## Examples The following example demonstrates a use of the `Exists` property in the context of copying a source directory to a target directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DirectoryInfo Usage Example/CPP/copydirectory.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/Exists/copydirectory.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/Exists/copydirectory.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DirectoryInfo Usage Example/VB/copydirectory.vb" id="Snippet1"::: @@ -2106,7 +2099,6 @@ namespace ConsoleApp ## Examples The following example uses the and methods to add and then remove an access control list (ACL) entry from a directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/GetAccessControl/sample.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/GetAccessControl/sample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/VB/sample.vb" id="Snippet1"::: @@ -2261,7 +2253,6 @@ namespace ConsoleApp ## Examples The following example retrieves all the directories in the root directory and displays the directory names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/directoryinfogetdirectories/CPP/directoryinfogetdirectories.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/GetDirectories/directoryinfogetdirectories.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/GetDirectories/directoryinfogetdirectories.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/directoryinfogetdirectories/VB/directoryinfogetdirectories.vb" id="Snippet1"::: @@ -2361,7 +2352,6 @@ namespace ConsoleApp ## Examples The following example counts the directories in a path that contain the specified letter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DirInfo GetDirs2/CPP/dirinfo getdirs2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/GetDirectories/dirinfo getdirs2.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/GetDirectories/dirinfo getdirs2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DirInfo GetDirs2/VB/dirinfo getdirs2.vb" id="Snippet1"::: @@ -2547,7 +2537,6 @@ namespace ConsoleApp ## Examples The following example lists all of the directories and files that begin with the letter "c" in "c:\\". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/cpp/searchoption.cpp" id="Snippet00"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/GetDirectories/searchoption.cs" id="Snippet00"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/GetDirectories/searchoption.fs" id="Snippet00"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/vb/searchoption.vb" id="Snippet00"::: @@ -3519,7 +3508,6 @@ namespace ConsoleApp ## Examples The following example demonstrates moving a directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/directoryinfomoveto/CPP/directoryinfomoveto.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/MoveTo/directoryinfomoveto.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/MoveTo/directoryinfomoveto.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/directoryinfomoveto/VB/directoryinfomoveto.vb" id="Snippet1"::: @@ -3608,7 +3596,6 @@ namespace ConsoleApp ## Examples The following example displays the name of the current `DirectoryInfo` instance only. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic DirectoryInfo.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/Name/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/Name/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic DirectoryInfo.Name Example/VB/source.vb" id="Snippet1"::: @@ -3696,7 +3683,6 @@ For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/commo The following example refers to the parent directory of a specified directory. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/directoryinfoparent/CPP/directoryinfoparent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/Parent/directoryinfoparent.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/Parent/directoryinfoparent.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/directoryinfoparent/VB/directoryinfoparent.vb" id="Snippet1"::: @@ -3843,7 +3829,6 @@ The following example refers to the parent directory of a specified directory. ## Examples The following example uses the and methods to add and then remove an access control list (ACL) entry from a directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/GetAccessControl/sample.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/DirectoryInfo/GetAccessControl/sample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/VB/sample.vb" id="Snippet1"::: diff --git a/xml/System.IO/EndOfStreamException.xml b/xml/System.IO/EndOfStreamException.xml index 21d2644f995..82625012f27 100644 --- a/xml/System.IO/EndOfStreamException.xml +++ b/xml/System.IO/EndOfStreamException.xml @@ -93,7 +93,6 @@ ## Examples The following code example shows how to read and write `Double` data to memory by using the and classes on top of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/BaseStream/rwdouble.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: diff --git a/xml/System.IO/ErrorEventArgs.xml b/xml/System.IO/ErrorEventArgs.xml index 801fe186e90..4774d085a1c 100644 --- a/xml/System.IO/ErrorEventArgs.xml +++ b/xml/System.IO/ErrorEventArgs.xml @@ -51,25 +51,24 @@ Provides data for the event. - contains the that caused the event. This class provides the method to retrieve the exception. + + + +## Examples + The following example creates a new instance of and initializes it with an . Then the example calls to retrieve the and display the error message. There is no form associated with this code. -## Remarks - contains the that caused the event. This class provides the method to retrieve the exception. - - - -## Examples - The following example creates a new instance of and initializes it with an . Then the example calls to retrieve the and display the error message. There is no form associated with this code. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/ErrorEventArgs/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ErrorEventArgs Example/VB/source.vb" id="Snippet1"::: - - The following example shows how to create a FileSystemWatcher to monitor file changes (creates, deletes, renames, changes) occurring on a disk drive. The example also shows how to properly receive error notifications. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ErrorEventArgs Example/VB/source.vb" id="Snippet1"::: + + The following example shows how to create a FileSystemWatcher to monitor file changes (creates, deletes, renames, changes) occurring on a disk drive. The example also shows how to properly receive error notifications. + :::code language="csharp" source="~/snippets/csharp/System.IO/ErrorEventArgs/Overview/filesystemwatcher.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FileSystemWatcher/VB/FileSystemWatcher.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FileSystemWatcher/VB/FileSystemWatcher.vb" id="Snippet1"::: + ]]> @@ -123,15 +122,14 @@ An that represents the error that occurred. Initializes a new instance of the class. - and initializes it with an . Then the example calls to retrieve the and display the error message. There is no form associated with this code. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/CPP/source.cpp" id="Snippet1"::: + and initializes it with an . Then the example calls to retrieve the and display the error message. There is no form associated with this code. + :::code language="csharp" source="~/snippets/csharp/System.IO/ErrorEventArgs/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -177,15 +175,14 @@ Gets the that represents the error that occurred. An that represents the error that occurred. - and initializes it with an . Then the example calls to retrieve the and display the error message. There is no form associated with this code. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/CPP/source.cpp" id="Snippet1"::: + and initializes it with an . Then the example calls to retrieve the and display the error message. There is no form associated with this code. + :::code language="csharp" source="~/snippets/csharp/System.IO/ErrorEventArgs/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ErrorEventArgs.ErrorEventArgs Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.IO/File.xml b/xml/System.IO/File.xml index ae713bca28e..07ec867677d 100644 --- a/xml/System.IO/File.xml +++ b/xml/System.IO/File.xml @@ -105,7 +105,6 @@ ## Examples The following example demonstrates how to use the class to check whether a file exists, and depending on the result, either create a new file and write to it, or open the existing file and read from it. Before running the code, create a `c:\temp` folder. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File Class Example/CPP/file class example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Overview/file class example.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Overview/file class example.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File Class Example/VB/file class example.vb" id="Snippet1"::: @@ -1281,7 +1280,6 @@ ## Examples The following example appends text to a file. The method creates a new file if the file doesn't exist. However, the directory named `temp` on drive C must exist for the example to complete successfully. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File_AppendText/CPP/file_appendtext.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/AppendText/file_appendtext.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/AppendText/file_appendtext.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File_AppendText/VB/file_appendtext.vb" id="Snippet1"::: @@ -1612,7 +1610,6 @@ ## Examples The following example creates a file in the specified path, writes some information to the file, and reads from the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File Create1/CPP/file create1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Create/file create1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Create/file create1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File Create1/VB/file create1.vb" id="Snippet1"::: @@ -1716,7 +1713,6 @@ ## Examples The following example creates a file with the specified buffer size. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File Create2/CPP/file create2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Create/file create2.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Create/file create2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File Create2/VB/file create2.vb" id="Snippet1"::: @@ -2032,7 +2028,6 @@ An I/O error occurred.
## Examples The following example creates a file for text writing and reading. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File CreateText/CPP/file createtext.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/CreateText/file createtext.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/CreateText/file createtext.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File CreateText/VB/file createtext.vb" id="Snippet1"::: @@ -2134,7 +2129,6 @@ An I/O error occurred.
## Examples The following code example uses the method and the method to encrypt and then decrypt a file. The file must exist for the example to work. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.File.Encrypt-Decrypt/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Decrypt/sample.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Decrypt/sample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.File.Encrypt-Decrypt/VB/sample.vb" id="Snippet1"::: @@ -2345,7 +2339,6 @@ An I/O error occurred.
## Examples The following code example uses the method and the method to encrypt and then decrypt a file. The file must exist for the example to work. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.File.Encrypt-Decrypt/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Decrypt/sample.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Decrypt/sample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.File.Encrypt-Decrypt/VB/sample.vb" id="Snippet1"::: @@ -2716,7 +2709,6 @@ Don't use the method for path validation; this m ## Examples The following example demonstrates the `GetAttributes` and `SetAttributes` methods by applying the `Archive` and `Hidden` attributes to a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File GetAttributes/CPP/file getattributes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/GetAttributes/file getattributes.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/GetAttributes/file getattributes.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File GetAttributes/VB/file getattributes.vb" id="Snippet1"::: @@ -3110,7 +3102,6 @@ Don't use the method for path validation; this m ## Examples The following example demonstrates `GetLastAccessTime`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File GetLastAccess/CPP/file getlastaccess.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/GetLastAccessTime/file getlastaccess.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/GetLastAccessTime/file getlastaccess.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File GetLastAccess/VB/file getlastaccess.vb" id="Snippet1"::: @@ -3364,7 +3355,6 @@ Don't use the method for path validation; this m ## Examples The following example demonstrates `GetLastWriteTime`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File GetLastWrite/CPP/file getlastwrite.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/GetLastWriteTime/file getlastwrite.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/GetLastWriteTime/file getlastwrite.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File GetLastWrite/VB/file getlastwrite.vb" id="Snippet1"::: @@ -3682,7 +3672,6 @@ For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/commo The following example moves a file. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File Move/CPP/file move.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Move/file move.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Move/file move.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File Move/VB/file move.vb" id="Snippet1"::: @@ -3773,7 +3762,6 @@ For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/commo The following example moves a file. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File Move/CPP/file move.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Move/file move.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Move/file move.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File Move/VB/file move.vb" id="Snippet1"::: @@ -3884,7 +3872,6 @@ The following example moves a file. ## Examples The following code example creates a temporary file and writes some text to it. The example then opens the file, using T:System.IO.FileMode.Open; that is, if the file did not already exist, it would not be created. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File Open1/CPP/file open1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Open/file open1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Open/file open1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File Open1/VB/file open1.vb" id="Snippet1"::: @@ -4041,7 +4028,6 @@ The following example moves a file. ## Examples The following example opens a file with read-only access. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File Open2/CPP/file open2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Open/file open2.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Open/file open2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File Open2/VB/file open2.vb" id="Snippet1"::: @@ -4154,7 +4140,6 @@ The following example moves a file. ## Examples The following example opens a file with read-only access and with file sharing disallowed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File Open3/CPP/file open3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Open/file open3.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Open/file open3.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File Open3/VB/file open3.vb" id="Snippet1"::: @@ -4330,7 +4315,6 @@ The following example moves a file. ## Examples The following example opens a file for reading. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File OpenRead/CPP/file openread.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/OpenRead/file openread.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/OpenRead/file openread.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File OpenRead/VB/file openread.vb" id="Snippet1"::: @@ -4426,7 +4410,6 @@ The following example moves a file. ## Examples The following example opens a text file for reading. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File OpenText/CPP/file opentext.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/OpenText/file opentext.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/OpenText/file opentext.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File OpenText/VB/file opentext.vb" id="Snippet1"::: @@ -4520,7 +4503,6 @@ The following example moves a file. ## Examples The following example opens a file for reading and writing. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File OpenWrite/CPP/file openwrite.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/OpenWrite/file openwrite.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/OpenWrite/file openwrite.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File OpenWrite/VB/file openwrite.vb" id="Snippet1"::: @@ -5680,7 +5662,6 @@ The following example moves a file. ## Examples The following code example uses the method to replace a file with another file and create a backup of the replaced file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.File.Replace/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Replace/sample.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Replace/sample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.File.Replace/VB/sample.vb" id="Snippet1"::: @@ -5795,7 +5776,6 @@ The caller does not have the required permission. ## Examples The following code example uses the method to replace a file with another file and create a backup of the replaced file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.File.Replace/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/Replace/sample.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/Replace/sample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.File.Replace/VB/sample.vb" id="Snippet1"::: @@ -6104,7 +6084,6 @@ It is not possible to change the compression status of a o ## Examples The following example demonstrates the `GetAttributes` and `SetAttributes` methods by applying the `Archive` and `Hidden` attributes to a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File GetAttributes/CPP/file getattributes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/GetAttributes/file getattributes.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/GetAttributes/file getattributes.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File GetAttributes/VB/file getattributes.vb" id="Snippet1"::: @@ -6492,7 +6471,6 @@ It is not possible to change the compression status of a o ## Examples The following example checks the file system for the specified file, creating it if necessary, and then sets and gets the last access time. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File SetLastAccess/CPP/file setlastaccess.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/SetLastAccessTime/file setlastaccess.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/SetLastAccessTime/file setlastaccess.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File SetLastAccess/VB/file setlastaccess.vb" id="Snippet1"::: @@ -6746,7 +6724,6 @@ It is not possible to change the compression status of a o ## Examples The following example checks the file system for the specified file, creating the file if necessary, and then sets and gets the last write time of the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/File SetLastWrite/CPP/file setlastwrite.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/File/SetLastWriteTime/file setlastwrite.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/File/SetLastWriteTime/file setlastwrite.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/File SetLastWrite/VB/file setlastwrite.vb" id="Snippet1"::: diff --git a/xml/System.IO/FileAccess.xml b/xml/System.IO/FileAccess.xml index 436927801a1..2dfbafc863b 100644 --- a/xml/System.IO/FileAccess.xml +++ b/xml/System.IO/FileAccess.xml @@ -72,23 +72,22 @@ Defines constants for read, write, or read/write access to a file. - , , , and other constructors where it is important to control the kind of access users have to a file. + + + +## Examples + The following `FileStream` constructor grants read-only access to an existing file (`FileAccess.Read`). -## Remarks - For an example of creating a file and writing text to a file, see [How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file). For an example of reading text from a file, see [How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file). For an example of reading from and writing to a binary file, see [How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file). - - A `FileAccess` parameter is specified in many of the constructors for , , , and other constructors where it is important to control the kind of access users have to a file. - - - -## Examples - The following `FileStream` constructor grants read-only access to an existing file (`FileAccess.Read`). - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileAccess Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileAccess/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileAccess/Overview/source.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileAccess Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileAccess Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.IO/FileInfo.xml b/xml/System.IO/FileInfo.xml index b451dfe584b..68957695264 100644 --- a/xml/System.IO/FileInfo.xml +++ b/xml/System.IO/FileInfo.xml @@ -123,7 +123,6 @@ When the properties are first retrieved, calls the method and caches information about the file. On subsequent calls, you must call to get the latest copy of the information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo Class/CPP/finfo class.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Overview/finfo class.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo Class/VB/finfo class.vb" id="Snippet1"::: @@ -205,13 +204,11 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following example uses this constructor to create two files, which are then written to, read from, copied, and deleted. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo Ctor/CPP/finfo ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/.ctor/finfo ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo Ctor/VB/finfo ctor.vb" id="Snippet1"::: The following example opens an existing file or creates a file, appends text to the file, and displays the results. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/fileinfomain/CPP/fileinfomain.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/.ctor/fileinfomain.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/fileinfomain/VB/fileinfomain.vb" id="Snippet1"::: @@ -286,13 +283,11 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following example appends text to a file and reads from the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo AppendText/CPP/finfo appendtext.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/AppendText/finfo appendtext.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo AppendText/VB/finfo appendtext.vb" id="Snippet1"::: The following example demonstrates appending text to the end of a file and also displays the result of the append operation to the console. The first time this routine is called, the file is created if it does not exist. After that, the specified text is appended to the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/fileinfoappendtext/CPP/fileinfoappendtext.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/AppendText/fileinfoappendtext.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/fileinfoappendtext/VB/fileinfoappendtext.vb" id="Snippet1"::: @@ -376,13 +371,11 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following example demonstrates both overloads of the `CopyTo` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo CopyTo2/CPP/finfo copyto2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/CopyTo/program.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo CopyTo2/VB/program.vb" id="Snippet1"::: The following example demonstrates copying one file to another file, throwing an exception if the destination file already exists. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FileInfoCopyTo1/CPP/fileinfocopyto1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/CopyTo/fileinfocopyto1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FileInfoCopyTo1/VB/fileinfocopyto1.vb" id="Snippet1"::: @@ -468,13 +461,11 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following example demonstrates both overloads of the `CopyTo` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo CopyTo2/CPP/finfo copyto2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/CopyTo/program.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo CopyTo2/VB/program.vb" id="Snippet1"::: The following example demonstrates copying one file to another file, specifying whether to overwrite a file that already exists. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/fileinfocopyto/CPP/fileinfocopyto.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/CopyTo/fileinfocopyto.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/fileinfocopyto/VB/fileinfocopyto.vb" id="Snippet1"::: @@ -559,13 +550,11 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following example creates a reference to a file, and then creates the file on disk using `FileInfo.Create()`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/fileinfodelete/CPP/fileinfodelete.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Create/fileinfodelete.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/fileinfodelete/VB/fileinfodelete.vb" id="Snippet1"::: The following example creates a file, adds some text to it, and reads from the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo Create/CPP/finfo create.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Create/finfo create.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo Create/VB/finfo create.vb" id="Snippet1"::: @@ -638,7 +627,6 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following example demonstrates the `CreateText` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo CreateText/CPP/finfo createtext.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/CreateText/finfo createtext.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo CreateText/VB/finfo createtext.vb" id="Snippet1"::: @@ -719,7 +707,6 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following code example uses the method and the method to encrypt and then decrypt a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Decrypt/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/VB/sample.vb" id="Snippet1"::: @@ -801,13 +788,11 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following example demonstrates the `Delete` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo Delete/CPP/finfo delete.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Delete/finfo delete.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo Delete/VB/finfo delete.vb" id="Snippet1"::: The following example creates, closes, and deletes a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/fileinfodelete/CPP/fileinfodelete.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Create/fileinfodelete.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/fileinfodelete/VB/fileinfodelete.vb" id="Snippet1"::: @@ -890,7 +875,6 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following example opens or creates a file, determines its full path, and determines and displays the full contents of the directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/fileinfodirectory/CPP/fileinfodirectory.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Directory/fileinfodirectory.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/fileinfodirectory/VB/fileinfodirectory.vb" id="Snippet1"::: @@ -1046,7 +1030,6 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following code example uses the method and the method to encrypt a file and then decrypt it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Decrypt/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.Encrypt-Decrypt/VB/sample.vb" id="Snippet1"::: @@ -1131,7 +1114,6 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following code example uses the property ensure a file exists before opening it. You can use this technique to throw a custom exception when the file is not found. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Exists/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Exists/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.Exists/vb/sample.vb" id="Snippet1"::: @@ -1193,7 +1175,6 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following code example uses the method and the method to add and then remove an access control list (ACL) entry from a file. You must supply a valid user or group account to run this example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/GetAccessControl/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/VB/sample.vb" id="Snippet1"::: @@ -1329,7 +1310,6 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following example creates a temporary file, uses the property to first check and then set its read-only status, and finally marks it as read-write in order to delete it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.isReadOnly/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/IsReadOnly/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.isReadOnly/VB/sample.vb" id="Snippet1"::: @@ -1419,7 +1399,6 @@ C:\Users\userName\AppData\Local\Temp\tmp70CB.tmp was successfully deleted. ## Examples The following example displays the size of the specified files. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FileLength/CPP/filelength.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Length/filelength.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FileLength/VB/filelength.vb" id="Snippet1"::: @@ -1653,7 +1632,6 @@ The following example demonstrates moving a file to a different location and ren ## Examples The following example uses the `Name` property to display the names of files in the current directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/fileinfoname/CPP/fileinfoname.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Name/fileinfoname.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/fileinfoname/VB/fileinfoname.vb" id="Snippet1"::: @@ -1733,7 +1711,6 @@ The following example demonstrates moving a file to a different location and ren ## Examples The following example opens a file, adds some information to the file, and reads the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo Open1/CPP/finfo open1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Open/finfo open1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo Open1/VB/finfo open1.vb" id="Snippet1"::: @@ -1855,7 +1832,6 @@ The following example demonstrates moving a file to a different location and ren ## Examples The following example opens a file as read-only and reads from the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo Open2/CPP/finfo open2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Open/finfo open2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo Open2/VB/finfo open2.vb" id="Snippet1"::: @@ -1938,7 +1914,6 @@ The following example demonstrates moving a file to a different location and ren ## Examples The following example demonstrates opening a file for reading and writing, but disallowing access to other users or processes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/fileinfoopen/CPP/fileinfoopen.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Open/fileinfoopen.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/fileinfoopen/VB/fileinfoopen.vb" id="Snippet1"::: @@ -2019,7 +1994,6 @@ The following example demonstrates moving a file to a different location and ren ## Examples The following example opens a file as read-only and reads from it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo OpenRead/CPP/finfo openread.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/OpenRead/finfo openread.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo OpenRead/VB/finfo openread.vb" id="Snippet1"::: @@ -2091,7 +2065,6 @@ The following example demonstrates moving a file to a different location and ren ## Examples The following example reads text from a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo OpenText/CPP/file opentext.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/OpenText/file opentext.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo OpenText/VB/file opentext.vb" id="Snippet1"::: @@ -2171,7 +2144,6 @@ The following example demonstrates moving a file to a different location and ren ## Examples The following example opens a file for writing and then reads from the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FInfo OpenWrite/CPP/file openwrite.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/OpenWrite/file openwrite.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FInfo OpenWrite/VB/file openwrite.vb" id="Snippet1"::: @@ -2274,7 +2246,6 @@ The following example demonstrates moving a file to a different location and ren ## Examples The following example uses the method to replace a file with another file and create a backup of the replaced file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Replace/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Replace/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.Replace/VB/sample.vb" id="Snippet1"::: @@ -2372,7 +2343,6 @@ The following example demonstrates moving a file to a different location and ren ## Examples The following example uses the method to replace a file with another file and create a backup of the replaced file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.Replace/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/Replace/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.Replace/VB/sample.vb" id="Snippet1"::: @@ -2459,7 +2429,6 @@ The following example demonstrates moving a file to a different location and ren ## Examples The following code example uses the method and the method to add and then remove an ACL entry from a file. You must supply a valid user or group account to run this example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileInfo/GetAccessControl/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.FileInfo.GetAccessControl-SetAccessControl/VB/sample.vb" id="Snippet1"::: diff --git a/xml/System.IO/FileMode.xml b/xml/System.IO/FileMode.xml index 98d93d70d81..21c806f6ea3 100644 --- a/xml/System.IO/FileMode.xml +++ b/xml/System.IO/FileMode.xml @@ -68,24 +68,23 @@ Specifies how the operating system should open a file. - , , and in the `Open` methods of and to control how a file is opened. + + `FileMode` parameters control whether a file is overwritten, created, opened, or some combination thereof. Use `Open` to open an existing file. To append to a file, use `Append`. To truncate a file or create a file if it doesn't exist, use `Create`. + + + +## Examples + The following `FileStream` constructor opens an existing file (`FileMode.Open`). -## Remarks - For an example of creating a file and writing text to a file, see [How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file). For an example of reading text from a file, see [How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file). For an example of reading from and writing to a binary file, see [How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file). - - A `FileMode` parameter is specified in many of the constructors for , , and in the `Open` methods of and to control how a file is opened. - - `FileMode` parameters control whether a file is overwritten, created, opened, or some combination thereof. Use `Open` to open an existing file. To append to a file, use `Append`. To truncate a file or create a file if it doesn't exist, use `Create`. - - - -## Examples - The following `FileStream` constructor opens an existing file (`FileMode.Open`). - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileAccess Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileAccess/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileAccess Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileAccess Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.IO/FileShare.xml b/xml/System.IO/FileShare.xml index 842f248d2ce..de73ac87427 100644 --- a/xml/System.IO/FileShare.xml +++ b/xml/System.IO/FileShare.xml @@ -72,24 +72,23 @@ Contains constants for controlling the kind of access other operations can have to the same file. - , , and in some of the `Open` methods of and to control how a file is opened. + + + +## Examples + The following constructor opens an existing file and grants read-only access to other users (`Read`). -## Remarks - For an example of creating a file and writing text to a file, see [How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file). For an example of reading text from a file, see [How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file). For an example of reading from and writing to a binary file, see [How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file). - - A typical use of this enumeration is to define whether two processes can simultaneously read from the same file. For example, if a file is opened and `Read` is specified, other users can open the file for reading but not for writing. - - A `FileShare` parameter is specified in some of the constructors for , , and in some of the `Open` methods of and to control how a file is opened. - - - -## Examples - The following constructor opens an existing file and grants read-only access to other users (`Read`). - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileAccess Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileAccess/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileAccess Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileAccess Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.IO/FileStream.xml b/xml/System.IO/FileStream.xml index 29608fb41fa..5cbc458e4e0 100644 --- a/xml/System.IO/FileStream.xml +++ b/xml/System.IO/FileStream.xml @@ -73,7 +73,6 @@ constructors. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FStream Class/CPP/fstream class.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/Overview/fstream class.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/Overview/fstream class.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FStream Class/VB/fstream class.vb" id="Snippet1"::: @@ -365,7 +364,6 @@ ## Examples The following code example shows how to write data to a file, byte by byte, and then verify that the data was written correctly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream1/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream1/VB/source.vb" id="Snippet1"::: @@ -1034,7 +1032,6 @@ The file was too large (when constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream2/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/source1.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/source1.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream2/VB/source.vb" id="Snippet4"::: @@ -2585,7 +2574,6 @@ Calling `DisposeAsync` allows the resources used by the constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream2/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/source1.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/source1.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream2/VB/source.vb" id="Snippet3"::: @@ -2747,7 +2735,6 @@ Calling `DisposeAsync` allows the resources used by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream3/CPP/fstreamlock.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/fstreamlock.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/fstreamlock.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream3/VB/fstreamlock.vb" id="Snippet4"::: @@ -3086,7 +3073,6 @@ Calling `DisposeAsync` allows the resources used by the constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream2/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/source1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/source1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream2/VB/source.vb" id="Snippet2"::: @@ -3158,7 +3144,6 @@ Calling `DisposeAsync` allows the resources used by the constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream2/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/source1.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/source1.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream2/VB/source.vb" id="Snippet4"::: @@ -3412,7 +3395,6 @@ If the absolute path is not known, this property returns a string similar to "[U ## Examples The following example uses the `Length` and `Position` properties to check for an end-of-file condition. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.Length Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/Length/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/Length/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileStream.Length Example/VB/source.vb" id="Snippet1"::: @@ -3812,7 +3794,6 @@ The following example shows how to read from a file asynchronously. ## Examples The following code example shows how to write data to a file, byte by byte, and then verify that the data was written correctly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream1/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream1/VB/source.vb" id="Snippet1"::: @@ -3963,7 +3944,6 @@ The following example shows how to read from a file asynchronously. ## Examples The following example shows how to write data to a file, byte by byte, and then verify that the data was written correctly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream1/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream1/VB/source.vb" id="Snippet1"::: @@ -4199,7 +4179,6 @@ The following example shows how to read from a file asynchronously. ## Examples The following code example demonstrates how to lock part of a file so another process cannot access that part of the file even though it has read/write access to the file, and then unlock the specified part of the file . Run the program simultaneously in different command windows and investigate using the different console input options. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream3/CPP/fstreamlock.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/fstreamlock.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/fstreamlock.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream3/VB/fstreamlock.vb" id="Snippet1"::: @@ -4347,7 +4326,6 @@ For a list of common file and directory operations, see [Common I/O Tasks](/dotn ## Examples This code example is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream3/CPP/fstreamlock.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/fstreamlock.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/fstreamlock.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream3/VB/fstreamlock.vb" id="Snippet3"::: @@ -4591,7 +4569,6 @@ This method stores in the task it returns all non-usage exceptions that the meth ## Examples The following code example shows how to write data to a file, byte by byte, and then verify that the data was written correctly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream1/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.IO/FileStream/.ctor/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream1/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.IO/FileSystemInfo.xml b/xml/System.IO/FileSystemInfo.xml index 140864f96a1..d44efda9109 100644 --- a/xml/System.IO/FileSystemInfo.xml +++ b/xml/System.IO/FileSystemInfo.xml @@ -104,7 +104,6 @@ ## Examples The following example shows how to loop through all the files and directories, querying some information about each entry. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FileSystemInfo/cpp/program.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemInfo/Overview/program.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FileSystemInfo/VB/FileSystemInfo.vb" id="Snippet1"::: @@ -336,7 +335,6 @@ ## Examples The following example demonstrates the property. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FileSystemInfo/cpp/program.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemInfo/Overview/program.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FileSystemInfo/VB/FileSystemInfo.vb" id="Snippet2"::: @@ -494,7 +492,6 @@ On Unix platforms that do not support creation or birth time, this property retu ## Examples The following example demonstrates the property. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FileSystemInfo/cpp/program.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemInfo/Overview/program.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FileSystemInfo/VB/FileSystemInfo.vb" id="Snippet2"::: @@ -854,7 +851,6 @@ The `Extension` property returns the extension, ## Examples The following example demonstrates the property. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FileSystemInfo/cpp/program.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemInfo/Overview/program.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FileSystemInfo/VB/FileSystemInfo.vb" id="Snippet2"::: diff --git a/xml/System.IO/FileSystemWatcher.xml b/xml/System.IO/FileSystemWatcher.xml index 5429bc8df0b..8e9581dc7f5 100644 --- a/xml/System.IO/FileSystemWatcher.xml +++ b/xml/System.IO/FileSystemWatcher.xml @@ -77,7 +77,6 @@ to watch the directory specified at run time. The component is set to watch for changes in `LastWrite` and `LastAccess` time, the creation, deletion, or renaming of text files in the directory. If a file is changed, created, or deleted, the path to the file prints to the console. When a file is renamed, the old and new paths print to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: ]]> @@ -168,7 +167,6 @@ This example uses the and namespaces. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: @@ -462,7 +460,6 @@ ## Examples The following example uses the event to display the file path to the console whenever the watched file is changed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: @@ -539,7 +536,6 @@ ## Examples The following example uses the event to display the file path to the console whenever the watched file is created. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: @@ -615,7 +611,6 @@ ## Examples The following example uses the event to display the file path to the console whenever the watched file is deleted. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: @@ -796,7 +791,6 @@ ## Examples The following example creates a to watch the directory specified at run time. The component is set to watch for changes in `LastWrite` and `LastAccess` time, the creation, deletion, or renaming of text files in the directory. If a file is changed, created, or deleted, the path to the file prints to the console. When a file is renamed, the old and new paths print to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: @@ -1030,7 +1024,6 @@ ## Examples The following example creates a to watch the directory specified at run time. The component is set to watch for changes in `LastWrite` and `LastAccess` time, the creation, deletion, or renaming of text files in the directory. If a file is changed, created, or deleted, the path to the file prints to the console. When a file is renamed, the old and new paths print to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: @@ -1292,7 +1285,6 @@ ## Examples The following example creates a to watch the directory specified at run time. The component is set to watch for changes in `LastWrite` and `LastAccess` time, the creation, deletion, or renaming of text files in the directory. If a file is changed, created, or deleted, the path to the file prints to the console. When a file is renamed, the old and new paths print to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: @@ -1727,7 +1719,6 @@ ## Examples The following example creates a to watch the directory specified at run time. The component is set to watch for changes in `LastWrite` and `LastAccess` time, the creation, deletion, or renaming of text files in the directory. If a file is changed, created, or deleted, the path to the file prints to the console. When a file is renamed, the old and new paths print to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: @@ -1812,7 +1803,6 @@ Public Delegate Sub RenamedEventHandler(sender As Object, e As RenamedEventArgs) ## Examples The following example uses the event to display the file path to the console whenever the watched file is renamed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.IO/IOException.xml b/xml/System.IO/IOException.xml index 199bd34919c..45bcfcd9c34 100644 --- a/xml/System.IO/IOException.xml +++ b/xml/System.IO/IOException.xml @@ -105,7 +105,6 @@ ## Examples This code example is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.FileStream3/CPP/fstreamlock.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/.ctor/fstreamlock.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.FileStream3/VB/fstreamlock.vb" id="Snippet6"::: diff --git a/xml/System.IO/MemoryStream.xml b/xml/System.IO/MemoryStream.xml index 14eb105fc8d..0bb525541df 100644 --- a/xml/System.IO/MemoryStream.xml +++ b/xml/System.IO/MemoryStream.xml @@ -103,7 +103,6 @@ ## Examples The following code example shows how to read and write data using memory as a backing store. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.MemoryStream/VB/memstream.vb" id="Snippet1"::: @@ -319,7 +318,6 @@ ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.MemoryStream/VB/memstream.vb" id="Snippet2"::: @@ -1040,7 +1038,6 @@ Refer to the remarks for additional usage ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.MemoryStream/VB/memstream.vb" id="Snippet5"::: @@ -1694,7 +1691,6 @@ The pending operation does not support writing.
## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.MemoryStream/VB/memstream.vb" id="Snippet5"::: @@ -1799,7 +1795,6 @@ The pending operation does not support writing.
## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.MemoryStream/VB/memstream.vb" id="Snippet5"::: @@ -1948,7 +1943,6 @@ The pending operation does not support writing.
## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.MemoryStream/VB/memstream.vb" id="Snippet7"::: @@ -2164,7 +2158,6 @@ The pending operation does not support writing.
## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.MemoryStream/VB/memstream.vb" id="Snippet8"::: @@ -2244,7 +2237,6 @@ The pending operation does not support writing.
## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.MemoryStream/VB/memstream.vb" id="Snippet6"::: @@ -2609,7 +2601,6 @@ The underlying buffer will not be exposed if the current `MemoryStream` instance ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.MemoryStream/VB/memstream.vb" id="Snippet3"::: @@ -2833,7 +2824,6 @@ The underlying buffer will not be exposed if the current `MemoryStream` instance ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.MemoryStream/CPP/memstream.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.IO/MemoryStream/Overview/memstream.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.MemoryStream/VB/memstream.vb" id="Snippet4"::: diff --git a/xml/System.IO/NotifyFilters.xml b/xml/System.IO/NotifyFilters.xml index ce0510ba244..f72a7da2e07 100644 --- a/xml/System.IO/NotifyFilters.xml +++ b/xml/System.IO/NotifyFilters.xml @@ -50,20 +50,19 @@ Specifies changes to watch for in a file or folder. - to watch the directory that is specified at runtime. The component is set to watch for any changes in LastWrite and LastAccess time, the creation, deletion, or renaming of text files in the directory. If a file is changed, created, or deleted, the path to the file prints to the console. When a file is renamed, the old and new paths print to the console. -## Remarks - You can combine the members of this enumeration to watch for more than one kind of change. For example, you can watch for changes in the size of a file or folder, and for changes in security settings. This raises an event anytime there is a change in size or security settings of a file or folder. - - - -## Examples - The following example creates a to watch the directory that is specified at runtime. The component is set to watch for any changes in LastWrite and LastAccess time, the creation, deletion, or renaming of text files in the directory. If a file is changed, created, or deleted, the path to the file prints to the console. When a file is renamed, the old and new paths print to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic NotifyFilters Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileSystemWatcher/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic NotifyFilters Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.IO/Path.xml b/xml/System.IO/Path.xml index 1d510fd98f9..0ce1b191c3a 100644 --- a/xml/System.IO/Path.xml +++ b/xml/System.IO/Path.xml @@ -116,7 +116,6 @@ For more information on file path formats on Windows, see [File path formats on ## Examples The following example demonstrates some of the main members of the `Path` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Path Class/CPP/path class.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/Overview/path class.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Path Class/VB/path class.vb" id="Snippet1"::: @@ -270,7 +269,6 @@ The following example displays field values on Windows and ## Examples The following example demonstrates a use of the `ChangeExtension` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet1"::: @@ -510,7 +508,6 @@ If any element in `paths` but the last one is not a drive and does not end with ## Examples The following example demonstrates using the `Combine` method on Windows. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/pathcombine/CPP/pathcombine.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/Combine/pathcombine.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/pathcombine/VB/pathcombine.vb" id="Snippet1"::: @@ -1048,7 +1045,6 @@ For a list of common I/O tasks, see [Common I/O tasks](/dotnet/standard/io/commo ## Examples The following example demonstrates using the `GetDirectoryName` method on a Windows-based desktop platform. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet3"::: @@ -1175,7 +1171,6 @@ This method obtains the extension of `path` by searching `path` for a period (.) ## Examples The following example demonstrates using the `GetExtension` method on a Windows-based desktop platform. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet4"::: @@ -1304,7 +1299,6 @@ For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/commo ## Examples The following example demonstrates the behavior of the `GetFileName` method on a Windows-based desktop platform. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet5"::: @@ -1422,7 +1416,6 @@ For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/commo ## Examples The following example demonstrates a use of the `GetFileNameWithoutExtension` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet6"::: @@ -1515,7 +1508,6 @@ For more information on file path formats on Windows, see [File path formats on ## Examples The following example demonstrates the `GetFullPath` method on a Windows-based desktop platform. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet7"::: @@ -1663,7 +1655,6 @@ The following example defines a variable, `basePath`, to represent an applicatio ## Examples The following example demonstrates the method and the method to retrieve invalid characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.Path.GetInvalidFile-PathChars/cpp/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/GetInvalidFileNameChars/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.Path.GetInvalidFile-PathChars/VB/example.vb" id="Snippet1"::: @@ -1724,7 +1715,6 @@ The following example defines a variable, `basePath`, to represent an applicatio ## Examples The following example demonstrates the method and the method to retrieve invalid characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.Path.GetInvalidFile-PathChars/cpp/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/GetInvalidFileNameChars/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.Path.GetInvalidFile-PathChars/VB/example.vb" id="Snippet1"::: @@ -1907,7 +1897,6 @@ For more information on file paths on Windows, see [File path formats on Windows ## Examples The following example demonstrates a use of the `GetPathRoot` method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet8"::: @@ -2341,7 +2330,6 @@ A trailing period in `path` is not considered an extension. ## Examples The following example demonstrates the use of the `HasExtension` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet11"::: @@ -2421,7 +2409,6 @@ The array returned from this method is not guaranteed to contain the complete se ## Examples The following example demonstrates the use of the `InvalidPathChars` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet13"::: @@ -2687,7 +2674,6 @@ Note that rooted paths can be either absolute (that is, fully qualified) or rela ## Examples The following example demonstrates how the `IsPathRooted` method can be used to test three strings. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet12"::: @@ -3306,7 +3292,6 @@ Not all invalid characters for directory and file names are interpreted as unacc ## Examples The following example demonstrates the use of the `PathSeparator` field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet13"::: @@ -3586,7 +3571,6 @@ The destination character span must be large enough to hold the concatenated pat ## Examples The following example demonstrates the use of the `VolumeSeparatorChar` field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.Path Members/CPP/pathmembers.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Path/ChangeExtension/pathmembers.cs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.Path Members/VB/pathmembers.vb" id="Snippet13"::: diff --git a/xml/System.IO/SearchOption.xml b/xml/System.IO/SearchOption.xml index 86f831c04b3..eba64da1db6 100644 --- a/xml/System.IO/SearchOption.xml +++ b/xml/System.IO/SearchOption.xml @@ -64,20 +64,19 @@ Specifies whether to search the current directory, or the current directory and all subdirectories. - is used to specify that only the top-level directory should be searched. -## Remarks - If you choose `AllDirectories` in your search and the directory structure contains a link that creates a loop, the search operation enters an infinite loop. - - - -## Examples - The following example lists all the directories and files that begin with the letter "c", as in "c:\\". In this example, is used to specify that only the top-level directory should be searched. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/cpp/searchoption.cpp" id="Snippet00"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/GetDirectories/searchoption.cs" id="Snippet00"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/vb/searchoption.vb" id="Snippet00"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.DirectoryInfo_SearchOptions/vb/searchoption.vb" id="Snippet00"::: + ]]> diff --git a/xml/System.IO/Stream.xml b/xml/System.IO/Stream.xml index 00f0749b2cd..c9e8b41bb5b 100644 --- a/xml/System.IO/Stream.xml +++ b/xml/System.IO/Stream.xml @@ -455,7 +455,6 @@ ## Examples The following is an example of using the `CanRead` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileStream.CanRead Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/CanRead/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileStream.CanRead Example/VB/source.vb" id="Snippet1"::: @@ -641,7 +640,6 @@ ## Examples The following is an example of using the `CanWrite` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.CanWrite Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Stream/CanWrite/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stream.CanWrite Example/VB/source.vb" id="Snippet1"::: @@ -2131,7 +2129,6 @@ ## Examples The following example shows how to use to read a block of data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Stream.Read Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/Stream/Read/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Stream.Read Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.IO/StreamReader.xml b/xml/System.IO/StreamReader.xml index 79156e1b552..d2fd92b04ad 100644 --- a/xml/System.IO/StreamReader.xml +++ b/xml/System.IO/StreamReader.xml @@ -109,7 +109,6 @@ ## Examples The following example uses an instance of to read text from a file. The constructor used in this example is not supported for use in Windows Store Apps. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ReadTextFile/CPP/readtextfile.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Overview/readtextfile.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ReadTextFile/VB/readtextfile.vb" id="Snippet1"::: @@ -203,7 +202,6 @@ ## Examples The following code example demonstrates this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor1/CPP/strmreader ctor1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/.ctor/strmreader ctor1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StrmReader Ctor1/VB/strmreader ctor1.vb" id="Snippet1"::: @@ -288,7 +286,6 @@ ## Examples The following code example demonstrates this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StrmReader Ctor2/CPP/strmreader ctor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/.ctor/strmreader ctor2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StrmReader Ctor2/VB/strmreader ctor2.vb" id="Snippet1"::: @@ -374,7 +371,6 @@ ## Examples The following code example demonstrates this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Overview/streamreadersample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamReader/VB/streamreadersample.vb" id="Snippet2"::: @@ -464,7 +460,6 @@ ## Examples The following code example demonstrates this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Overview/streamreadersample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamReader/VB/streamreadersample.vb" id="Snippet2"::: @@ -551,7 +546,6 @@ ## Examples The following code example demonstrates this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Overview/streamreadersample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamReader/VB/streamreadersample.vb" id="Snippet2"::: @@ -705,7 +699,6 @@ ## Examples The following code example demonstrates this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Overview/streamreadersample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamReader/VB/streamreadersample.vb" id="Snippet2"::: @@ -804,7 +797,6 @@ ## Examples The following code example demonstrates this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Overview/streamreadersample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamReader/VB/streamreadersample.vb" id="Snippet2"::: @@ -904,7 +896,6 @@ ## Examples The following code example demonstrates this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Overview/streamreadersample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamReader/VB/streamreadersample.vb" id="Snippet2"::: @@ -1008,7 +999,6 @@ ## Examples The following code example demonstrates this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Overview/streamreadersample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamReader/VB/streamreadersample.vb" id="Snippet2"::: @@ -1111,7 +1101,6 @@ ## Examples The following code example demonstrates this constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamReader/CPP/streamreadersample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Overview/streamreadersample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamReader/VB/streamreadersample.vb" id="Snippet2"::: @@ -1466,7 +1455,6 @@ Following a call to , any operations on th ## Examples The following code example gets the encoding of the specified object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StrmReader CurrentEncoding/CPP/strmreader currentencoding.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/CurrentEncoding/strmreader currentencoding.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StrmReader CurrentEncoding/VB/strmreader currentencoding.vb" id="Snippet1"::: @@ -1807,7 +1795,6 @@ Following a call to , any operations on th ## Examples The following code example reads lines from a file until the end of the file is reached. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StrmReader Peek/CPP/strmreader peek.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Peek/strmreader peek.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StrmReader Peek/VB/strmreader peek.vb" id="Snippet1"::: @@ -1899,13 +1886,11 @@ Following a call to , any operations on th ## Examples The following code example demonstrates a simple use of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StrmReader Read1/CPP/strmreader read1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Read/strmreader read1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StrmReader Read1/VB/strmreader read1.vb" id="Snippet1"::: The following code example demonstrates reading a single character using the method overload, formatting the ASCII integer output as decimal and hexadecimal. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StrmRdrRead/CPP/strmrdrread.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Read/strmrdrread.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StrmRdrRead/VB/strmrdrread.vb" id="Snippet1"::: @@ -2046,7 +2031,6 @@ Following a call to , any operations on th ## Examples The following code example reads five characters at a time until the end of the file is reached. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StrmReader Read2/CPP/strmreader read2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/Read/strmreader read2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StrmReader Read2/VB/strmreader read2.vb" id="Snippet1"::: @@ -2513,7 +2497,6 @@ Following a call to , any operations on th ## Examples The following code example reads lines from a file until the end of the file is reached. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StrmReader ReadLine/CPP/strmreader readline.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/ReadLine/strmreader readline.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StrmReader ReadLine/VB/strmreader readline.vb" id="Snippet1"::: @@ -2734,7 +2717,6 @@ This method stores in the task it returns all non-usage exceptions that the meth ## Examples The following code example reads all the way to the end of a file in one operation. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StrmReader ReadToEnd/CPP/strmreader readtoend.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamReader/ReadToEnd/strmreader readtoend.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StrmReader ReadToEnd/VB/strmreader readtoend.vb" id="Snippet1"::: diff --git a/xml/System.IO/StreamWriter.xml b/xml/System.IO/StreamWriter.xml index 2e3e2832c0b..209f7bcc58a 100644 --- a/xml/System.IO/StreamWriter.xml +++ b/xml/System.IO/StreamWriter.xml @@ -1081,7 +1081,6 @@ ## Examples The following example shows the syntax for using the `AutoFlush` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamWriter/CPP/logger.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamWriter/AutoFlush/logger.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamWriter/VB/logger.vb" id="Snippet5"::: @@ -1213,7 +1212,6 @@ ## Examples The following code example demonstrates the `Close` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamWriter/CPP/logger.cpp" id="Snippet17"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamWriter/AutoFlush/logger.cs" id="Snippet17"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamWriter/VB/logger.vb" id="Snippet17"::: @@ -1398,7 +1396,6 @@ ## Examples The following example retrieves the encoding of the specified instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamWriter/CPP/logger.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamWriter/AutoFlush/logger.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamWriter/VB/logger.vb" id="Snippet11"::: @@ -1677,7 +1674,6 @@ For a list of common I/O tasks, see [Common I/O Tasks](/dotnet/standard/io/commo ## Examples The following example demonstrates a use of the `Null` field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StreamWriter/CPP/logger.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamWriter/AutoFlush/logger.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StreamWriter/VB/logger.vb" id="Snippet6"::: @@ -2251,7 +2247,6 @@ See for a descr ## Examples This example writes eight characters from a 13-element array to a file, beginning at the third element of the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic StreamWriter.Write2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StreamWriter/Write/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic StreamWriter.Write2 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.IO/StringReader.xml b/xml/System.IO/StringReader.xml index 91485a10180..c5fdc1282dc 100644 --- a/xml/System.IO/StringReader.xml +++ b/xml/System.IO/StringReader.xml @@ -85,36 +85,36 @@ Implements a that reads from a string. - enables you to read a string synchronously or asynchronously. You can read a character at a time with the or the method, a line at a time using the or the method and an entire string using the or the method. - + enables you to read a string synchronously or asynchronously. You can read a character at a time with the or the method, a line at a time using the or the method and an entire string using the or the method. + [!INCLUDE[note_unnecessary_dispose](~/includes/note-unnecessary-dispose.md)] - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - The following example shows how to read an entire string asynchronously. - + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + The following example shows how to read an entire string asynchronously. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringReader/Overview/example2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.stringreader/vb/example2.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.stringreader/vb/example2.vb" id="Snippet2"::: + ]]>
@@ -178,33 +178,32 @@ The string to which the should be initialized. Initializes a new instance of the class that reads from the specified string. -


| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - This code example is part of a larger example provided for the class. +


| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StringReader/.ctor/stringrw.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringReaderWriter/VB/stringrw.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringReaderWriter/VB/stringrw.vb" id="Snippet2"::: + ]]>
The parameter is . @@ -258,16 +257,16 @@ Closes the . - method. + +This implementation of `Close` calls the , method passing a `true` value. Following a call to `Close`, other methods might throw an exception. -For an example of creating a file and writing text to a file, see [How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file). For an example of reading text from a file, see [How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file). For an example of reading from and writing to a binary file, see [How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file). - -This method overrides the method. - -This implementation of `Close` calls the , method passing a `true` value. Following a call to `Close`, other methods might throw an exception. - ]]> File and Stream I/O @@ -327,11 +326,11 @@ This implementation of `Close` calls the to release both managed and unmanaged resources; to release only unmanaged resources. Releases the unmanaged resources used by the and optionally releases the managed resources. - references. This method invokes the `Dispose` method of each referenced object. - + references. This method invokes the `Dispose` method of each referenced object. + ]]> @@ -398,24 +397,24 @@ This implementation of `Close` calls the Returns the next available character but does not consume it. An integer representing the next character to be read, or -1 if no more characters are available or the stream does not support seeking. - method returns an integer value in order to determine whether the end of the file, or another error has occurred. This allows a user to first check if the returned value is -1 before casting it to a type. - - This method overrides the method. - - The current position of the `StringReader` is not changed by this operation. - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Get the size of a file.|| - + method returns an integer value in order to determine whether the end of the file, or another error has occurred. This allows a user to first check if the returned value is -1 before casting it to a type. + + This method overrides the method. + + The current position of the `StringReader` is not changed by this operation. + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Get the size of a file.|| + ]]> The current reader is closed. @@ -490,35 +489,34 @@ This implementation of `Close` calls the Reads the next character from the input string and advances the character position by one character. The next character from the underlying string, or -1 if no more characters are available. - method. - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp" id="Snippet3"::: + method. + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringReader/.ctor/stringrw.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringReaderWriter/VB/stringrw.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringReaderWriter/VB/stringrw.vb" id="Snippet3"::: + ]]>
The current reader is closed. @@ -630,28 +628,28 @@ This implementation of `Close` calls the Reads a block of characters from the input string and advances the character position by . The total number of characters read into the buffer. This can be less than the number of characters requested if that many characters are not currently available, or zero if the end of the underlying string has been reached. - . - - The method will read up to `count` characters from the into the `buffer` character array starting at position `index`. Returns the actual number of characters read, or zero if the end of the string has been reached and no characters are read. - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - + . + + The method will read up to `count` characters from the into the `buffer` character array starting at position `index`. Returns the actual number of characters read, or zero if the end of the string has been reached and no characters are read. + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + ]]>
@@ -772,16 +770,16 @@ This implementation of `Close` calls the Reads a specified maximum number of characters from the current string asynchronously and writes the data to a buffer, beginning at the specified index. A task that represents the asynchronous read operation. The value of the parameter contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the string has been reached. - , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . - -## Examples - The following example shows how to read the first 23 characters of a string asynchronously. - + +## Examples + The following example shows how to read the first 23 characters of a string asynchronously. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringReader/Overview/example1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.stringreader/vb/example1.vb" id="Snippet1"::: @@ -965,11 +963,11 @@ This implementation of `Close` calls the Reads a specified maximum number of characters from the current string asynchronously and writes the data to a buffer, beginning at the specified index. A task that represents the asynchronous read operation. The value of the parameter contains the total number of bytes read into the buffer. The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the string has been reached. - @@ -1037,39 +1035,38 @@ This implementation of `Close` calls the Reads a line of characters from the current string and returns the data as a string. The next line from the current string, or if the end of the string is reached. - method. - - A line is defined as a sequence of characters followed by a line feed ("\n"), a carriage return ("\r"), a carriage return immediately followed by a line feed ("\r\n"), or the end-of-stream marker. The string that is returned does not contain the terminating carriage return or line feed. The returned value is `null` if the end-of-stream marker has been reached. That is to say, if there is nothing between the last line read and the end-of-stream marker, the method returns `null`. - - If the current method throws an , the reader's position in the underlying string is advanced by the number of characters the method was able to read, but the characters already read into the internal buffer are discarded. Because the position of the reader in the string cannot be changed, the characters already read are unrecoverable, and can be accessed only by reinitializing the . To avoid such a situation, use the method and store the read characters in a preallocated buffer. - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp" id="Snippet2"::: + method. + + A line is defined as a sequence of characters followed by a line feed ("\n"), a carriage return ("\r"), a carriage return immediately followed by a line feed ("\r\n"), or the end-of-stream marker. The string that is returned does not contain the terminating carriage return or line feed. The returned value is `null` if the end-of-stream marker has been reached. That is to say, if there is nothing between the last line read and the end-of-stream marker, the method returns `null`. + + If the current method throws an , the reader's position in the underlying string is advanced by the number of characters the method was able to read, but the characters already read into the internal buffer are discarded. Because the position of the reader in the string cannot be changed, the characters already read are unrecoverable, and can be accessed only by reinitializing the . To avoid such a situation, use the method and store the read characters in a preallocated buffer. + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringReader/.ctor/stringrw.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringReaderWriter/VB/stringrw.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringReaderWriter/VB/stringrw.vb" id="Snippet2"::: + ]]>
The current reader is closed. @@ -1138,10 +1135,10 @@ This implementation of `Close` calls the , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . - -## Examples - The following example shows how to read one line at a time from a string asynchronously. - + +## Examples + The following example shows how to read one line at a time from a string asynchronously. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringReader/Overview/example3.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.stringreader/vb/example3.vb" id="Snippet3"::: @@ -1251,37 +1248,36 @@ This method stores in the task it returns all non-usage exceptions that the meth Reads all characters from the current position to the end of the string and returns them as a single string. The content from the current position to the end of the underlying string. - method. - - If the current method throws an , the reader's position in the underlying string is advanced by the number of characters the method was able to read, but the characters already read into the internal buffer are discarded. Because the position of the reader in the string cannot be changed, the characters already read are unrecoverable, and can be accessed only by reinitializing the . To avoid such a situation, use the method and store the read characters in a preallocated buffer. - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.TextReaderWriter/CPP/textrw.cpp" id="Snippet5"::: + method. + + If the current method throws an , the reader's position in the underlying string is advanced by the number of characters the method was able to read, but the characters already read into the internal buffer are discarded. Because the position of the reader in the string cannot be changed, the characters already read are unrecoverable, and can be accessed only by reinitializing the . To avoid such a situation, use the method and store the read characters in a preallocated buffer. + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringReader/ReadToEnd/textrw.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.TextReaderWriter/VB/textrw.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.TextReaderWriter/VB/textrw.vb" id="Snippet5"::: + ]]>
There is insufficient memory to allocate a buffer for the returned string. @@ -1349,10 +1345,10 @@ This method stores in the task it returns all non-usage exceptions that the meth ## Remarks This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . - -## Examples - The following example shows how to read an entire string asynchronously. - + +## Examples + The following example shows how to read an entire string asynchronously. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringReader/Overview/example2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.stringreader/vb/example2.vb" id="Snippet2"::: diff --git a/xml/System.IO/StringWriter.xml b/xml/System.IO/StringWriter.xml index b8264002986..8f7ac0156bc 100644 --- a/xml/System.IO/StringWriter.xml +++ b/xml/System.IO/StringWriter.xml @@ -85,37 +85,36 @@ Implements a for writing information to a string. The information is stored in an underlying . - enables you to write to a string synchronously or asynchronously. You can write a character at a time with the or the method, a string at a time using the or the method. In addition, you can write a character, an array of characters or a string followed by the line terminator asynchronously with one of the methods. - + enables you to write to a string synchronously or asynchronously. You can write a character at a time with the or the method, a string at a time using the or the method. In addition, you can write a character, an array of characters or a string followed by the line terminator asynchronously with one of the methods. + [!INCLUDE[note_unnecessary_dispose](~/includes/note-unnecessary-dispose.md)] + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + The following code example demonstrates the creation of a continuous paragraph from a group of double-spaced sentences, and then the conversion of the paragraph back to the original text. - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - The following code example demonstrates the creation of a continuous paragraph from a group of double-spaced sentences, and then the conversion of the paragraph back to the original text. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/StringReader/.ctor/stringrw.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringReaderWriter/VB/stringrw.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringReaderWriter/VB/stringrw.vb" id="Snippet1"::: + ]]>
@@ -186,35 +185,34 @@ Initializes a new instance of the class. - object is automatically created and associated with the new instance of the class. Since a format control is not specified for this constructor, the new instance will be initialized with . - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - The following code example demonstrates how to construct a string using the `StringWriter` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp" id="Snippet1"::: + object is automatically created and associated with the new instance of the class. Since a format control is not specified for this constructor, the new instance will be initialized with . + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + The following code example demonstrates how to construct a string using the `StringWriter` class. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/.ctor/strwriter1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter1/VB/strwriter1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter1/VB/strwriter1.vb" id="Snippet1"::: + ]]>
File and Stream I/O @@ -277,35 +275,34 @@ An object that controls formatting. Initializes a new instance of the class with the specified format control. - object is automatically created and associated with the new instance of the class. - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - The following code example demonstrates how to construct a string in a specific culture. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter2/CPP/strwriter2.cpp" id="Snippet1"::: + object is automatically created and associated with the new instance of the class. + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + The following code example demonstrates how to construct a string in a specific culture. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/.ctor/strwriter2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter2/VB/strwriter2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter2/VB/strwriter2.vb" id="Snippet1"::: + ]]>
File and Stream I/O @@ -367,35 +364,34 @@ The object to write to. Initializes a new instance of the class that writes to the specified . - . - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - The following code example demonstrates using the class to modify the underlying string in a closed `StringWriter`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter3/CPP/strwriter3.cpp" id="Snippet1"::: + . + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + The following code example demonstrates using the class to modify the underlying string in a closed `StringWriter`. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/.ctor/strwriter3.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter3/VB/strwriter3.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter3/VB/strwriter3.vb" id="Snippet1"::: + ]]>
@@ -463,24 +459,24 @@ An object that controls formatting. Initializes a new instance of the class that writes to the specified and has the specified format provider. -


| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - +


| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + ]]>
@@ -541,26 +537,25 @@ Closes the current and the underlying stream. - . - - This implementation of `Close` calls the method passing a `true` value. - - Flushing the stream will not flush its underlying encoder unless you explicitly call `Close`. Setting to `true` means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters. - - - -## Examples - This code example is part of a larger example provided for the constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter3/CPP/strwriter3.cpp" id="Snippet2"::: + . + + This implementation of `Close` calls the method passing a `true` value. + + Flushing the stream will not flush its underlying encoder unless you explicitly call `Close`. Setting to `true` means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters. + + + +## Examples + This code example is part of a larger example provided for the constructor. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/.ctor/strwriter3.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter3/VB/strwriter3.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter3/VB/strwriter3.vb" id="Snippet2"::: + ]]> File and Stream I/O @@ -626,11 +621,11 @@ to release both managed and unmanaged resources; to release only unmanaged resources. Releases the unmanaged resources used by the and optionally releases the managed resources. - references. This method invokes the `Dispose` method of each referenced object. - + references. This method invokes the `Dispose` method of each referenced object. + ]]> @@ -696,28 +691,27 @@ Gets the in which the output is written. The in which the output is written. - constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp" id="Snippet4"::: + constructor. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/.ctor/strwriter1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter1/VB/strwriter1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter1/VB/strwriter1.vb" id="Snippet4"::: + ]]> File and Stream I/O @@ -829,28 +823,27 @@ Returns the underlying . The underlying . - constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp" id="Snippet3"::: + constructor. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/.ctor/strwriter1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter1/VB/strwriter1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter1/VB/strwriter1.vb" id="Snippet3"::: + ]]> File and Stream I/O @@ -913,26 +906,25 @@ Returns a string containing the characters written to the current so far. The string containing the characters written to the current . - constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter2/CPP/strwriter2.cpp" id="Snippet2"::: + constructor. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/.ctor/strwriter2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter2/VB/strwriter2.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter2/VB/strwriter2.vb" id="Snippet2"::: + ]]> File and Stream I/O @@ -1008,35 +1000,34 @@ The character to write. Writes a character to the string. - . - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - This code example is part of a larger example provided for the constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp" id="Snippet2"::: + . + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + This code example is part of a larger example provided for the constructor. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/.ctor/strwriter1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter1/VB/strwriter1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter1/VB/strwriter1.vb" id="Snippet2"::: + ]]>
The writer is closed. @@ -1147,37 +1138,36 @@ The string to write. Writes a string to the current string. - . - - If the specified string is `null`, nothing is written. - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringReaderWriter/CPP/stringrw.cpp" id="Snippet3"::: + . + + If the specified string is `null`, nothing is written. + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringReader/.ctor/stringrw.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringReaderWriter/VB/stringrw.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringReaderWriter/VB/stringrw.vb" id="Snippet3"::: + ]]>
The writer is closed. @@ -1284,37 +1274,36 @@ The maximum number of characters to write. Writes a subarray of characters to the string. - . - - This method writes `count` characters of data to this `StringWriter` from `buffer`, starting at position `index`. - - The following table lists examples of other typical or related I/O tasks. - -|To do this...|See the example in this topic...| -|-------------------|--------------------------------------| -|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| -|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| -|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| -|Get the size of a file.|| -|Get the attributes of a file.|| -|Set the attributes of a file.|| -|Determine if a file exists.|| -|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| -|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| - - - -## Examples - This code example is part of a larger example provided for the constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.StringWriter1/CPP/strwriter1.cpp" id="Snippet2"::: + . + + This method writes `count` characters of data to this `StringWriter` from `buffer`, starting at position `index`. + + The following table lists examples of other typical or related I/O tasks. + +|To do this...|See the example in this topic...| +|-------------------|--------------------------------------| +|Create a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Write to a text file.|[How to: Write Text to a File](/dotnet/standard/io/how-to-write-text-to-a-file)| +|Read from a text file.|[How to: Read Text from a File](/dotnet/standard/io/how-to-read-text-from-a-file)| +|Append text to a file.|[How to: Open and Append to a Log File](/dotnet/standard/io/how-to-open-and-append-to-a-log-file)



| +|Get the size of a file.|| +|Get the attributes of a file.|| +|Set the attributes of a file.|| +|Determine if a file exists.|| +|Read from a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| +|Write to a binary file.|[How to: Read and Write to a Newly Created Data File](/dotnet/standard/io/how-to-read-and-write-to-a-newly-created-data-file)| + + + +## Examples + This code example is part of a larger example provided for the constructor. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/.ctor/strwriter1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter1/VB/strwriter1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.StringWriter1/VB/strwriter1.vb" id="Snippet2"::: + ]]>
@@ -1400,10 +1389,10 @@ ## Remarks This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . - -## Examples - The following example shows how to write characters by using the method. - + +## Examples + The following example shows how to write characters by using the method. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/WriteAsync/example5.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.stringwriter/vb/example5.vb" id="Snippet5"::: @@ -1482,10 +1471,10 @@ This method stores in the task it returns all non-usage exceptions that the meth ## Remarks This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . - -## Examples - The following example shows how to write a string by using the method. - + +## Examples + The following example shows how to write a string by using the method. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/WriteAsync/example4.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.stringwriter/vb/example4.vb" id="Snippet4"::: @@ -1666,10 +1655,10 @@ This method stores in the task it returns all non-usage exceptions that the meth ## Remarks This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . - -## Examples - The following example shows how to write characters by using the method. - + +## Examples + The following example shows how to write characters by using the method. + :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/WriteAsync/example6.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.stringwriter/vb/example6.vb" id="Snippet6"::: @@ -2116,7 +2105,7 @@ The line terminator is defined by the pro The following example shows how to write characters by using the method. :::code language="csharp" source="~/snippets/csharp/System.IO/StringWriter/WriteAsync/example3.cs" id="Snippet3"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.stringwriter/vb/example3.vb" id="Snippet3"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.stringwriter/vb/example3.vb" id="Snippet3"::: ]]>
diff --git a/xml/System.Media/SoundPlayer.xml b/xml/System.Media/SoundPlayer.xml index dca90a74148..0e916ee0c77 100644 --- a/xml/System.Media/SoundPlayer.xml +++ b/xml/System.Media/SoundPlayer.xml @@ -47,35 +47,33 @@ Controls playback of a sound from a .wav file. - class provides a simple interface for loading and playing a .wav file. The class supports loading a .wav file from a file path, a URL, a that contains a .wav file, or an embedded resource that contains a .wav file. - - To play a sound using the class, configure a with a path to the .wav file and call one of the play methods. You can identify the .wav file to play by using one of the constructors or by setting either the or property. The file can be loaded prior to playing by using one of the load methods, or loading can be deferred until one of the play methods is called. A configured to load a .wav file from a or URL must load the .wav file into memory before playback begins. - - You can load or play a .wav file synchronously or asynchronously. If you call a synchronous load or play method, the calling thread will wait until the method returns, which may cause painting and other events to be interrupted. Calling an asynchronous load or play method will allow the calling thread to continue without interruption. For more information on asynchronous method calls, see [How to: Run an Operation in the Background](/dotnet/framework/winforms/controls/how-to-run-an-operation-in-the-background). - - When a has finished loading a .wav file, it raises the event. You can examine the in your event handler to determine if the load succeeded or failed. The event is raised when the audio source is set to a new file path or URL. The event is raised when the audio source is set to a new . For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - For more information about , see [SoundPlayer Class Overview](/dotnet/framework/winforms/controls/soundplayer-class-overview). - + class provides a simple interface for loading and playing a .wav file. The class supports loading a .wav file from a file path, a URL, a that contains a .wav file, or an embedded resource that contains a .wav file. + + To play a sound using the class, configure a with a path to the .wav file and call one of the play methods. You can identify the .wav file to play by using one of the constructors or by setting either the or property. The file can be loaded prior to playing by using one of the load methods, or loading can be deferred until one of the play methods is called. A configured to load a .wav file from a or URL must load the .wav file into memory before playback begins. + + You can load or play a .wav file synchronously or asynchronously. If you call a synchronous load or play method, the calling thread will wait until the method returns, which may cause painting and other events to be interrupted. Calling an asynchronous load or play method will allow the calling thread to continue without interruption. For more information on asynchronous method calls, see [How to: Run an Operation in the Background](/dotnet/desktop/winforms/controls/how-to-run-an-operation-in-the-background). + + When a has finished loading a .wav file, it raises the event. You can examine the in your event handler to determine if the load succeeded or failed. The event is raised when the audio source is set to a new file path or URL. The event is raised when the audio source is set to a new . For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + For more information about , see [SoundPlayer Class Overview](/dotnet/desktop/winforms/controls/soundplayer-class-overview). + > [!NOTE] -> The class cannot play other file types, such as .wma or .mp3. If you want to play other file types, you can use the Windows Media Player control. For more information, see [Using the Windows Media Player Control in a .NET Framework Solution](https://go.microsoft.com/fwlink/?LinkId=131267) and [Windows Media Player Object Model Reference for Visual Basic .NET and C#](https://go.microsoft.com/fwlink/?LinkId=131269) in the Windows Media Player SDK. - - - -## Examples - The following code example demonstrates the use of the class for playing .wav files from a local path or a Uniform Resource Identifier (URI). - +> The class cannot play other file types, such as .wma or .mp3. If you want to play other file types, you can use the [MediaPlayer](/uwp/api/windows.media.playback.mediaplayer). + +## Examples + The following code example demonstrates the use of the class for playing .wav files from a local path or a Uniform Resource Identifier (URI). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Sound/CPP/soundtestform.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SoundPlayer/Overview/soundtestform.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet1"::: + ]]> - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -114,14 +112,14 @@ Initializes a new instance of the class. - with no audio source. Until it is configured with an audio source path, the will play a beep sound when one of its playback methods is called. - + with no audio source. Until it is configured with an audio source path, the will play a beep sound when one of its playback methods is called. + ]]> - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -162,14 +160,14 @@ A to a .wav file. Initializes a new instance of the class, and attaches the .wav file within the specified . - passed to the `stream` parameter should be a containing a .wav file. The data returned by the method of the should be the data within a .wav file. - + passed to the `stream` parameter should be a containing a .wav file. The data returned by the method of the should be the data within a .wav file. + ]]> - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms)
@@ -203,15 +201,15 @@ The location of a .wav file to load. Initializes a new instance of the class, and attaches the specified .wav file. - will still be constructed, but subsequent calls to a load or play method will fail. - + will still be constructed, but subsequent calls to a load or play method will fail. + ]]> The URL value specified by cannot be resolved. - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms)
@@ -258,7 +256,7 @@ Initializes a new instance of the class. To be added. The specified in cannot be resolved. - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms)
@@ -299,7 +297,7 @@ if a .wav file is loaded; if a .wav file has not yet been loaded. To be added. - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -333,30 +331,30 @@ Loads a sound synchronously. - method uses the current thread to load a .wav file, preventing the thread from handling other messages until the load is complete. - + method uses the current thread to load a .wav file, preventing the thread from handling other messages until the load is complete. + > [!CAUTION] -> The method may produce a delay while loading a large .wav file. In addition, painting and other events will be blocked until the load is completed. Use the method to load a sound asynchronously, which allows the calling thread to continue without interruption. - +> The method may produce a delay while loading a large .wav file. In addition, painting and other events will be blocked until the load is completed. Use the method to load a sound asynchronously, which allows the calling thread to continue without interruption. + This method raises the event when loading completes, even if the load was not successful. - -## Examples - The following code example demonstrates the use of the method to attach a .wav file to an instance of the class. This code example is part of a larger example provided for the class. - + +## Examples + The following code example demonstrates the use of the method to attach a .wav file to an instance of the class. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Sound/CPP/soundtestform.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SoundPlayer/Overview/soundtestform.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet2"::: + ]]> The elapsed time during loading exceeds the time, in milliseconds, specified by . The file specified by cannot be found. - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -390,22 +388,22 @@ Loads a .wav file from a stream or a Web resource using a new thread. - is configured to load a .wav file from a or Web resource, this method begins loading a .wav file from the location using a new thread. - - This method raises the event when loading completes, even if the load was not successful. - - If a is configured to load a .wav file from a local file path, this method does nothing, because loading is deferred until playing begins. - - For more information about asynchronous loading, see [How to: Load a Sound Asynchronously within a Windows Form](/dotnet/framework/winforms/controls/how-to-load-a-sound-asynchronously-within-a-windows-form). - + is configured to load a .wav file from a or Web resource, this method begins loading a .wav file from the location using a new thread. + + This method raises the event when loading completes, even if the load was not successful. + + If a is configured to load a .wav file from a local file path, this method does nothing, because loading is deferred until playing begins. + + For more information about asynchronous loading, see [How to: Load a Sound Asynchronously within a Windows Form](/dotnet/desktop/winforms/controls/how-to-load-a-sound-asynchronously-within-a-windows-form). + This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as , are still thrown synchronously. For the stored exceptions, see the exceptions thrown by . - -## Examples - The following code example demonstrates the use of the method to asynchronously load a .wav file for use by an instance of the class. This code example is part of a larger example provided for the class. - + +## Examples + The following code example demonstrates the use of the method to asynchronously load a .wav file for use by an instance of the class. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Sound/CPP/soundtestform.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SoundPlayer/Overview/soundtestform.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet3"::: @@ -416,8 +414,8 @@ This method stores in the task it returns all non-usage exceptions that the meth The file specified by cannot be found. - SoundPlayer Class Overview (Windows Forms) - How to: Load a Sound Asynchronously within a Windows Form + SoundPlayer Class Overview (Windows Forms) + How to: Load a Sound Asynchronously within a Windows Form @@ -451,26 +449,26 @@ This method stores in the task it returns all non-usage exceptions that the meth Occurs when a .wav file has been successfully or unsuccessfully loaded. - event handler to receive a notification indicating that the contents of a .wav file have been loaded. This code example is part of a larger example provided for the class. - + event handler to receive a notification indicating that the contents of a .wav file have been loaded. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Sound/CPP/soundtestform.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SoundPlayer/Overview/soundtestform.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet8"::: + ]]> - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -510,14 +508,14 @@ This method stores in the task it returns all non-usage exceptions that the meth Gets or sets the time, in milliseconds, in which the .wav file must load. The number of milliseconds to wait. The default is 10000 (10 seconds). - exception is thrown. - + exception is thrown. + ]]> - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -554,22 +552,22 @@ This method stores in the task it returns all non-usage exceptions that the meth An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -606,22 +604,22 @@ This method stores in the task it returns all non-usage exceptions that the meth An that contains the event data. Raises the event. - has been set. - - Raising an event invokes the event handler through a delegate. For more information, see How to: Provide Event functionality and [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + has been set. + + Raising an event invokes the event handler through a delegate. For more information, see How to: Provide Event functionality and [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -658,22 +656,22 @@ This method stores in the task it returns all non-usage exceptions that the meth An that contains the event data. Raises the event. - audio source for this has been set. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + audio source for this has been set. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -713,22 +711,22 @@ This method stores in the task it returns all non-usage exceptions that the meth Plays the .wav file using a new thread, and loads the .wav file first if it has not been loaded. - method plays the sound using a new thread. If you call before the .wav file has been loaded into memory, the .wav file will be loaded before playback starts. You can use the or method to load the .wav file to memory in advance. After a .wav file is successfully loaded from a or URL, future calls to playback methods for the will not need to reload the .wav file until the path for the sound changes. - - If the .wav file has not been specified or it fails to load, the method will play the default beep sound. - - - -## Examples - The following code example demonstrates the use of the method to asynchronously play a .wav file. This code example is part of a larger example provided for the class. - + method plays the sound using a new thread. If you call before the .wav file has been loaded into memory, the .wav file will be loaded before playback starts. You can use the or method to load the .wav file to memory in advance. After a .wav file is successfully loaded from a or URL, future calls to playback methods for the will not need to reload the .wav file until the path for the sound changes. + + If the .wav file has not been specified or it fails to load, the method will play the default beep sound. + + + +## Examples + The following code example demonstrates the use of the method to asynchronously play a .wav file. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Sound/CPP/soundtestform.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SoundPlayer/Overview/soundtestform.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet5"::: + ]]> The elapsed time during loading exceeds the time, in milliseconds, specified by . @@ -736,7 +734,7 @@ This method stores in the task it returns all non-usage exceptions that the meth The .wav header is corrupted; the file specified by is not a PCM .wav file. - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -776,24 +774,24 @@ This method stores in the task it returns all non-usage exceptions that the meth Plays and loops the .wav file using a new thread, and loads the .wav file first if it has not been loaded. - method plays and loops the sound using a new thread. If you call before the .wav file has been loaded into memory, the .wav file will be loaded before playback starts. You can use the or method to load the .wav file to memory in advance. After a .wav file is successfully loaded from a or URL, future calls to playback methods for the will not need to reload the .wav file until the path for the sound changes. - - If the .wav file has not been specified or it fails to load, the method will play the default beep sound. - - For more information about , see [How to: Loop a Sound Playing on a Windows Form](/dotnet/framework/winforms/controls/how-to-loop-a-sound-playing-on-a-windows-form). - - - -## Examples - The following code example demonstrates the use of the method to repeatedly play a .wav file. The .wav will be played until the method is called. This code example is part of a larger example provided for the class. - + method plays and loops the sound using a new thread. If you call before the .wav file has been loaded into memory, the .wav file will be loaded before playback starts. You can use the or method to load the .wav file to memory in advance. After a .wav file is successfully loaded from a or URL, future calls to playback methods for the will not need to reload the .wav file until the path for the sound changes. + + If the .wav file has not been specified or it fails to load, the method will play the default beep sound. + + For more information about , see [How to: Loop a Sound Playing on a Windows Form](/dotnet/desktop/winforms/controls/how-to-loop-a-sound-playing-on-a-windows-form). + + + +## Examples + The following code example demonstrates the use of the method to repeatedly play a .wav file. The .wav will be played until the method is called. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Sound/CPP/soundtestform.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SoundPlayer/Overview/soundtestform.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet6"::: + ]]> The elapsed time during loading exceeds the time, in milliseconds, specified by . @@ -801,7 +799,7 @@ This method stores in the task it returns all non-usage exceptions that the meth The .wav header is corrupted; the file specified by is not a PCM .wav file. - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -841,22 +839,22 @@ This method stores in the task it returns all non-usage exceptions that the meth Plays the .wav file and loads the .wav file first if it has not been loaded. - method uses the current thread to play a .wav file, preventing the thread from handling other messages until the load is complete. You can use the or method to load the .wav file to memory in advance. After a .wav file is successfully loaded from a or URL, future calls to playback methods for the will not need to reload the .wav file until the path for the sound changes. - - If the .wav file has not been specified or it fails to load, the method will play the default beep sound. - - - -## Examples - The following code example demonstrates the use of the method to synchronously play a .wav file. - + method uses the current thread to play a .wav file, preventing the thread from handling other messages until the load is complete. You can use the or method to load the .wav file to memory in advance. After a .wav file is successfully loaded from a or URL, future calls to playback methods for the will not need to reload the .wav file until the path for the sound changes. + + If the .wav file has not been specified or it fails to load, the method will play the default beep sound. + + + +## Examples + The following code example demonstrates the use of the method to synchronously play a .wav file. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.PlaySync/CPP/system.windows.forms.sound.playasync.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SoundPlayer/PlaySync/system.windows.forms.sound.playasync.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PlaySync/VB/system.windows.forms.sound.playasync.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PlaySync/VB/system.windows.forms.sound.playasync.vb" id="Snippet1"::: + ]]> The elapsed time during loading exceeds the time, in milliseconds, specified by . @@ -864,7 +862,7 @@ This method stores in the task it returns all non-usage exceptions that the meth The .wav header is corrupted; the file specified by is not a PCM .wav file. - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -904,23 +902,23 @@ This method stores in the task it returns all non-usage exceptions that the meth Gets or sets the file path or URL of the .wav file to load. The file path or URL from which to load a .wav file, or if no file path is present. The default is . - when the property is set to a . - - - -## Examples - The following code example demonstrates the use of the property to assign the .wav file source to an instance of the class. This code example is part of a larger example provided for the class. - + when the property is set to a . + + + +## Examples + The following code example demonstrates the use of the property to assign the .wav file source to an instance of the class. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Sound/CPP/soundtestform.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SoundPlayer/Overview/soundtestform.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet2"::: + ]]> - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -954,25 +952,25 @@ This method stores in the task it returns all non-usage exceptions that the meth Occurs when a new audio source path for this has been set. - has been set. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates the use of the event handler to receive a notification when the has been attached to a different .wav file. This code example is part of a larger example provided for the class. - + has been set. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates the use of the event handler to receive a notification when the has been attached to a different .wav file. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Sound/CPP/soundtestform.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SoundPlayer/Overview/soundtestform.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet9"::: + ]]> - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -1006,18 +1004,18 @@ This method stores in the task it returns all non-usage exceptions that the meth Stops playback of the sound if playback is occurring. - method to halt a .wav file that is currently playing. This code example is part of a larger example provided for the class. - + method to halt a .wav file that is currently playing. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Sound/CPP/soundtestform.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SoundPlayer/Overview/soundtestform.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Sound/VB/soundtestform.vb" id="Snippet7"::: + ]]> - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -1052,15 +1050,15 @@ This method stores in the task it returns all non-usage exceptions that the meth Gets or sets the from which to load the .wav file. A from which to load the .wav file, or if no stream is available. The default is . - property is set to a new and valid sound location. - + property is set to a new and valid sound location. + ]]> - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -1094,16 +1092,16 @@ This method stores in the task it returns all non-usage exceptions that the meth Occurs when a new audio source for this has been set. - audio source for this has been set. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - + audio source for this has been set. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + ]]> - SoundPlayer Class Overview (Windows Forms) + SoundPlayer Class Overview (Windows Forms) @@ -1146,11 +1144,11 @@ This method stores in the task it returns all non-usage exceptions that the meth The destination (see ) for this serialization. For a description of this member, see the method. - instance is cast to an interface. - + instance is cast to an interface. + ]]> diff --git a/xml/System.Media/SystemSound.xml b/xml/System.Media/SystemSound.xml index 9d808bbae01..cc123412e32 100644 --- a/xml/System.Media/SystemSound.xml +++ b/xml/System.Media/SystemSound.xml @@ -28,20 +28,20 @@ Represents a system sound type. - property. - + property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SystemSoundsExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SystemSound/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet1"::: + ]]> - SoundPlayer Class (Windows Forms) + SoundPlayer Class (Windows Forms) @@ -75,25 +75,25 @@ Plays the system sound type. - method plays the sound asynchronously. - - - -## Examples - The following code example demonstrates the use of the property. - + method plays the sound asynchronously. + + + +## Examples + The following code example demonstrates the use of the property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SystemSoundsExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SystemSound/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet1"::: + ]]> - SoundPlayer Class (Windows Forms) + SoundPlayer Class (Windows Forms) diff --git a/xml/System.Media/SystemSounds.xml b/xml/System.Media/SystemSounds.xml index 55ce7c95352..147a827a423 100644 --- a/xml/System.Media/SystemSounds.xml +++ b/xml/System.Media/SystemSounds.xml @@ -38,18 +38,18 @@ Retrieves sounds associated with a set of Windows operating system sound-event types. This class cannot be inherited. - class provides methods for retrieving the sounds associated with a set of operating system sound-event types for the current user. The sounds associated with each type of operating system sound event can be configured in Windows Control Panel. - - provides static methods to access the sounds associated with the , , , and sound events. Each property returns a that can be used to play the sound. - + class provides methods for retrieving the sounds associated with a set of operating system sound-event types for the current user. The sounds associated with each type of operating system sound event can be configured in Windows Control Panel. + + provides static methods to access the sounds associated with the , , , and sound events. Each property returns a that can be used to play the sound. + ]]> - SoundPlayer Class (Windows Forms) + SoundPlayer Class (Windows Forms) @@ -83,20 +83,20 @@ Gets the sound associated with the program event in the current Windows sound scheme. A associated with the program event in the current Windows sound scheme. - property. - + property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SystemSoundsExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SystemSound/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet1"::: + ]]> - SoundPlayer Class (Windows Forms) + SoundPlayer Class (Windows Forms) @@ -133,20 +133,20 @@ property. - + +The following code example demonstrates the use of the property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SystemSoundsExample/CPP/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SystemSound/Overview/form1.cs" id="Snippet2"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet2"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet2"::: + ]]> - SoundPlayer Class (Windows Forms) + SoundPlayer Class (Windows Forms) @@ -180,20 +180,20 @@ The following code example demonstrates the use of the Gets the sound associated with the program event in the current Windows sound scheme. A associated with the program event in the current Windows sound scheme. - property. - + property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SystemSoundsExample/CPP/form1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SystemSound/Overview/form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet3"::: + ]]> - SoundPlayer Class (Windows Forms) + SoundPlayer Class (Windows Forms) @@ -227,20 +227,20 @@ The following code example demonstrates the use of the Gets the sound associated with the program event in the current Windows sound scheme. A associated with the program event in the current Windows sound scheme. - property. - + property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SystemSoundsExample/CPP/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SystemSound/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet4"::: + ]]> - SoundPlayer Class (Windows Forms) + SoundPlayer Class (Windows Forms) @@ -274,20 +274,20 @@ The following code example demonstrates the use of the Gets the sound associated with the program event in the current Windows sound scheme. A associated with the program event in the current Windows sound scheme. - property. - + property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SystemSoundsExample/CPP/form1.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Media/SystemSound/Overview/form1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SystemSoundsExample/VB/form1.vb" id="Snippet5"::: + ]]> - SoundPlayer Class (Windows Forms) + SoundPlayer Class (Windows Forms) diff --git a/xml/System.Resources/ResXResourceReader.xml b/xml/System.Resources/ResXResourceReader.xml index 21ebbb29181..194719bfe4e 100644 --- a/xml/System.Resources/ResXResourceReader.xml +++ b/xml/System.Resources/ResXResourceReader.xml @@ -82,7 +82,6 @@ ## Examples The following example demonstrates how to use a to iterate through the resources in a .resx file. First, the `rsxr` is created for the file `items.resx`. Next, the method is used to create an to iterate through the resources and display the contents to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResXResourceReader/Overview/resxresourcereader.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/VB/resxresourcereader.vb" id="Snippet1"::: @@ -219,7 +218,6 @@ ## Examples The following example creates a new instance of the class for the specified file, iterates through the resources of the file, and displays the contents to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResXResourceReader/Overview/resxresourcereader.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/VB/resxresourcereader.vb" id="Snippet1"::: @@ -552,7 +550,6 @@ ## Examples The following example displays the resources of a file to the console, and then uses the method to shut down the reader and to make its resources available for other processes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResXResourceReader/Overview/resxresourcereader.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/VB/resxresourcereader.vb" id="Snippet1"::: @@ -845,7 +842,6 @@ ## Examples The following example uses the method to iterate through the metadata resources in an XML resource file. This code example is part of a larger example provided for the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResXResourceReader/Overview/useresxdatanodes.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/VB/useresxdatanodes.vb" id="Snippet4"::: @@ -982,7 +978,6 @@ ## Examples The following example enumerates and displays resource items in an XML file. Initially, is set to `false` to show both data and metadata items as they occur in the resource file. The second enumeration has the set to `true` so that resource data elements are returned as objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResXResourceReader/Overview/useresxdatanodes.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/VB/useresxdatanodes.vb" id="Snippet2"::: diff --git a/xml/System.Resources/ResourceReader.xml b/xml/System.Resources/ResourceReader.xml index 0e46d4666de..ba681d3c935 100644 --- a/xml/System.Resources/ResourceReader.xml +++ b/xml/System.Resources/ResourceReader.xml @@ -368,7 +368,6 @@ Label11="Mobile Phone:" ## Examples The following example moves through a file's resources and displays all the key/value pairs it finds. The code then uses the method to shut down the and to release all resources used by it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceReader/Close/getenumerator.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/VB/getenumerator.vb" id="Snippet1"::: diff --git a/xml/System.Resources/ResourceSet.xml b/xml/System.Resources/ResourceSet.xml index 9b9c6ae70ad..8ecc36a0206 100644 --- a/xml/System.Resources/ResourceSet.xml +++ b/xml/System.Resources/ResourceSet.xml @@ -76,19 +76,19 @@ Stores all the resources localized for one particular culture, ignoring all other cultures, including any fallback rules. - class enumerates over an , loading every name and value, and storing them in a . A custom can be used. - - You can instantiate a object that represents the resources of a specific culture by calling the method. - + The class enumerates over an , loading every name and value, and storing them in a . A custom can be used. + + You can instantiate a object that represents the resources of a specific culture by calling the method. + > [!IMPORTANT] -> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - +> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + ]]> @@ -240,11 +240,11 @@ The reader that will be used. Creates a new instance of the class using the specified resource reader. - . - + . + ]]> The parameter is . @@ -298,15 +298,14 @@ Resource file to read. Creates a new instance of the class using the system default that opens and reads resources from the given file. - class for a specific file, iterates through the resources used by that file, and displays their contents to the console. + class for a specific file, iterates through the resources used by that file, and displays their contents to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceSet/.ctor/getenumerator.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: + ]]> The parameter is . @@ -354,25 +353,24 @@ Closes and releases any resources used by this . - after a call to this method might fail. - - can be safely called multiple times. - + after a call to this method might fail. + + can be safely called multiple times. + > [!NOTE] -> The current implementation of calls (`true`). - - - -## Examples - The following code example uses the method to release all resources used by the calling instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp" id="Snippet1"::: +> The current implementation of calls (`true`). + + + +## Examples + The following code example uses the method to release all resources used by the calling instance. + :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceSet/.ctor/getenumerator.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: + ]]> @@ -432,14 +430,14 @@ Disposes of the resources (other than memory) used by the current instance of . - when you are finished using the . The method leaves the in an unusable state. After calling , you must release all references to the so the memory it was occupying can be reclaimed by garbage collection. - + when you are finished using the . The method leaves the in an unusable state. After calling , you must release all references to the so the memory it was occupying can be reclaimed by garbage collection. + > [!NOTE] -> The current method is the implementation of . This implementation calls (`true`). - +> The current method is the implementation of . This implementation calls (`true`). + ]]> @@ -489,11 +487,11 @@ Indicates whether the objects contained in the current instance should be explicitly closed. Releases resources (other than memory) associated with the current instance, closing internal managed objects if requested. - @@ -645,32 +643,31 @@ Returns an that can iterate through the . An for this . - also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - After the end of the collection is passed, the enumerator is positioned after the last element in the collection, and calling returns `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , will return the element that it is set to, even if the enumerator is already invalidated. - - You can use the property to access the value stored in the current element. Use the property to access the key of the current element. Use the property to access the value of the current element. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads could still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following example demonstrates how to create a `rs` for the file `items.resources`. Next, the method is used to create an for `rs`. The iterates through `rs` and displays the contents to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp" id="Snippet1"::: + also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + After the end of the collection is passed, the enumerator is positioned after the last element in the collection, and calling returns `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , will return the element that it is set to, even if the enumerator is already invalidated. + + You can use the property to access the value stored in the current element. Use the property to access the key of the current element. Use the property to access the value of the current element. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads could still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following example demonstrates how to create a `rs` for the file `items.resources`. Next, the method is used to create an for `rs`. The iterates through `rs` and displays the contents to the console. + :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceSet/.ctor/getenumerator.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: + ]]> The resource set has been closed or disposed. @@ -739,11 +736,11 @@ Searches for a resource object with the specified name. The requested resource. - . - + . + ]]> The parameter is . @@ -805,13 +802,13 @@ Searches for a resource object with the specified name in a case-insensitive manner, if requested. The requested resource. - . The advantage is that results of case-insensitive string comparisons performed by this method are the same on all computers regardless of culture. The disadvantage is that the results are not consistent with the casing rules of all cultures. - - For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). Using the `GetObject` method with `ignoreCase` set to `true`, this comparison succeeds. - + . The advantage is that results of case-insensitive string comparisons performed by this method are the same on all computers regardless of culture. The disadvantage is that the results are not consistent with the casing rules of all cultures. + + For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). Using the `GetObject` method with `ignoreCase` set to `true`, this comparison succeeds. + ]]> The parameter is . @@ -941,13 +938,13 @@ Searches for a resource with the specified name in a case-insensitive manner, if requested. The value of a resource, if the value is a . - . The advantage is that results of case-insensitive string comparisons performed by this method are the same on all computers regardless of culture. The disadvantage is that the results are not consistent with the casing rules of all cultures. - - For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). Using the `GetString` method with `ignoreCase` set to `true`, this comparison succeeds. - + . The advantage is that results of case-insensitive string comparisons performed by this method are the same on all computers regardless of culture. The disadvantage is that the results are not consistent with the casing rules of all cultures. + + For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). Using the `GetString` method with `ignoreCase` set to `true`, this comparison succeeds. + ]]> The parameter is . diff --git a/xml/System.Resources/ResourceWriter.xml b/xml/System.Resources/ResourceWriter.xml index 78382ca1492..9fa96e7f042 100644 --- a/xml/System.Resources/ResourceWriter.xml +++ b/xml/System.Resources/ResourceWriter.xml @@ -93,7 +93,6 @@ ## Examples The following example writes several strings into the myResources.resources file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ResourceWriter Example/VB/source.vb" id="Snippet1"::: @@ -162,7 +161,6 @@ ## Examples The following code example defines a new instance of the class that writes to a specified stream. The code adds resources to the writer and writes the resources to the stream. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/.ctor/resourcewritercstr1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/VB/resourcewritercstr1.vb" id="Snippet1"::: @@ -223,7 +221,6 @@ ## Examples The following code example defines a new instance of the class that will write to a specified file. The code adds resources to the writer and writes the resources to the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ResourceWriter Example/VB/source.vb" id="Snippet1"::: @@ -555,7 +552,6 @@ ## Examples The following example uses the method to add string resources to a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/.ctor/resourcewritercstr1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/VB/resourcewritercstr1.vb" id="Snippet1"::: @@ -789,7 +785,6 @@ ## Examples The following example uses the method to write all resource objects in a class to the output stream. The code then shuts down the writer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/.ctor/resourcewritercstr1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/VB/resourcewritercstr1.vb" id="Snippet1"::: @@ -853,7 +848,6 @@ ## Examples The following code example uses the method to write all resource objects in a class to the output stream. The code then shuts down the writer and make the writer's resources available for other processes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/Dispose/resourcewriterdispose.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/VB/resourcewriterdispose.vb" id="Snippet1"::: @@ -931,7 +925,6 @@ ## Examples The following code example uses the method to write all resource objects in a class to the output stream - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/Generate/resourcewritergenerate.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/VB/resourcewritergenerate.vb" id="Snippet1"::: diff --git a/xml/System.Runtime.CompilerServices/InternalsVisibleToAttribute.xml b/xml/System.Runtime.CompilerServices/InternalsVisibleToAttribute.xml index 80ffe0fd1a3..311a9f21f8a 100644 --- a/xml/System.Runtime.CompilerServices/InternalsVisibleToAttribute.xml +++ b/xml/System.Runtime.CompilerServices/InternalsVisibleToAttribute.xml @@ -68,9 +68,8 @@ The following example uses the @@ -170,7 +168,6 @@ The following example provides the source code for the `Friend2` assembly. Note If the following example is compiled into a strong-named assembly named `Friend1`, it can successfully call the `FileUtilities.AppendDirectorySeparator` method, even though the method is internal to the `Assembly1` assembly. Note that if you are compiling in C# from the command line, you must use the **/out** compiler switch to ensure that the name of the friend assembly is available when the compiler binds to external references. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/friend1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/vb/friend1.vb" id="Snippet2"::: @@ -183,7 +180,6 @@ The following example provides the source code for the `Friend2` assembly. Note The following example provides the source code for the `Friend2` assembly. Note that if you are compiling in C# from the command line, you must use the **/out** compiler switch to ensure that the name of the friend assembly is available when the compiler binds to external references. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend2.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/friend2.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/vb/friend2.vb" id="Snippet6"::: diff --git a/xml/System.Runtime.ConstrainedExecution/ReliabilityContractAttribute.xml b/xml/System.Runtime.ConstrainedExecution/ReliabilityContractAttribute.xml index 8181c8fcbfa..dada4b41779 100644 --- a/xml/System.Runtime.ConstrainedExecution/ReliabilityContractAttribute.xml +++ b/xml/System.Runtime.ConstrainedExecution/ReliabilityContractAttribute.xml @@ -53,22 +53,21 @@ Defines a contract for reliability between the author of some code, and the developers who have a dependency on that code. - attribute provides a mechanism for you to document your code, and to indicate what type of reliability guarantees you can make in the face of exceptional conditions that could potentially lead to an inconsistent state. In this context, exceptional conditions are defined as asynchronous exceptions that can be generated at run time by the common language runtime, such as aborted threads, out-of-memory situations, and stack overflows. You can apply the attribute to assemblies, types, and methods. + + Use this attribute with the enumeration to define a reliability contract by documenting the level of reliability in a particular piece of code. + + + +## Examples + The following code example demonstrates the use of the attribute to document the level of reliability of an assembly. -## Remarks - The attribute provides a mechanism for you to document your code, and to indicate what type of reliability guarantees you can make in the face of exceptional conditions that could potentially lead to an inconsistent state. In this context, exceptional conditions are defined as asynchronous exceptions that can be generated at run time by the common language runtime, such as aborted threads, out-of-memory situations, and stack overflows. You can apply the attribute to assemblies, types, and methods. - - Use this attribute with the enumeration to define a reliability contract by documenting the level of reliability in a particular piece of code. - - - -## Examples - The following code example demonstrates the use of the attribute to document the level of reliability of an assembly. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/cpp/FxCop.Reliability.ReliabilityContract.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.ConstrainedExecution/ReliabilityContractAttribute/ReliabilityContract.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/vb/FxCop.Reliability.ReliabilityContract.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/vb/FxCop.Reliability.ReliabilityContract.vb" id="Snippet1"::: + ]]> @@ -117,14 +116,14 @@ One of the values. Initializes a new instance of the class with the specified guarantee and value. - constructor to create a constrained execution region and a `finally` block that is guaranteed to execute. - + constructor to create a constrained execution region and a `finally` block that is guaranteed to execute. + :::code language="csharp" source="~/snippets/csharp/System.Runtime.ConstrainedExecution/Cer/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.ConstrainedExecution/vb/program.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.ConstrainedExecution/vb/program.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.Serialization/SerializationInfo.xml b/xml/System.Runtime.Serialization/SerializationInfo.xml index d98ac12df07..e89b55a361f 100644 --- a/xml/System.Runtime.Serialization/SerializationInfo.xml +++ b/xml/System.Runtime.Serialization/SerializationInfo.xml @@ -69,15 +69,15 @@ Stores all the data needed to serialize or deserialize an object. This class cannot be inherited. - method on either or populates the store with the name, type, and value of each piece of information it wants to serialize. During deserialization, the appropriate function can extract this information. - - Objects are added to the store at serialization time using the methods and extracted from the store at deserialization using the methods. - + method on either or populates the store with the name, type, and value of each piece of information it wants to serialize. During deserialization, the appropriate function can extract this information. + + Objects are added to the store at serialization time using the methods and extracted from the store at deserialization using the methods. + For more information about customizing serialization, see [Custom Serialization](/dotnet/standard/serialization/custom-serialization). - + ]]> @@ -151,11 +151,11 @@ The used during deserialization. Creates a new instance of the class. - passed as the `converter` parameter converts data from its internal representation to the form the user requested. The internal representation of the data within the depends on the formatter that created it. - + passed as the `converter` parameter converts data from its internal representation to the form the user requested. The internal representation of the data within the depends on the formatter that created it. + ]]> @@ -278,35 +278,35 @@ The Boolean value to serialize. Adds a Boolean value into the store. - to be thrown. For example: - -```csharp -void ISerializable.GetObject(SerializationInfo info, StreamingContext context) -{ - // This will not cause an exception to be thrown. - info.AddValue("ABC", true); - info.AddValue("abc", false); - // However, this will cause the SerializationException to be thrown. - info.AddValue("XYZ", true); - info.AddValue("XYZ", false); -} -``` - -```vb -Private Sub GetObjectData(ByVal info As SerializationInfo, _ -ByVal context As StreamingContext) - ' This will not cause an exception to be thrown. - info.AddValue("ABC", "upper case") - info.AddValue("abc", "lower case") - ' However, this will cause the SerializationException to be thrown. - info.AddValue("XYZ", "same case") - info.AddValue("XYZ", "same case") -End Sub -``` - + to be thrown. For example: + +```csharp +void ISerializable.GetObject(SerializationInfo info, StreamingContext context) +{ + // This will not cause an exception to be thrown. + info.AddValue("ABC", true); + info.AddValue("abc", false); + // However, this will cause the SerializationException to be thrown. + info.AddValue("XYZ", true); + info.AddValue("XYZ", false); +} +``` + +```vb +Private Sub GetObjectData(ByVal info As SerializationInfo, _ +ByVal context As StreamingContext) + ' This will not cause an exception to be thrown. + info.AddValue("ABC", "upper case") + info.AddValue("abc", "lower case") + ' However, this will cause the SerializationException to be thrown. + info.AddValue("XYZ", "same case") + info.AddValue("XYZ", "same case") +End Sub +``` + ]]> The parameter is . @@ -362,11 +362,11 @@ End Sub The byte value to serialize. Adds an 8-bit unsigned integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -422,11 +422,11 @@ End Sub The character value to serialize. Adds a Unicode character value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -482,11 +482,11 @@ End Sub The value to serialize. Adds a value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -542,11 +542,11 @@ End Sub The decimal value to serialize. Adds a decimal value into the store. - to be thrown. - + to be thrown. + ]]> If The parameter is . @@ -602,11 +602,11 @@ End Sub The double value to serialize. Adds a double-precision floating-point value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -662,11 +662,11 @@ End Sub The value to serialize. Adds a 16-bit signed integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -722,11 +722,11 @@ End Sub The value to serialize. Adds a 32-bit signed integer value into the store. - to be thrown. - + ]]> The parameter is . @@ -782,11 +782,11 @@ End Sub The Int64 value to serialize. Adds a 64-bit signed integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -850,13 +850,13 @@ End Sub The value to be serialized. Any children of this object will automatically be serialized. Adds the specified object into the store, where it is associated with a specified name. - to be thrown. - + to be thrown. + ]]> @@ -919,11 +919,11 @@ End Sub The value to serialize. Adds an 8-bit signed integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -979,11 +979,11 @@ End Sub The single value to serialize. Adds a single-precision floating-point value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -1045,11 +1045,11 @@ End Sub The value to serialize. Adds a 16-bit unsigned integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -1111,11 +1111,11 @@ End Sub The value to serialize. Adds a 32-bit unsigned integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -1177,11 +1177,11 @@ End Sub The value to serialize. Adds a 64-bit unsigned integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -1247,13 +1247,13 @@ End Sub The to associate with the current object. This parameter must always be the type of the object itself or of one of its base classes. Adds a value into the store, where is associated with and is serialized as being of . - to be thrown. - + to be thrown. + ]]> If or is . @@ -1310,18 +1310,18 @@ End Sub Gets or sets the assembly name of the type to serialize during serialization only. The full name of the assembly of the type to serialize. - is the same as the value returned by property of the assembly of the containing type. This is the assembly name that the formatter uses when serializing type information for this object. - - The assembly name contains the name of the assembly, version, culture, and some security information about the object. - - Users who are changing the type being serialized (for example, to send a proxy for a particular type) will set the value of this property. - + is the same as the value returned by property of the assembly of the containing type. This is the assembly name that the formatter uses when serializing type information for this object. + + The assembly name contains the name of the assembly, version, culture, and some security information about the object. + + Users who are changing the type being serialized (for example, to send a proxy for a particular type) will set the value of this property. + > [!CAUTION] -> Do not use this property during deserialization because the value of this property is undefined. - +> Do not use this property during deserialization because the value of this property is undefined. + ]]> The value the property is set to is . @@ -1371,16 +1371,16 @@ End Sub Gets or sets the full name of the to serialize. The full name of the type to serialize. - is the same as what would be returned by calling the on . This is the type name the formatter uses when serializing type information for this object. - - Users who are changing the type to serialize (for example, to send a proxy for a particular type) will want to set the value of this property. - + is the same as what would be returned by calling the on . This is the type name the formatter uses when serializing type information for this object. + + Users who are changing the type to serialize (for example, to send a proxy for a particular type) will want to set the value of this property. + > [!CAUTION] -> Do not use this property during deserialization because the value of this property is undefined. - +> Do not use this property during deserialization because the value of this property is undefined. + ]]> The value this property is set to is . @@ -1434,11 +1434,11 @@ End Sub Retrieves a Boolean value from the store. The Boolean value associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1495,11 +1495,11 @@ End Sub Retrieves an 8-bit unsigned integer value from the store. The 8-bit unsigned integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1556,11 +1556,11 @@ End Sub Retrieves a Unicode character value from the store. The Unicode character associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1617,11 +1617,11 @@ End Sub Retrieves a value from the store. The value associated with . - , or can be converted to a , that value is returned; otherwise, a is thrown. All conversions are done by the associated with this . - + , or can be converted to a , that value is returned; otherwise, a is thrown. All conversions are done by the associated with this . + ]]> @@ -1678,11 +1678,11 @@ End Sub Retrieves a decimal value from the store. A decimal value from the . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1739,11 +1739,11 @@ End Sub Retrieves a double-precision floating-point value from the store. The double-precision floating-point value associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1797,11 +1797,11 @@ End Sub Returns a used to iterate through the name-value pairs in the store. A for parsing the name-value pairs contained in the store. - @@ -1854,11 +1854,11 @@ End Sub Retrieves a 16-bit signed integer value from the store. The 16-bit signed integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1915,11 +1915,11 @@ End Sub Retrieves a 32-bit signed integer value from the store. The 32-bit signed integer associated with . - is thrown. All conversions are done by the associated with this . - + ]]> @@ -1976,11 +1976,11 @@ End Sub Retrieves a 64-bit signed integer value from the store. The 64-bit signed integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2043,11 +2043,11 @@ End Sub Retrieves an 8-bit signed integer value from the store. The 8-bit signed integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2104,11 +2104,11 @@ End Sub Retrieves a single-precision floating-point value from the store. The single-precision floating-point value associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2172,11 +2172,11 @@ End Sub Retrieves a value from the store. The associated with . - , or can be converted to a , that value is returned; otherwise, a is thrown. All conversions are done by the associated with this . - + , or can be converted to a , that value is returned; otherwise, a is thrown. All conversions are done by the associated with this . + ]]> @@ -2239,11 +2239,11 @@ End Sub Retrieves a 16-bit unsigned integer value from the store. The 16-bit unsigned integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2306,11 +2306,11 @@ End Sub Retrieves a 32-bit unsigned integer value from the store. The 32-bit unsigned integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2373,11 +2373,11 @@ End Sub Retrieves a 64-bit unsigned integer value from the store. The 64-bit unsigned integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2449,22 +2449,21 @@ End Sub Retrieves a value from the store. The object of the specified associated with . - is of the type requested (or one of its derived classes), that value is returned directly. Otherwise, is called to convert it to the appropriate type. + is of the type requested (or one of its derived classes), that value is returned directly. Otherwise, is called to convert it to the appropriate type. + + The value returned by the method can always be safely cast to the type specified in the `type` parameter. + + + +## Examples + The following code example demonstrates the use of the method: - The value returned by the method can always be safely cast to the type specified in the `type` parameter. - - - -## Examples - The following code example demonstrates the use of the method: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.Serialization/SerializationInfo/GetValue/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2702,11 +2701,11 @@ End Sub The of the object to serialize. Sets the of the object to serialize. - is responsible for setting the of the instance before passing it to . However, users who want to send proxies for their objects will need to change the type represented by this instance. Using the method is equivalent to setting both the and the . - + ]]> The parameter is . diff --git a/xml/System.Security.AccessControl/DirectorySecurity.xml b/xml/System.Security.AccessControl/DirectorySecurity.xml index 1355f88a786..928ee9b10e1 100644 --- a/xml/System.Security.AccessControl/DirectorySecurity.xml +++ b/xml/System.Security.AccessControl/DirectorySecurity.xml @@ -60,7 +60,6 @@ ## Examples The following code example uses the class to add and then remove an access control list (ACL) entry from a directory. You must supply a valid user or group account to run this example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/GetAccessControl/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/VB/sample.vb" id="Snippet1"::: diff --git a/xml/System.Security.AccessControl/RegistryRights.xml b/xml/System.Security.AccessControl/RegistryRights.xml index 6549c403548..49f5fd7735b 100644 --- a/xml/System.Security.AccessControl/RegistryRights.xml +++ b/xml/System.Security.AccessControl/RegistryRights.xml @@ -36,24 +36,23 @@ Specifies the access control rights that can be applied to registry objects. - enumeration to specify registry access rights when you create objects. To apply access rights to a registry key, first add objects to a object, then attach the object to the key using the method, or an appropriate overload of the method. + + + +## Examples + The following code example demonstrates the use of the enumeration. The code creates a test key, allowing the current user ReadKey and Delete access rights but denying ChangePermissions and WriteKey rights. Subsequent attempts to manipulate the key succeed or fail depending on these permissions. + + Before the key is deleted, the code pauses. You can switch to the Registry Editor (Regedit.exe or Regedt32.exe) and verify that the same access rights apply when the key is accessed using the Registry Editor. + + This example works best if you use **RunAs** from the command line to run the Registry Editor and the sample code as a local user without administrator rights. For example, if you have defined a local user named TestUser, the command `runas /user:TestUser cmd` opens a command window from which you can run the Registry Editor and then the example code. -## Remarks - Use the enumeration to specify registry access rights when you create objects. To apply access rights to a registry key, first add objects to a object, then attach the object to the key using the method, or an appropriate overload of the method. - - - -## Examples - The following code example demonstrates the use of the enumeration. The code creates a test key, allowing the current user ReadKey and Delete access rights but denying ChangePermissions and WriteKey rights. Subsequent attempts to manipulate the key succeed or fail depending on these permissions. - - Before the key is deleted, the code pauses. You can switch to the Registry Editor (Regedit.exe or Regedt32.exe) and verify that the same access rights apply when the key is accessed using the Registry Editor. - - This example works best if you use **RunAs** from the command line to run the Registry Editor and the sample code as a local user without administrator rights. For example, if you have defined a local user named TestUser, the command `runas /user:TestUser cmd` opens a command window from which you can run the Registry Editor and then the example code. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RegistrySecurity101/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/RegistryKey/SetAccessControl/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RegistrySecurity101/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RegistrySecurity101/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/OpenFlags.xml b/xml/System.Security.Cryptography.X509Certificates/OpenFlags.xml index 1651f06366a..88f96c12f83 100644 --- a/xml/System.Security.Cryptography.X509Certificates/OpenFlags.xml +++ b/xml/System.Security.Cryptography.X509Certificates/OpenFlags.xml @@ -58,20 +58,19 @@ Specifies the way to open the X.509 certificate store. - permission to be granted. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes you have three certificates to add to and remove from a local store. -## Remarks - The `ReadOnly`, `ReadWrite`, and `MaxAllowed` flags are mutually exclusive. The `OpenExistingOnly` flag is the only flag that does not require the permission to be granted. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/PublicKey.xml b/xml/System.Security.Cryptography.X509Certificates/PublicKey.xml index 6fb9149874b..c2b4c6119c2 100644 --- a/xml/System.Security.Cryptography.X509Certificates/PublicKey.xml +++ b/xml/System.Security.Cryptography.X509Certificates/PublicKey.xml @@ -59,25 +59,24 @@ Represents a certificate's public key information. This class cannot be inherited. - object contains the object identifier () representing the public key algorithm, the ASN-encoded parameters, and the ASN.1-encoded key value. - - - -## Examples - The following example demonstrates how to use the public key from a object to encrypt a file. It also shows how to decrypt the encrypted file using the private key for that certificate. - + object contains the object identifier () representing the public key algorithm, the ASN-encoded parameters, and the ASN.1-encoded key value. + + + +## Examples + The following example demonstrates how to use the public key from a object to encrypt a file. It also shows how to decrypt the encrypted file using the private key for that certificate. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509certificate2/vb/program.vb" id="Snippet1"::: - - The following example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509certificate2/vb/program.vb" id="Snippet1"::: + + The following example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -299,15 +298,14 @@ Gets the ASN.1-encoded representation of the public key value. The ASN.1-encoded representation of the public key value. - @@ -687,20 +685,19 @@ Gets an derived object or a derived object representing the public key. An object representing the public key. - and keys are supported. Call this property to obtain a certificate's public key. Repeated calls to this property will return the same key. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, and then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + and keys are supported. Call this property to obtain a certificate's public key. Repeated calls to this property will return the same key. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, and then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The key algorithm is not supported. @@ -749,20 +746,19 @@ Gets an object identifier (OID) object of the public key. An object identifier (OID) object of the public key. - diff --git a/xml/System.Security.Cryptography.X509Certificates/StoreLocation.xml b/xml/System.Security.Cryptography.X509Certificates/StoreLocation.xml index 921e3f40ac3..14019b9bf23 100644 --- a/xml/System.Security.Cryptography.X509Certificates/StoreLocation.xml +++ b/xml/System.Security.Cryptography.X509Certificates/StoreLocation.xml @@ -52,22 +52,21 @@ Specifies the location of the X.509 certificate store. - constructor. - - - +This enumeration is used with the constructor. + + + ## Examples -The following example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes you have three certificates to add to and remove from a local store. +The following example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes you have three certificates to add to and remove from a local store. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.xml b/xml/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.xml index 7ad05a667ad..c2ba652b3fc 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.xml @@ -59,20 +59,19 @@ Defines the constraints set on a certificate. This class cannot be inherited. - class to display the information. -## Remarks - This class provides properties that define the basic constraints set on a certificate. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -127,15 +126,14 @@ Initializes a new instance of the class. - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -186,11 +184,11 @@ if the extension is critical; otherwise, . Initializes a new instance of the class using an object and a value that identifies whether the extension is critical. - object. - + object. + ]]> @@ -293,20 +291,19 @@ if the certificate is a certificate authority (CA) certificate, otherwise, . - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -357,11 +354,11 @@ The encoded data to use to create the extension. Initializes a new instance of the class using an object. - object. - + object. + ]]> @@ -481,20 +478,19 @@ if the certificate has a restriction on the number of path levels it allows, otherwise, . - property to determine the number of levels allowed. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + property to determine the number of levels allowed. + + + +## Examples + The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> The extension cannot be decoded. @@ -543,20 +539,19 @@ Gets the number of levels allowed in a certificate's path. An integer indicating the number of levels allowed in a certificate's path. - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> The extension cannot be decoded. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Certificate.xml b/xml/System.Security.Cryptography.X509Certificates/X509Certificate.xml index 9017c372454..e1d9ef167db 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Certificate.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Certificate.xml @@ -112,7 +112,6 @@ ## Examples The following example loads an X.509 certificate from a file, calls the method, and displays the results to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/Overview/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/VB/example.vb" id="Snippet1"::: @@ -257,7 +256,6 @@ ## Examples The following example loads an X.509 certificate file into an object, exports the certificate as a byte array, and then imports the byte array into another object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/VB/sample.vb" id="Snippet1"::: @@ -489,7 +487,6 @@ ## Examples The following example loads an X.509 certificate from a file, calls the method, and displays the results to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/Overview/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/VB/example.vb" id="Snippet1"::: @@ -1361,7 +1358,6 @@ ## Examples The following example creates an from a specified certification file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/CreateFromCertFile/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.ToString Method/VB/example.vb" id="Snippet1"::: @@ -1662,7 +1658,6 @@ ## Examples The following example compares two certificates for equality. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/Equals/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.Equals Method/VB/example.vb" id="Snippet1"::: @@ -1744,7 +1739,6 @@ ## Examples The following example compares two certificates for equality. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/Equals/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.Equals Method/VB/example.vb" id="Snippet1"::: @@ -1830,7 +1824,6 @@ ## Examples The following example loads an X.509 certificate file into an object, exports the certificate as a byte array, and then imports the byte array into another object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/VB/sample.vb" id="Snippet1"::: @@ -2197,7 +2190,6 @@ ## Examples The following example uses the method to fill an array of bytes with the hash value for an X.509 certificate. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetCertHash/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetCertHash Method/VB/example.vb" id="Snippet1"::: @@ -2312,7 +2304,6 @@ ## Examples The following example uses the method to get an X.509 certificate hash value, convert it to a string, and display it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetCertHashString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/VB/example.vb" id="Snippet1"::: @@ -2422,7 +2413,6 @@ ## Examples The following example uses the method to get the effective date of a certificate and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetEffectiveDateString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/VB/example.vb" id="Snippet1"::: @@ -2488,7 +2478,6 @@ ## Examples The following example uses the method to get the expiration date of a certificate and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetExpirationDateString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/VB/example.vb" id="Snippet1"::: @@ -2551,7 +2540,6 @@ ## Examples The following example uses the method to get the format of a certificate and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetFormat/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetFormat Method/VB/example.vb" id="Snippet1"::: @@ -2620,7 +2608,6 @@ ## Examples The following example uses the method to return an integer representation of a certificate's hash code and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetHashCode/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetHashCode Method/VB/example.vb" id="Snippet1"::: @@ -2694,7 +2681,6 @@ ## Examples The following example uses the method to return the certificate issuer's name and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetIssuerName/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/VB/example.vb" id="Snippet1"::: @@ -2765,7 +2751,6 @@ ## Examples The following example uses the method to get a certificate's key algorithm in string format and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetKeyAlgorithm/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/VB/example.vb" id="Snippet1"::: @@ -2831,7 +2816,6 @@ ## Examples The following example uses the method to return a certificate's key algorithm parameters as an array of bytes and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetKeyAlgorithmParameters/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/VB/example.vb" id="Snippet1"::: @@ -2897,7 +2881,6 @@ ## Examples The following example uses the method to return a certificate's key algorithm parameters in string format and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetKeyAlgorithmParametersString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/VB/example.vb" id="Snippet1"::: @@ -2972,7 +2955,6 @@ ## Examples The following example uses the method to return the name of a certificate's principal and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetName/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetName Method/VB/example.vb" id="Snippet1"::: @@ -3039,7 +3021,6 @@ This value corresponds to the contents of the `subjectPublicKey` field of the Su ## Examples The following example uses the method to return a certificate's public key as an array of bytes and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetPublicKey/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/VB/example.vb" id="Snippet1"::: @@ -3098,7 +3079,6 @@ This value corresponds to the contents of the `subjectPublicKey` field of the Su ## Examples The following example uses the method to return a certificate's public key as a string and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetPublicKeyString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/VB/example.vb" id="Snippet1"::: @@ -3162,7 +3142,6 @@ The output of this method is equivalent to the output of the method to return a certificate's raw data as an array of bytes and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetRawCertData/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/VB/example.vb" id="Snippet1"::: @@ -3218,7 +3197,6 @@ The output of this method is equivalent to the output of the method to return a certificate's raw data as a string and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetRawCertDataString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/VB/example.vb" id="Snippet1"::: @@ -3282,7 +3260,6 @@ The output of this method is equivalent to the output of the method to return a certificate's serial number as an array of bytes and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetSerialNumber/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/VB/example.vb" id="Snippet1"::: @@ -3339,7 +3316,6 @@ The output of this method is equivalent to the output of the method to return a certificate's serial number as a string and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetSerialNumberString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/VB/example.vb" id="Snippet1"::: @@ -3568,7 +3544,6 @@ The output of this method is equivalent to the output of the method, and displays the results to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/Import/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/VB/sample.vb" id="Snippet1"::: @@ -4301,7 +4276,6 @@ The output of this method is equivalent to the output of the method to display the value of a certificate to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/CreateFromCertFile/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.ToString Method/VB/example.vb" id="Snippet1"::: @@ -4369,7 +4343,6 @@ The output of this method is equivalent to the output of the method to display the value of a certificate to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/CreateFromCertFile/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.ToString Method/VB/example.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2.xml b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2.xml index 2008746e8ba..0a601c3f209 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2.xml @@ -64,30 +64,29 @@ Represents an X.509 certificate. - class is designed to model the usage scenarios defined in specifications issued by the Internet Engineering Task Force (IETF) Public Key Infrastructure, X.509 (PKIX) working group. The most informative of these specifications is RFC 3280, "[Certificate and Certificate Revocation List (CRL) Profile](https://go.microsoft.com/fwlink/?LinkId=45286)." - + class is designed to model the usage scenarios defined in specifications issued by the Internet Engineering Task Force (IETF) Public Key Infrastructure, X.509 (PKIX) working group. The most informative of these specifications is RFC 3280, "[Certificate and Certificate Revocation List (CRL) Profile](https://go.microsoft.com/fwlink/?LinkId=45286)." + > [!IMPORTANT] -> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. -> -> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. - - - -## Examples - The following example demonstrates how to use an object to encrypt and decrypt a file. - +> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. +> +> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. + + + +## Examples + The following example demonstrates how to use an object to encrypt and decrypt a file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509certificate2/vb/program.vb" id="Snippet1"::: - - The following example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509certificate2/vb/program.vb" id="Snippet1"::: + + The following example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -156,20 +155,19 @@ Initializes a new instance of the class. - object, unlike the other constructors for this class that use certificate information from a byte array, a pointer, or a certificate file. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + object, unlike the other constructors for this class that use certificate information from a byte array, a pointer, or a certificate file. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> @@ -227,21 +225,21 @@ A byte array containing data from an X.509 certificate. Initializes a new instance of the class using information from a byte array. - object using certificate information from a byte array. The byte array can be binary (DER) encoded or PEM-encoded X.509 data. The byte array can also be a PKCS7 (Authenticode) signed file; the signer certificate is used to create the object. - - If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - + object using certificate information from a byte array. The byte array can be binary (DER) encoded or PEM-encoded X.509 data. The byte array can also be a PKCS7 (Authenticode) signed file; the signer certificate is used to create the object. + + If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -294,22 +292,22 @@ A pointer to a certificate context in unmanaged code. The C structure is called . Initializes a new instance of the class using an unmanaged handle. - object using a handle for the Microsoft Cryptographic API certificate context, `PCCERT_CONTEXT`. Note that the immediate caller of this constructor requires unmanaged code permission. - + object using a handle for the Microsoft Cryptographic API certificate context, `PCCERT_CONTEXT`. Note that the immediate caller of this constructor requires unmanaged code permission. + > [!IMPORTANT] -> The constructor creates a copy of the certificate context. Do not assume that the context structure you passed to the constructor is valid; it may have been released. You can get a copy of the current `PCCERT_CONTEXT` structure from the property, but it is valid only during the lifetime of the object. - +> The constructor creates a copy of the certificate context. Do not assume that the context structure you passed to the constructor is valid; it may have been released. You can get a copy of the current `PCCERT_CONTEXT` structure from the property, but it is valid only during the lifetime of the object. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -403,19 +401,19 @@ An object. Initializes a new instance of the class using an object. - class using an object. - + class using an object. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -472,21 +470,21 @@ The name of a certificate file. Initializes a new instance of the class using a certificate file name. - object using a certificate file name. It supports binary (DER) encoding or PEM encoding. - - If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - + object using a certificate file name. It supports binary (DER) encoding or PEM encoding. + + If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -555,24 +553,24 @@ The password required to access the X.509 certificate data. Initializes a new instance of the class using a byte array and a password. - [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -639,24 +637,24 @@ The password required to access the X.509 certificate data. Initializes a new instance of the class using a byte array and a password. - object using a byte array and a password that is needed to access the certificate data. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a key container. - + object using a byte array and a password that is needed to access the certificate data. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a key container. + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -780,24 +778,24 @@ The password required to access the X.509 certificate data. Initializes a new instance of the class using a certificate file name and a password. - [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -864,24 +862,24 @@ The password required to access the X.509 certificate data. Initializes a new instance of the class using a certificate file name and a password used to access the certificate. - object using a certificate file name and a password needed to access the certificate. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a key container. - + object using a certificate file name and a password needed to access the certificate. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a key container. + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -952,24 +950,24 @@ A bitwise combination of the enumeration values that control where and how to import the certificate. Initializes a new instance of the class using a byte array, a password, and a key storage flag. - [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -1038,24 +1036,24 @@ A bitwise combination of the enumeration values that control where and how to import the certificate. Initializes a new instance of the class using a byte array, a password, and a key storage flag. - object using a byte array, a password that is needed to access the certificate data, and a key storage flag. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a Microsoft Cryptographic API Cryptographic Service Provider (CSP). - + object using a byte array, a password that is needed to access the certificate data, and a key storage flag. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a Microsoft Cryptographic API Cryptographic Service Provider (CSP). + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -1155,22 +1153,22 @@ A bitwise combination of the enumeration values that control where and how to import the certificate. Initializes a new instance of the class using a certificate file name, a password, and a key storage flag. - [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - -If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + +If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -1241,19 +1239,19 @@ If you create an A bitwise combination of the enumeration values that control where and how to import the certificate. Initializes a new instance of the class using a certificate file name, a password, and a key storage flag. - certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - + certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -1322,24 +1320,24 @@ If you create an A bitwise combination of the enumeration values that control where and how to import the certificate. Initializes a new instance of the class using a certificate file name, a password used to access the certificate, and a key storage flag. - object using a certificate file name, a password needed to access the certificate, and a key storage flag. - + object using a certificate file name, a password needed to access the certificate, and a key storage flag. + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -1393,22 +1391,21 @@ If you create an if the certificate is archived, if the certificate is not archived. - object unless the property is set to `true`. No physical archival activity occurs when the value is set or unset. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + object unless the property is set to `true`. No physical archival activity occurs when the value is set or unset. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The certificate is unreadable. @@ -1587,13 +1584,13 @@ The specified private key doesn't match the public key for this certificate. to enumerate PEM-encoded values and apply any custom loading behavior. - + For PEM-encoded keys without a password, use . - + ]]> @@ -1679,15 +1676,15 @@ The password specified for the private key is incorrect. ## Remarks See for additional documentation about exceptions that can be thrown. - + Password protected PEM-encoded keys are always expected to have the PEM label "ENCRYPTED PRIVATE KEY". - + PEM-encoded items that have a different label are ignored. Combined PEM-encoded certificates and keys do not require a specific order. For the certificate, the first certificate with a CERTIFICATE label is loaded. For the private key, the first private key with the label "ENCRYPTED PRIVATE KEY" is loaded. More advanced scenarios for loading certificates and private keys can leverage to enumerate PEM-encoded values and apply any custom loading behavior. - + For PEM-encoded keys without a password, use . - + ]]> @@ -1762,7 +1759,7 @@ The password specified for the private key is incorrect. ## Remarks This loads the first well-formed PEM found with a CERTIFICATE label. - + For PEM-encoded certificates with a private key, use . For PEM-encoded certificates in a file, use . @@ -1827,7 +1824,7 @@ For PEM-encoded certificates in a file, use to enumerate PEM-encoded values and apply any custom loading behavior. @@ -2027,20 +2024,19 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Gets a collection of objects. An object. - ), key identifiers (), certificate policies, revocation information (CRL Distribution Point extension), and other uses. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + ), key identifiers (), certificate policies, revocation information (CRL Distribution Point extension), and other uses. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The certificate is unreadable. @@ -2095,22 +2091,21 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Gets or sets the associated alias for a certificate. The certificate's friendly name. - The certificate is unreadable. @@ -2180,20 +2175,19 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Indicates the type of certificate contained in a byte array. An object. - @@ -2296,11 +2290,11 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Indicates the type of certificate contained in a file. An object. - @@ -2559,20 +2553,19 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Gets the subject and issuer names from a certificate. The name of the certificate. - @@ -2688,13 +2681,13 @@ The certificate is encoded according to the IETF RFC 7468 "strict" A byte array containing data from an X.509 certificate. Populates an object with data from a byte array. - object with its associated values. - - Since this method accepts only a byte array, it can be used only for certificate types that do not require a password, including a PEM-encoded or DER-encoded X.509 certificate or a PFX/PKCS12 certificate. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. - + object with its associated values. + + Since this method accepts only a byte array, it can be used only for certificate types that do not require a password, including a PEM-encoded or DER-encoded X.509 certificate or a PFX/PKCS12 certificate. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. + ]]> @@ -2753,13 +2746,13 @@ The certificate is encoded according to the IETF RFC 7468 "strict" The name of a certificate. Populates an object with information from a certificate file. - object with the certificate the file contains. - - This method can be used with several certificate types, including PEM-encoded or DER-encoded X.509 certificates, PFX/PKCS12 certificates, and signer certificates such as Authenticode. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. - + object with the certificate the file contains. + + This method can be used with several certificate types, including PEM-encoded or DER-encoded X.509 certificates, PFX/PKCS12 certificates, and signer certificates such as Authenticode. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. + ]]> @@ -2834,14 +2827,14 @@ The certificate is encoded according to the IETF RFC 7468 "strict" A bitwise combination of the enumeration values that control where and how to import the certificate. Populates an object using data from a byte array, a password, and a key storage flag. - [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + ]]> @@ -2912,25 +2905,24 @@ The certificate is encoded according to the IETF RFC 7468 "strict" A bitwise combination of the enumeration values that control where and how to import the certificate. Populates an object using data from a byte array, a password, and flags for determining how to import the private key. - object using a password for the certificate represented by the byte array. The value can be used to control where and how to import the private key. - - This method accepts a byte array and can be used for certificate types such as PEM-encoded or DER-encoded X.509 certificates or PFX/PKCS12 certificates. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. - + object using a password for the certificate represented by the byte array. The value can be used to control where and how to import the private key. + + This method accepts a byte array and can be used for certificate types such as PEM-encoded or DER-encoded X.509 certificates or PFX/PKCS12 certificates. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - - -## Examples - The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + + +## Examples + The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -3005,11 +2997,11 @@ The certificate is encoded according to the IETF RFC 7468 "strict" A bitwise combination of the enumeration values that control where and how to import the certificate. Populates an object with information from a certificate file, a password, and a key storage flag. - @@ -3080,14 +3072,14 @@ The certificate is encoded according to the IETF RFC 7468 "strict" A bitwise combination of the enumeration values that control where and how to import the certificate. Populates an object with information from a certificate file, a password, and a value. - object with information from a certificate file, a password, and an value. - + object with information from a certificate file, a password, and an value. + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + ]]> @@ -3135,22 +3127,21 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Gets the distinguished name of the certificate issuer. An object that contains the name of the certificate issuer. - method. - - The distinguished name for the certificate is a textual representation of the certificate subject or issuer. This representation consists of name attributes (for example, "CN=MyName, OU=MyOrgUnit, C=US"). - - - -## Examples - The following code example creates a command-line executable file that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: + method. + + The distinguished name for the certificate is a textual representation of the certificate subject or issuer. This representation consists of name attributes (for example, "CN=MyName, OU=MyOrgUnit, C=US"). + + + +## Examples + The following code example creates a command-line executable file that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> The certificate context is invalid. @@ -3269,20 +3260,19 @@ The Subject Alternative Name extension or Subject Name could not be decoded.Gets the date in local time after which a certificate is no longer valid. A object that represents the expiration date for the certificate. - The certificate is unreadable. @@ -3331,20 +3321,19 @@ The Subject Alternative Name extension or Subject Name could not be decoded.Gets the date in local time on which a certificate becomes valid. A object that represents the effective date of the certificate. - The certificate is unreadable. @@ -3402,25 +3391,24 @@ The Subject Alternative Name extension or Subject Name could not be decoded.Gets or sets the object that represents the private key associated with a certificate. An object, which is either an RSA or DSA cryptographic service provider. - or a object in .NET Core or an or a object in .NET Framework. If no private key is associated with the certificate, it returns `null`. - + or a object in .NET Core or an or a object in .NET Framework. If no private key is associated with the certificate, it returns `null`. + > [!WARNING] -> If you set this property to `null` or to another key without first deleting it, a private key file is left on the disk. - - To properly delete the private key associated with this property, set `PersistKeyInCsp` to `false`, and then call the method. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: +> If you set this property to `null` or to another key without first deleting it, a private key file is left on the disk. + + To properly delete the private key associated with this property, set `PersistKeyInCsp` to `false`, and then call the method. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The key value is not an RSA or DSA key, or the key is unreadable. @@ -3474,22 +3462,21 @@ The Subject Alternative Name extension or Subject Name could not be decoded.Gets a object associated with a certificate. A object. - object, which contains the object identifier () representing the public key algorithm, the ASN.1-encoded parameters, and the ASN.1-encoded key value. - - You can also obtain the key as an object by referencing the property. This property supports only RSA or DSA keys, so it returns either an or a object that represents the public key. - - - -## Examples - The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + object, which contains the object identifier () representing the public key algorithm, the ASN.1-encoded parameters, and the ASN.1-encoded key value. + + You can also obtain the key as an object by referencing the property. This property supports only RSA or DSA keys, so it returns either an or a object that represents the public key. + + + +## Examples + The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The key value is not an RSA or DSA key, or the key is unreadable. @@ -3538,15 +3525,14 @@ The Subject Alternative Name extension or Subject Name could not be decoded.Gets the raw X.509 public data of a certificate. The raw X.509 public data of a certificate. - @@ -3638,11 +3624,11 @@ Unlike Resets the state of an object. - @@ -3690,20 +3676,19 @@ Unlike Gets the serial number of a certificate as a big-endian hexadecimal string. The serial number of the certificate as a big-endian hexadecimal string. - @@ -3751,20 +3736,19 @@ Unlike Gets the algorithm used to create the signature of a certificate. The object identifier of the signature algorithm. - ) identifies the type of signature algorithm used by the certificate. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + ) identifies the type of signature algorithm used by the certificate. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The certificate is unreadable. @@ -3813,20 +3797,19 @@ Unlike Gets the subject distinguished name from a certificate. An object that represents the name of the certificate subject. - The certificate context is invalid. @@ -3875,22 +3858,21 @@ Unlike Gets the thumbprint of a certificate. The thumbprint of the certificate. - . - - - -## Examples - The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: + + + +## Examples + The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -3950,22 +3932,21 @@ Unlike Displays an X.509 certificate in text format. The certificate information. - object to obtain precise information about the content or use the method to obtain information about the certificate. - - This method displays the certificate in text format. - - - -## Examples - The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: + object to obtain precise information about the content or use the method to obtain information about the certificate. + + This method displays the certificate in text format. + + + +## Examples + The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -4018,22 +3999,21 @@ Unlike Displays an X.509 certificate in text format. The certificate information. - object to obtain precise information. - - This method displays the certificate in text format. If the `verbose` parameter is set to `true`, the text display includes the public key, private key, and extensions. If `verbose` is set to `false`, the text display includes those fields available from the X.509 certificate, including thumbprint, serial number, subject and issuer names, and validity date information. - - - -## Examples - The following code example creates a command line executable that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: + object to obtain precise information. + + This method displays the certificate in text format. If the `verbose` parameter is set to `true`, the text display includes the public key, private key, and extensions. If `verbose` is set to `false`, the text display includes those fields available from the X.509 certificate, including thumbprint, serial number, subject and issuer names, and validity date information. + + + +## Examples + The following code example creates a command line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -4134,22 +4114,21 @@ Unlike if the validation succeeds; if the validation fails. - object. - - Note that the default chaining engine can be overridden using the class. On Microsoft Windows Server 2003, the default engine conforms to the specification described in RFC3280, "[Certificate and Certificate Revocation List (CRL) Profile](https://go.microsoft.com/fwlink/?LinkId=45286)." - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + object. + + Note that the default chaining engine can be overridden using the class. On Microsoft Windows Server 2003, the default engine conforms to the specification described in RFC3280, "[Certificate and Certificate Revocation List (CRL) Profile](https://go.microsoft.com/fwlink/?LinkId=45286)." + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The certificate is unreadable. @@ -4198,20 +4177,19 @@ Unlike Gets the X.509 format version of a certificate. The certificate format. - The certificate is unreadable. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2Collection.xml b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2Collection.xml index 384ed91691a..874cfff4477 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2Collection.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2Collection.xml @@ -71,20 +71,19 @@ Represents a collection of objects. This class cannot be inherited. - store is opened, the result is represented by an object. If you are familiar with the unmanaged Cryptographic API constructs, you can think of an as a memory store of objects. - - - -## Examples - The following code example opens the current user's personal certificate store, selects only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. + store is opened, the result is represented by an object. If you are familiar with the unmanaged Cryptographic API constructs, you can think of an as a memory store of objects. + + + +## Examples + The following code example opens the current user's personal certificate store, selects only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> @@ -145,20 +144,19 @@ Initializes a new instance of the class without any information. - object, which is unlike the other constructors that use certificate or collection information to create the object. - - - -## Examples - The following code example opens the current user's personal certificate store, selects only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + object, which is unlike the other constructors that use certificate or collection information to create the object. + + + +## Examples + The following code example opens the current user's personal certificate store, selects only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> @@ -251,15 +249,14 @@ An array of objects. Initializes a new instance of the class using an array of objects. - @@ -307,15 +304,14 @@ An object. Initializes a new instance of the class using the specified certificate collection. - @@ -367,20 +363,19 @@ Adds an object to the end of the . The index at which the has been added. - object to a collection and returns the index location of the certificate. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object to a collection and returns the index location of the certificate. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -444,11 +439,11 @@ An array of objects. Adds multiple objects in an array to the object. - objects to add to an object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. - + objects to add to an object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. + ]]> @@ -501,11 +496,11 @@ An object. Adds multiple objects in an object to another object. - object that you want to add to another object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. - + object that you want to add to another object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. + ]]> @@ -560,13 +555,13 @@ if the contains the specified ; otherwise, . - property. That is, this method is an O(`n`) operation, where `n` is . - - This method determines equality by calling the method. - + property. That is, this method is an O(`n`) operation, where `n` is . + + This method determines equality by calling the method. + ]]> @@ -638,11 +633,11 @@ Exports X.509 certificate information into a byte array. X.509 certificate information in a byte array. - @@ -697,21 +692,21 @@ Exports X.509 certificate information into a byte array using a password. X.509 certificate information in a byte array. - types: - -- - -- - -- - -- - -- - + types: + +- + +- + +- + +- + +- + ]]> The certificate is unreadable, the content is invalid or, in the case of a certificate requiring a password, the private key could not be exported because the password provided was incorrect. @@ -942,22 +937,21 @@ Searches an object using the search criteria specified by the enumeration and the object. An object. - objects if no user interaction is needed. Use the method to allow the user to select objects. - - Note that this method can be used in a cascading or nested style, narrowing the search criteria with each call to the method. - - - -## Examples - The following code example opens the current user's personal certificate store, finds only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + objects if no user interaction is needed. Use the method to allow the user to select objects. + + Note that this method can be used in a cascading or nested style, narrowing the search criteria with each call to the method. + + + +## Examples + The following code example opens the current user's personal certificate store, finds only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> @@ -1119,11 +1113,11 @@ Returns an enumerator that can iterate through a object. An object that can iterate through the object. - @@ -1195,23 +1189,23 @@ A byte array containing data from an X.509 certificate. Imports a certificate in the form of a byte array into a object. - object. This method supports the following types: - -- - -- - -- - -- - -- - -- - + object. This method supports the following types: + +- + +- + +- + +- + +- + +- + ]]> @@ -1313,23 +1307,23 @@ The name of the file containing the certificate information. Imports a certificate file into a object. - types: - -- - -- - -- - -- - -- - -- - + types: + +- + +- + +- + +- + +- + +- + ]]> @@ -1399,23 +1393,23 @@ A bitwise combination of the enumeration values that control how and where the certificate is imported. Imports a certificate, in the form of a byte array that requires a password to access the certificate, into a object. - value can be used to control this process. Note that if you do not create a key container, the private key is not persisted. - - This method imports a certificate byte array into a collection of certificates. This method supports the following types: - -- - -- - -- - -- - -- - + value can be used to control this process. Note that if you do not create a key container, the private key is not persisted. + + This method imports a certificate byte array into a collection of certificates. This method supports the following types: + +- + +- + +- + +- + +- + ]]> @@ -1631,27 +1625,27 @@ A bitwise combination of the enumeration values that control how and where the certificate is imported. Imports a certificate file that requires a password into a object. - value can be used to control this process. Note that if you do not create a key container, the private key is not persisted. - - Note that a PFX/PKCS12 file can contain more than one certificate. This method imports the first certificate associated with the private key or, if no private key is found, the first certificate found. - - This method supports the following types: - -- - -- - -- - -- - -- - -- - + value can be used to control this process. Note that if you do not create a key container, the private key is not persisted. + + Note that a PFX/PKCS12 file can contain more than one certificate. This method imports the first certificate associated with the private key or, if no private key is found, the first certificate found. + + This method supports the following types: + +- + +- + +- + +- + +- + +- + ]]> @@ -1694,7 +1688,7 @@ ## Remarks PEM-encoded items with a CERTIFICATE PEM label will be imported. PEM items with other labels will be ignored. - + More advanced scenarios for loading certificates and can leverage to enumerate PEM-encoded values and apply any custom loading behavior. ]]> @@ -1800,25 +1794,25 @@ The object to insert. Inserts an object into the object at the specified index. - property already equals the capacity of the list, the capacity is doubled by automatically reallocating the internal array before the new element is inserted. - - If `index` is equal to , `certificate` is added to the end of the collection. - + property already equals the capacity of the list, the capacity is doubled by automatically reallocating the internal array before the new element is inserted. + + If `index` is equal to , `certificate` is added to the end of the collection. + ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + is greater than the property. - The collection is read-only. - - -or- - + The collection is read-only. + + -or- + The collection has a fixed size. is . @@ -1871,27 +1865,26 @@ Gets or sets the element at the specified index. The element at the specified index. - - is less than zero. - - -or- - + is less than zero. + + -or- + is equal to or greater than the property. is . @@ -1943,11 +1936,11 @@ The object to be removed from the object. Removes the first occurrence of a certificate from the object. - @@ -2011,11 +2004,11 @@ An array of objects. Removes multiple objects in an array from an object. - objects to remove from an object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. - + objects to remove from an object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. + ]]> @@ -2068,11 +2061,11 @@ An object. Removes multiple objects in an object from another object. - object that you want to remove from another object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. - + object that you want to remove from another object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2UI.xml b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2UI.xml index cfa9d8b08ee..ba72ac354a9 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2UI.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2UI.xml @@ -38,20 +38,19 @@ Displays user interface dialogs that allow you to select and view X.509 certificates. This class cannot be inherited. - class to present user interface dialogs that display detailed information about an X.509 certificate or allow users to select one or more certificates from a collection of X.509 certificates. + + + +## Examples + The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. -## Remarks - Use the methods of the class to present user interface dialogs that display detailed information about an X.509 certificate or allow users to select one or more certificates from a collection of X.509 certificates. - - - -## Examples - The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> @@ -88,11 +87,11 @@ Displays a dialog box that contains the properties of an X.509 certificate and its associated certificate chain. - @@ -137,20 +136,19 @@ The X.509 certificate to display. Displays a dialog box that contains the properties of an X.509 certificate and its associated certificate chain. - method displays a dialog box with detailed information about the specified X.509 certificate. The dialog box includes buttons for installing or copying the certificate. - - - -## Examples - The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + method displays a dialog box with detailed information about the specified X.509 certificate. The dialog box includes buttons for installing or copying the certificate. + + + +## Examples + The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The parameter is . @@ -199,11 +197,11 @@ A handle to the parent window to use for the display dialog. Displays a dialog box that contains the properties of an X.509 certificate and its associated certificate chain using a handle to a parent window. - method displays a dialog box with detailed information about the specified X.509 certificate. This method can be used to nest dialog boxes that display certificate information. The dialog box includes buttons for installing or copying the certificate. - + method displays a dialog box with detailed information about the specified X.509 certificate. This method can be used to nest dialog boxes that display certificate information. The dialog box includes buttons for installing or copying the certificate. + ]]> The parameter is . @@ -218,11 +216,11 @@ Displays a dialog box for selecting an X.509 certificate from a certificate collection. - method. - + method. + ]]> @@ -283,20 +281,19 @@ Displays a dialog box for selecting an X.509 certificate from a certificate collection. An object that contains the selected certificate or certificates. - method if you require users to manually select X.509 certificates using a dialog box. If no user interaction is required, use the method. - - - -## Examples - The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + method if you require users to manually select X.509 certificates using a dialog box. If no user interaction is required, use the method. + + + +## Examples + The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The parameter is not a valid flag. @@ -368,11 +365,11 @@ Displays a dialog box for selecting an X.509 certificate from a certificate collection using a handle to a parent window. An object that contains the selected certificate or certificates. - method if you require users to manually select X.509 certificates using a dialog box. If no user interaction is required, use the method. - + method if you require users to manually select X.509 certificates using a dialog box. If no user interaction is required, use the method. + ]]> The parameter is not a valid flag. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Chain.xml b/xml/System.Security.Cryptography.X509Certificates/X509Chain.xml index 157cc396c66..7beb89f252b 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Chain.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Chain.xml @@ -68,25 +68,24 @@ Represents a chain-building engine for certificates. - object has a global error status called that should be used for certificate validation. The rules governing certificate validation are complex, and it is easy to oversimplify the validation logic by ignoring the error status of one or more of the elements involved. The global error status takes into consideration the status of each element in the chain. - + object has a global error status called that should be used for certificate validation. The rules governing certificate validation are complex, and it is easy to oversimplify the validation logic by ignoring the error status of one or more of the elements involved. The global error status takes into consideration the status of each element in the chain. + > [!IMPORTANT] -> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. -> -> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. - +> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. +> +> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. + When disposing , the certificates in are not disposed. You should dispose of the certificates in this collection when the certificate instances are no longer needed. + +## Examples + The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. -## Examples - The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet1"::: + ]]> @@ -151,15 +150,14 @@ Initializes a new instance of the class. - @@ -212,20 +210,19 @@ to use the machine context; to use the current user context. Initializes a new instance of the class specifying a value that indicates whether the machine context should be used. - @@ -277,11 +274,11 @@ An handle to an X.509 chain. Initializes a new instance of the class using an handle to an X.509 chain. - The parameter is . @@ -342,20 +339,19 @@ if the X.509 certificate is valid; otherwise, . - object. Certificates that meet these chain policy rules might still be invalid for specific uses with such features as Security/MIME (SMIME), Authenticode, or Secure Sockets Layer (SSL). If further processing is required to determine whether the certificate is valid for a specific policy, derive a class from and override the method so that it calls the base class `Build` method first, and then does the additional processing. - - - -## Examples - The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: + object. Certificates that meet these chain policy rules might still be invalid for specific uses with such features as Security/MIME (SMIME), Authenticode, or Secure Sockets Layer (SSL). If further processing is required to determine whether the certificate is valid for a specific policy, derive a class from and override the method so that it calls the base class `Build` method first, and then does the additional processing. + + + +## Examples + The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> The is not a valid certificate or is . @@ -403,11 +399,11 @@ Gets a handle to an X.509 chain. An handle to an X.509 chain. - @@ -461,22 +457,21 @@ Gets a collection of objects. An object. - object is a representation of an element in the chain that was built during a call to the method. - + object is a representation of an element in the chain that was built during a call to the method. + A chain element consists of an object, an structure, and an extra information string. - - - -## Examples - The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet4"::: + + + +## Examples + The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: + ]]> @@ -524,20 +519,19 @@ Gets or sets the to use when building an X.509 certificate chain. The object associated with this X.509 chain. - The value being set for this property is . @@ -586,11 +580,11 @@ Gets the status of each element in an object. An array of objects. - @@ -637,11 +631,11 @@ Creates an object after querying for the mapping defined in the CryptoConfig file, and maps the chain to that mapping. An object. - @@ -655,13 +649,13 @@ Releases the resources used by this . - [!NOTE] -> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. - +> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. + ]]> @@ -717,13 +711,13 @@ Releases all of the resources used by this . - [!NOTE] -> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. - +> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. + ]]> @@ -780,13 +774,13 @@ to release both managed and unmanaged resources; to release only unmanaged resources. Releases the unmanaged resources used by this , and optionally releases the managed resources. - [!NOTE] -> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. - +> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509ChainElement.xml b/xml/System.Security.Cryptography.X509Certificates/X509ChainElement.xml index b02b92ca6ec..8329426c5f2 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509ChainElement.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509ChainElement.xml @@ -59,11 +59,11 @@ Represents an element of an X.509 chain. - when calling the property. - + when calling the property. + ]]> @@ -117,20 +117,19 @@ Gets the X.509 certificate at a particular chain element. An object. - @@ -184,11 +183,11 @@ Gets the error status of the current X.509 certificate in a chain. An array of objects. - objects, each consisting of an error code bit and a descriptive localized error message. - + objects, each consisting of an error code bit and a descriptive localized error message. + ]]> @@ -242,20 +241,19 @@ Gets additional error information from an unmanaged certificate chain structure. A string representing the member of the unmanaged structure in the Crypto API. - diff --git a/xml/System.Security.Cryptography.X509Certificates/X509ChainElementCollection.xml b/xml/System.Security.Cryptography.X509Certificates/X509ChainElementCollection.xml index e285447ab58..459f5f81618 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509ChainElementCollection.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509ChainElementCollection.xml @@ -74,20 +74,19 @@ Represents a collection of objects. This class cannot be inherited. - property is called. - - - -## Examples - The following code example opens the current user's personal certificate store, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + property is called. + + + +## Examples + The following code example opens the current user's personal certificate store, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: + ]]> @@ -193,20 +192,19 @@ Gets the number of elements in the collection. An integer representing the number of elements in the collection. - @@ -255,11 +253,11 @@ Gets an object that can be used to navigate through a collection of chain elements. An object. - class implements , which enables you to use methods such as , and to view the contents of the collection. - + class implements , which enables you to use methods such as , and to view the contents of the collection. + ]]> @@ -308,20 +306,19 @@ Gets a value indicating whether the collection of chain elements is synchronized. Always returns . - object is not thread safe. - - - -## Examples - The following code example opens the current user's personal certificate store, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet4"::: + object is not thread safe. + + + +## Examples + The following code example opens the current user's personal certificate store, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: + ]]> @@ -373,11 +370,11 @@ Gets the object at the specified index. An object. - object in the collection. - + object in the collection. + ]]> @@ -430,11 +427,11 @@ Gets an object that can be used to synchronize access to an object. A pointer reference to the current object. - @@ -569,7 +566,7 @@ ## Remarks -This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. +This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. ]]> @@ -611,7 +608,7 @@ This member is an explicit interface member implementation. It can be used only ## Remarks -This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. +This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. ]]> @@ -664,11 +661,11 @@ This member is an explicit interface member implementation. It can be used only Gets an object that can be used to navigate a collection of chain elements. An object. - diff --git a/xml/System.Security.Cryptography.X509Certificates/X509ChainPolicy.xml b/xml/System.Security.Cryptography.X509Certificates/X509ChainPolicy.xml index e7061ca6ef3..0a78e101a7c 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509ChainPolicy.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509ChainPolicy.xml @@ -59,20 +59,19 @@ Represents the chain policy to be applied when building an X509 certificate chain. This class cannot be inherited. - object can have an property that specifies the policy to be used in the verification process. Note that only objects can construct an object. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + object can have an property that specifies the policy to be used in the verification process. Note that only objects can construct an object. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet1"::: + ]]> @@ -167,24 +166,22 @@ Gets a collection of object identifiers (OIDs) specifying which application policies or enhanced key usages (EKUs) the certificate must support. An object. - @@ -238,18 +235,17 @@ Gets a collection of object identifiers (OIDs) specifying which certificate policies the certificate must support. An object. - @@ -284,9 +280,9 @@ A new chain policy instance that has the same settings as this instance. To be added. - on an element in , have an effect on both chain policy instances. @@ -417,11 +413,11 @@ The collection is respected only when Gets an object that represents an additional collection of certificates that can be searched by the chaining engine when validating a certificate chain. An object. - @@ -469,11 +465,11 @@ The collection is respected only when Resets the members to their default values. - @@ -527,20 +523,19 @@ The collection is respected only when Gets or sets values for X509 revocation flags. An object. - enumeration. is the default value. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: + enumeration. is the default value. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> The value supplied is not a valid flag. @@ -595,20 +590,19 @@ The collection is respected only when Gets or sets values for X509 certificate revocation mode. An object. - enumeration. is the default value. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: + enumeration. is the default value. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> The value supplied is not a valid flag. @@ -707,11 +701,11 @@ When Gets or sets the maximum amount of time to be spent during online revocation verification or downloading the certificate revocation list (CRL). A value of means there are no limits. A object. - @@ -765,20 +759,19 @@ When Gets verification flags for the certificate. A value from the enumeration. - enumeration. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: + enumeration. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> The value supplied is not a valid flag. is the default value. @@ -837,26 +830,25 @@ When Gets or sets the time for which the chain is to be validated. A object. - property. -This property is important when validating signed messages, since the signature must have been valid at the time of signing, not at the time of validation. -Every certificate in the chain must have a time no later than this property's value and a - time no earlier than this property's value. Otherwise, the flag is asserted. + property. +This property is important when validating signed messages, since the signature must have been valid at the time of signing, not at the time of validation. +Every certificate in the chain must have a time no later than this property's value and a + time no earlier than this property's value. Otherwise, the flag is asserted. On Windows, this property may also be used to determine the revocation status of a certificate. The parameterless constructor for the class sets the property to the time the constructor is called. -Calling the method replaces the value of with the current system time, +Calling the method replaces the value of with the current system time, not with the time that the object was constructed. ## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509ChainStatus.xml b/xml/System.Security.Cryptography.X509Certificates/X509ChainStatus.xml index 79a41ab6489..7bdc8f2a52d 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509ChainStatus.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509ChainStatus.xml @@ -59,20 +59,19 @@ Provides a simple structure for storing X509 chain status and error information. - property. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. -## Remarks - This structure is used in conjunction with the property. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> @@ -134,20 +133,19 @@ Specifies the status of the X509 chain. An value. - @@ -201,20 +199,19 @@ Specifies a description of the value. A localizable string. - enumeration. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet4"::: + enumeration. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.xml b/xml/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.xml index b74159d04f3..fc6c43a6b43 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.xml @@ -59,20 +59,19 @@ Defines the collection of object identifiers (OIDs) that indicates the applications that use the key. This class cannot be inherited. - class to display the information. -## Remarks - An enhanced key usage (EKU) extension is a collection of object identifiers (OIDs) that indicate the applications that use the key. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -127,20 +126,19 @@ Initializes a new instance of the class. - class. After the instance has been created, you can then use the property to obtain the collection of object identifiers (OIDs) that indicate the applications that use the key. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class. After the instance has been created, you can then use the property to obtain the collection of object identifiers (OIDs) that indicate the applications that use the key. + + + +## Examples + The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -191,11 +189,11 @@ if the extension is critical; otherwise, . Initializes a new instance of the class using an object and a value that identifies whether the extension is critical. - object. - + object. + ]]> @@ -340,15 +338,14 @@ Gets the collection of object identifiers (OIDs) that indicate the applications that use the key. An object indicating the applications that use the key. - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Extension.xml b/xml/System.Security.Cryptography.X509Certificates/X509Extension.xml index 9d389e29234..cd1a0490e44 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Extension.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Extension.xml @@ -59,32 +59,31 @@ Represents an X509 extension. - class can be used to create extensions that are associated with a certificate but are not part of a certificate as issued by a certification authority (CA). + + In its most basic form, an X509 extension has an object identifier (OID), a Boolean value describing whether the extension is considered critical or not, and ASN-encoded data. Custom extensions can be registered in a file. + + The.NET Framework includes implementations of several common X509 extensions: + +- . Describes the key usages of a certificate. + +- . Describes the constraints for a certificate. + +- . Describes the enhanced key usages of a certificate. + +- . Describes the key identifier. For example, used with XMLDSIG. + + + +## Examples + The following code example demonstrates using the class. -## Remarks - X509 extensions are dynamic, extended properties that can be added to an X509 certificate and changed. The class can be used to create extensions that are associated with a certificate but are not part of a certificate as issued by a certification authority (CA). - - In its most basic form, an X509 extension has an object identifier (OID), a Boolean value describing whether the extension is considered critical or not, and ASN-encoded data. Custom extensions can be registered in a file. - - The.NET Framework includes implementations of several common X509 extensions: - -- . Describes the key usages of a certificate. - -- . Describes the constraints for a certificate. - -- . Describes the enhanced key usages of a certificate. - -- . Describes the key identifier. For example, used with XMLDSIG. - - - -## Examples - The following code example demonstrates using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -145,20 +144,19 @@ Initializes a new instance of the class. - object, unlike the other constructors for this class that use certificate information from either a byte array, a pointer or a certificate file to create the object. - - - -## Examples - The following code example demonstrates using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + object, unlike the other constructors for this class that use certificate information from either a byte array, a pointer or a certificate file to create the object. + + + +## Examples + The following code example demonstrates using the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -209,20 +207,19 @@ if the extension is critical; otherwise . Initializes a new instance of the class. - object. - - - -## Examples - The following code example demonstrates using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + object. + + + +## Examples + The following code example demonstrates using the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -275,20 +272,19 @@ if the extension is critical; otherwise . Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -389,20 +385,19 @@ if the extension is critical; otherwise . Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -497,20 +492,19 @@ The to be copied. Copies the extension properties of the specified object. - and add them to the instance of the class from which this method is called. - - - -## Examples - The following code example demonstrates using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + and add them to the instance of the class from which this method is called. + + + +## Examples + The following code example demonstrates using the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -573,20 +567,19 @@ if the extension is critical; otherwise, . - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509FindType.xml b/xml/System.Security.Cryptography.X509Certificates/X509FindType.xml index d154e6a5e72..57887bf1c24 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509FindType.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509FindType.xml @@ -52,22 +52,21 @@ Specifies the type of value the method searches for. - identifies the type of value provided in the `findValue` parameter for the method. You can use to search an collection by subject name, thumbprint, serial number, valid date range, or other value. + + You can use a combination of `FindByTime` value types to find certificates that are valid in a given time range. The union of certificates returned using FindByTimeValid, FindByTimeNotYetValid, and FindByTimeExpired for a given time represents all certificates in the queried collection. + + + +## Examples + The following example opens the current user's personal certificate store, finds only valid certificates, allows the user to select a certificate, and then writes certificate information to the console. The output depends on the certificate you select. -## Remarks - identifies the type of value provided in the `findValue` parameter for the method. You can use to search an collection by subject name, thumbprint, serial number, valid date range, or other value. - - You can use a combination of `FindByTime` value types to find certificates that are valid in a given time range. The union of certificates returned using FindByTimeValid, FindByTimeNotYetValid, and FindByTimeExpired for a given time represents all certificates in the queried collection. - - - -## Examples - The following example opens the current user's personal certificate store, finds only valid certificates, allows the user to select a certificate, and then writes certificate information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.xml b/xml/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.xml index ad2cd0c2eb3..604b9453333 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.xml @@ -59,20 +59,19 @@ Defines the usage of a key contained within an X.509 certificate. This class cannot be inherited. - class uses the flags in the enumeration to define or determine key usage. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class uses the flags in the enumeration to define or determine key usage. + + + +## Examples + The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -127,15 +126,14 @@ Initializes a new instance of the class. - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -186,11 +184,11 @@ if the extension is critical; otherwise, . Initializes a new instance of the class using an object and a value that identifies whether the extension is critical. - object. - + object. + ]]> @@ -334,11 +332,11 @@ Gets the key usage flag associated with the certificate. One of the values. - enumeration that indicates how to use the certificate key. - + enumeration that indicates how to use the certificate key. + ]]> The extension cannot be decoded. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509NameType.xml b/xml/System.Security.Cryptography.X509Certificates/X509NameType.xml index 5946f4619bc..b48ff4f3319 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509NameType.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509NameType.xml @@ -52,20 +52,19 @@ Specifies the type of name the X509 certificate contains. - . + + + +## Examples + The following example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. -## Remarks - The name type can be a simple name, an email address, a User Principal Name (UPN), a Domain Name System (DNS) name or a URL. An X509 certificate can have one or more of these names. You can obtain the name of a certificate using the method . - - - -## Examples - The following example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509RevocationFlag.xml b/xml/System.Security.Cryptography.X509Certificates/X509RevocationFlag.xml index e1e378051fe..581488a95f2 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509RevocationFlag.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509RevocationFlag.xml @@ -52,20 +52,19 @@ Specifies which X509 certificates in the chain should be checked for revocation. - diff --git a/xml/System.Security.Cryptography.X509Certificates/X509RevocationMode.xml b/xml/System.Security.Cryptography.X509Certificates/X509RevocationMode.xml index 276d4473fc6..2ed709fd374 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509RevocationMode.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509RevocationMode.xml @@ -52,23 +52,22 @@ Specifies the mode used to check for X509 certificate revocation. - [!NOTE] -> Specifying an online check can result in a long delay while the certificate authority is contacted. - - +> Specifying an online check can result in a long delay while the certificate authority is contacted. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509SelectionFlag.xml b/xml/System.Security.Cryptography.X509Certificates/X509SelectionFlag.xml index 1eaf69bfa1d..cb9f4460cf5 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509SelectionFlag.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509SelectionFlag.xml @@ -27,20 +27,19 @@ Specifies the type of selection requested using the method. - method. + + + +## Examples + The following code example demonstrates how to use the selection flag with the method. This code example is part of a larger example provided for the class. The larger example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. -## Remarks - This flag represents either a single or multiple certificate selection using the method. - - - -## Examples - The following code example demonstrates how to use the selection flag with the method. This code example is part of a larger example provided for the class. The larger example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Store.xml b/xml/System.Security.Cryptography.X509Certificates/X509Store.xml index 93dbaa1616e..948f8fadfaf 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Store.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Store.xml @@ -68,40 +68,39 @@ Represents an X.509 store, which is a physical store where certificates are persisted and managed. This class cannot be inherited. - [!IMPORTANT] -> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. -> -> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. - - - -## Examples - This section contains two examples. The first example demonstrates how you can open standard X.509 stores and list the number of certificates in each. - - The second example demonstrates how you can add and remove single certificates and ranges of certificates. - - **Example 1** - - This example tries to open each standard store in each standard location on the current computer. It prints a summary that shows whether each store exists and, if so, the number of certificates it contains. - - The example creates an object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. - +> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. +> +> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. + + + +## Examples + This section contains two examples. The first example demonstrates how you can open standard X.509 stores and list the number of certificates in each. + + The second example demonstrates how you can add and remove single certificates and ranges of certificates. + + **Example 1** + + This example tries to open each standard store in each standard location on the current computer. It prints a summary that shows whether each store exists and, if so, the number of certificates it contains. + + The example creates an object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/storenames1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: - - **Example 2** + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: + + **Example 2** + + This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -162,20 +161,19 @@ Initializes a new instance of the class using the personal certificates store of the current user. - object using the personal X.509 certificate store for the current user. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object using the personal X.509 certificate store for the current user. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -221,11 +219,11 @@ A handle to an store. Initializes a new instance of the class using an Intptr handle to an store. - The parameter is . @@ -279,20 +277,19 @@ One of the enumeration values that specifies the location of the X.509 certificate store. Initializes a new instance of the class using the personal certificate store from the specified store location value. - object, specifying the store location, which is either the location for the current user or the local computer. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object, specifying the store location, which is either the location for the current user or the local computer. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -344,20 +341,19 @@ One of the enumeration values that specifies the name of the X.509 certificate store. Initializes a new instance of the class using the specified store name from the current user's certificate stores. - . - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + . + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -411,20 +407,19 @@ The name of the certificate store. Initializes a new instance of the class using the specified store name. - object using a particular X.509 store name for the current user. To create a new store, specify a name that does not exist. A new store will be created with that name. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object using a particular X.509 store name for the current user. To create a new store, specify a name that does not exist. A new store will be created with that name. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -474,20 +469,19 @@ One of the enumeration values that specifies the location of the X.509 certificate store. Initializes a new instance of the class using the specified and values. - object, specifying both the store name and the store location. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object, specifying both the store name and the store location. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -539,20 +533,19 @@ One of the enumeration values that specifies the location of the X.509 certificate store. Initializes a new instance of the class using a specified store name and store location. - object using a store name and location. To create a new store, specify a name that does not exist. A new store will be created with that name. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object using a store name and location. To create a new store, specify a name that does not exist. A new store will be created with that name. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -690,20 +683,19 @@ The certificate to add. Adds a certificate to an X.509 certificate store. - @@ -755,20 +747,19 @@ The collection of certificates to add. Adds a collection of certificates to an X.509 certificate store. - @@ -819,35 +810,34 @@ Returns a collection of certificates located in an X.509 certificate store. A collection of certificates. - or operations performed on the store will not have any effect on the collection that is returned. This snapshot is recalculated each time the property is called, so the use of this property inside an iterative function is not recommended. - - - -## Examples - This section contains two examples. The first example demonstrates how you can open standard X.509 stores and list the number of certificates in each. - - The second example demonstrates how you can add and remove single certificates and ranges of certificates. - - **Example 1** - - This example tries to open each standard store in each standard location on the current computer. It prints a summary that shows whether each store exists and, if so, the number of certificates it contains. - - The example creates an object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. - + or operations performed on the store will not have any effect on the collection that is returned. This snapshot is recalculated each time the property is called, so the use of this property inside an iterative function is not recommended. + + + +## Examples + This section contains two examples. The first example demonstrates how you can open standard X.509 stores and list the number of certificates in each. + + The second example demonstrates how you can add and remove single certificates and ranges of certificates. + + **Example 1** + + This example tries to open each standard store in each standard location on the current computer. It prints a summary that shows whether each store exists and, if so, the number of certificates it contains. + + The example creates an object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/storenames1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: - - **Example 2** - - This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: + + **Example 2** + + This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -893,20 +883,19 @@ Closes an X.509 certificate store. - @@ -956,13 +945,13 @@ Releases the resources used by this . - [!NOTE] -> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. - +> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. + ]]> @@ -1055,35 +1044,34 @@ Gets the location of the X.509 certificate store. The location of the certificate store. - object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. - + object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/storenames1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: - - **Example 2** - - This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: + + **Example 2** + + This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -1142,35 +1130,34 @@ Gets the name of the X.509 certificate store. The name of the certificate store. - object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. - + object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/storenames1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: - - **Example 2** - - This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: + + **Example 2** + + This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -1221,20 +1208,19 @@ A bitwise combination of enumeration values that specifies the way to open the X.509 certificate store. Opens an X.509 certificate store or creates a new store, depending on flag settings. - , to enumerate the certificates in the store. You can create a new store by passing a store name that does not exist to the class constructor, and then using any of the flags except . - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + , to enumerate the certificates in the store. You can create a new store by passing a store name that does not exist to the class constructor, and then using any of the flags except . + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> The store cannot be opened as requested. @@ -1288,20 +1274,19 @@ The certificate to remove. Removes a certificate from an X.509 certificate store. - @@ -1353,24 +1338,23 @@ A range of certificates to remove. Removes a range of certificates from an X.509 certificate store. - [!IMPORTANT] -> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - - This method removes more than one certificate from an X.509 certificate store; if one certificate removal fails, the operation is reverted and no certificates are removed. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: +> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + + This method removes more than one certificate from an X.509 certificate store; if one certificate removal fails, the operation is reverted and no certificates are removed. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -1419,11 +1403,11 @@ Gets an handle to an store. A handle to an store. - property to provide compatibility with the unmanaged [Microsoft Cryptographic API (CAPI)](/windows/win32/seccrypto/cryptography-reference). - + ]]> The store is not open. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.xml b/xml/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.xml index d9a4af0a6e0..30df26d8537 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.xml @@ -59,20 +59,19 @@ Defines a string that identifies a certificate's subject key identifier (SKI). This class cannot be inherited. - class to display the information. -## Remarks - There are several ways to identify a certificate: by the hash of the certificate, by the issuer and serial number, and by the subject key identifier (SKI). The SKI provides a unique identification for the certificate's subject and is often used when working with XML digital signing. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -127,15 +126,14 @@ Initializes a new instance of the class. - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -269,11 +267,11 @@ if the extension is critical; otherwise, . Initializes a new instance of the class using encoded data and a value that identifies whether the extension is critical. - object. - + object. + ]]> @@ -372,11 +370,11 @@ if the extension is critical; otherwise, . Initializes a new instance of the class using a string and a value that identifies whether the extension is critical. - @@ -529,11 +527,11 @@ Gets a string that represents the subject key identifier (SKI) for a certificate. A string, encoded in hexadecimal format, that represents the subject key identifier (SKI). - The extension cannot be decoded. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509VerificationFlags.xml b/xml/System.Security.Cryptography.X509Certificates/X509VerificationFlags.xml index c09908a35bf..5e25f6e747a 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509VerificationFlags.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509VerificationFlags.xml @@ -58,20 +58,19 @@ Specifies conditions under which verification of certificates in the X509 chain should be conducted. - diff --git a/xml/System.Security.Cryptography.Xml/CipherData.xml b/xml/System.Security.Cryptography.Xml/CipherData.xml index 8f7b73f8f6a..a8ddb2e5492 100644 --- a/xml/System.Security.Cryptography.Xml/CipherData.xml +++ b/xml/System.Security.Cryptography.Xml/CipherData.xml @@ -53,7 +53,6 @@ ## Examples The following code example uses the class to create an `` element that contains a `` element, and then writes the XML to an XML file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/Overview/encrypteddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/VB/encrypteddata.vb" id="Snippet1"::: @@ -107,7 +106,6 @@ ## Examples The following code example shows how to create a new instance of the class. The entire sample can be found in the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/Overview/encrypteddata.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/VB/encrypteddata.vb" id="Snippet2"::: @@ -159,7 +157,6 @@ ## Examples The following code example shows how to create a new instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/encrypteddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/VB/encrypteddata.vb" id="Snippet1"::: @@ -211,7 +208,6 @@ ## Examples The following code example shows how to create a new instance of the class using information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -265,7 +261,6 @@ The `` element identifies a source that, when processed, yields ## Examples The following code example shows how to create a new instance of the class using information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -320,7 +315,6 @@ The `` element identifies a source that, when processed, yields ## Examples The following code example shows how to create a new instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/encrypteddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/VB/encrypteddata.vb" id="Snippet1"::: @@ -372,7 +366,6 @@ The `` element identifies a source that, when processed, yields ## Examples The following code example demonstrates how to create a new instance of the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/Overview/encrypteddata.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/VB/encrypteddata.vb" id="Snippet2"::: diff --git a/xml/System.Security.Cryptography.Xml/CipherReference.xml b/xml/System.Security.Cryptography.Xml/CipherReference.xml index 1f5273320a5..9190544977d 100644 --- a/xml/System.Security.Cryptography.Xml/CipherReference.xml +++ b/xml/System.Security.Cryptography.Xml/CipherReference.xml @@ -60,7 +60,6 @@ EncryptedXml exml = new EncryptedXml(doc, ev); ## Examples The following code example creates a new instance of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -122,7 +121,6 @@ EncryptedXml exml = new EncryptedXml(doc, ev); ## Examples The following code example creates a new instance of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -193,7 +191,6 @@ EncryptedXml exml = new EncryptedXml(doc, ev); ## Examples The following code example creates a new instance of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -244,7 +241,6 @@ EncryptedXml exml = new EncryptedXml(doc, ev); ## Examples The following code example creates a new instance of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -294,7 +290,6 @@ EncryptedXml exml = new EncryptedXml(doc, ev); ## Examples The following code example shows one way to use the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherReference/GetXml/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CipherReference2/VB/example.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography.Xml/DSAKeyValue.xml b/xml/System.Security.Cryptography.Xml/DSAKeyValue.xml index 7322895b601..d8b30f458d6 100644 --- a/xml/System.Security.Cryptography.Xml/DSAKeyValue.xml +++ b/xml/System.Security.Cryptography.Xml/DSAKeyValue.xml @@ -39,32 +39,30 @@ Represents the private key of the element. - class represents the `` element, which contains a public key. + + Use to identify the public key that corresponds to the private key that was used to create the digital signature. + + If a key is not explicitly supplied to the constructor, a new key pair is randomly generated. + + The class is used with XML signatures. For more information about the W3C specification, see [XML Signature Syntax and Processing Version 1.1](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example demonstrates how to use the class in XML encryption to create a detached signature. -## Remarks - The class represents the `` element, which contains a public key. - - Use to identify the public key that corresponds to the private key that was used to create the digital signature. - - If a key is not explicitly supplied to the constructor, a new key pair is randomly generated. - - The class is used with XML signatures. For more information about the W3C specification, see [XML Signature Syntax and Processing Version 1.1](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example demonstrates how to use the class in XML encryption to create a detached signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DSAKeyValue/Overview/exampledetached.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/VB/exampledetached.vb" id="Snippet1"::: - - The following code example demonstrates how to use the class in XML encryption to create an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/VB/exampledetached.vb" id="Snippet1"::: + + The following code example demonstrates how to use the class in XML encryption to create an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DSAKeyValue/Overview/exampleenvelope.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/VB/exampleenvelope.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/VB/exampleenvelope.vb" id="Snippet1"::: + ]]> @@ -116,11 +114,11 @@ Initializes a new instance of the class with a new, randomly-generated public key. - key, this constructor uses the default implementation of as defined by the class. - + key, this constructor uses the default implementation of as defined by the class. + ]]> @@ -157,19 +155,17 @@ The instance of an implementation of the class that holds the public key. Initializes a new instance of the class with the specified public key. - class in XML encryption. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp" id="Snippet2"::: + class in XML encryption. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DSAKeyValue/Overview/exampledetached.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/VB/exampledetached.vb" id="Snippet2"::: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/VB/exampledetached.vb" id="Snippet2"::: + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DSAKeyValue/Overview/exampleenvelope.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/VB/exampleenvelope.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/VB/exampleenvelope.vb" id="Snippet2"::: + ]]> @@ -207,11 +203,11 @@ Returns the XML representation of a element. The XML representation of the element. - object. - + object. + ]]> @@ -248,11 +244,11 @@ Gets or sets the key value represented by a object. The public key represented by a object. - @@ -292,11 +288,11 @@ The XML element to load the state from. Loads a state from an XML element. - object. - + object. + ]]> The parameter is . diff --git a/xml/System.Security.Cryptography.Xml/DataObject.xml b/xml/System.Security.Cryptography.Xml/DataObject.xml index e56c2de8074..828434122e3 100644 --- a/xml/System.Security.Cryptography.Xml/DataObject.xml +++ b/xml/System.Security.Cryptography.Xml/DataObject.xml @@ -39,28 +39,26 @@ Represents the object element of an XML signature that holds data to be signed. - class to store information or metadata directly in an XML signature. For example, you can store the signature generation date or the signer's identity. The class may or may not be covered by the XML signature. + + The class corresponds to the `` element in the World Wide Web Consortium (W3C) specification for XML Signatures. For more information about the W3C specification, see [https://www.w3.org/TR/xmldsig-core/](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example demonstrates how to generate an enveloping XML signature. -## Remarks - Use the class to store information or metadata directly in an XML signature. For example, you can store the signature generation date or the signer's identity. The class may or may not be covered by the XML signature. - - The class corresponds to the `` element in the World Wide Web Consortium (W3C) specification for XML Signatures. For more information about the W3C specification, see [https://www.w3.org/TR/xmldsig-core/](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example demonstrates how to generate an enveloping XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: - - The following code example demonstrates how to check an XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: + + The following code example demonstrates how to check an XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: + ]]> @@ -102,26 +100,24 @@ Initializes a new instance of the class. - class is used with XML signatures. After you have initialized the , you can assign the and properties. - - - -## Examples - The following code example demonstrates how to generate an enveloping XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp" id="Snippet1"::: + class is used with XML signatures. After you have initialized the , you can assign the and properties. + + + +## Examples + The following code example demonstrates how to generate an enveloping XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: - - The following code example demonstrates how to check an XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: + + The following code example demonstrates how to check an XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: + ]]> @@ -164,11 +160,11 @@ The data to initialize the new instance of with. Initializes a new instance of the class with the specified identification, MIME type, encoding, and data. - class is used with XML signatures. The `id` parameter refers to the name of the element that contains the data to be used. The `data` parameter refers to the XML node list that contains the `id` parameter element. - + class is used with XML signatures. The `id` parameter refers to the name of the element that contains the data to be used. The `data` parameter refers to the XML node list that contains the `id` parameter element. + ]]> The parameter is . @@ -212,26 +208,24 @@ Gets or sets the data value of the current object. The data of the current . - property. - - - -## Examples - The following code example demonstrates how to generate an enveloping XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp" id="Snippet1"::: + property. + + + +## Examples + The following code example demonstrates how to generate an enveloping XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: - - The following code example demonstrates how to check an XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: + + The following code example demonstrates how to check an XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: + ]]> The value used to set the property is . @@ -270,11 +264,11 @@ Gets or sets the encoding of the current object. The type of encoding of the current object. - @@ -312,11 +306,11 @@ Returns the XML representation of the object. The XML representation of the object. - . - + . + ]]> @@ -354,26 +348,24 @@ Gets or sets the identification of the current object. The name of the element that contains data to be used. - from another location. The default value of this property is `null`, which implies that no identification is present. This property is commonly referenced by the property. - - - -## Examples - The following code example demonstrates how to generate an enveloping XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp" id="Snippet1"::: + from another location. The default value of this property is `null`, which implies that no identification is present. This property is commonly referenced by the property. + + + +## Examples + The following code example demonstrates how to generate an enveloping XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: - - The following code example demonstrates how to check an XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: + + The following code example demonstrates how to check an XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: + ]]> @@ -413,11 +405,11 @@ The XML element to load the state from. Loads a state from an XML element. - object. - + object. + ]]> The value from the XML element is . @@ -456,11 +448,11 @@ Gets or sets the MIME type of the current object. The MIME type of the current object. The default is . - . - + . + ]]> diff --git a/xml/System.Security.Cryptography.Xml/EncryptedReference.xml b/xml/System.Security.Cryptography.Xml/EncryptedReference.xml index dea608aaa7e..0e2dad8f975 100644 --- a/xml/System.Security.Cryptography.Xml/EncryptedReference.xml +++ b/xml/System.Security.Cryptography.Xml/EncryptedReference.xml @@ -38,20 +38,19 @@ Represents the abstract base class used in XML encryption from which the , , and classes derive. - method in the class to write the XML values to the console. - - -## Examples - The following example uses the method in the class to write the XML values to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherReference/GetXml/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CipherReference2/VB/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CipherReference2/VB/example.vb" id="Snippet1"::: + ]]> @@ -92,13 +91,13 @@ Initializes a new instance of the class. - , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. - + , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. + For more information about XML encryption standards, see [XML Encryption Requirements](https://www.w3.org/TR/xml-encryption-req/). - + ]]> @@ -134,15 +133,15 @@ The Uniform Resource Identifier (URI) that points to the data to encrypt. Initializes a new instance of the class using the specified Uniform Resource Identifier (URI). - , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. - + , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. + For more information about XML encryption standards, see [XML Encryption Requirements](https://www.w3.org/TR/xml-encryption-req/). - + ]]> The parameter is . @@ -181,13 +180,13 @@ A object that describes transforms to be done on the data to encrypt. Initializes a new instance of the class using the specified Uniform Resource Identifier (URI) and transform chain. - , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. - + , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. + For more information about XML encryption standards, see [XML Encryption Requirements](https://www.w3.org/TR/xml-encryption-req/). - + ]]> The parameter is . @@ -271,11 +270,11 @@ if the cache is valid; otherwise, . - @@ -312,20 +311,19 @@ Returns the XML representation of an object. An object that represents the values of the element in XML encryption. - object. - - - -## Examples - The following example uses the method in the class to write the XML values to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp" id="Snippet1"::: + object. + + + +## Examples + The following example uses the method in the class to write the XML values to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherReference/GetXml/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CipherReference2/VB/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CipherReference2/VB/example.vb" id="Snippet1"::: + ]]> The property is . @@ -416,11 +414,11 @@ Gets or sets a reference type. The reference type of the encrypted data. - , , and derived classes. For example, a object sets this property value to . - + , , and derived classes. For example, a object sets this property value to . + ]]> @@ -495,11 +493,11 @@ Gets or sets the Uniform Resource Identifier (URI) of an object. The Uniform Resource Identifier (URI) of the object. - The property was set to . diff --git a/xml/System.Security.Cryptography.Xml/EncryptedXml.xml b/xml/System.Security.Cryptography.Xml/EncryptedXml.xml index 31336465823..de4c7814b28 100644 --- a/xml/System.Security.Cryptography.Xml/EncryptedXml.xml +++ b/xml/System.Security.Cryptography.Xml/EncryptedXml.xml @@ -64,31 +64,26 @@ ## Examples The following code example demonstrates how to create a simple utility class that uses the algorithm to encrypt an XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -109,25 +104,21 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -182,25 +173,21 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -259,13 +246,11 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -381,7 +366,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/AddKeyNameMapping/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/VB/sample.vb" id="Snippet1"::: @@ -484,7 +468,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -555,13 +538,11 @@ ## Examples The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -862,13 +843,11 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/AddKeyNameMapping/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -937,7 +916,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -1010,7 +988,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/AddKeyNameMapping/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/VB/sample.vb" id="Snippet1"::: @@ -1041,19 +1018,16 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -1108,19 +1082,16 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -1184,7 +1155,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -1215,7 +1185,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -1328,7 +1297,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -1694,7 +1662,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -1756,7 +1723,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -1927,7 +1893,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -2014,7 +1979,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -2101,7 +2065,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -2149,7 +2112,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -2236,7 +2198,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -2362,7 +2323,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -2566,7 +2526,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography.Xml/EncryptionMethod.xml b/xml/System.Security.Cryptography.Xml/EncryptionMethod.xml index 2d1a1e84d3d..6f3f0247613 100644 --- a/xml/System.Security.Cryptography.Xml/EncryptionMethod.xml +++ b/xml/System.Security.Cryptography.Xml/EncryptionMethod.xml @@ -38,30 +38,28 @@ Encapsulates the encryption algorithm used for XML encryption. - ` tag uses a Uniform Resource Identifier (URI) to identify the encryption algorithm that must be used to decrypt XML data. The class encapsulates the `` tag defined by the World Wide Web Consortium (W3C) [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. + + Use the class to identify the encryption algorithm associated with the element or the element. + + Use one of the URI identifiers defined by the W3C [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. + + + +## Examples + The following code example demonstrates how to create a simple utility class that uses the algorithm to encrypt an XML document. -## Remarks - The `` tag uses a Uniform Resource Identifier (URI) to identify the encryption algorithm that must be used to decrypt XML data. The class encapsulates the `` tag defined by the World Wide Web Consortium (W3C) [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. - - Use the class to identify the encryption algorithm associated with the element or the element. - - Use one of the URI identifiers defined by the W3C [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. - - - -## Examples - The following code example demonstrates how to create a simple utility class that uses the algorithm to encrypt an XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/VB/sample.vb" id="Snippet1"::: - - The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/VB/sample.vb" id="Snippet1"::: + + The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: + ]]> @@ -102,11 +100,11 @@ Initializes a new instance of the class. - class without specifying the Uniform Resource Identifier (URI) of an encryption algorithm. - + class without specifying the Uniform Resource Identifier (URI) of an encryption algorithm. + ]]> @@ -143,28 +141,26 @@ The Uniform Resource Identifier (URI) that describes the algorithm represented by an instance of the class. Initializes a new instance of the class specifying an algorithm Uniform Resource Identifier (URI). - class using the URI of an encryption algorithm. - - Use one of the URI identifiers defined by the World Wide Web Consortium [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. - - - -## Examples - The following code example demonstrates how to create a simple utility class that uses the algorithm to encrypt an XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp" id="Snippet1"::: + class using the URI of an encryption algorithm. + + Use one of the URI identifiers defined by the World Wide Web Consortium [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. + + + +## Examples + The following code example demonstrates how to create a simple utility class that uses the algorithm to encrypt an XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/VB/sample.vb" id="Snippet1"::: - - The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/VB/sample.vb" id="Snippet1"::: + + The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: + ]]> @@ -201,11 +197,11 @@ Returns an object that encapsulates an instance of the class. An object that encapsulates an instance of the class. - method returns a representation of the `` element. - + method returns a representation of the `` element. + ]]> @@ -242,13 +238,13 @@ Gets or sets a Uniform Resource Identifier (URI) that describes the algorithm to use for XML encryption. A Uniform Resource Identifier (URI) that describes the algorithm to use for XML encryption. - property describes the Uniform Resource Identifier (URI) of the encryption algorithm used to encrypt data associated with either the element or the element. - - Use one of the URI identifiers defined by the World Wide Web Consortium [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. - + property describes the Uniform Resource Identifier (URI) of the encryption algorithm used to encrypt data associated with either the element or the element. + + Use one of the URI identifiers defined by the World Wide Web Consortium [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. + ]]> @@ -284,11 +280,11 @@ Gets or sets the algorithm key size used for XML encryption. The algorithm key size, in bits, used for XML encryption. - property describes the key size of the encryption algorithm used to encrypt data associated with either the element or the element. - + property describes the key size of the encryption algorithm used to encrypt data associated with either the element or the element. + ]]> The property was set to a value that was less than 0. @@ -328,11 +324,11 @@ An object to parse. Parses the specified object and configures the internal state of the object to match. - method configures the object to match the state of an object. - + method configures the object to match the state of an object. + ]]> The parameter is . diff --git a/xml/System.Security.Cryptography.Xml/IRelDecryptor.xml b/xml/System.Security.Cryptography.Xml/IRelDecryptor.xml index 7b932605d49..e09e6550607 100644 --- a/xml/System.Security.Cryptography.Xml/IRelDecryptor.xml +++ b/xml/System.Security.Cryptography.Xml/IRelDecryptor.xml @@ -30,20 +30,19 @@ Defines methods that decrypt an XrML element. - interface with the class to decrypt an XrML `` element. + + + +## Examples + The following code example shows how to validate an XML digital signature using the interface and the class. -## Remarks - Use the interface with the class to decrypt an XrML `` element. - - - -## Examples - The following code example shows how to validate an XML digital signature using the interface and the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/IRelDecryptor/Overview/sample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: + ]]> @@ -87,11 +86,11 @@ Decrypts an XrML element that is contained within a object. A object that contains a decrypted element. - method decrypts an XrML `` element and returns a plaintext stream. - + method decrypts an XrML `` element and returns a plaintext stream. + ]]> diff --git a/xml/System.Security.Cryptography.Xml/KeyInfo.xml b/xml/System.Security.Cryptography.Xml/KeyInfo.xml index eb83ffbffdc..4b171ca2779 100644 --- a/xml/System.Security.Cryptography.Xml/KeyInfo.xml +++ b/xml/System.Security.Cryptography.Xml/KeyInfo.xml @@ -43,42 +43,38 @@ Represents an XML digital signature or XML encryption element. - class represents key information in XML digital signing and encryption. - - The class enables you to imbed key-related information intended to help identify the key necessary for validating or decrypting the XML document. Multiple types of key-related information can be included within a single ; each type of key-related information has an associated class derived from . - + class represents key information in XML digital signing and encryption. + + The class enables you to imbed key-related information intended to help identify the key necessary for validating or decrypting the XML document. Multiple types of key-related information can be included within a single ; each type of key-related information has an associated class derived from . + For more information about the `` element, see the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/) or the [XML encryption specification](https://www.w3.org/TR/xmlenc-core/), which are available on the W3C website. + + + +## Examples + The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - -## Examples - The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -111,33 +107,29 @@ Initializes a new instance of the class. - object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -177,33 +169,29 @@ The to add to the object. Adds a that represents a particular type of information to the object. - object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -287,13 +275,13 @@ Returns an enumerator of the objects in the object. An enumerator of the subelements of that can be used to iterate through the collection. - @@ -334,13 +322,13 @@ Returns an enumerator of the objects of the specified type in the object. An enumerator of the subelements of that can be used to iterate through the collection. - diff --git a/xml/System.Security.Cryptography.Xml/KeyInfoEncryptedKey.xml b/xml/System.Security.Cryptography.Xml/KeyInfoEncryptedKey.xml index 79ef5ca2174..9eed0e3af9d 100644 --- a/xml/System.Security.Cryptography.Xml/KeyInfoEncryptedKey.xml +++ b/xml/System.Security.Cryptography.Xml/KeyInfoEncryptedKey.xml @@ -46,20 +46,19 @@ Wraps the class, it to be placed as a subelement of the class. - class wraps the class, which allows you to add the class as a subelement of the class. Initialize the class to an instance of the class when you need to add an encrypted session key to your encrypted XML document. + + + +## Examples + The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. -## Remarks - The class wraps the class, which allows you to add the class as a subelement of the class. Initialize the class to an instance of the class when you need to add an encrypted session key to your encrypted XML document. - - - -## Examples - The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -72,15 +71,14 @@ Initializes a new instance of the class. - @@ -112,11 +110,11 @@ Initializes a new instance of the class. - class using an instance of the class. Use the property to specify an object when you use this constructor. - + class using an instance of the class. Use the property to specify an object when you use this constructor. + ]]> @@ -152,15 +150,14 @@ An object that encapsulates an encrypted key. Initializes a new instance of the class using an object. - @@ -203,11 +200,11 @@ Gets or sets an object that encapsulates an encrypted key. An object that encapsulates an encrypted key. - class wraps the class, which allows you to add the class as a subelement of the class. Use the property to access the class contained within the class. - + class wraps the class, which allows you to add the class as a subelement of the class. Use the property to access the class contained within the class. + ]]> The property is . diff --git a/xml/System.Security.Cryptography.Xml/KeyInfoName.xml b/xml/System.Security.Cryptography.Xml/KeyInfoName.xml index f0c193a2f0a..1be6dad14d7 100644 --- a/xml/System.Security.Cryptography.Xml/KeyInfoName.xml +++ b/xml/System.Security.Cryptography.Xml/KeyInfoName.xml @@ -39,40 +39,36 @@ Represents a subelement of an XMLDSIG or XML Encryption element. - ` element contains a string identifier that the party validating or decrypting an XML document uses to identify the corresponding key. For example, if you receive an encrypted or signed XML document that has a `` element value of "AsymmetricKey1", you will use a key that you and the sender have named "AsymmetricKey1" to decrypt or verify the document. Both parties must agree on a key name mapping ahead of time. Note that the actual key is not imbedded in the XML document. + + For more information about the `` element, see Section 4.4.1 of the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/) or the [XML Encryption specification](https://www.w3.org/TR/xmlenc-core/), which are available on the W3C website. + + + +## Examples + The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. -## Remarks - The `` element contains a string identifier that the party validating or decrypting an XML document uses to identify the corresponding key. For example, if you receive an encrypted or signed XML document that has a `` element value of "AsymmetricKey1", you will use a key that you and the sender have named "AsymmetricKey1" to decrypt or verify the document. Both parties must agree on a key name mapping ahead of time. Note that the actual key is not imbedded in the XML document. - - For more information about the `` element, see Section 4.4.1 of the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/) or the [XML Encryption specification](https://www.w3.org/TR/xmlenc-core/), which are available on the W3C website. - - - -## Examples - The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -114,33 +110,29 @@ Initializes a new instance of the class. - object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -177,13 +169,13 @@ The string identifier that is the value of the element. Initializes a new instance of the class by specifying the string identifier that is the value of the element. - property. - + property. + ]]> @@ -221,11 +213,11 @@ Returns an XML representation of the object. An XML representation of the object. - object returned by this method is suitable for use as a subelement of an XMLDSIG or XML Encryption `` element. - + object returned by this method is suitable for use as a subelement of an XMLDSIG or XML Encryption `` element. + ]]> @@ -265,11 +257,11 @@ The object that specifies the state of the object. Parses the input object and configures the internal state of the object to match. - method is typically used to process a `` subelement of a `` element. - + method is typically used to process a `` subelement of a `` element. + ]]> The parameter is . @@ -308,38 +300,34 @@ Gets or sets the string identifier contained within a element. The string identifier that is the value of the element. - property can contain any string; the interpretation of the string is specific to the application. White space is significant in the string value. - - - -## Examples - The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + property can contain any string; the interpretation of the string is specific to the application. White space is significant in the string value. + + + +## Examples + The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/KeyInfoX509Data.xml b/xml/System.Security.Cryptography.Xml/KeyInfoX509Data.xml index e49f931c59d..500022e4601 100644 --- a/xml/System.Security.Cryptography.Xml/KeyInfoX509Data.xml +++ b/xml/System.Security.Cryptography.Xml/KeyInfoX509Data.xml @@ -39,32 +39,30 @@ Represents an subelement of an XMLDSIG or XML Encryption element. - class represents the `` element that contains X.509v3 certificate information related to the validation or encryption key. For example, an `` element might contain an X.509 certificate whose subject public key is the validation key, or a chain of X.509 certificates that terminate in a certificate for the validating key, or other identifiers for related X.509 certificates. + + Use the class whenever you need to include X.509 certificate data in an encrypted or signed XML document. + + For more information about the `` element, see Section 4.4.4 of the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/) or the [XML Encryption specification](https://www.w3.org/TR/xmlenc-core/), which are available on the W3C website. + + + +## Examples + This section contains two code examples. The first example demonstrates how to sign an XML file using a detached signature. The second example demonstrates how to sign an XML file using an envelope signature. + + **Example #1** -## Remarks - The class represents the `` element that contains X.509v3 certificate information related to the validation or encryption key. For example, an `` element might contain an X.509 certificate whose subject public key is the validation key, or a chain of X.509 certificates that terminate in a certificate for the validating key, or other identifiers for related X.509 certificates. - - Use the class whenever you need to include X.509 certificate data in an encrypted or signed XML document. - - For more information about the `` element, see Section 4.4.4 of the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/) or the [XML Encryption specification](https://www.w3.org/TR/xmlenc-core/), which are available on the W3C website. - - - -## Examples - This section contains two code examples. The first example demonstrates how to sign an XML file using a detached signature. The second example demonstrates how to sign an XML file using an envelope signature. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfoX509Data/Overview/examplecreatedetached.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/VB/examplecreatedetached.vb" id="Snippet1"::: - - **Example #2** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/VB/examplecreatedetached.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfoX509Data/Overview/examplecreateenvelope.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/VB/examplecreateenvelope.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/VB/examplecreateenvelope.vb" id="Snippet1"::: + ]]> @@ -174,23 +172,21 @@ The object to initialize the new instance of from. Initializes a new instance of the class from the specified X.509v3 certificate. - The parameter is . @@ -235,14 +231,14 @@ One of the values that specifies how much of the certificate chain to include. Initializes a new instance of the class from the specified X.509v3 certificate. - object while signing and verifying an XML document. - + object while signing and verifying an XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfoX509Data/.ctor/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.KeyInfoX509Data/vb/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.KeyInfoX509Data/vb/sample.vb" id="Snippet1"::: + ]]> The parameter is . @@ -324,13 +320,13 @@ The serial number portion of the pair to add to the object. Adds the specified issuer name and serial number pair to the object. - method adds information about an issuer name and serial number pair to a list of objects that are accessible through the property. - + method adds information about an issuer name and serial number pair to a list of objects that are accessible through the property. + ]]> @@ -344,11 +340,11 @@ Adds a subject key identifier (SKI) to the object. - @@ -388,11 +384,11 @@ A byte array that represents the subject key identifier (SKI) to add to the object. Adds the specified subject key identifier (SKI) byte array to the object. - @@ -437,11 +433,11 @@ A string that represents the subject key identifier (SKI) to add to the object. Adds the specified subject key identifier (SKI) string to the object. - @@ -586,11 +582,11 @@ Returns an XML representation of the object. An XML representation of the object. - object returned by this method is suitable for use as a subelement of an XMLDSIG or XML encryption `` element. - + object returned by this method is suitable for use as a subelement of an XMLDSIG or XML encryption `` element. + ]]> @@ -628,15 +624,15 @@ Gets a list of structures that represent an issuer name and serial number pair. A list of structures that represent an issuer name and serial number pair. - property represents the `` element of an XML digital signature using a list of structures contained within. The `` element represents an issuer name and serial number pair, which identify a specific X.509v3 certificate. - - The issuer of an X.509 certificate is the name of the certification authority that issued the certificate. Certification authorities assign each certificate they issue a unique serial number. - - You can add a name and serial number pair using the method. - + property represents the `` element of an XML digital signature using a list of structures contained within. The `` element represents an issuer name and serial number pair, which identify a specific X.509v3 certificate. + + The issuer of an X.509 certificate is the name of the certification authority that issued the certificate. Certification authorities assign each certificate they issue a unique serial number. + + You can add a name and serial number pair using the method. + ]]> @@ -676,18 +672,18 @@ The object that specifies the state of the object. Parses the input object and configures the internal state of the object to match. - ` subelement of a `` element. - + ` subelement of a `` element. + ]]> The parameter is . - The parameter does not contain an <> node. - - -or- - + The parameter does not contain an <> node. + + -or- + The parameter does not contain an <> node. @@ -724,11 +720,11 @@ Gets a list of the subject key identifiers (SKIs) contained in the object. A list of the subject key identifiers (SKIs) contained in the object. - @@ -766,11 +762,11 @@ Gets a list of the subject names of the entities contained in the object. A list of the subject names of the entities contained in the object. - diff --git a/xml/System.Security.Cryptography.Xml/RSAKeyValue.xml b/xml/System.Security.Cryptography.Xml/RSAKeyValue.xml index 8714fb7b2f9..b5a096e6c40 100644 --- a/xml/System.Security.Cryptography.Xml/RSAKeyValue.xml +++ b/xml/System.Security.Cryptography.Xml/RSAKeyValue.xml @@ -41,27 +41,25 @@ class represents the `` element of an XML signature defined by the XML digital signature specification. The `` element is the subelement of the `` element (represented by the class) that describes an public key. The `` element contains the public key that corresponds to the private key used to digitally sign a document. A recipient of the document uses the public key to validate the XML signature. - - Use the class whenever you want to add a public key to your XML digital signature. - - If a key is not explicitly supplied to the constructor, a new key pair is randomly generated. - - For more information about the `` element, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example demonstrates how to generate and verify an enveloped XML signature using the object. +## Remarks + The class represents the `` element of an XML signature defined by the XML digital signature specification. The `` element is the subelement of the `` element (represented by the class) that describes an public key. The `` element contains the public key that corresponds to the private key used to digitally sign a document. A recipient of the document uses the public key to validate the XML signature. + + Use the class whenever you want to add a public key to your XML digital signature. + + If a key is not explicitly supplied to the constructor, a new key pair is randomly generated. + + For more information about the `` element, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example demonstrates how to generate and verify an enveloped XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example demonstrates how to generate and verify a detached XML signature using the object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example demonstrates how to generate and verify a detached XML signature using the object. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: @@ -108,7 +106,7 @@ to hold the public key. ]]> @@ -149,16 +147,14 @@ object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: +## Examples + The following code example demonstrates how to generate and verify an enveloped XML signature using the object. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example demonstrates how to generate and verify a detached XML signature using the object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example demonstrates how to generate and verify a detached XML signature using the object. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: @@ -241,9 +237,9 @@ Based upon [The RSAKeyValue Element](https://www.w3.org/TR/2002/REC-xmldsig-core property represents the public key to add to an XML digital signature using the `` subelement and the `` subelement of the `` element. - +## Remarks + The property represents the public key to add to an XML digital signature using the `` subelement and the `` subelement of the `` element. + For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). ]]> diff --git a/xml/System.Security.Cryptography.Xml/Reference.xml b/xml/System.Security.Cryptography.Xml/Reference.xml index 6b564ff911e..8d0be3c956c 100644 --- a/xml/System.Security.Cryptography.Xml/Reference.xml +++ b/xml/System.Security.Cryptography.Xml/Reference.xml @@ -63,7 +63,6 @@ ## Examples The following code example demonstrates how to generate and verify an enveloped XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: @@ -113,13 +112,11 @@ ## Examples The following code example demonstrates how to generate and verify an enveloped XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: The following code example demonstrates how to generate and verify a detached XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: @@ -211,7 +208,6 @@ ## Examples The following code example uses the class to sign and verify an XML document using an envelope signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: @@ -268,13 +264,11 @@ ## Examples The following code example demonstrates how to generate and verify an enveloped XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: The following code example demonstrates how to generate and verify a detached XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: @@ -666,7 +660,6 @@ ## Examples The following code example demonstrates how to generate and verify an enveloped XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography.Xml/Signature.xml b/xml/System.Security.Cryptography.Xml/Signature.xml index 02c06ab7123..6edc26c53fa 100644 --- a/xml/System.Security.Cryptography.Xml/Signature.xml +++ b/xml/System.Security.Cryptography.Xml/Signature.xml @@ -39,28 +39,26 @@ Represents the element of an XML signature. - class represents the `` element of an XML signature defined by the XML digital signature specification. The `` element is the root element of an XML digital signature. The , , , and properties encapsulate the subelements of the `` element. + + For more information about the `` element, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example uses the class with the class to sign and verify an XML document using an envelope signature. -## Remarks - The class represents the `` element of an XML signature defined by the XML digital signature specification. The `` element is the root element of an XML digital signature. The , , , and properties encapsulate the subelements of the `` element. - - For more information about the `` element, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example uses the class with the class to sign and verify an XML document using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: - - The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: + + The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: + ]]> @@ -94,21 +92,19 @@ Initializes a new instance of the class. - class with the class to sign and verify an XML document using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: + class with the class to sign and verify an XML document using an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: - - The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: + + The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: + ]]> @@ -149,11 +145,11 @@ The to be added to the list of objects to be signed. Adds a to the list of objects to be signed. - method adds a object to a collection that is accessible using the property. - + method adds a object to a collection that is accessible using the property. + ]]> @@ -192,10 +188,10 @@ Returns the XML representation of the . The XML representation of the . To be added. - The property is . - - -or- - + The property is . + + -or- + The property is . @@ -239,11 +235,11 @@ Gets or sets the ID of the current . The ID of the current . The default is . - property to add a string ID to the XML representation of the current element. The ID is used to reference the from another location. - + property to add a string ID to the XML representation of the current element. The ID is used to reference the from another location. + ]]> @@ -281,28 +277,26 @@ Gets or sets the of the current . The of the current . - property uses a object to represent the `` element of an XML digital signature. - - For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example uses the class with the class to sign and verify an XML document using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: + property uses a object to represent the `` element of an XML digital signature. + + For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example uses the class with the class to sign and verify an XML document using an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: - - The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: + + The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: + ]]> @@ -354,10 +348,10 @@ Loads a state from an XML element. To be added. The parameter is . - The parameter does not contain a valid . - - -or- - + The parameter does not contain a valid . + + -or- + The parameter does not contain a valid . @@ -394,15 +388,15 @@ Gets or sets a list of objects to be signed. A list of objects to be signed. - property uses a collection of objects to represent the `` tag of an XML digital signature. - - You can also add a to this collection using the method. - - For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - + property uses a collection of objects to represent the `` tag of an XML digital signature. + + You can also add a to this collection using the method. + + For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + ]]> @@ -447,13 +441,13 @@ Gets or sets the value of the digital signature. A byte array that contains the value of the digital signature. - property uses a byte array to represent the `` element of an XML digital signature contained within. - - For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - + property uses a byte array to represent the `` element of an XML digital signature contained within. + + For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + ]]> @@ -498,28 +492,26 @@ Gets or sets the of the current . The of the current . - property uses the class to represent the `` element of an XML digital signature contained within. - - For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example uses the class with the class to sign and verify an XML document using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: + property uses the class to represent the `` element of an XML digital signature contained within. + + For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example uses the class with the class to sign and verify an XML document using an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: - - The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: + + The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/SignedXml.xml b/xml/System.Security.Cryptography.Xml/SignedXml.xml index 2295e750831..2a998b6108f 100644 --- a/xml/System.Security.Cryptography.Xml/SignedXml.xml +++ b/xml/System.Security.Cryptography.Xml/SignedXml.xml @@ -43,13 +43,11 @@ @@ -109,19 +107,16 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a single element of an XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/VB/sample.vb" id="Snippet1"::: @@ -176,19 +171,16 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a single element of an XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/VB/sample.vb" id="Snippet1"::: @@ -295,7 +287,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example computes and XML signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/AddObject/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/VB/example.vb" id="Snippet1"::: @@ -352,19 +343,16 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a single element of an XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/VB/sample.vb" id="Snippet1"::: @@ -427,19 +415,16 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/exampleenvelope.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/VB/exampleenvelope.vb" id="Snippet1"::: The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/exampledetached.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/VB/exampledetached.vb" id="Snippet1"::: The following code example shows how to sign and verify a single element of an XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/VB/sample.vb" id="Snippet1"::: @@ -498,13 +483,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/exampledetached.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/VB/exampledetached.vb" id="Snippet1"::: The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/exampleenvelope.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/VB/exampleenvelope.vb" id="Snippet1"::: @@ -564,13 +547,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/xmldsigdetachedkeyedhashalg.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/VB/xmldsigdetachedkeyedhashalg.vb" id="Snippet1"::: The following code example shows how to sign and verify an entire XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/xmldsigenvkeyedhashalg.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/VB/xmldsigenvkeyedhashalg.vb" id="Snippet1"::: @@ -705,7 +686,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignatureReturningKey/exampleenvelope.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/VB/exampleenvelope.vb" id="Snippet1"::: @@ -782,13 +762,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: The following code example shows how to sign and verify an entire XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: @@ -852,13 +830,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/xmldsigdetachedkeyedhashalg.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/VB/xmldsigdetachedkeyedhashalg.vb" id="Snippet1"::: The following code example shows how to sign and verify an entire XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/xmldsigenvkeyedhashalg.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/VB/xmldsigenvkeyedhashalg.vb" id="Snippet1"::: @@ -1103,13 +1079,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: The following code example uses the object when signing an XML document. This example saves the signature in a new file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: @@ -1167,7 +1141,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to use the method to verify an XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet3"::: @@ -1389,13 +1362,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example uses the property to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: The following code example uses the property to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: @@ -1695,19 +1666,16 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/exampleenvelope.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/VB/exampleenvelope.vb" id="Snippet1"::: The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/exampledetached.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/VB/exampledetached.vb" id="Snippet1"::: The following code example shows how to sign and verify a single element of an XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/VB/sample.vb" id="Snippet1"::: @@ -1845,7 +1813,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example demonstrates how to use members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet2"::: @@ -1901,7 +1868,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example demonstrates how to call members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet2"::: @@ -2142,7 +2108,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example demonstrates how to use members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet2"::: @@ -2196,7 +2161,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an XML document using the class. This sample creates an envelope signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigExcC14NTransformUrl/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/VB/example.vb" id="Snippet1"::: @@ -2250,7 +2214,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an XML document using the class. This sample creates an envelope signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigExcC14NWithCommentsTransformUrl/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/VB/sample.vb" id="Snippet1"::: @@ -2835,7 +2798,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example demonstrates how to use members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet2"::: diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigBase64Transform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigBase64Transform.xml index 47efb851fbb..8a93344fca1 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigBase64Transform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigBase64Transform.xml @@ -39,24 +39,23 @@ Represents the decoding transform as defined in Section 6.6.2 of the XMLDSIG specification. - object when you need to sign the raw data associated with the encoded content of an element. - - The Uniform Resource Identifier (URI) that describes the object is defined by the field. - - For more information about the `Base64` decoding transform, see Section 6.6.2 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example demonstrates how to use members of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet2"::: + object when you need to sign the raw data associated with the encoded content of an element. + + The Uniform Resource Identifier (URI) that describes the object is defined by the field. + + For more information about the `Base64` decoding transform, see Section 6.6.2 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example demonstrates how to use members of the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet2"::: + ]]> @@ -89,15 +88,14 @@ Initializes a new instance of the class. - constructor. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet1"::: + constructor. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet1"::: + ]]> @@ -180,20 +178,19 @@ Returns the output of the current object. The output of the current object. - . - - - -## Examples - The following code example demonstrates the use of the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet7"::: + . + + + +## Examples + The following code example demonstrates the use of the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet7"::: + ]]> @@ -234,20 +231,19 @@ Returns the output of the current object of type . The output of the current object of type . - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet8"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet8"::: + ]]> The parameter is not a object. @@ -285,20 +281,19 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - are , , and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet4"::: + are , , and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet4"::: + ]]> @@ -338,11 +333,11 @@ An object to load into the current object. Parses the specified object as transform-specific content of a element; this method is not supported because the object has no inner XML elements. - object has no inner XML elements. - + object has no inner XML elements. + ]]> @@ -382,20 +377,19 @@ The input to load into the current object. Loads the specified input into the current object. - property. - - - -## Examples - The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet11"::: + property. + + + +## Examples + The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet11"::: + ]]> The parameter is a and it is . @@ -433,20 +427,19 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; only objects of one of these types are returned from the methods of the current object. - is the only valid output type for object. - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet5"::: + is the only valid output type for object. + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigC14NTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigC14NTransform.xml index a9285019cab..0c8b1aa7973 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigC14NTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigC14NTransform.xml @@ -39,38 +39,36 @@ Represents the C14N XML canonicalization transform for a digital signature as defined by the World Wide Web Consortium (W3C), without comments. - class represents the C14N XML canonicalization transform that describes the canonical form of an XML document. This transform allows a signer to create a digest (used to create a digital signature) using the canonical form of an XML document. A recipient can then verify the XML digital signature using the same canonical form of the XML document with the same transform. + + Use the class when you need to sign an XML document that does not contain comments. + + In most cases, a new instance of a canonicalization transform class is not required. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. + + The URI that describes the class is defined by the field and the field. + + You would only need to create a new instance of a canonicalization transform class for manually hashing an XML document or for using your own canonicalization algorithm. + + For more information about the C14N transform, see Sections 6.5 and 6.6.1 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/TR/xml-c14n). + + + +## Examples + This section contains two code examples. The first example demonstrates how to sign non-XML data using a detached signature. Example #1 creates a signature of `www.microsoft.com` in an XML file and then verifies the file. The second example demonstrates how to call members of the class. + + **Example #1** -## Remarks - The class represents the C14N XML canonicalization transform that describes the canonical form of an XML document. This transform allows a signer to create a digest (used to create a digital signature) using the canonical form of an XML document. A recipient can then verify the XML digital signature using the same canonical form of the XML document with the same transform. - - Use the class when you need to sign an XML document that does not contain comments. - - In most cases, a new instance of a canonicalization transform class is not required. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. - - The URI that describes the class is defined by the field and the field. - - You would only need to create a new instance of a canonicalization transform class for manually hashing an XML document or for using your own canonicalization algorithm. - - For more information about the C14N transform, see Sections 6.5 and 6.6.1 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/TR/xml-c14n). - - - -## Examples - This section contains two code examples. The first example demonstrates how to sign non-XML data using a detached signature. Example #1 creates a signature of `www.microsoft.com` in an XML file and then verifies the file. The second example demonstrates how to call members of the class. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - **Example #2** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet2"::: + ]]> @@ -112,15 +110,14 @@ Initializes a new instance of the class. - constructor. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet3"::: + constructor. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet3"::: + ]]> @@ -158,15 +155,14 @@ to include comments; otherwise, . Initializes a new instance of the class with comments, if specified. - constructor. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet1"::: + constructor. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet1"::: + ]]> @@ -292,20 +288,19 @@ Returns the output of the current object. The output of the current object. - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet8"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet8"::: + ]]> @@ -346,20 +341,19 @@ Returns the output of the current object of type . The output of the current object of type . - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet9"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet9"::: + ]]> The parameter is not a object. @@ -397,20 +391,19 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - are , , and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet5"::: + are , , and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet5"::: + ]]> @@ -450,11 +443,11 @@ An object to load into the current object. Parses the specified object as transform-specific content of a element; this method is not supported because this element has no inner XML elements. - object has no inner XML elements. - + object has no inner XML elements. + ]]> @@ -494,20 +487,19 @@ The input to load into the current object. Loads the specified input into the current object. - property. - - - -## Examples - The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet12"::: + property. + + + +## Examples + The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet12"::: + ]]> The parameter is a object and it is . @@ -545,20 +537,19 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; the methods of the current object return only objects of one of these types. - is the only valid output type for . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet6"::: + is the only valid output type for . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet6"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform.xml index f8eb1988d24..90aa02fec8e 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform.xml @@ -33,38 +33,36 @@ Represents the C14N XML canonicalization transform for a digital signature as defined by the World Wide Web Consortium (W3C), with comments. - class represents the C14N XML canonicalization transform that describes the canonical form of an XML document. This transform allows a signer to create a digest using the canonical form of an XML document. A recipient can then verify the digital signature using the same canonical form of the XML document with the same transform. + + Use the class when you need to sign an XML document that contains comments. + + Note that you cannot directly create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. + + The URI that describes the class is defined by the field. + + The URI that describes the class is defined by the field and the field. + + For more information about the C14N with comments transform, see Sections 6.5 and 6.6.1 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/TR/xml-c14n). + + + +## Examples + This section contains two code examples. The first example demonstrates how to sign an XML file using a detached signature. This example creates a signature of `www.microsoft.com` in an XML file and then verifies the file. The second example demonstrates how to sign an XML file using an envelope signature. This example creates a signature of an XML file and then saves the signature in new XML file. + + **Example #1** -## Remarks - The class represents the C14N XML canonicalization transform that describes the canonical form of an XML document. This transform allows a signer to create a digest using the canonical form of an XML document. A recipient can then verify the digital signature using the same canonical form of the XML document with the same transform. - - Use the class when you need to sign an XML document that contains comments. - - Note that you cannot directly create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. - - The URI that describes the class is defined by the field. - - The URI that describes the class is defined by the field and the field. - - For more information about the C14N with comments transform, see Sections 6.5 and 6.6.1 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/TR/xml-c14n). - - - -## Examples - This section contains two code examples. The first example demonstrates how to sign an XML file using a detached signature. This example creates a signature of `www.microsoft.com` in an XML file and then verifies the file. The second example demonstrates how to sign an XML file using an envelope signature. This example creates a signature of an XML file and then saves the signature in new XML file. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform/Overview/sampledetached.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/VB/sampledetached.vb" id="Snippet1"::: - - **Example #2** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/VB/sampledetached.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform/Overview/sampleenvelope.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/VB/sampleenvelope.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/VB/sampleenvelope.vb" id="Snippet1"::: + ]]> @@ -97,23 +95,21 @@ Initializes a new instance of the class. - diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransform.xml index 04e0f1d2913..1add160367b 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransform.xml @@ -39,34 +39,32 @@ Represents the enveloped signature transform for an XML digital signature as defined by the W3C. - class removes the `` element from an XML document before the digest is computed. With this transform, you can sign and verify all elements of an XML document except the XML digital signature elements. + + Although you can create and insert a signature into an XML document, verifying the modified document using the embedded signature will fail because the document now has additional elements. This transform removes the `` element and allows you to verify the document using its original form. + + Use the class whenever you create an enveloped signature. + + For more information about the enveloped signature transform, see Section 6.6.4 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + This section contains two code examples. The first example demonstrates how to sign an XML file using an envelope signature. The second example demonstrates how to use members of the class. + + **Example #1** -## Remarks - The class removes the `` element from an XML document before the digest is computed. With this transform, you can sign and verify all elements of an XML document except the XML digital signature elements. - - Although you can create and insert a signature into an XML document, verifying the modified document using the embedded signature will fail because the document now has additional elements. This transform removes the `` element and allows you to verify the document using its original form. - - Use the class whenever you create an enveloped signature. - - For more information about the enveloped signature transform, see Section 6.6.4 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - This section contains two code examples. The first example demonstrates how to sign an XML file using an envelope signature. The second example demonstrates how to use members of the class. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - **Example #2** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet2"::: + ]]> @@ -108,15 +106,14 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet2"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet2"::: + ]]> @@ -154,15 +151,14 @@ to include comments; otherwise, . Initializes a new instance of the class with comments, if specified. - constructor with a value of `true` to include comments. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet3"::: + constructor with a value of `true` to include comments. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet3"::: + ]]> @@ -245,20 +241,19 @@ Returns the output of the current object. The output of the current object. - . - - - -## Examples - The following code example demonstrates how to use the method. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet8"::: + . + + + +## Examples + The following code example demonstrates how to use the method. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet8"::: + ]]> The containing XML document is . @@ -300,20 +295,19 @@ Returns the output of the current object of type . The output of the current object of type . - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet9"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet9"::: + ]]> The parameter is not an object. @@ -351,20 +345,19 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - are , , and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet5"::: + are , , and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet5"::: + ]]> @@ -404,20 +397,19 @@ An to load into the current object. Parses the specified as transform-specific content of a element and configures the internal state of the current object to match the element. - , a call to this method does not change the state of the transform. - - - -## Examples - The following code example demonstrates how to call the method using the specified object to configure the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet11"::: + , a call to this method does not change the state of the transform. + + + +## Examples + The following code example demonstrates how to call the method using the specified object to configure the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet11"::: + ]]> @@ -457,20 +449,19 @@ The input to load into the current object. Loads the specified input into the current object. - property. - - - -## Examples - The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet12"::: + property. + + + +## Examples + The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet12"::: + ]]> The parameter is . @@ -509,20 +500,19 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; only objects of one of these types are returned from the methods of the current object. - are and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet6"::: + are and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet6"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.xml index 0afbe64e6c0..d9545b9b92e 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.xml @@ -38,32 +38,31 @@ Represents the exclusive C14N XML canonicalization transform for a digital signature as defined by the World Wide Web Consortium (W3C), without comments. - class represents the exclusive C14N XML canonicalization transform without comments. This class is similar to the class, which allows a signer to create a digest using the canonical form of an XML document. However, the class excludes ancestor context from a canonicalized subdocument. + + Use the class when you need to canonicalize an XML subdocument so that it is independent from its XML context. For example, applications such as Web services that use signed XML within complex communication protocols often need to canonicalize XML in this manner. Such applications often envelop XML within various dynamically constructed elements, which can substantially change the document and cause XML signature verification to fail. The class solves this problem by excluding such ancestor context from the canonical subdocument. + + Typically, you do not create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes a transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. + + You are required to create a new instance of a canonicalization transform class only when you want to manually hash an XML document or use your own canonicalization algorithm. + + The URI that describes the class is defined by the field. + + The URI that describes the class is defined by the field. + + For more information about the exclusive C14N transform, see the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/2001/10/xml-exc-c14n). + + + +## Examples + The following code example shows how to sign an XML document with the class using an envelope signature. -## Remarks - The class represents the exclusive C14N XML canonicalization transform without comments. This class is similar to the class, which allows a signer to create a digest using the canonical form of an XML document. However, the class excludes ancestor context from a canonicalized subdocument. - - Use the class when you need to canonicalize an XML subdocument so that it is independent from its XML context. For example, applications such as Web services that use signed XML within complex communication protocols often need to canonicalize XML in this manner. Such applications often envelop XML within various dynamically constructed elements, which can substantially change the document and cause XML signature verification to fail. The class solves this problem by excluding such ancestor context from the canonical subdocument. - - Typically, you do not create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes a transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. - - You are required to create a new instance of a canonicalization transform class only when you want to manually hash an XML document or use your own canonicalization algorithm. - - The URI that describes the class is defined by the field. - - The URI that describes the class is defined by the field. - - For more information about the exclusive C14N transform, see the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/2001/10/xml-exc-c14n). - - - -## Examples - The following code example shows how to sign an XML document with the class using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigExcC14NTransformUrl/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/VB/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/VB/example.vb" id="Snippet1"::: + ]]> @@ -171,11 +170,11 @@ The namespace prefixes to canonicalize using the standard canonicalization algorithm. Initializes a new instance of the class specifying a list of namespace prefixes to canonicalize using the standard canonicalization algorithm. - @@ -215,11 +214,11 @@ The namespace prefixes to canonicalize using the standard canonicalization algorithm. Initializes a new instance of the class specifying whether to include comments, and specifying a list of namespace prefixes. - @@ -374,19 +373,19 @@ Returns the output of the current object as an object of the specified type. The output of the current object as an object of the specified type. - method returns the output of the current transform after it is run on the value previously set by a call to the method. - - The type of the returned object must be one of the type objects in the property. - + method returns the output of the current transform after it is run on the value previously set by a call to the method. + + The type of the returned object must be one of the type objects in the property. + ]]> - The parameter is not a object. - - -or- - + The parameter is not a object. + + -or- + The parameter does not derive from a object. @@ -428,20 +427,19 @@ Gets or sets a string that contains namespace prefixes to canonicalize using the standard canonicalization algorithm. A string that contains namespace prefixes to canonicalize using the standard canonicalization algorithm. - property contains a white-space delimited list of namespace prefixes to canonicalize using the standard canonicalization algorithm rather than the exclusive canonicalization algorithm. To specify the default namespace, which does not have a prefix, pass the special prefix "#default". - - - -## Examples - The following code example shows how to sign an XML document with the class using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp" id="Snippet1"::: + property contains a white-space delimited list of namespace prefixes to canonicalize using the standard canonicalization algorithm rather than the exclusive canonicalization algorithm. To specify the default namespace, which does not have a prefix, pass the special prefix "#default". + + + +## Examples + The following code example shows how to sign an XML document with the class using an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigExcC14NTransformUrl/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/VB/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/VB/example.vb" id="Snippet1"::: + ]]> @@ -477,13 +475,13 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - property must contain at least one element because every object must accept at least one type as valid input. - - A object typically accepts one or more of the following types as input: , , or . - + property must contain at least one element because every object must accept at least one type as valid input. + + A object typically accepts one or more of the following types as input: , , or . + ]]> @@ -522,11 +520,11 @@ An object that specifies transform-specific content for the current object. Parses the specified object as transform-specific content of a element and configures the internal state of the current object to match the element. - ` element. - + ` element. + ]]> @@ -565,21 +563,21 @@ The input to load into the current object. When overridden in a derived class, loads the specified input into the current object. - property. - + property. + ]]> - The parameter is not a object. - - -or- - - The parameter is not an object. - - -or- - + The parameter is not a object. + + -or- + + The parameter is not an object. + + -or- + The parameter is not an object. @@ -614,11 +612,11 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; the methods of the current object return only objects of one of these types. - property must contain at least one element because every transform must generate at least one type as output. - + property must contain at least one element because every transform must generate at least one type as output. + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransform.xml index f822414059f..af6326dd634 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransform.xml @@ -32,28 +32,27 @@ Represents the exclusive C14N XML canonicalization transform for a digital signature as defined by the World Wide Web Consortium (W3C), with comments. - class represents the exclusive C14N XML canonicalization transform with comments. This class is similar to the class, which allows a signer to create a digest using the canonical form of an XML document. However, the class excludes ancestor context from a canonicalized subdocument. + + Use the class when you need to canonicalize an XML subdocument so that it is independent from its XML context. For example, applications such as Web services that use signed XML within complex communication protocols often need to canonicalize XML in this manner. Such applications often envelop XML within various dynamically constructed elements, which can substantially change the document and cause XML signature verification to fail. The class solves this problem by excluding such ancestor context from the canonical subdocument. + + Note that you cannot directly create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. + + The URI that describes the class is defined by the field. + + For more information about the exclusive C14N transform, see the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/), which is available from the W3C website. The canonicalization algorithm is defined in the [W3C Canonical XML specification](https://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/). + + + +## Examples + The following code example shows how to sign and verify an XML document using the class. This example creates an envelope signature. -## Remarks - The class represents the exclusive C14N XML canonicalization transform with comments. This class is similar to the class, which allows a signer to create a digest using the canonical form of an XML document. However, the class excludes ancestor context from a canonicalized subdocument. - - Use the class when you need to canonicalize an XML subdocument so that it is independent from its XML context. For example, applications such as Web services that use signed XML within complex communication protocols often need to canonicalize XML in this manner. Such applications often envelop XML within various dynamically constructed elements, which can substantially change the document and cause XML signature verification to fail. The class solves this problem by excluding such ancestor context from the canonical subdocument. - - Note that you cannot directly create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. - - The URI that describes the class is defined by the field. - - For more information about the exclusive C14N transform, see the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/), which is available from the W3C website. The canonicalization algorithm is defined in the [W3C Canonical XML specification](https://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/). - - - -## Examples - The following code example shows how to sign and verify an XML document using the class. This example creates an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigExcC14NWithCommentsTransformUrl/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/VB/sample.vb" id="Snippet1"::: + ]]> @@ -127,11 +126,11 @@ The namespace prefixes to canonicalize using the standard canonicalization algorithm. Initializes a new instance of the class specifying a list of namespace prefixes to canonicalize using the standard canonicalization algorithm. - diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigXPathTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigXPathTransform.xml index 3f55561aeaf..0d721177d4b 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigXPathTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigXPathTransform.xml @@ -39,33 +39,32 @@ Represents the XPath transform for a digital signature as defined by the W3C. - class allows you to address an XML document using the XPath language. This class uses an XPath expression to select the XML nodes you want to sign or encrypt while removing all others from either cryptographic operation. + + Use the class to sign or encrypt specific parts of an XML document using an XPath expression. For information on initializing the class to the value of an XPath transform string, see the method. + + The Uniform Resource Identifier (URI) that describes the class is defined by the field. + + For more information about the XPath transform, see Section 6.6.3 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + This section contains two code examples. The first code example shows how to sign and verify an XML document using the class with an envelope signature. This example signs an XML document and saves the signature in a new XML document. The second code example demonstrates how to call members of the class. + + **Example #1** -## Remarks - The class allows you to address an XML document using the XPath language. This class uses an XPath expression to select the XML nodes you want to sign or encrypt while removing all others from either cryptographic operation. - - Use the class to sign or encrypt specific parts of an XML document using an XPath expression. For information on initializing the class to the value of an XPath transform string, see the method. - - The Uniform Resource Identifier (URI) that describes the class is defined by the field. - - For more information about the XPath transform, see Section 6.6.3 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - This section contains two code examples. The first code example shows how to sign and verify an XML document using the class with an envelope signature. This example signs an XML document and saves the signature in a new XML document. The second code example demonstrates how to call members of the class. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXPathTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: - - **Example #2** - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet2"::: + ]]> @@ -98,15 +97,14 @@ Initializes a new instance of the class. - class. This example creates an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp" id="Snippet1"::: + class. This example creates an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXPathTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: + ]]> @@ -155,11 +153,11 @@ Returns the output of the current object. - method to retrieve a object that contains an XML representation of an XPath transform. - + method to retrieve a object that contains an XML representation of an XPath transform. + ]]> @@ -197,21 +195,21 @@ Returns the output of the current object. The output of the current object. - . - - Use the method to retrieve a object that contains an XML representation of an XPath transform. - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - + . + + Use the method to retrieve a object that contains an XML representation of an XPath transform. + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet8"::: + ]]> @@ -252,21 +250,21 @@ Returns the output of the current object of type . The output of the current object of type . - . - - Use the method to retrieve a object that contains an XML representation of an XPath transform. - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - + . + + Use the method to retrieve a object that contains an XML representation of an XPath transform. + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet7"::: + ]]> The parameter is not an object. @@ -304,19 +302,19 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - are , , and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. - + are , , and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet4"::: + ]]> @@ -356,34 +354,33 @@ An object to load into the current object. Parses the specified object as transform-specific content of a element and configures the internal state of the current object to match the element. - method to initialize the class with an XPath transform. - - To initialize the class with an XPath transform, complete the following steps. - -1. Create a new class and set the property to the value of an XPath transform string. - -2. Call the method to create an object that represents the transform. - -3. Create a new instance of the class and pass the previously created object to the method. - - - -## Examples - The following code example shows how to sign and verify an XML document using the class. This sample creates an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp" id="Snippet1"::: + method to initialize the class with an XPath transform. + + To initialize the class with an XPath transform, complete the following steps. + +1. Create a new class and set the property to the value of an XPath transform string. + +2. Call the method to create an object that represents the transform. + +3. Create a new instance of the class and pass the previously created object to the method. + + + +## Examples + The following code example shows how to sign and verify an XML document using the class. This sample creates an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXPathTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: + ]]> - The parameter is . - - -or- - + The parameter is . + + -or- + The parameter does not contain an element. @@ -422,21 +419,21 @@ The input to load into the current object. Loads the specified input into the current object. - method to initialize an object to the value of an XPath transform using an , , or object. For information about initializing an object using an XPath transform string, see the method. - - The type of the input object must be one of the types in the property. - - - -## Examples - The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. - + method to initialize an object to the value of an XPath transform using an , , or object. For information about initializing an object using an XPath transform string, see the method. + + The type of the input object must be one of the types in the property. + + + +## Examples + The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet11"::: + ]]> @@ -473,19 +470,19 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; the methods of the current object return only objects of one of these types. - is the only valid output type for . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. - + is the only valid output type for . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigXsltTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigXsltTransform.xml index e5cca544101..aefb402df9e 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigXsltTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigXsltTransform.xml @@ -43,34 +43,32 @@ Represents the XSLT transform for a digital signature as defined by the W3C. - class allows you to address an XML document using an XSLT transformation. This class uses XSLT to transform XML nodes into other XML nodes that you want to sign or encrypt. + + Use the class to sign or encrypt specific parts of an XML document using an XSLT transformation. + + The Uniform Resource Identifier (URI) that describes the class is defined by the field. + + For more information about the XSLT transform, see Section 6.6.5 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + This section contains two code examples. The first code example shows how to sign and verify an XML document using the class with an envelope signature. The second code example demonstrates how to use members of the class. + + **Example #1** -## Remarks - The class allows you to address an XML document using an XSLT transformation. This class uses XSLT to transform XML nodes into other XML nodes that you want to sign or encrypt. - - Use the class to sign or encrypt specific parts of an XML document using an XSLT transformation. - - The Uniform Resource Identifier (URI) that describes the class is defined by the field. - - For more information about the XSLT transform, see Section 6.6.5 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - This section contains two code examples. The first code example shows how to sign and verify an XML document using the class with an envelope signature. The second code example demonstrates how to use members of the class. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXsltTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: - - **Example #2** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet2"::: + ]]> @@ -112,15 +110,14 @@ Initializes a new instance of the class. - class with an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp" id="Snippet1"::: + class with an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXsltTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: + ]]> @@ -238,20 +235,19 @@ Returns the output of the current object. The output of the current object. - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet8"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet8"::: + ]]> @@ -292,20 +288,19 @@ Returns the output of the current object of type . The output of the current object of type . - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet7"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet7"::: + ]]> The parameter is not a object. @@ -343,20 +338,19 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - are , , and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet4"::: + are , , and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet4"::: + ]]> @@ -396,26 +390,25 @@ An object that encapsulates an XSLT style sheet to load into the current object. This style sheet is applied to the document loaded by the method. Parses the specified object as transform-specific content of a element and configures the internal state of the current object to match the element. - ` element. - - - -## Examples - The following code example shows how to sign and verify an XML document using the class with an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp" id="Snippet1"::: + ` element. + + + +## Examples + The following code example shows how to sign and verify an XML document using the class with an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXsltTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: + ]]> - The parameter is . - - -or- - + The parameter is . + + -or- + The parameter does not contain an object. @@ -454,20 +447,19 @@ The input to load into the current object. Loads the specified input into the current object. - property. The valid input types to are , , and . - - - -## Examples - The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet11"::: + property. The valid input types to are , , and . + + + +## Examples + The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet11"::: + ]]> @@ -504,20 +496,19 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; only objects of one of these types are returned from the methods of the current object. - is the only valid output type for . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet5"::: + is the only valid output type for . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlLicenseTransform.xml b/xml/System.Security.Cryptography.Xml/XmlLicenseTransform.xml index f3164da70eb..e2bfff26bc5 100644 --- a/xml/System.Security.Cryptography.Xml/XmlLicenseTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlLicenseTransform.xml @@ -46,24 +46,23 @@ Represents the license transform algorithm used to normalize XrML licenses for signatures. - class represents the license transform algorithm as defined in the MPEG Rights Extension Language (MPEG REL). + + Use the class to transform XrML licenses for signatures. + + The Uniform Resource Identifier (URI) that describes the class is defined by the field. + + + +## Examples + The following code example shows how to validate an XML digital signature using the interface and the class. -## Remarks - The class represents the license transform algorithm as defined in the MPEG Rights Extension Language (MPEG REL). - - Use the class to transform XrML licenses for signatures. - - The Uniform Resource Identifier (URI) that describes the class is defined by the field. - - - -## Examples - The following code example shows how to validate an XML digital signature using the interface and the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/IRelDecryptor/Overview/sample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: + ]]> @@ -135,20 +134,19 @@ Gets or sets the decryptor of the current object. The decryptor of the current object. - object uses an interface to decrypt `` elements from the current `` element. - - - -## Examples - The following code example shows how to validate an XML digital signature using the interface and the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp" id="Snippet2"::: + object uses an interface to decrypt `` elements from the current `` element. + + + +## Examples + The following code example shows how to validate an XML digital signature using the interface and the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/IRelDecryptor/Overview/sample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: + ]]> @@ -229,11 +227,11 @@ Returns the output of an object. The output of the object. - . - + . + ]]> @@ -307,11 +305,11 @@ Gets an array of types that are valid inputs to the method of the current object. An array of types that are valid inputs to the method of the current object; you can pass only objects of one of these types to the method of the current object. - class is . - + class is . + ]]> @@ -386,18 +384,18 @@ The input to load into the current object. The type of the input object must be . Loads the specified input into the current object. To be added. - The context was not set before this transform was invoked. - - -or- - - The element was not set before this transform was invoked. - - -or- - - The element was not set before this transform was invoked. - - -or- - + The context was not set before this transform was invoked. + + -or- + + The element was not set before this transform was invoked. + + -or- + + The element was not set before this transform was invoked. + + -or- + The property was not set before this transform was invoked. @@ -432,11 +430,11 @@ Gets an array of types that are valid outputs from the method of the current object. An array of valid output types for the current object; only objects of one of these types are returned from the methods of the current object. - class is . - + class is . + ]]> diff --git a/xml/System.Security.Cryptography/AsnEncodedData.xml b/xml/System.Security.Cryptography/AsnEncodedData.xml index 7fc54f4baa8..9a03018f897 100644 --- a/xml/System.Security.Cryptography/AsnEncodedData.xml +++ b/xml/System.Security.Cryptography/AsnEncodedData.xml @@ -69,7 +69,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -136,7 +135,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -272,7 +270,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -339,7 +336,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -437,7 +433,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -541,7 +536,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -615,7 +609,6 @@ extension.Format(true); class. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: ]]> @@ -685,7 +678,6 @@ The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -751,7 +743,6 @@ The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/AsnEncodedDataCollection.xml b/xml/System.Security.Cryptography/AsnEncodedDataCollection.xml index 6b22cf06753..b805bcd1b11 100644 --- a/xml/System.Security.Cryptography/AsnEncodedDataCollection.xml +++ b/xml/System.Security.Cryptography/AsnEncodedDataCollection.xml @@ -64,20 +64,19 @@ Represents a collection of objects. This class cannot be inherited. - interface. - - - -## Examples - The following code example shows how to use the class. + interface. + + + +## Examples + The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -120,15 +119,14 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -223,15 +221,14 @@ Adds an object to the object. The index of the added object. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -290,20 +287,19 @@ One of the OIDs is and the OIDs do not match.The location where the copy operation starts. Copies the object into an array. - object into an array. The copying begins at the specified index location. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + object into an array. The copying begins at the specified index location. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -353,20 +349,19 @@ One of the OIDs is and the OIDs do not match.Gets the number of objects in a collection. The number of objects. - objects the collection contains. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + objects the collection contains. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -414,20 +409,19 @@ One of the OIDs is and the OIDs do not match.Returns an object that can be used to navigate the object. An object. - class implements the interface, which allows you to move within a collection. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + class implements the interface, which allows you to move within a collection. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -477,20 +471,19 @@ One of the OIDs is and the OIDs do not match. in all cases. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -541,20 +534,19 @@ One of the OIDs is and the OIDs do not match.Gets an object from the object. An object. - object from an object, if you know its location. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + object from an object, if you know its location. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -604,15 +596,14 @@ One of the OIDs is and the OIDs do not match.The object to remove. Removes an object from the object. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -663,20 +654,19 @@ One of the OIDs is and the OIDs do not match.Gets an object that can be used to synchronize access to the object. An object used to synchronize access to the object. - is not thread safe. Derived classes can provide their own synchronized version of the using this property. The synchronizing code must perform operations on the property of the class, not directly on the class itself. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + is not thread safe. Derived classes can provide their own synchronized version of the using this property. The synchronizing code must perform operations on the property of the class, not directly on the class itself. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -731,18 +721,18 @@ One of the OIDs is and the OIDs do not match.The location where the copy operation starts. Copies the object into an array. - object into an array. The copying begins at the index location specified. - + object into an array. The copying begins at the index location specified. + ]]> is a multidimensional array, which is not supported by this method. -or- - + The length for is invalid. is . @@ -878,11 +868,11 @@ This member is an explicit interface member implementation. It can be used only Returns an object that can be used to navigate the object. An object that can be used to navigate the collection. - class implements the interface, which allows you to move within a collection. - + class implements the interface, which allows you to move within a collection. + ]]> diff --git a/xml/System.Security.Cryptography/AsnEncodedDataEnumerator.xml b/xml/System.Security.Cryptography/AsnEncodedDataEnumerator.xml index 76cb1f49681..8c093daad06 100644 --- a/xml/System.Security.Cryptography/AsnEncodedDataEnumerator.xml +++ b/xml/System.Security.Cryptography/AsnEncodedDataEnumerator.xml @@ -61,20 +61,19 @@ Provides the ability to navigate through an object. This class cannot be inherited. - interface. - - - -## Examples - The following code example shows how to use the class. + interface. + + + +## Examples + The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -121,24 +120,23 @@ Gets the current object in an object. The current object in the collection. - method must be called to advance the enumerator to the first element of the collection before reading the value of the property; otherwise, returns `null` or throws an exception. - - also returns `null` or throws an exception if the last call to returns `false`, which indicates that the end of the collection has been reached. - - does not move the position of the enumerator, and consecutive calls to return the same object until is called. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + method must be called to advance the enumerator to the first element of the collection before reading the value of the property; otherwise, returns `null` or throws an exception. + + also returns `null` or throws an exception if the last call to returns `false`, which indicates that the end of the collection has been reached. + + does not move the position of the enumerator, and consecutive calls to return the same object until is called. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -190,24 +188,23 @@ , if the enumerator was successfully advanced to the next element; , if the enumerator has passed the end of the collection. - method moves the enumerator over the first element of the collection. Subsequent calls to advance the enumerator past subsequent elements. - - After the end of the collection is passed, calls to return `false`. - - An enumerator is valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to can throw an . - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + method moves the enumerator over the first element of the collection. Subsequent calls to advance the enumerator past subsequent elements. + + After the end of the collection is passed, calls to return `false`. + + An enumerator is valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to can throw an . + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> The collection was modified after the enumerator was created. @@ -258,20 +255,19 @@ Sets an enumerator to its initial position. - object. An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid, and the next call to the method throws an . - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + object. An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid, and the next call to the method throws an . + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> The collection was modified after the enumerator was created. diff --git a/xml/System.Security.Cryptography/AsymmetricAlgorithm.xml b/xml/System.Security.Cryptography/AsymmetricAlgorithm.xml index 1c3adbd5446..9cf1043c850 100644 --- a/xml/System.Security.Cryptography/AsymmetricAlgorithm.xml +++ b/xml/System.Security.Cryptography/AsymmetricAlgorithm.xml @@ -62,42 +62,40 @@ Represents the abstract base class from which all implementations of asymmetric algorithms must inherit. - class is an implementation of a public-key algorithm. For an in-depth discussion of public-key encryption and algorithms, see the "Public-Key Encryption" section in [Cryptographic Services](/dotnet/standard/security/cryptographic-services). For information about how to use the Strong Name tool (Sn.exe) to create key pairs, see [How to: Create a Public-Private Key Pair](/dotnet/standard/assembly/create-public-private-key-pair). - - You can use public-key systems to form digital signatures. Digital signatures are used to help to protect the integrity of data. For example, to use a public-key system to digitally sign a message, the sender first applies a hash function to the message to create a message digest. The sender then encrypts the message digest with the sender's private key to create the sender's personal signature. Upon receiving the message and signature, the receiver decrypts the signature using the sender's public key to recover the message digest and hashes the message using the same hash algorithm that the sender used. If the message digest that the receiver computes matches the message digest received from the sender, the receiver can assume that the message was not altered while in transit. Note that anyone can verify a signature, because the sender's public key is common knowledge. This technique does not retain the secrecy of the message; for the message to be secret, it must also be encrypted. - - The .NET Framework provides the following classes that implement digital signature algorithms: , , (base class), and . - - The namespace provides concrete classes for and only. - - To learn how to use the RSA algorithm to encrypt and decrypt XML data, and create and verify XML digital signatures, see these articles: - -- [How to: Encrypt XML Elements with Asymmetric Keys](/dotnet/standard/security/how-to-encrypt-xml-elements-with-asymmetric-keys) - -- [How to: Decrypt XML Elements with Asymmetric Keys](/dotnet/standard/security/how-to-decrypt-xml-elements-with-asymmetric-keys) - -- [How to: Sign XML Documents with Digital Signatures](/dotnet/standard/security/how-to-sign-xml-documents-with-digital-signatures) - -- [How to: Verify the Digital Signatures of XML Documents](/dotnet/standard/security/how-to-verify-the-digital-signatures-of-xml-documents) - - - -## Examples - The following code example demonstrates how to implement a custom asymmetric algorithm inherited from the class. An additional class is provided to demonstrate how to use the custom class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet2"::: - - Here's an additional class that demonstrates how to use the custom class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet3"::: - + class is an implementation of a public-key algorithm. For an in-depth discussion of public-key encryption and algorithms, see the "Public-Key Encryption" section in [Cryptographic Services](/dotnet/standard/security/cryptographic-services). For information about how to use the Strong Name tool (Sn.exe) to create key pairs, see [How to: Create a Public-Private Key Pair](/dotnet/standard/assembly/create-public-private-key-pair). + + You can use public-key systems to form digital signatures. Digital signatures are used to help to protect the integrity of data. For example, to use a public-key system to digitally sign a message, the sender first applies a hash function to the message to create a message digest. The sender then encrypts the message digest with the sender's private key to create the sender's personal signature. Upon receiving the message and signature, the receiver decrypts the signature using the sender's public key to recover the message digest and hashes the message using the same hash algorithm that the sender used. If the message digest that the receiver computes matches the message digest received from the sender, the receiver can assume that the message was not altered while in transit. Note that anyone can verify a signature, because the sender's public key is common knowledge. This technique does not retain the secrecy of the message; for the message to be secret, it must also be encrypted. + +.NET provides the following classes that implement digital signature algorithms: , , (base class), and . + + The namespace provides concrete classes for and only. + + To learn how to use the RSA algorithm to encrypt and decrypt XML data, and create and verify XML digital signatures, see these articles: + +- [How to: Encrypt XML Elements with Asymmetric Keys](/dotnet/standard/security/how-to-encrypt-xml-elements-with-asymmetric-keys) + +- [How to: Decrypt XML Elements with Asymmetric Keys](/dotnet/standard/security/how-to-decrypt-xml-elements-with-asymmetric-keys) + +- [How to: Sign XML Documents with Digital Signatures](/dotnet/standard/security/how-to-sign-xml-documents-with-digital-signatures) + +- [How to: Verify the Digital Signatures of XML Documents](/dotnet/standard/security/how-to-verify-the-digital-signatures-of-xml-documents) + + + +## Examples + The following code example demonstrates how to implement a custom asymmetric algorithm inherited from the class. An additional class is provided to demonstrate how to use the custom class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet2"::: + + Here's an additional class that demonstrates how to use the custom class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet3"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet3"::: + ]]> Cryptographic Services @@ -143,11 +141,11 @@ Initializes a new instance of the class. - and classes are the only currently supported implementations. - + and classes are the only currently supported implementations. + ]]> The implementation of the derived class is not valid. @@ -196,22 +194,21 @@ Releases all resources used by the class. - method. - - Calling `Dispose` allows the resources used by the class to be reallocated for other purposes. For more information about `Dispose`, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged). - - - -## Examples - The following code example demonstrates how to call the method to release the resources of the current `customCrypto` object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet1"::: - + method. + + Calling `Dispose` allows the resources used by the class to be reallocated for other purposes. For more information about `Dispose`, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged). + + + +## Examples + The following code example demonstrates how to call the method to release the resources of the current `customCrypto` object. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -284,19 +281,18 @@ Creates a default cryptographic object used to perform the asymmetric algorithm. A new instance, unless the default settings have been changed with the <cryptoClass> element. - method in an extended class. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet11"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet11"::: - + method in an extended class. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet11"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet11"::: + ]]> .NET Core 2.0 - 3.1 and .NET 5 and later: In all cases. @@ -366,49 +362,48 @@ This method is obsolete in .NET 5 and later versions. - The asymmetric algorithm implementation to use. The following table shows the valid values for the parameter and the algorithms they map to. - - Parameter value - - Implements - - System.Security.Cryptography.AsymmetricAlgorithm - - RSA - - System.Security.Cryptography.RSA - - DSA - - System.Security.Cryptography.DSA - - ECDsa - - ECDsaCng - - System.Security.Cryptography.ECDsaCng - - ECDH - - ECDiffieHellman - - ECDiffieHellmanCng - - System.Security.Cryptography.ECDiffieHellmanCng - + The asymmetric algorithm implementation to use. The following table shows the valid values for the parameter and the algorithms they map to. + + Parameter value + + Implements + + System.Security.Cryptography.AsymmetricAlgorithm + + RSA + + System.Security.Cryptography.RSA + + DSA + + System.Security.Cryptography.DSA + + ECDsa + + ECDsaCng + + System.Security.Cryptography.ECDsaCng + + ECDH + + ECDiffieHellman + + ECDiffieHellmanCng + + System.Security.Cryptography.ECDiffieHellmanCng + Creates an instance of the specified implementation of an asymmetric algorithm. A new instance of the specified asymmetric algorithm implementation. - method in an extended class. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet12"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet12"::: - + method in an extended class. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet12"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet12"::: + ]]> Cryptographic Services @@ -468,16 +463,16 @@ This method is obsolete in .NET 5 and later versions. Releases all resources used by the current instance of the class. - . The `Dispose` method leaves the in an unusable state. After calling `Dispose`, you must release all references to the so the garbage collector can reclaim the memory that the was occupying. - - For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). - -> [!NOTE] -> Always call `Dispose` before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method. - + . The `Dispose` method leaves the in an unusable state. After calling `Dispose`, you must release all references to the so the garbage collector can reclaim the memory that the was occupying. + + For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). + +> [!NOTE] +> Always call `Dispose` before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method. + ]]> @@ -533,19 +528,19 @@ This method is obsolete in .NET 5 and later versions. to release both managed and unmanaged resources; to release only unmanaged resources. Releases the unmanaged resources used by the class and optionally releases the managed resources. - method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`. - - When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this references. This method invokes the `Dispose()` method of each referenced object. - + method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`. + + When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this references. This method invokes the `Dispose()` method of each referenced object. + ]]> - can be called multiple times by other objects. When overriding , be careful not to reference objects that have been previously disposed in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. - + can be called multiple times by other objects. When overriding , be careful not to reference objects that have been previously disposed in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. + For more information about and , see Cleaning Up Unmanaged Resources. Cryptographic Services @@ -597,19 +592,19 @@ This method is obsolete in .NET 5 and later versions. Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password. A byte array containing the PKCS#8 EncryptedPrivateKeyInfo representation of this key. - - The key could not be exported. - --or- - - indicates that should be used, which requires -based passwords. + The key could not be exported. + +-or- + + indicates that should be used, which requires -based passwords. @@ -660,11 +655,11 @@ This method is obsolete in .NET 5 and later versions. Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password. A byte array containing the PKCS#8 EncryptedPrivateKeyInfo representation of this key. - The key could not be exported. @@ -711,12 +706,12 @@ This method is obsolete in .NET 5 and later versions. Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password, PEM encoded. A string containing the PEM-encoded PKCS#8 EncryptedPrivateKeyInfo. - A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with -----BEGIN ENCRYPTED PRIVATE KEY----- and end with -----END ENCRYPTED PRIVATE KEY-----, with the base64 encoded DER contents of the key between the PEM boundaries. + A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with -----BEGIN ENCRYPTED PRIVATE KEY----- and end with -----END ENCRYPTED PRIVATE KEY-----, with the base64 encoded DER contents of the key between the PEM boundaries. - The PEM is encoded according to the IETF RFC 7468 "strict" encoding rules. + The PEM is encoded according to the IETF RFC 7468 "strict" encoding rules. - An implementation for or + An implementation for or has not been provided. The key could not be exported. @@ -762,24 +757,24 @@ This method is obsolete in .NET 5 and later versions. Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password, PEM encoded. A string containing the PEM-encoded PKCS#8 EncryptedPrivateKeyInfo. - - An implementation for or + An implementation for or has not been provided. The key could not be exported. @@ -852,21 +847,21 @@ This method is obsolete in .NET 5 and later versions. Exports the current key in the PKCS#8 PrivateKeyInfo format, PEM encoded. A string containing the PEM-encoded PKCS#8 PrivateKeyInfo. - - An implementation for or + An implementation for or has not been provided. The key could not be exported. @@ -937,22 +932,22 @@ This method is obsolete in .NET 5 and later versions. Exports the public-key portion of the current key in the X.509 SubjectPublicKeyInfo format, PEM encoded. A string containing the PEM-encoded X.509 SubjectPublicKeyInfo. - - An implementation for or + An implementation for or has not been provided. The key could not be exported. @@ -1006,15 +1001,14 @@ This method is obsolete in .NET 5 and later versions. The XML string to use to reconstruct the object. When overridden in a derived class, reconstructs an object from an XML string. Otherwise, throws a . - method to parse the specified XML string to populate the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet4"::: - + method to parse the specified XML string to populate the current object. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet4"::: + ]]> Cryptographic Services @@ -1060,40 +1054,40 @@ This method is obsolete in .NET 5 and later versions. When this method returns, contains a value that indicates the number of bytes read from . This parameter is treated as uninitialized. When overridden in a derived class, imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a byte-based password, replacing the keys for this object. - throws a by default. - + throws a by default. + ]]> - The password is incorrect. - --or- - -The contents of indicate the Key Derivation Function (KDF) to apply is the legacy PKCS#12 KDF, which requires -based passwords. - --or- - -The contents of do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. - --or- - -The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. - --or- - -The contents of represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + The password is incorrect. + +-or- + +The contents of indicate the Key Derivation Function (KDF) to apply is the legacy PKCS#12 KDF, which requires -based passwords. + +-or- + +The contents of do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. + +-or- + +The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. + +-or- + +The contents of represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. A derived type has not overriden this member. @@ -1138,35 +1132,35 @@ The algorithm-specific key import failed. When this method returns, contains a value that indicates the number of bytes read from . This parameter is treated as uninitialized. When overridden in a derived class, imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object. - throws a by default. - + throws a by default. + ]]> - The password is incorrect. - --or- - -The contents of do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. - --or- - -The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. - --or- - -The contents of represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + The password is incorrect. + +-or- + +The contents of do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. + +-or- + +The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. + +-or- + +The contents of represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. A derived type has not overriden this member. @@ -1206,45 +1200,45 @@ The algorithm-specific key import failed. The bytes to use as a password when decrypting the key material. When overridden in a derived class, imports an encrypted RFC 7468 PEM-encoded key, replacing the keys for this object. - . - + . + ]]> A derived type has not overridden this member. - does not contain a PEM-encoded key with a recognized label. - --or- - - contains multiple PEM-encoded keys with a recognized label. + does not contain a PEM-encoded key with a recognized label. + +-or- + + contains multiple PEM-encoded keys with a recognized label. - - - The password is incorrect. - --or- - -The base-64 decoded contents of the PEM text from - do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. - --or- - -The base-64 decoded contents of the PEM text from - indicate the key is for an algorithm other than the algorithm - represented by this instance. - --or- - -The base-64 decoded contents of the PEM text from - represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + + + The password is incorrect. + +-or- + +The base-64 decoded contents of the PEM text from + do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. + +-or- + +The base-64 decoded contents of the PEM text from + indicate the key is for an algorithm other than the algorithm + represented by this instance. + +-or- + +The base-64 decoded contents of the PEM text from + represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. @@ -1283,45 +1277,45 @@ The algorithm-specific key import failed. The password to use for decrypting the key material. When overridden in a derived class, imports an encrypted RFC 7468 PEM-encoded key, replacing the keys for this object. - . - + . + ]]> A derived type has not overridden this member. - does not contain a PEM-encoded key with a recognized label. - --or- - - contains multiple PEM-encoded keys with a recognized label. + does not contain a PEM-encoded key with a recognized label. + +-or- + + contains multiple PEM-encoded keys with a recognized label. - - - The password is incorrect. - --or- - -The base-64 decoded contents of the PEM text from - do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. - --or- - -The base-64 decoded contents of the PEM text from - indicate the key is for an algorithm other than the algorithm - represented by this instance. - --or- - -The base-64 decoded contents of the PEM text from - represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + + + The password is incorrect. + +-or- + +The base-64 decoded contents of the PEM text from + do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. + +-or- + +The base-64 decoded contents of the PEM text from + indicate the key is for an algorithm other than the algorithm + represented by this instance. + +-or- + +The base-64 decoded contents of the PEM text from + represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. @@ -1358,25 +1352,25 @@ The algorithm-specific key import failed. The text of the PEM key to import. When overridden in a derived class, imports an RFC 7468 textually encoded key, replacing the keys for this object. - . - + . + ]]> A derived type has not overridden this member. - does not contain a PEM-encoded key with a recognized label. - --or- - - contains multiple PEM-encoded keys with a recognized label. - --or- - - contains an encrypted PEM-encoded key. + does not contain a PEM-encoded key with a recognized label. + +-or- + + contains multiple PEM-encoded keys with a recognized label. + +-or- + + contains an encrypted PEM-encoded key. @@ -1418,29 +1412,29 @@ Because each algorithm may have algorithm-specific PEM labels, the default behav When this method returns, contains a value that indicates the number of bytes read from . This parameter is treated as uninitialized. When overriden in a derived class, imports the public/private keypair from a PKCS#8 PrivateKeyInfo structure after decryption, replacing the keys for this object. - throws a by default. - + throws a by default. + ]]> - The contents of do not represent an ASN.1-BER-encoded PKCS#8 PrivateKeyInfo structure. - --or- - -The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. - --or- - -The contents of represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + The contents of do not represent an ASN.1-BER-encoded PKCS#8 PrivateKeyInfo structure. + +-or- + +The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. + +-or- + +The contents of represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. A derived type has not overriden this member. @@ -1483,28 +1477,28 @@ The algorithm-specific key import failed. When this method returns, contains a value that indicates the number of bytes read from . This parameter is treated as uninitialized. When overriden in a derived class, imports the public key from an X.509 SubjectPublicKeyInfo structure after decryption, replacing the keys for this object. - throws a by default. + throws a by default. ]]> - The contents of do not represent an ASN.1-DER-encoded X.509 SubjectPublicKeyInfo structure. - --or- - -The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. - --or- - -The contents of represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + The contents of do not represent an ASN.1-DER-encoded X.509 SubjectPublicKeyInfo structure. + +-or- + +The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. + +-or- + +The contents of represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. A derived type has not overriden this member. @@ -1561,15 +1555,14 @@ The algorithm-specific key import failed. When overridden in a derived class, gets the name of the key exchange algorithm. Otherwise, throws an . The name of the key exchange algorithm. - property to return the name for the key exchange algorithm. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet6"::: - + property to return the name for the key exchange algorithm. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet6"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet6"::: + ]]> Cryptographic Services @@ -1618,20 +1611,19 @@ The algorithm-specific key import failed. Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm. The size, in bits, of the key modulus used by the asymmetric algorithm. - property. - - - -## Examples - The following code example demonstrates how to override the property to verify that it falls within the range identified in the local `keySizes` member variable. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet9"::: - + property. + + + +## Examples + The following code example demonstrates how to override the property to verify that it falls within the range identified in the local `keySizes` member variable. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet9"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet9"::: + ]]> The key modulus size is invalid. @@ -1680,13 +1672,13 @@ The algorithm-specific key import failed. Represents the size, in bits, of the key modulus used by the asymmetric algorithm. - property. - - This field is accessed through the property. - + property. + + This field is accessed through the property. + ]]> Cryptographic Services @@ -1741,20 +1733,19 @@ The algorithm-specific key import failed. Gets the key sizes that are supported by the asymmetric algorithm. An array that contains the key sizes supported by the asymmetric algorithm. - property to retrieve the , , and properties. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp" id="Snippet10"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet10"::: - + property to retrieve the , , and properties. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet10"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet10"::: + ]]> Cryptographic Services @@ -1812,13 +1803,13 @@ The algorithm-specific key import failed. Specifies the key sizes that are supported by the asymmetric algorithm. - property. - + property. + ]]> Cryptographic Services @@ -1876,15 +1867,14 @@ The algorithm-specific key import failed. When implemented in a derived class, gets the name of the signature algorithm. Otherwise, always throws a . The name of the signature algorithm. - property to return the name of the signature algorithm. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet7"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet7"::: - + property to return the name of the signature algorithm. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet7"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet7"::: + ]]> Cryptographic Services @@ -1922,11 +1912,11 @@ The algorithm-specific key import failed. For a description of this member, see . - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1984,15 +1974,14 @@ This member is an explicit interface member implementation. It can be used only When overridden in a derived class, creates and returns an XML string representation of the current object. Otherwise, throws a . An XML string encoding of the current object. - method to create an XML representation of the parameters in the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet5"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet5"::: - + method to create an XML representation of the parameters in the current object. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet5"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet5"::: + ]]> Cryptographic Services @@ -2049,21 +2038,21 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - throws a by default. - + throws a by default. + ]]> - The key could not be exported. - --or- - - indicates that should be used, which requires -based passwords. + The key could not be exported. + +-or- + + indicates that should be used, which requires -based passwords. A derived type has not overriden this member. @@ -2120,13 +2109,13 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - throws a by default. - + throws a by default. + ]]> The key could not be exported. @@ -2179,12 +2168,12 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with -----BEGIN ENCRYPTED PRIVATE KEY----- and end with -----END ENCRYPTED PRIVATE KEY-----, with the base64 encoded DER contents of the key between the PEM boundaries. + A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with -----BEGIN ENCRYPTED PRIVATE KEY----- and end with -----END ENCRYPTED PRIVATE KEY-----, with the base64 encoded DER contents of the key between the PEM boundaries. - The PEM is encoded according to the IETF RFC 7468 "strict" encoding rules. + The PEM is encoded according to the IETF RFC 7468 "strict" encoding rules. - An implementation for + An implementation for has not been provided. The key could not be exported. @@ -2235,25 +2224,25 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - - An implementation for + An implementation for has not been provided. The key could not be exported. @@ -2298,11 +2287,11 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - throws a by default. - + throws a by default. + ]]> The key could not be exported. @@ -2345,20 +2334,20 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - - An implementation for + An implementation for has not been provided. The key could not be exported. @@ -2403,11 +2392,11 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - throws a by default. - + throws a by default. + ]]> The key could not be exported. @@ -2450,23 +2439,23 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - - An implementation for + An implementation for has not been provided. The key could not be exported. diff --git a/xml/System.Security.Cryptography/CryptoConfig.xml b/xml/System.Security.Cryptography/CryptoConfig.xml index 0c7ca1c956e..b450e7387b5 100644 --- a/xml/System.Security.Cryptography/CryptoConfig.xml +++ b/xml/System.Security.Cryptography/CryptoConfig.xml @@ -115,7 +115,6 @@ ## Examples The following code example demonstrates how to use members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/VB/members.vb" id="Snippet1"::: @@ -453,7 +452,6 @@ ## Examples The following code example demonstrates how to call the method to create a new SHA-1 provider. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/VB/members.vb" id="Snippet4"::: @@ -550,7 +548,6 @@ ## Examples The following code example demonstrates how to call the method to initialize a new RSA provider instance accessing the `TestContainer` key container. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/VB/members.vb" id="Snippet5"::: @@ -626,7 +623,6 @@ ## Examples The following code example demonstrates how to call the method to encode the specified object identifier. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/VB/members.vb" id="Snippet6"::: @@ -708,7 +704,6 @@ ## Examples The following code example demonstrates how to call the method to retrieve an object identifier (OID) from the string name of the SHA-1 algorithm. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/VB/members.vb" id="Snippet3"::: diff --git a/xml/System.Security.Cryptography/CryptographicException.xml b/xml/System.Security.Cryptography/CryptographicException.xml index fa97ca92020..0bd492633e5 100644 --- a/xml/System.Security.Cryptography/CryptographicException.xml +++ b/xml/System.Security.Cryptography/CryptographicException.xml @@ -78,22 +78,21 @@ The exception that is thrown when an error occurs during a cryptographic operation. - uses the HRESULT CORSEC_E_CRYPTO, unless an alternate error code is specified. + + For a list of initial property values for an instance of , see the constructor. + + + +## Examples + The following code example demonstrates how to use members of the class. -## Remarks - uses the HRESULT CORSEC_E_CRYPTO, unless an alternate error code is specified. - - For a list of initial property values for an instance of , see the constructor. - - - -## Examples - The following code example demonstrates how to use members of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet2"::: + ]]> @@ -149,25 +148,24 @@ Initializes a new instance of the class with default properties. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The localized error message string.| - - - -## Examples - The following code example demonstrates how to construct a with no parameters. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet1"::: + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The localized error message string.| + + + +## Examples + The following code example demonstrates how to construct a with no parameters. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet1"::: + ]]> @@ -221,27 +219,26 @@ The error code. Initializes a new instance of the class with the specified error code. - constructor accepts a system `HRESULT` error code and sets the property to a localized message that corresponds to the `HRESULT`. - - The following table shows the initial property values for an instance of . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The localized error message string.| - - - -## Examples - The following code example demonstrates how to construct a using an error code for an . This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet3"::: + constructor accepts a system `HRESULT` error code and sets the property to a localized message that corresponds to the `HRESULT`. + + The following table shows the initial property values for an instance of . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The localized error message string.| + + + +## Examples + The following code example demonstrates how to construct a using an error code for an . This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet3"::: + ]]> @@ -290,25 +287,24 @@ The error message that explains the reason for the exception. Initializes a new instance of the class with a specified error message. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The error message string.| - - - -## Examples - The following code example demonstrates how to construct a using a custom error message. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet4"::: + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The error message string.| + + + +## Examples + The following code example demonstrates how to construct a using a custom error message. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet4"::: + ]]> @@ -371,11 +367,11 @@ The contextual information about the source or destination. Initializes a new instance of the class with serialized data. - @@ -426,27 +422,26 @@ The exception that is the cause of the current exception. If the parameter is not , the current exception is raised in a block that handles the inner exception. Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. - - The following table shows the initial property values for an instance of . - -|Property|Value| -|--------------|-----------| -||The inner exception reference.| -||The error message string.| - - - -## Examples - The following code example demonstrates how to construct a using a custom error message and an inner exception. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet5"::: + property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. + + The following table shows the initial property values for an instance of . + +|Property|Value| +|--------------|-----------| +||The inner exception reference.| +||The error message string.| + + + +## Examples + The following code example demonstrates how to construct a using a custom error message and an inner exception. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet5"::: + ]]> @@ -513,25 +508,24 @@ The error message that explains the reason for the exception. Initializes a new instance of the class with a specified error message in the specified format. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The error message string.| - - - -## Examples - The following code example demonstrates how to construct a using a time format and the current date. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet6"::: + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The error message string.| + + + +## Examples + The following code example demonstrates how to construct a using a time format and the current date. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet6"::: + ]]> diff --git a/xml/System.Security.Cryptography/CspKeyContainerInfo.xml b/xml/System.Security.Cryptography/CspKeyContainerInfo.xml index 401a5c33992..e7ea8795f50 100644 --- a/xml/System.Security.Cryptography/CspKeyContainerInfo.xml +++ b/xml/System.Security.Cryptography/CspKeyContainerInfo.xml @@ -66,22 +66,21 @@ Provides additional information about a cryptographic key pair. This class cannot be inherited. - or the , a key container will not be created until you call a method that uses the key. Some properties of the class will throw a if a key container has not been created. + + + +## Examples + The following code example creates a key container and retrieves information about that container. -## Remarks - Use this class to obtain additional information about a key pair, such as the key container name or the key number. - - In cases where a random key is generated by the or the , a key container will not be created until you call a method that uses the key. Some properties of the class will throw a if a key container has not been created. - - - -## Examples - The following code example creates a key container and retrieves information about that container. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspKeyContainerInfo/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/VB/sample.vb" id="Snippet1"::: + ]]> @@ -134,15 +133,14 @@ A object that provides information about the key. Initializes a new instance of the class using the specified parameters. - @@ -196,15 +194,14 @@ if the key is accessible; otherwise, . - The key type is not supported. @@ -245,18 +242,18 @@ Gets a object that represents access rights and audit rules for a container. A object that represents access rights and audit rules for a container. - property to retrieve the object that manages the creation of discretionary access control lists (DACLS) and system access control lists (SACLS) for a container. - + property to retrieve the object that manages the creation of discretionary access control lists (DACLS) and system access control lists (SACLS) for a container. + ]]> The key type is not supported. - The cryptographic service provider cannot be found. - - -or- - + The cryptographic service provider cannot be found. + + -or- + The key container was not found. @@ -309,22 +306,21 @@ if the key can be exported; otherwise, . - The key type is not supported. - The cryptographic service provider cannot be found. - - -or- - + The cryptographic service provider cannot be found. + + -or- + The key container was not found. @@ -377,15 +373,14 @@ if the key is a hardware key; otherwise, . - The cryptographic service provider cannot be found. @@ -434,15 +429,14 @@ Gets a key container name. The key container name. - @@ -489,24 +483,23 @@ Gets a value that describes whether an asymmetric key was created as a signature key or an exchange key. One of the values that describes whether an asymmetric key was created as a signature key or an exchange key. - property is derived from the field of the object that was used to initialize the object. - - An exchange key is an asymmetric key pair used to encrypt session keys so that they can be safely stored and exchanged with other users. The value specifies an exchange key. This value corresponds to the `AT_KEYEXCHANGE` value used in the unmanaged Microsoft Cryptographic API (CAPI). - - A signature key is an asymmetric key pair used for authenticating (digitally signed) messages or files. The value specifies a signature key. This value corresponds to the `AT_SIGNATURE` value used in CAPI. - - - -## Examples - The following code example creates a key container and retrieves information about that container. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp" id="Snippet1"::: + property is derived from the field of the object that was used to initialize the object. + + An exchange key is an asymmetric key pair used to encrypt session keys so that they can be safely stored and exchanged with other users. The value specifies an exchange key. This value corresponds to the `AT_KEYEXCHANGE` value used in the unmanaged Microsoft Cryptographic API (CAPI). + + A signature key is an asymmetric key pair used for authenticating (digitally signed) messages or files. The value specifies a signature key. This value corresponds to the `AT_SIGNATURE` value used in CAPI. + + + +## Examples + The following code example creates a key container and retrieves information about that container. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspKeyContainerInfo/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/VB/sample.vb" id="Snippet1"::: + ]]> @@ -554,15 +547,14 @@ if the key is from the machine key set; otherwise, . - @@ -616,22 +608,21 @@ if the key pair is protected; otherwise, . - The key type is not supported. - The cryptographic service provider cannot be found. - - -or- - + The cryptographic service provider cannot be found. + + -or- + The key container was not found. @@ -678,20 +669,19 @@ Gets the provider name of a key. The provider name. - @@ -738,20 +728,19 @@ Gets the provider type of a key. The provider type. The default is 1. - @@ -799,20 +788,19 @@ if the key container was randomly generated; otherwise, . - @@ -866,15 +854,14 @@ if the key is removable; otherwise, . - The cryptographic service provider (CSP) was not found. @@ -932,22 +919,21 @@ Gets a unique key container name. The unique key container name. - The key type is not supported. - The cryptographic service provider cannot be found. - - -or- - + The cryptographic service provider cannot be found. + + -or- + The key container was not found. diff --git a/xml/System.Security.Cryptography/CspParameters.xml b/xml/System.Security.Cryptography/CspParameters.xml index 1a5ba833efd..6e9bb6ada80 100644 --- a/xml/System.Security.Cryptography/CspParameters.xml +++ b/xml/System.Security.Cryptography/CspParameters.xml @@ -85,13 +85,11 @@ ## Examples The following code example creates a key container using the class and saves the key in the container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/Overview/capikey.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/capikey/VB/capikey.vb" id="Snippet1"::: The following code example uses the class to select a Smart Card Cryptographic Service Provider. It then signs and verifies data using the smart card. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/Overview/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.SmartCardCSP/VB/example.vb" id="Snippet1"::: @@ -161,7 +159,6 @@ ## Examples The following code example creates a key container using the class and saves the key in the container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/Overview/capikey.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/capikey/VB/capikey.vb" id="Snippet1"::: @@ -293,7 +290,6 @@ ## Examples The following code example uses the class to select a Smart Card Cryptographic Service Provider. It then signs and verifies data using the smart card. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/Overview/example.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.SmartCardCSP/VB/example.vb" id="Snippet1"::: @@ -618,7 +614,6 @@ ## Examples The following code example creates a key container using the class and saves the key in the container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/Overview/capikey.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/capikey/VB/capikey.vb" id="Snippet1"::: @@ -685,7 +680,6 @@ ## Examples The following code example demonstrates how to use the enumeration to specify a key type for an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/KeyNumber/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.KeyNumber/VB/sample.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/DES.xml b/xml/System.Security.Cryptography/DES.xml index 1d5ab4cb022..27478190ef3 100644 --- a/xml/System.Security.Cryptography/DES.xml +++ b/xml/System.Security.Cryptography/DES.xml @@ -69,14 +69,14 @@ Represents the base class for the Data Encryption Standard (DES) algorithm from which all implementations must derive. - [!NOTE] > A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the class instead of the class. Use only for compatibility with legacy applications and data. - + ]]> Cryptographic Services @@ -124,19 +124,19 @@ Initializes a new instance of the class. - class to the default values shown in the following table. - -|Field|Default Value| -|-----------|-------------------| -||64| -||64| -||64| - + class to the default values shown in the following table. + +|Field|Default Value| +|-----------|-------------------| +||64| +||64| +||64| + ]]> Cryptographic Services @@ -205,26 +205,24 @@ Creates an instance of a cryptographic object to perform the Data Encryption Standard () algorithm. A cryptographic object. - object that can be used for encrypting and decrypting data. - - + object that can be used for encrypting and decrypting data. + + + +## Examples + The following code example shows how to create and use a object to encrypt and decrypt data in a file. -## Examples - The following code example shows how to create and use a object to encrypt and decrypt data in a file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DES/Create/fileexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DES.Create.File/VB/fileexample.vb" id="Snippet1"::: - - The following code example shows how to create and use a object to encrypt and decrypt data in memory. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DES.Create.File/VB/fileexample.vb" id="Snippet1"::: + + The following code example shows how to create and use a object to encrypt and decrypt data in memory. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DES/Create/memoryexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -347,13 +345,13 @@ if the key is semi-weak; otherwise, . - ) algorithm; this method checks for those semi-weak keys. - - Attempting to set a semi-weak key results in a . When is called to create a random key, a semi-weak key will never be returned. - + ) algorithm; this method checks for those semi-weak keys. + + Attempting to set a semi-weak key results in a . When is called to create a random key, a semi-weak key will never be returned. + ]]> The size of the parameter is not valid. @@ -407,13 +405,13 @@ if the key is weak; otherwise, . - ) algorithm; this method checks for those weak keys. - - Attempting to set a weak key results in a . When is called to create a random key, a weak key will never be returned. - + ) algorithm; this method checks for those weak keys. + + Attempting to set a weak key results in a . When is called to create a random key, a weak key will never be returned. + ]]> The size of the parameter is not valid. @@ -462,15 +460,15 @@ Gets or sets the secret key for the Data Encryption Standard () algorithm. The secret key for the algorithm. - is called to create a new random value. - - The length of the key must be equal to . - - This algorithm supports a key length of 64 bits. - + is called to create a new random value. + + The length of the key must be equal to . + + This algorithm supports a key length of 64 bits. + ]]> An attempt was made to set the key to . diff --git a/xml/System.Security.Cryptography/DESCryptoServiceProvider.xml b/xml/System.Security.Cryptography/DESCryptoServiceProvider.xml index 850a19db322..ad95d7ae3e6 100644 --- a/xml/System.Security.Cryptography/DESCryptoServiceProvider.xml +++ b/xml/System.Security.Cryptography/DESCryptoServiceProvider.xml @@ -70,23 +70,22 @@ Defines a wrapper object to access the cryptographic service provider (CSP) version of the Data Encryption Standard () algorithm. This class cannot be inherited. - [!IMPORTANT] > A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the class instead of the class. Use only for compatibility with legacy applications and data. -## Examples - The following code example uses (an implementation of ) with the specified key () and initialization vector () to encrypt a file specified by `inName`. It then outputs the encrypted result to the file specified by `outName`. +## Examples + The following code example uses (an implementation of ) with the specified key () and initialization vector () to encrypt a file specified by `inName`. It then outputs the encrypted result to the file specified by `outName`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DESCryptoServiceProvider/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic DES Example/VB/source.vb" id="Snippet1"::: - - Decryption can be handled in the same way; use instead of . The same key () and initialization vector () used to encrypt the file must be used to decrypt it. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic DES Example/VB/source.vb" id="Snippet1"::: + + Decryption can be handled in the same way; use instead of . The same key () and initialization vector () used to encrypt the file must be used to decrypt it. + ]]> Cryptographic Services @@ -136,17 +135,16 @@ Initializes a new instance of the class. - (an implementation of ) with the specified key () and initialization vector () to encrypt a file specified by `inName`. It then outputs the encrypted result to the file specified by `outName`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp" id="Snippet1"::: + (an implementation of ) with the specified key () and initialization vector () to encrypt a file specified by `inName`. It then outputs the encrypted result to the file specified by `outName`. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DESCryptoServiceProvider/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic DES Example/VB/source.vb" id="Snippet1"::: - - Decryption can be handled in the same way; use instead of . The same key () and initialization vector () used to encrypt the file must be used to decrypt it. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic DES Example/VB/source.vb" id="Snippet1"::: + + Decryption can be handled in the same way; use instead of . The same key () and initialization vector () used to encrypt the file must be used to decrypt it. + ]]> The Data Encryption Standard () cryptographic service provider is not available. @@ -188,11 +186,11 @@ Creates a symmetric decryptor object with the current property and initialization vector (). A symmetric decryptor object. - overload with the same signature. - + overload with the same signature. + ]]> @@ -259,25 +257,25 @@ Creates a symmetric Data Encryption Standard () decryptor object with the specified key () and initialization vector (). A symmetric decryptor object. - overload with the same parameters. - + overload with the same parameters. + ]]> - The value of the property is . - - -or- - - The value of the property is and the value of the property is not 8. - - -or- - - An invalid key size was used. - - -or- - + The value of the property is . + + -or- + + The value of the property is and the value of the property is not 8. + + -or- + + An invalid key size was used. + + -or- + The algorithm key size was not available. Cryptographic Services @@ -326,13 +324,13 @@ Creates a symmetric encryptor object with the current property and initialization vector (). A symmetric encryptor object. - property is `null`, the method is called to create a new random . If the current property is `null`, the method is called to create a new random . - - Use the overload with the same signature to decrypt the result of this method. - + property is `null`, the method is called to create a new random . If the current property is `null`, the method is called to create a new random . + + Use the overload with the same signature to decrypt the result of this method. + ]]> @@ -399,40 +397,38 @@ Creates a symmetric Data Encryption Standard () encryptor object with the specified key () and initialization vector (). A symmetric encryptor object. - overload with the same parameters to decrypt the result of this method. - - - -## Examples - The following code example shows how to create and use a object to encrypt and decrypt data in a file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp" id="Snippet1"::: + overload with the same parameters to decrypt the result of this method. + + + +## Examples + The following code example shows how to create and use a object to encrypt and decrypt data in a file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DESCryptoServiceProvider/CreateEncryptor/fileexample.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/VB/fileexample.vb" id="Snippet1"::: - - The following code example shows how to create and use a object to encrypt and decrypt data in memory. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/VB/fileexample.vb" id="Snippet1"::: + + The following code example shows how to create and use a object to encrypt and decrypt data in memory. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DESCryptoServiceProvider/CreateEncryptor/memoryexample.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/VB/memoryexample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/VB/memoryexample.vb" id="Snippet1"::: + ]]> - The value of the property is . - - -or- - - The value of the property is and the value of the property is not 8. - - -or- - - An invalid key size was used. - - -or- - + The value of the property is . + + -or- + + The value of the property is and the value of the property is not 8. + + -or- + + An invalid key size was used. + + -or- + The algorithm key size was not available. Cryptographic Services @@ -479,11 +475,11 @@ Generates a random initialization vector () to use for the algorithm. - when none is specified. - + when none is specified. + ]]> Cryptographic Services @@ -531,13 +527,13 @@ Generates a random key () to be used for the algorithm. - ) or a semi-weak key (see ). - - This algorithm supports a key length of 64 bits. - + ) or a semi-weak key (see ). + + This algorithm supports a key length of 64 bits. + ]]> Cryptographic Services diff --git a/xml/System.Security.Cryptography/DSASignatureDeformatter.xml b/xml/System.Security.Cryptography/DSASignatureDeformatter.xml index 34983570b81..47cf79eb74d 100644 --- a/xml/System.Security.Cryptography/DSASignatureDeformatter.xml +++ b/xml/System.Security.Cryptography/DSASignatureDeformatter.xml @@ -65,18 +65,17 @@ Verifies a Digital Signature Algorithm () PKCS#1 v1.5 signature. - [!IMPORTANT] -> The creators of the DSA algorithm have withdrawn their support for it. Consider using the class or the class instead of the class. Use only for compatibility with legacy applications and data. - +> The creators of the DSA algorithm have withdrawn their support for it. Consider using the class or the class instead of the class. Use only for compatibility with legacy applications and data. + ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DSASignatureDeformatter/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/VB/sample.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -130,13 +129,12 @@ Initializes a new instance of the class. - Cryptographic Services @@ -234,13 +232,12 @@ The name of the hash algorithm to use for the signature deformatter. Specifies the hash algorithm for the Digital Signature Algorithm () signature deformatter. - The parameter does not map to the hash algorithm. @@ -349,20 +346,19 @@ if the signature is valid for the data; otherwise, . - - is . - - -or- - + is . + + -or- + is . The DSA key is missing. Cryptographic Services diff --git a/xml/System.Security.Cryptography/DSASignatureFormatter.xml b/xml/System.Security.Cryptography/DSASignatureFormatter.xml index acf0a614b1c..a1557d332ad 100644 --- a/xml/System.Security.Cryptography/DSASignatureFormatter.xml +++ b/xml/System.Security.Cryptography/DSASignatureFormatter.xml @@ -65,18 +65,17 @@ Creates a Digital Signature Algorithm () signature. - [!IMPORTANT] -> The creators of the DSA algorithm have withdrawn their support for it. Consider using the class or the class instead of the class. Use only for compatibility with legacy applications and data. - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp" id="Snippet1"::: +> The creators of the DSA algorithm have withdrawn their support for it. Consider using the class or the class instead of the class. Use only for compatibility with legacy applications and data. + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DSASignatureFormatter/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/VB/sample.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -175,13 +174,12 @@ The instance of the Digital Signature Algorithm () that holds the key. Initializes a new instance of the class with the specified key. - @@ -235,26 +233,25 @@ Creates the Digital Signature Algorithm () PKCS #1 signature for the specified data. The digital signature for the specified data. - . - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp" id="Snippet1"::: + . + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DSASignatureFormatter/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/VB/sample.vb" id="Snippet1"::: + ]]> is . - The OID is . - - -or- - + The OID is . + + -or- + The DSA key is . Cryptographic Services @@ -304,13 +301,12 @@ The name of the hash algorithm to use for the signature formatter. Specifies the hash algorithm for the Digital Signature Algorithm () signature formatter. - The parameter does not map to the hash algorithm. diff --git a/xml/System.Security.Cryptography/DataProtectionScope.xml b/xml/System.Security.Cryptography/DataProtectionScope.xml index 0cafc7728db..af41c1b5820 100644 --- a/xml/System.Security.Cryptography/DataProtectionScope.xml +++ b/xml/System.Security.Cryptography/DataProtectionScope.xml @@ -33,22 +33,21 @@ Specifies the scope of the data protection to be applied by the method. - and methods to protect data through encryption. + + **Caution** The LocalMachine enumeration value allows multiple accounts to unprotect data. Use this value only when you trust every account on a computer. For most situations, you should use the CurrentUser value. + + + +## Examples + The following code example shows how to use data protection. -## Remarks - This enumeration is used with the and methods to protect data through encryption. - - **Caution** The LocalMachine enumeration value allows multiple accounts to unprotect data. Use this value only when you trust every account on a computer. For most situations, you should use the CurrentUser value. - - - -## Examples - The following code example shows how to use data protection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DataProtectionScope/Overview/dataprotectionsample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography/FromBase64Transform.xml b/xml/System.Security.Cryptography/FromBase64Transform.xml index 8cb4f87cc27..dcdde0d8deb 100644 --- a/xml/System.Security.Cryptography/FromBase64Transform.xml +++ b/xml/System.Security.Cryptography/FromBase64Transform.xml @@ -78,7 +78,6 @@ ## Examples The following example decodes a base 64-encoded file to an output text file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/FromBase64Transform/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/VB/class1.vb" id="Snippet1"::: @@ -192,7 +191,6 @@ ## Examples The following example decodes a base 64-encoded file to an output text file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/FromBase64Transform/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/VB/class1.vb" id="Snippet1"::: @@ -762,7 +760,6 @@ For more information about Dispose and Finalize, see [Cleaning Up Unmanaged Reso ## Examples The following example decrypts a base 64-encoded file to an output text file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/FromBase64Transform/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/VB/class1.vb" id="Snippet1"::: @@ -846,7 +843,6 @@ For more information about Dispose and Finalize, see [Cleaning Up Unmanaged Reso ## Examples The following example decrypts a base 64-encoded file to an output text file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/FromBase64Transform/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/VB/class1.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/HMACSHA256.xml b/xml/System.Security.Cryptography/HMACSHA256.xml index 5e5d4acb8b9..50b387c30d4 100644 --- a/xml/System.Security.Cryptography/HMACSHA256.xml +++ b/xml/System.Security.Cryptography/HMACSHA256.xml @@ -83,7 +83,6 @@ ## Examples The following example shows how to sign a file by using the object and then how to verify the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HMACSHA256/Overview/hmacsha256.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/HMACSHA256/vb/hmacsha256.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/HMACSHA384.xml b/xml/System.Security.Cryptography/HMACSHA384.xml index 23f85773e1c..ed2e8903e11 100644 --- a/xml/System.Security.Cryptography/HMACSHA384.xml +++ b/xml/System.Security.Cryptography/HMACSHA384.xml @@ -83,7 +83,6 @@ ## Examples The following example shows how to sign a file by using the object, and then how to verify the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HMACSHA384/Overview/hmacsha384.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/HMACSHA384/vb/hmacsha384.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/HMACSHA512.xml b/xml/System.Security.Cryptography/HMACSHA512.xml index 2c08947e42e..b4768d235fe 100644 --- a/xml/System.Security.Cryptography/HMACSHA512.xml +++ b/xml/System.Security.Cryptography/HMACSHA512.xml @@ -83,7 +83,6 @@ ## Examples The following example shows how to sign a file by using the object and then how to verify the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HMACSHA512/Overview/hmacsha512.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/HMACSHA512/vb/hmacsha512.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/HashAlgorithm.xml b/xml/System.Security.Cryptography/HashAlgorithm.xml index 1a687a01934..79afaf96a57 100644 --- a/xml/System.Security.Cryptography/HashAlgorithm.xml +++ b/xml/System.Security.Cryptography/HashAlgorithm.xml @@ -90,7 +90,6 @@ ## Examples The following code example computes the hash for an array. This example assumes that there is a predefined byte array `dataArray[]`. is a derived class of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HashAlgorithm/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/KeyNumber.xml b/xml/System.Security.Cryptography/KeyNumber.xml index 4c18fd9db46..e6abf96cba0 100644 --- a/xml/System.Security.Cryptography/KeyNumber.xml +++ b/xml/System.Security.Cryptography/KeyNumber.xml @@ -62,18 +62,17 @@ Specifies whether to create an asymmetric signature key or an asymmetric exchange key. - property to inspect a key type or with the field to specify a key type. + +## Examples + The following code example demonstrates how to use the enumeration to specify a key type for an object. -## Remarks - Use the `KeyNumber` enumeration with the property to inspect a key type or with the field to specify a key type. - -## Examples - The following code example demonstrates how to use the enumeration to specify a key type for an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/KeyNumber/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.KeyNumber/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.KeyNumber/VB/sample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography/KeySizes.xml b/xml/System.Security.Cryptography/KeySizes.xml index 39bf23e91e4..59dc9a1c4bb 100644 --- a/xml/System.Security.Cryptography/KeySizes.xml +++ b/xml/System.Security.Cryptography/KeySizes.xml @@ -58,15 +58,14 @@ Determines the set of valid key sizes for the symmetric cryptographic algorithms. - class. -## Examples - The following example shows the use of members of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeySizes/Overview/members.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -119,15 +118,14 @@ The interval between valid key sizes. Initializes a new instance of the class with the specified key values. - constructor. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp" id="Snippet2"::: + constructor. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeySizes/Overview/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet2"::: + ]]> @@ -175,15 +173,14 @@ Specifies the maximum key size. The maximum key size. - property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp" id="Snippet4"::: + property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeySizes/Overview/members.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet4"::: + ]]> @@ -231,15 +228,14 @@ Specifies the minimum key size. The minimum key size. - property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp" id="Snippet3"::: + property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeySizes/Overview/members.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet3"::: + ]]> @@ -287,15 +283,14 @@ Specifies the interval between valid key sizes. The interval between valid key sizes. - property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp" id="Snippet5"::: + property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeySizes/Overview/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Security.Cryptography/KeyedHashAlgorithm.xml b/xml/System.Security.Cryptography/KeyedHashAlgorithm.xml index 0e2efcadbc1..9272d121ace 100644 --- a/xml/System.Security.Cryptography/KeyedHashAlgorithm.xml +++ b/xml/System.Security.Cryptography/KeyedHashAlgorithm.xml @@ -481,7 +481,6 @@ Allows an to attempt to free resources and perfor ## Examples The following code example demonstrates how to override the property to retrieve the key used in the current object. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp" id="Snippet22"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeyedHashAlgorithm/Key/contosokeyedhash.cs" id="Snippet22"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/VB/contosokeyedhash.vb" id="Snippet22"::: diff --git a/xml/System.Security.Cryptography/MaskGenerationMethod.xml b/xml/System.Security.Cryptography/MaskGenerationMethod.xml index 9dc1445eb64..6ddffd6e4ea 100644 --- a/xml/System.Security.Cryptography/MaskGenerationMethod.xml +++ b/xml/System.Security.Cryptography/MaskGenerationMethod.xml @@ -61,22 +61,21 @@ Represents the abstract class from which all mask generator algorithms must derive. - compute masks that are used in key exchange algorithms such as Optimal Asymmetric Encryption Padding (OAEP). + + This class is used by implementations of key exchange algorithms only for mask generation. Application code does not use this class directly. + + + +## Examples + The following code example demonstrates how to derive from the class. -## Remarks - Derived classes of compute masks that are used in key exchange algorithms such as Optimal Asymmetric Encryption Padding (OAEP). - - This class is used by implementations of key exchange algorithms only for mask generation. Application code does not use this class directly. - - - -## Examples - The following code example demonstrates how to derive from the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/MaskGenerationMethod/Overview/maskgenerator.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/VB/maskgenerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/VB/maskgenerator.vb" id="Snippet1"::: + ]]> @@ -175,13 +174,13 @@ When overridden in a derived class, generates a mask with the specified length using the specified random seed. A randomly generated mask whose length is equal to the parameter. - to create and return a mask using the specified seed. This code example is part of a larger example provided for the class. - - System.Security.Cryptography.MaskGenerationMethod#3 - + to create and return a mask using the specified seed. This code example is part of a larger example provided for the class. + + System.Security.Cryptography.MaskGenerationMethod#3 + ]]> diff --git a/xml/System.Security.Cryptography/Oid.xml b/xml/System.Security.Cryptography/Oid.xml index db54717f5c5..e780746ff09 100644 --- a/xml/System.Security.Cryptography/Oid.xml +++ b/xml/System.Security.Cryptography/Oid.xml @@ -57,18 +57,17 @@ Represents a cryptographic object identifier. This class cannot be inherited. - property is set to "1.3.6.1.5.5.7.3.4", the property, which is localized, is set automatically to "Secure Email". + +## Examples + The following code example shows how to use the class. -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + ]]> @@ -126,18 +125,17 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -184,18 +182,17 @@ The object identifier information to use to create the new object identifier. Initializes a new instance of the class using the specified object. - object to a new object. - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -250,18 +247,17 @@ An object identifier. Initializes a new instance of the class using a string value of an object. - object to a new object. - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -317,18 +313,17 @@ The friendly name of the identifier. Initializes a new instance of the class using the specified value and friendly name. - object. Note that if the Oid value is not recognized, the `value` and `friendlyName` parameters are not verified to determine if they correspond to each other. This is because there are object identifiers that .NET does not recognize, although an application may be able to interpret them. - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -376,21 +371,20 @@ Gets or sets the friendly name of the identifier. The friendly name of the identifier. - property is set to a known value, the value of the other property is updated automatically to a corresponding value. For example, if the property is set to "Secure Email", the property is set automatically to "1.3.6.1.5.5.7.3.4". In .NET 5 and later versions, this property is *init only*, meaning that its value can't be changed once it's been set. -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> .NET 5 and later: An attempt is made to set the value and the value has previously been set. @@ -553,21 +547,20 @@ In .NET 5 and later versions, this property is *init only*, meaning that its val Gets or sets the dotted number of the identifier. The dotted number of the identifier. - property is set to a known value, the value of the other property is updated automatically to a corresponding value. For example, if the property is set to "1.3.6.1.5.5.7.3.4", the property is set automatically to "Secure Email". In .NET 5 and later versions, this property is *init only*, meaning that its value can't be changed once it's been set. - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> .NET 5 and later: An attempt is made to set the value and the value has previously been set. diff --git a/xml/System.Security.Cryptography/OidCollection.xml b/xml/System.Security.Cryptography/OidCollection.xml index 512cc58f72b..a6c9eb0dd2e 100644 --- a/xml/System.Security.Cryptography/OidCollection.xml +++ b/xml/System.Security.Cryptography/OidCollection.xml @@ -64,20 +64,19 @@ Represents a collection of objects. This class cannot be inherited. - interface. - - - -## Examples - The following code example shows how to use the class. + interface. + + + +## Examples + The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -120,20 +119,19 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -184,20 +182,19 @@ Adds an object to the object. The index of the added object. - object to an existing collection at the current location. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + object to an existing collection at the current location. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -249,20 +246,19 @@ The location where the copy operation starts. Copies the object into an array. - object into an array at the specified location. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + object into an array at the specified location. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -312,15 +308,14 @@ Gets the number of objects in a collection. The number of objects in a collection. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -368,20 +363,19 @@ Returns an object that can be used to navigate the object. An object. - class implements the interface, which allows you to move within a collection. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + class implements the interface, which allows you to move within a collection. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -431,20 +425,19 @@ in all cases. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -505,20 +498,19 @@ Gets an object from the object. An object. - object from an object, if you know its location. You can use the property to retrieve an object if you know the value of the object's property or property. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + object from an object, if you know its location. You can use the property to retrieve an object if you know the value of the object's property or property. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -576,20 +568,19 @@ Gets the first object that contains a value of the property or a value of the property that matches the specified string value from the object. An object. - object from an object if you know the value of the or property of the object. You can use the property to retrieve an object if you know its location in the collection. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + object from an object if you know the value of the or property of the object. You can use the property to retrieve an object if you know its location in the collection. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -638,11 +629,11 @@ Gets an object that can be used to synchronize access to the object. An object that can be used to synchronize access to the object. - is not thread safe. Derived classes can provide their own synchronized version of the class using this property. The synchronizing code must perform operations on the property of the object, not directly on the object itself. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might simultaneously be modifying the object. - + is not thread safe. Derived classes can provide their own synchronized version of the class using this property. The synchronizing code must perform operations on the property of the object, not directly on the object itself. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might simultaneously be modifying the object. + ]]> @@ -697,18 +688,18 @@ The location where the copy operation starts. Copies the object into an array. - object into an array at the specified location. - + object into an array at the specified location. + ]]> - cannot be a multidimensional array. - - -or- - + cannot be a multidimensional array. + + -or- + The length of is an invalid offset length. is . @@ -844,11 +835,11 @@ This member is an explicit interface member implementation. It can be used only Returns an object that can be used to navigate the object. An object that can be used to navigate the collection. - class implements the interface, which allows you to move within a collection. - + class implements the interface, which allows you to move within a collection. + ]]> diff --git a/xml/System.Security.Cryptography/OidEnumerator.xml b/xml/System.Security.Cryptography/OidEnumerator.xml index fad23c6800a..77c0338b5b0 100644 --- a/xml/System.Security.Cryptography/OidEnumerator.xml +++ b/xml/System.Security.Cryptography/OidEnumerator.xml @@ -61,20 +61,19 @@ Provides the ability to navigate through an object. This class cannot be inherited. - interface. - - - -## Examples - The following code example shows how to use the class. + interface. + + + +## Examples + The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -121,24 +120,23 @@ Gets the current object in an object. The current object in the collection. - method must be called to advance the enumerator to the first element of the collection before reading the value of the property; otherwise, returns `null` or throws an exception. - - also returns `null` or throws an exception if the last call to returns `false`, which indicates that the end of the collection has been reached. - - does not move the position of the enumerator, and consecutive calls to return the same object, until is called. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + method must be called to advance the enumerator to the first element of the collection before reading the value of the property; otherwise, returns `null` or throws an exception. + + also returns `null` or throws an exception if the last call to returns `false`, which indicates that the end of the collection has been reached. + + does not move the position of the enumerator, and consecutive calls to return the same object, until is called. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -190,24 +188,23 @@ , if the enumerator was successfully advanced to the next element; , if the enumerator has passed the end of the collection. - method moves the enumerator over the first element of the collection. Subsequent calls to advances the enumerator past subsequent items in the collection. - - After the end of the collection is passed, calls to return `false`. - - An enumerator is valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to throws an . - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + method moves the enumerator over the first element of the collection. Subsequent calls to advances the enumerator past subsequent items in the collection. + + After the end of the collection is passed, calls to return `false`. + + An enumerator is valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to throws an . + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> The collection was modified after the enumerator was created. @@ -258,20 +255,19 @@ Sets an enumerator to its initial position. - object. An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to the method throws an . - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + object. An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to the method throws an . + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> The collection was modified after the enumerator was created. diff --git a/xml/System.Security.Cryptography/PasswordDeriveBytes.xml b/xml/System.Security.Cryptography/PasswordDeriveBytes.xml index ff906302c94..cc4c935a6b9 100644 --- a/xml/System.Security.Cryptography/PasswordDeriveBytes.xml +++ b/xml/System.Security.Cryptography/PasswordDeriveBytes.xml @@ -79,7 +79,6 @@ ## Examples The following code example creates a key from a password using the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/VB/sample.vb" id="Snippet1"::: @@ -167,7 +166,6 @@ ## Examples The following code example creates a key from a password using the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/VB/sample.vb" id="Snippet1"::: @@ -317,7 +315,6 @@ ## Examples The following code example creates a key from a password using the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/VB/sample.vb" id="Snippet1"::: @@ -827,7 +824,6 @@ ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/VB/sample.vb" id="Snippet2"::: diff --git a/xml/System.Security.Cryptography/ProtectedData.xml b/xml/System.Security.Cryptography/ProtectedData.xml index 1870c622968..1bdd4f7bd6b 100644 --- a/xml/System.Security.Cryptography/ProtectedData.xml +++ b/xml/System.Security.Cryptography/ProtectedData.xml @@ -44,26 +44,25 @@ Provides methods for encrypting and decrypting data. This class cannot be inherited. - [!IMPORTANT] > Because it depends on DPAPI, the `ProtectedData` class is supported on the Windows platform only. Its use on .NET Core on platforms other than Windows throws a . - -The class consists of two wrappers for the unmanaged DPAPI, and . These two methods can be used to encrypt and decrypt data such as passwords, keys, and connection strings. - -If you use these methods during impersonation, you may receive the following error: "Key not valid for use in specified state." This occurs because the DPAPI stores the key data in user profiles. If the profile is not loaded, DPAPI won't be able to perform the decryption. To prevent this error, load the profile of the user you want to impersonate before calling either method. Using DPAPI with impersonation can incur significant complication and requires careful design choices. -## Examples - The following example shows how to use data protection. +The class consists of two wrappers for the unmanaged DPAPI, and . These two methods can be used to encrypt and decrypt data such as passwords, keys, and connection strings. + +If you use these methods during impersonation, you may receive the following error: "Key not valid for use in specified state." This occurs because the DPAPI stores the key data in user profiles. If the profile is not loaded, DPAPI won't be able to perform the decryption. To prevent this error, load the profile of the user you want to impersonate before calling either method. Using DPAPI with impersonation can incur significant complication and requires careful design choices. + +## Examples + The following example shows how to use data protection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DataProtectionScope/Overview/dataprotectionsample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: + ]]> @@ -123,23 +122,22 @@ If you use these methods during impersonation, you may receive the following err Encrypts the data in a specified byte array and returns a byte array that contains the encrypted data. A byte array representing the encrypted data. - method. - + method. + > [!NOTE] -> If you use this method during impersonation, you may receive the following error: "Key not valid for use in specified state." To prevent this error, load the profile of the user you want to impersonate before calling the method. - - - -## Examples - The following example shows how to use data protection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp" id="Snippet1"::: +> If you use this method during impersonation, you may receive the following error: "Key not valid for use in specified state." To prevent this error, load the profile of the user you want to impersonate before calling the method. + + + +## Examples + The following example shows how to use data protection. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DataProtectionScope/Overview/dataprotectionsample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: + ]]> The parameter is . @@ -344,23 +342,22 @@ If you use these methods during impersonation, you may receive the following err Decrypts the data in a specified byte array and returns a byte array that contains the decrypted data. A byte array representing the decrypted data. - method. If the `optionalEntropy` parameter was used during encryption, it must be supplied to unencrypt the data. - + method. If the `optionalEntropy` parameter was used during encryption, it must be supplied to unencrypt the data. + > [!NOTE] -> If you use this method during impersonation, you may receive the following error: "Key not valid for use in specified state." To prevent this error, load the profile of the user you want to impersonate before calling the method. - - - -## Examples - The following code example shows how to use data protection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp" id="Snippet1"::: +> If you use this method during impersonation, you may receive the following error: "Key not valid for use in specified state." To prevent this error, load the profile of the user you want to impersonate before calling the method. + + + +## Examples + The following code example shows how to use data protection. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DataProtectionScope/Overview/dataprotectionsample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: + ]]> The parameter is . diff --git a/xml/System.Security.Cryptography/RC2.xml b/xml/System.Security.Cryptography/RC2.xml index f59d8d9be8d..420e9442aa6 100644 --- a/xml/System.Security.Cryptography/RC2.xml +++ b/xml/System.Security.Cryptography/RC2.xml @@ -220,13 +220,11 @@ ## Examples The following example shows how to create and use an RC2 object to encrypt and decrypt data in a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2/Create/fileexample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2.Create.File/VB/fileexample.vb" id="Snippet1"::: The following example shows how to create and use an RC2 object to encrypt and decrypt data in memory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2/Create/memoryexample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/RC2CryptoServiceProvider.xml b/xml/System.Security.Cryptography/RC2CryptoServiceProvider.xml index e2bb45200f3..4425846e58a 100644 --- a/xml/System.Security.Cryptography/RC2CryptoServiceProvider.xml +++ b/xml/System.Security.Cryptography/RC2CryptoServiceProvider.xml @@ -70,26 +70,26 @@ Defines a wrapper object to access the cryptographic service provider (CSP) implementation of the algorithm. This class cannot be inherited. - implementation supports key lengths from 40 bits to 128 bits in increments of 8 bits. - - The object is a block cipher that encrypts and decrypts data in blocks of 8 bytes. This class pads the final block of data if it is less than 8 bytes. As a result of this padding, the length of encrypted data could be greater than the original plaintext. - - Note that the object does not use salt. - + implementation supports key lengths from 40 bits to 128 bits in increments of 8 bits. + + The object is a block cipher that encrypts and decrypts data in blocks of 8 bytes. This class pads the final block of data if it is less than 8 bytes. As a result of this padding, the length of encrypted data could be greater than the original plaintext. + + Note that the object does not use salt. + > [!NOTE] -> A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the algorithm and its derived classes instead of the class. Use only for compatibility with legacy applications and data. - - - -## Examples - The following code example encrypts and then decrypts a string. - +> A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the algorithm and its derived classes instead of the class. Use only for compatibility with legacy applications and data. + + + +## Examples + The following code example encrypts and then decrypts a string. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/Overview/class1.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -147,14 +147,14 @@ Initializes a new instance of the class. - The cryptographic service provider (CSP) cannot be acquired. @@ -234,33 +234,33 @@ Creates a symmetric decryptor object with the specified key () and initialization vector (). A symmetric decryptor object. - overload with the same parameters. - - - -## Examples - The following code example encrypts and then decrypts a string. - + overload with the same parameters. + + + +## Examples + The following code example encrypts and then decrypts a string. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: + ]]> - An cipher mode was used. - - -or- - - A cipher mode with a feedback size other than 8 bits was used. - - -or- - - An invalid key size was used. - - -or- - + An cipher mode was used. + + -or- + + A cipher mode with a feedback size other than 8 bits was used. + + -or- + + An invalid key size was used. + + -or- + The algorithm key size was not available. Cryptographic Services @@ -337,33 +337,33 @@ Creates a symmetric encryptor object with the specified key () and initialization vector (). A symmetric encryptor object. - overload with the same parameters to decrypt the result of this method. - - - -## Examples - The following code example encrypts and then decrypts a string. - + overload with the same parameters to decrypt the result of this method. + + + +## Examples + The following code example encrypts and then decrypts a string. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: + ]]> - An cipher mode was used. - - -or- - - A cipher mode with a feedback size other than 8 bits was used. - - -or- - - An invalid key size was used. - - -or- - + An cipher mode was used. + + -or- + + A cipher mode with a feedback size other than 8 bits was used. + + -or- + + An invalid key size was used. + + -or- + The algorithm key size was not available. Cryptographic Services @@ -456,19 +456,19 @@ Generates a random initialization vector () to use for the algorithm. - when none is specified. - - - -## Examples - The following code example encrypts and then decrypts a string. - + when none is specified. + + + +## Examples + The following code example encrypts and then decrypts a string. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -516,21 +516,21 @@ Generates a random key () to be used for the algorithm. - implementation supports key lengths from 40 bits to 128 bits in increments of 8 bits. - - - -## Examples - The following code example encrypts and then decrypts a string. - + implementation supports key lengths from 40 bits to 128 bits in increments of 8 bits. + + + +## Examples + The following code example encrypts and then decrypts a string. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -588,20 +588,19 @@ if the key should be created with an 11-byte-long, zero-value salt; otherwise, . The default is . - property allows you to interoperate with an existing application that uses an 11-byte-long, zero-value salt. For most scenarios, you should not use a salt with an key. + property allows you to interoperate with an existing application that uses an 11-byte-long, zero-value salt. For most scenarios, you should not use a salt with an key. + + + +## Examples + The following code example sets the property to `true`, and then encrypts and decrypts a value. - - -## Examples - The following code example sets the property to `true`, and then encrypts and decrypts a value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/UseSalt/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/VB/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/VB/example.vb" id="Snippet1"::: + ]]> Cryptographic Services diff --git a/xml/System.Security.Cryptography/RNGCryptoServiceProvider.xml b/xml/System.Security.Cryptography/RNGCryptoServiceProvider.xml index a7ab0266c81..9493543bead 100644 --- a/xml/System.Security.Cryptography/RNGCryptoServiceProvider.xml +++ b/xml/System.Security.Cryptography/RNGCryptoServiceProvider.xml @@ -70,19 +70,18 @@ Implements a cryptographic Random Number Generator (RNG) using the implementation provided by the cryptographic service provider (CSP). This class cannot be inherited. - [!IMPORTANT] -> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - - - -## Examples - The following code example shows how to create a random number with the class. +> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + + + +## Examples + The following code example shows how to create a random number with the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RNGCryptoServiceProvider/Overview/rngcsp.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RNGCSP/VB/rngcsp.vb" id="Snippet1"::: @@ -146,15 +145,14 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RNGCryptoServiceProvider/Overview/rngcsp.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RNGCSP/VB/rngcsp.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RNGCSP/VB/rngcsp.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -208,11 +206,11 @@ A byte array. This value is ignored. Initializes a new instance of the class. - class. Calling this method is equivalent to calling the constructor and passing `null`. - + class. Calling this method is equivalent to calling the constructor and passing `null`. + ]]> Cryptographic Services @@ -318,11 +316,11 @@ The string input. This parameter is ignored. Initializes a new instance of the class. - class. Calling this method is equivalent to calling the constructor and passing `null`. - + class. Calling this method is equivalent to calling the constructor and passing `null`. + ]]> Cryptographic Services @@ -461,22 +459,21 @@ The array to fill with a cryptographically strong sequence of random values. Fills an array of bytes with a cryptographically strong sequence of random values. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RNGCryptoServiceProvider/Overview/rngcsp.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RNGCSP/VB/rngcsp.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RNGCSP/VB/rngcsp.vb" id="Snippet1"::: + ]]> The cryptographic service provider (CSP) cannot be acquired. @@ -622,20 +619,19 @@ The array to fill with a cryptographically strong sequence of random nonzero values. Fills an array of bytes with a cryptographically strong sequence of random nonzero values. - The cryptographic service provider (CSP) cannot be acquired. diff --git a/xml/System.Security.Cryptography/RSACryptoServiceProvider.xml b/xml/System.Security.Cryptography/RSACryptoServiceProvider.xml index 90c2139f0c7..ef09c633e72 100644 --- a/xml/System.Security.Cryptography/RSACryptoServiceProvider.xml +++ b/xml/System.Security.Cryptography/RSACryptoServiceProvider.xml @@ -76,13 +76,11 @@ class to encrypt a string into an array of bytes and then decrypt the bytes back into a string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/VB/sample.vb" id="Snippet1"::: The following code example exports the key information created using the into an object. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/VB/sample.vb" id="Snippet1"::: ]]> @@ -162,7 +160,6 @@ If no key is loaded via the class to encrypt a string into an array of bytes and then decrypt the bytes back into a string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/VB/sample.vb" id="Snippet1"::: @@ -238,7 +235,6 @@ If no key is loaded via the , generates a new key, and stores it in a key container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/.ctor/example1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/VB/example.vb" id="Snippet1"::: @@ -320,7 +316,6 @@ If no key is loaded via the object, generates a new key, and stores it in a key container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/VB/example.vb" id="Snippet1"::: @@ -404,7 +399,6 @@ If no key is loaded via the , generates a new key, and stores it in a key container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/.ctor/example2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/VB/example.vb" id="Snippet1"::: @@ -489,7 +483,6 @@ If no key is loaded via the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspKeyContainerInfo/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/VB/sample.vb" id="Snippet1"::: @@ -577,7 +570,6 @@ If no key is loaded via the class; however, the class may be preferable in large data operations. The encrypted value can be saved as an `nvarchar` data type in Microsoft SQL Server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Decrypt/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/VB/example.vb" id="Snippet1"::: @@ -860,7 +852,6 @@ If no key is loaded via the object to the value of a public key (sent by another party), generates a session key using the algorithm, and then encrypts the session key using the object. Using this scheme, the session key could be sent back to the owner of the private RSA key and the two parties could use the session key to exchange encrypted data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Encrypt/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/VB/sample.vb" id="Snippet1"::: @@ -1129,7 +1120,6 @@ If no key is loaded via the into an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/VB/sample.vb" id="Snippet1"::: @@ -1478,7 +1468,6 @@ If no key is loaded via the object into an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/ImportParameters/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/VB/sample.vb" id="Snippet1"::: @@ -1727,7 +1716,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example creates an object and persists the key to a key container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/PersistKeyInCsp/example.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/VB/example.vb" id="Snippet1"::: @@ -1929,7 +1917,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example signs and verifies data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignData/example1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/VB/example.vb" id="Snippet1"::: @@ -2007,7 +1994,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example signs and verifies data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignData/example2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/VB/example.vb" id="Snippet1"::: @@ -2097,7 +2083,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example signs and verifies data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignData/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/VB/example.vb" id="Snippet1"::: @@ -2195,7 +2180,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example encrypts some data, creates a hash of the encrypted data, and then signs hash with a digital signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignHash/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/VB/class1.vb" id="Snippet1"::: @@ -2326,7 +2310,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example creates an object and sets the static property to use the machine key store instead of the user profile key store. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/UseMachineKeyStore/example2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/VB/example2.vb" id="Snippet2"::: @@ -2416,7 +2399,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following example shows how to use the method to verify a signature. This code example is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignHash/class1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/VB/class1.vb" id="Snippet2"::: @@ -2509,7 +2491,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following example shows how to use the method to verify a signature. This code example is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignHash/class1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/VB/class1.vb" id="Snippet2"::: diff --git a/xml/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.xml b/xml/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.xml index 63d4db99db6..4c15b11062e 100644 --- a/xml/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.xml +++ b/xml/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.xml @@ -65,24 +65,24 @@ Decrypts Optimal Asymmetric Encryption Padding (OAEP) key exchange data. - to create the key exchange message with the algorithm. - + to create the key exchange message with the algorithm. + > [!CAUTION] -> It is highly recommended that you not attempt to create your own key exchange method from the basic functionality provided, because many details of the operation must be performed carefully in order for the key exchange to be successful. - - - -## Examples - The following example shows how to use the class to recreate an exchange key to be used to decrypt a message. - +> It is highly recommended that you not attempt to create your own key exchange method from the basic functionality provided, because many details of the operation must be performed carefully in order for the key exchange to be successful. + + + +## Examples + The following example shows how to use the class to recreate an exchange key to be used to decrypt a message. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -136,11 +136,11 @@ Initializes a new instance of the class. - to establish the key before calling . - + to establish the key before calling . + ]]> Cryptographic Services @@ -245,19 +245,19 @@ Extracts secret information from the encrypted key exchange data. The secret information derived from the key exchange data. - method to recreate an exchange key from a message sender. This code example is part of a larger example provided for the class. - + method to recreate an exchange key from a message sender. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Overview/program.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet3"::: + ]]> The key exchange data verification has failed. @@ -314,15 +314,14 @@ Gets the parameters for the Optimal Asymmetric Encryption Padding (OAEP) key exchange. An XML string containing the parameters of the OAEP key exchange operation. - property to retrieve an XML representation of the parameters. This code example is part of a larger example provided for the class. -## Examples - The following code example demonstrates how to call the property to retrieve an XML representation of the parameters. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet12"::: + ]]> Cryptographic Services @@ -373,11 +372,11 @@ The instance of the algorithm that holds the private key. Sets the private key to use for decrypting the secret information. - . - + . + ]]> diff --git a/xml/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.xml b/xml/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.xml index c9dd2e26c96..be3d9c73af7 100644 --- a/xml/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.xml +++ b/xml/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.xml @@ -65,24 +65,24 @@ Creates Optimal Asymmetric Encryption Padding (OAEP) key exchange data using . - to receive the key exchange and extract the secret information from it. - + to receive the key exchange and extract the secret information from it. + > [!CAUTION] -> It is highly recommended that you not attempt to create your own key exchange method from the basic functionality provided, because many details of the operation must be performed carefully in order for the key exchange to be successful. - - - -## Examples - The following example shows how to use the class to create an exchange key for a message recipient. - +> It is highly recommended that you not attempt to create your own key exchange method from the basic functionality provided, because many details of the operation must be performed carefully in order for the key exchange to be successful. + + + +## Examples + The following example shows how to use the class to create an exchange key for a message recipient. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -136,11 +136,11 @@ Initializes a new instance of the class. - to set the key before calling . - + to set the key before calling . + ]]> Cryptographic Services @@ -255,11 +255,11 @@ Creates the encrypted key exchange data from the specified input data. The encrypted key exchange data to be sent to the intended recipient. - The key is missing. @@ -322,19 +322,19 @@ Creates the encrypted key exchange data from the specified input data. The encrypted key exchange data to be sent to the intended recipient. - method to create an exchange key for a message recipient. This code example is part of a larger example provided for the class - + method to create an exchange key for a message recipient. This code example is part of a larger example provided for the class + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter/CreateKeyExchange/program.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsapkcs1keyexchangeformatter2/vb/program.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsapkcs1keyexchangeformatter2/vb/program.vb" id="Snippet2"::: + ]]> Cryptographic Services @@ -383,15 +383,14 @@ Gets or sets the parameter used to create padding in the key exchange creation process. The parameter value. - property to an field. This code example is part of a larger example provided for the class. -## Examples - The following code example demonstrates how to set the property to an field. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet7"::: + ]]> Cryptographic Services @@ -440,15 +439,14 @@ Gets the parameters for the Optimal Asymmetric Encryption Padding (OAEP) key exchange. An XML string containing the parameters of the OAEP key exchange operation. - property to retrieve an XML representation of the parameters. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp" id="Snippet13"::: + property to retrieve an XML representation of the parameters. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet13"::: + ]]> Cryptographic Services @@ -497,20 +495,19 @@ Gets or sets the random number generator algorithm to use in the creation of the key exchange. The instance of a random number generator algorithm to use. - property to a random number. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp" id="Snippet6"::: + property to a random number. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet6"::: + ]]> Cryptographic Services @@ -561,20 +558,19 @@ The instance of the algorithm that holds the public key. Sets the public key to use for encrypting the key exchange data. - . - - - -## Examples - The following code example demonstrates how to use the method to set an key for decryption. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp" id="Snippet5"::: + . + + + +## Examples + The following code example demonstrates how to use the method to set an key for decryption. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Security.Cryptography/RandomNumberGenerator.xml b/xml/System.Security.Cryptography/RandomNumberGenerator.xml index ab99bf5b532..665001cd565 100644 --- a/xml/System.Security.Cryptography/RandomNumberGenerator.xml +++ b/xml/System.Security.Cryptography/RandomNumberGenerator.xml @@ -73,14 +73,14 @@ Provides functionality for generating random values. - Cryptographic Services @@ -131,11 +131,11 @@ To create a random number generator, call the @System.Security.Cryptography.Rand Initializes a new instance of . - . - + . + ]]> Cryptographic Services @@ -340,16 +340,16 @@ To create a random number generator, call the @System.Security.Cryptography.Rand When overridden in a derived class, releases all resources used by the current instance of the class. - . The `Dispose` method leaves the in an unusable state. After calling `Dispose`, you must release all references to the so the garbage collector can reclaim the memory that the was occupying. - - For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). - -> [!NOTE] -> Always call `Dispose` before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method. - + . The `Dispose` method leaves the in an unusable state. After calling `Dispose`, you must release all references to the so the garbage collector can reclaim the memory that the was occupying. + + For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). + +> [!NOTE] +> Always call `Dispose` before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method. + ]]> @@ -401,19 +401,19 @@ To create a random number generator, call the @System.Security.Cryptography.Rand to release both managed and unmanaged resources; to release only unmanaged resources. When overridden in a derived class, releases the unmanaged resources used by the and optionally releases the managed resources. - method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`. - - When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this references. This method invokes the `Dispose()` method of each referenced object. - + method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`. + + When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this references. This method invokes the `Dispose()` method of each referenced object. + ]]> - can be called multiple times by other objects. When overriding , be careful not to reference objects that have been previously disposed in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. - + can be called multiple times by other objects. When overriding , be careful not to reference objects that have been previously disposed in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. + For more information about and , see Cleaning Up Unmanaged Resources. Cryptographic Services @@ -517,18 +517,17 @@ To create a random number generator, call the @System.Security.Cryptography.Rand The array to fill with cryptographically strong random bytes. When overridden in a derived class, fills an array of bytes with a cryptographically strong random sequence of values. - Cryptographic Services @@ -695,7 +694,7 @@ To create a random number generator, call the @System.Security.Cryptography.Rand The length of string to create. - if the hexadecimal characters should be lowercase; if they should be uppercase. + if the hexadecimal characters should be lowercase; if they should be uppercase. The default is . Creates a string filled with cryptographically random hexadecimal characters. A string populated with random hexadecimal characters. @@ -731,7 +730,7 @@ To create a random number generator, call the @System.Security.Cryptography.Rand The buffer to receive the characters. - if the hexadecimal characters should be lowercase; if they should be uppercase. + if the hexadecimal characters should be lowercase; if they should be uppercase. The default is . Fills a buffer with cryptographically random hexadecimal characters. The behavior of this is the same as using and specifying hexadecimal characters as the choices. This implementation is optimized specifically for hexadecimal characters. @@ -774,15 +773,15 @@ To create a random number generator, call the @System.Security.Cryptography.Rand Generates a random integer between 0 (inclusive) and a specified exclusive upper bound using a cryptographically strong random number generator. A random integer between 0 (inclusive) and (exclusive). - . - - This method uses a discard-and-retry strategy to avoid the low value bias that a simple modular arithmetic operation would produce. - + . + + This method uses a discard-and-retry strategy to avoid the low value bias that a simple modular arithmetic operation would produce. + ]]> The parameter is less than or equal to 0. @@ -827,17 +826,17 @@ To create a random number generator, call the @System.Security.Cryptography.Rand Generates a random integer between a specified inclusive lower bound and a specified exclusive upper bound using a cryptographically strong random number generator. A random integer between (inclusive) and (exclusive). - . - - This method uses a discard-and-retry strategy to avoid the low value bias that a simple modular arithmetic operation would produce. - - Negative values are permitted for both `fromInclusive` and `toExclusive`. - + . + + This method uses a discard-and-retry strategy to avoid the low value bias that a simple modular arithmetic operation would produce. + + Negative values are permitted for both `fromInclusive` and `toExclusive`. + ]]> The parameter is less than or equal to the parameter. @@ -1003,20 +1002,19 @@ To create a random number generator, call the @System.Security.Cryptography.Rand The array to fill with cryptographically strong random nonzero bytes. When overridden in a derived class, fills an array of bytes with a cryptographically strong random sequence of nonzero values. - Cryptographic Services diff --git a/xml/System.Security.Cryptography/Rfc2898DeriveBytes.xml b/xml/System.Security.Cryptography/Rfc2898DeriveBytes.xml index 60486010b50..4b4c7fe5db2 100644 --- a/xml/System.Security.Cryptography/Rfc2898DeriveBytes.xml +++ b/xml/System.Security.Cryptography/Rfc2898DeriveBytes.xml @@ -82,7 +82,6 @@ ## Examples The following code example uses the class to create two identical keys for the class. It then encrypts and decrypts some data using the keys. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet1"::: @@ -174,7 +173,6 @@ ## Examples The following code example uses the class to create two identical keys for the class. It then encrypts and decrypts some data using the keys. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet1"::: @@ -413,7 +411,6 @@ For more information about PBKDF2, see [RFC 2898](https://www.rfc-editor.org/inf ## Examples The following code example uses the class to create two identical keys for the class. It then encrypts and decrypts some data using the keys. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet1"::: @@ -891,7 +888,6 @@ For more information about PBKDF2, see [RFC 2898](https://www.rfc-editor.org/inf ## Examples The following example shows how to use the method to get the key for an instance of . This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet2"::: @@ -992,7 +988,6 @@ For more information about PBKDF2, see [RFC 2898](https://www.rfc-editor.org/inf ## Examples The following example shows how to use the property to display the number of iterations used in the generation of the key. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet3"::: @@ -1412,7 +1407,6 @@ The `password` is converted to bytes using the UTF8 encoding. For other encoding ## Examples The following example shows how to use the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet5"::: diff --git a/xml/System.Security.Cryptography/RijndaelManaged.xml b/xml/System.Security.Cryptography/RijndaelManaged.xml index e1d16bdcb80..e80da098c55 100644 --- a/xml/System.Security.Cryptography/RijndaelManaged.xml +++ b/xml/System.Security.Cryptography/RijndaelManaged.xml @@ -73,18 +73,17 @@ Accesses the managed version of the algorithm. This class cannot be inherited. - -compatible). In .NET Core, it is the same as AES and supports only a 128-bit block size. - + -compatible). In .NET Core, it is the same as AES and supports only a 128-bit block size. + > [!IMPORTANT] -> The class is the predecessor of the algorithm. You should use the algorithm instead of . For more information, see the entry [The Differences Between Rijndael and AES](https://learn.microsoft.com/archive/blogs/shawnfa/the-differences-between-rijndael-and-aes) in the .NET Security blog. - -## Examples - The following example demonstrates how to encrypt and decrypt sample data using the `RijndaelManaged` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp" id="Snippet1"::: +> The class is the predecessor of the algorithm. You should use the algorithm instead of . For more information, see the entry [The Differences Between Rijndael and AES](https://learn.microsoft.com/archive/blogs/shawnfa/the-differences-between-rijndael-and-aes) in the .NET Security blog. + +## Examples + The following example demonstrates how to encrypt and decrypt sample data using the `RijndaelManaged` class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RijndaelManaged/Overview/class1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RijndaelManaged Example/VB/class1.vb" id="Snippet1"::: @@ -131,15 +130,14 @@ Initializes a new instance of the class. - This class is not compliant with the FIPS algorithm. @@ -180,10 +178,10 @@ Gets or sets the block size, in bits, of the cryptographic operation. The block size, in bits, of the cryptographic operation. The default is 128 bits. - for more information about block size. + for more information about block size. ]]> @@ -233,11 +231,11 @@ Creates a symmetric decryptor object with the current property and initialization vector (). A symmetric decryptor object. - overload with the same signature. - + overload with the same signature. + ]]> @@ -298,28 +296,27 @@ Creates a symmetric decryptor object with the specified and initialization vector (). A symmetric decryptor object. - overload with the same signature. - - The `rgbkey` size must be 128, 192, or 256 bits. - - - -## Examples - The following code example demonstrates how to use the method to decrypt messages encoded with the same signature parameter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp" id="Snippet1"::: + overload with the same signature. + + The `rgbkey` size must be 128, 192, or 256 bits. + + + +## Examples + The following code example demonstrates how to use the method to decrypt messages encoded with the same signature parameter. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RijndaelManaged/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RijndaelManaged Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RijndaelManaged Example/VB/class1.vb" id="Snippet1"::: + ]]> - The parameter is . - - -or- - + The parameter is . + + -or- + The parameter is . The value of the property is not , , or . Cryptographic Services @@ -360,12 +357,12 @@ Creates a symmetric encryptor object with the current property and initialization vector (). A symmetric encryptor object. - property is `null`, the method is called to create a new random . If the current property is `null`, the method is called to create a new random . - - Use the overload with the same signature to decrypt the result of this method. + property is `null`, the method is called to create a new random . If the current property is `null`, the method is called to create a new random . + + Use the overload with the same signature to decrypt the result of this method. ]]> @@ -426,28 +423,27 @@ Creates a symmetric encryptor object with the specified and initialization vector (). A symmetric encryptor object. - overload with the same signature to decrypt the result of this method. - - The `rgbkey` size must be 128, 192, or 256 bits. - - - -## Examples - The following code examples demonstrates how to encrypt a message using the `CreateEncryptor` method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp" id="Snippet1"::: + overload with the same signature to decrypt the result of this method. + + The `rgbkey` size must be 128, 192, or 256 bits. + + + +## Examples + The following code examples demonstrates how to encrypt a message using the `CreateEncryptor` method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RijndaelManaged/Overview/class1.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RijndaelManaged Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RijndaelManaged Example/VB/class1.vb" id="Snippet1"::: + ]]> - The parameter is . - - -or- - + The parameter is . + + -or- + The parameter is . The value of the property is not , , or . Cryptographic Services @@ -574,18 +570,17 @@ Generates a random initialization vector () to be used for the algorithm. - Cryptographic Services @@ -633,18 +628,17 @@ Generates a random to be used for the algorithm. - Cryptographic Services @@ -684,10 +678,10 @@ Gets or sets the initialization vector (IV) to use for the symmetric algorithm. The initialization vector (IV) to use for the symmetric algorithm. - for more information about initialization vectors. + for more information about initialization vectors. ]]> @@ -727,10 +721,10 @@ Gets or sets the secret key used for the symmetric algorithm. The secret key used for the symmetric algorithm. - for more information about the secret key. + for more information about the secret key. ]]> @@ -770,10 +764,10 @@ Gets or sets the size, in bits, of the secret key used for the symmetric algorithm. The size, in bits, of the secret key used for the symmetric algorithm. The default is 256 bits. - @@ -813,10 +807,10 @@ Gets the key sizes, in bits, that are supported by the symmetric algorithm. The key sizes, in bits, that are supported by the symmetric algorithm. - @@ -856,10 +850,10 @@ Gets or sets the mode for operation of the symmetric algorithm. The mode for operation of the symmetric algorithm. The default is - enumeration for a description of specific modes. + enumeration for a description of specific modes. ]]> @@ -899,10 +893,10 @@ Gets or sets the padding mode used in the symmetric algorithm. The padding mode used in the symmetric algorithm. The default is . - property for more information about padding. + property for more information about padding. ]]> diff --git a/xml/System.Security.Cryptography/SHA256.xml b/xml/System.Security.Cryptography/SHA256.xml index 84b2ff59f48..b9b36ecd3be 100644 --- a/xml/System.Security.Cryptography/SHA256.xml +++ b/xml/System.Security.Cryptography/SHA256.xml @@ -72,7 +72,6 @@ ## Examples The following example calculates the SHA-256 hash for all files in a directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HashAlgorithm/ComputeHash/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA256 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SHA256Managed.xml b/xml/System.Security.Cryptography/SHA256Managed.xml index e56f330b061..9dd8376d90f 100644 --- a/xml/System.Security.Cryptography/SHA256Managed.xml +++ b/xml/System.Security.Cryptography/SHA256Managed.xml @@ -81,7 +81,6 @@ ## Examples The following example calculates the SHA-256 hash for all files in a directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HashAlgorithm/ComputeHash/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA256 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SHA384.xml b/xml/System.Security.Cryptography/SHA384.xml index cf56d6e8e7e..e3fada16642 100644 --- a/xml/System.Security.Cryptography/SHA384.xml +++ b/xml/System.Security.Cryptography/SHA384.xml @@ -72,7 +72,6 @@ ## Examples The following example computes the hash for `data` and stores it in `result`. This example assumes that there is a predefined constant `DATA_SIZE`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SHA384/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA384 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SHA384Managed.xml b/xml/System.Security.Cryptography/SHA384Managed.xml index 4e6e0fd653d..435fa142600 100644 --- a/xml/System.Security.Cryptography/SHA384Managed.xml +++ b/xml/System.Security.Cryptography/SHA384Managed.xml @@ -81,7 +81,6 @@ ## Examples The following example computes the hash for `data` and stores it in `result`. This example assumes that there is a predefined constant `DATA_SIZE`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384Managed Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SHA384Managed/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA384Managed Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SHA512.xml b/xml/System.Security.Cryptography/SHA512.xml index 75b97dd9458..e726e6b95c7 100644 --- a/xml/System.Security.Cryptography/SHA512.xml +++ b/xml/System.Security.Cryptography/SHA512.xml @@ -74,7 +74,6 @@ ## Examples The following example computes the hash for `data` and stores it in `result`. This example assumes that there is a predefined constant `DATA_SIZE`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SHA512/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA512 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SHA512Managed.xml b/xml/System.Security.Cryptography/SHA512Managed.xml index 79ea0ffe6df..c49f848628c 100644 --- a/xml/System.Security.Cryptography/SHA512Managed.xml +++ b/xml/System.Security.Cryptography/SHA512Managed.xml @@ -81,7 +81,6 @@ ## Examples The following example computes the hash for `data` and stores it in `result`. This example assumes that there is a predefined constant `DATA_SIZE`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512Managed Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SHA512Managed/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA512Managed Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SymmetricAlgorithm.xml b/xml/System.Security.Cryptography/SymmetricAlgorithm.xml index 6cf7153a856..8e68834d66d 100644 --- a/xml/System.Security.Cryptography/SymmetricAlgorithm.xml +++ b/xml/System.Security.Cryptography/SymmetricAlgorithm.xml @@ -78,7 +78,6 @@ ## Examples The following code example uses the class with the specified property and initialization vector () to encrypt a file specified by `inName`, and outputs the encrypted result to the file specified by `outName`. The `desKey` and `desIV` parameters to the method are 8-byte arrays. You must have the high encryption pack installed to run this example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SymmetricAlgorithm/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic CryptoStream Example/VB/source.vb" id="Snippet1"::: @@ -654,7 +653,6 @@ We recommend that you specify the algorithm by calling the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/cpp/encryptor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SymmetricAlgorithm/CreateEncryptor/encryptor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/vb/encryptor.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/ToBase64Transform.xml b/xml/System.Security.Cryptography/ToBase64Transform.xml index 805522741be..d5f4e1d9c3b 100644 --- a/xml/System.Security.Cryptography/ToBase64Transform.xml +++ b/xml/System.Security.Cryptography/ToBase64Transform.xml @@ -78,7 +78,6 @@ ## Examples The following code example demonstrates how to use members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet1"::: @@ -178,7 +177,6 @@ ## Examples The following code example demonstrates how to call the property to determine if the current transform can be reused. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet3"::: @@ -238,7 +236,6 @@ ## Examples The following code example demonstrates how to call the method to verify that multiple blocks can be transformed. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet4"::: @@ -301,7 +298,6 @@ ## Examples The following code example demonstrates how to call the method to free up unused resources by the current transform. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet7"::: @@ -541,7 +537,6 @@ ## Examples The following code example demonstrates how to call the property to retrieve the input block size of the current transform. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet5"::: @@ -605,7 +600,6 @@ ## Examples The following code example demonstrates how to call the property to create a new byte array with the size of the output block size. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet6"::: @@ -731,7 +725,6 @@ For more information about `Dispose` and `Finalize`, see [Cleaning Up Unmanaged ## Examples The following code example demonstrates how to call the method to iterate through `inputBytes` transforming by `blockSize`. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet8"::: @@ -807,7 +800,6 @@ For more information about `Dispose` and `Finalize`, see [Cleaning Up Unmanaged ## Examples The following code example demonstrates how to call the method to transform the final block of data. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet9"::: diff --git a/xml/System.Security.Cryptography/TripleDES.xml b/xml/System.Security.Cryptography/TripleDES.xml index ae3b04001f5..6bc20e33421 100644 --- a/xml/System.Security.Cryptography/TripleDES.xml +++ b/xml/System.Security.Cryptography/TripleDES.xml @@ -68,28 +68,28 @@ Represents the base class for Triple Data Encryption Standard algorithms from which all implementations must derive. - uses three successive iterations of the algorithm. It can use either two or three 56-bit keys. - + uses three successive iterations of the algorithm. It can use either two or three 56-bit keys. + > [!NOTE] -> A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the class and its derived classes instead of the class. Use only for compatibility with legacy applications and data. - - This algorithm supports key lengths from 128 bits to 192 bits in increments of 64 bits. - - - -## Examples - The following code example shows how to create and use a object to encrypt and decrypt data in a file. - +> A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the class and its derived classes instead of the class. Use only for compatibility with legacy applications and data. + + This algorithm supports key lengths from 128 bits to 192 bits in increments of 64 bits. + + + +## Examples + The following code example shows how to create and use a object to encrypt and decrypt data in a file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/TripleDES/Create/fileexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.File/VB/fileexample.vb" id="Snippet1"::: - - The following code example shows how to create and use a object to encrypt and decrypt data in memory. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.File/VB/fileexample.vb" id="Snippet1"::: + + The following code example shows how to create and use a object to encrypt and decrypt data in memory. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/TripleDES/Create/memoryexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: ]]> @@ -143,19 +143,19 @@ Initializes a new instance of the class. - class to the default values listed in the following table. - -|Field|Default Value| -|-----------|-------------------| -||192| -||64| -||64| - + class to the default values listed in the following table. + +|Field|Default Value| +|-----------|-------------------| +||192| +||64| +||64| + ]]> Cryptographic Services @@ -229,25 +229,24 @@ Creates an instance of a cryptographic object to perform the algorithm. An instance of a cryptographic object. - class. - - - -## Examples - The following code example shows how to create and use a object to encrypt and decrypt data in a file. + class. + + + +## Examples + The following code example shows how to create and use a object to encrypt and decrypt data in a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/TripleDES/Create/fileexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.File/VB/fileexample.vb" id="Snippet1"::: - - The following code example shows how to create and use a object to encrypt and decrypt data in memory. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.File/VB/fileexample.vb" id="Snippet1"::: + + The following code example shows how to create and use a object to encrypt and decrypt data in memory. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/TripleDES/Create/memoryexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -373,13 +372,13 @@ if the key is weak; otherwise, . - . When is called to create a random key, a weak key will never be returned. - + . When is called to create a random key, a weak key will never be returned. + ]]> The size of the parameter is not valid. @@ -431,18 +430,18 @@ Gets or sets the secret key for the algorithm. The secret key for the algorithm. - An attempt was made to set the key to . - An attempt was made to set a key whose length is invalid. - - -or- - + An attempt was made to set a key whose length is invalid. + + -or- + An attempt was made to set a weak key (see ). Cryptographic Services @@ -477,9 +476,9 @@ Gets the block sizes, in bits, that are supported by the symmetric algorithm. An array that contains the block sizes supported by the algorithm. - @@ -515,9 +514,9 @@ Gets the key sizes, in bits, that are supported by the symmetric algorithm. An array that contains the key sizes supported by the algorithm. - diff --git a/xml/System.Security/AllowPartiallyTrustedCallersAttribute.xml b/xml/System.Security/AllowPartiallyTrustedCallersAttribute.xml index 589b7eaa360..7ad1a65f92f 100644 --- a/xml/System.Security/AllowPartiallyTrustedCallersAttribute.xml +++ b/xml/System.Security/AllowPartiallyTrustedCallersAttribute.xml @@ -60,37 +60,36 @@ Allows an assembly to be called by partially trusted code. Without this declaration, only fully trusted callers are able to use the assembly. This class cannot be inherited. - [!IMPORTANT] > Partially trusted code is no longer supported. This attribute has no effect in .NET Core. - + > [!NOTE] -> The .NET Framework 4 introduces new security rules that affect the behavior of the attribute (see [Security-Transparent Code, Level 2](/dotnet/framework/misc/security-transparent-code-level-2)). In the .NET Framework 4, all code defaults to security-transparent, that is, partially trusted. However, you can annotate individual types and members to assign them other transparency attributes. For this and other security changes, see [Security Changes](/dotnet/framework/security/security-changes). - - .NET Framework version 2.0 () assemblies must be strong-named to effectively use the (APTCA) attribute. .NET Framework 4 () assemblies do not have to be strong-named for the APTCA attribute to be effective, and they can contain transparent, security-critical and security-safe-critical code. For more information about applying attributes at the assembly level, see [Applying Attributes](/dotnet/standard/attributes/applying-attributes). - - By default, if a strong-named, assembly does not explicitly apply this attribute at the assembly level, it can be called only by other assemblies that are granted full trust. This restriction is enforced by placing a for `FullTrust` on every public or protected method on every publicly accessible class in the assembly. Assemblies that are intended to be called by partially trusted code can declare their intent through the use of . An example of the declaration in C# is `[assembly:AllowPartiallyTrustedCallers]`; an example in Visual Basic is ``. - +> The .NET Framework 4 introduces new security rules that affect the behavior of the attribute (see [Security-Transparent Code, Level 2](/dotnet/framework/misc/security-transparent-code-level-2)). In the .NET Framework 4, all code defaults to security-transparent, that is, partially trusted. However, you can annotate individual types and members to assign them other transparency attributes. For this and other security changes, see [Security Changes](/dotnet/framework/security/security-changes). + + .NET Framework version 2.0 () assemblies must be strong-named to effectively use the (APTCA) attribute. .NET Framework 4 () assemblies do not have to be strong-named for the APTCA attribute to be effective, and they can contain transparent, security-critical and security-safe-critical code. For more information about applying attributes at the assembly level, see [Applying Attributes](/dotnet/standard/attributes/applying-attributes). + + By default, if a strong-named, assembly does not explicitly apply this attribute at the assembly level, it can be called only by other assemblies that are granted full trust. This restriction is enforced by placing a for `FullTrust` on every public or protected method on every publicly accessible class in the assembly. Assemblies that are intended to be called by partially trusted code can declare their intent through the use of . An example of the declaration in C# is `[assembly:AllowPartiallyTrustedCallers]`; an example in Visual Basic is ``. + > [!CAUTION] -> The presence of this assembly-level attribute prevents the default behavior of placing `FullTrust` security checks, and makes the assembly callable from any other (partially or fully trusted) assembly. - - When the APTCA attribute is present, all other security checks function as intended, including any class-level or method-level declarative security attributes that are present. This attribute blocks only the implicit, fully trusted caller demand. - - This is not a declarative security attribute, but a regular attribute (it derives from , not from ). +> The presence of this assembly-level attribute prevents the default behavior of placing `FullTrust` security checks, and makes the assembly callable from any other (partially or fully trusted) assembly. + + When the APTCA attribute is present, all other security checks function as intended, including any class-level or method-level declarative security attributes that are present. This attribute blocks only the implicit, fully trusted caller demand. + + This is not a declarative security attribute, but a regular attribute (it derives from , not from ). + + For more information, see [Using Libraries from Partially Trusted Code](/dotnet/framework/misc/using-libraries-from-partially-trusted-code). + + + +## Examples + The following example shows how to use the class. - For more information, see [Using Libraries from Partially Trusted Code](/dotnet/framework/misc/using-libraries-from-partially-trusted-code). - - - -## Examples - The following example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/AllowPartiallyTrustedCallersAttribute/Overview/AllowPartiallyTrustedCallersAttribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/VB/allowpartiallytrustedcallersattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/VB/allowpartiallytrustedcallersattribute.vb" id="Snippet1"::: + ]]> @@ -134,16 +133,16 @@ Initializes a new instance of the class. - class. - + class. + ]]> @@ -185,35 +184,35 @@ Gets or sets the default partial trust visibility for code that is marked with the (APTCA) attribute. One of the enumeration values. The default is . - . - -- Explicit, unconditional APTCA: - - ``` - [assembly: AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=VisibleToAllHosts)] - ``` - - The assembly can always be called by partial-trust code. - -- Explicit, conditional APTCA: - - ``` - [assembly: AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=NotVisibleByDefault)] - ``` - - The assembly has been audited for partial trust, but it is not visible to partial-trust code by default. To make the assembly visible to partial-trust code, add it to the property. - + . + +- Explicit, unconditional APTCA: + + ``` + [assembly: AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=VisibleToAllHosts)] + ``` + + The assembly can always be called by partial-trust code. + +- Explicit, conditional APTCA: + + ``` + [assembly: AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=NotVisibleByDefault)] + ``` + + The assembly has been audited for partial trust, but it is not visible to partial-trust code by default. To make the assembly visible to partial-trust code, add it to the property. + ]]> diff --git a/xml/System.Security/ISecurityEncodable.xml b/xml/System.Security/ISecurityEncodable.xml index f96cdbc31da..ecf245df660 100644 --- a/xml/System.Security/ISecurityEncodable.xml +++ b/xml/System.Security/ISecurityEncodable.xml @@ -76,23 +76,22 @@ Defines the methods that convert permission object state to and from XML element representation. - [!NOTE] -> You must implement this interface for any new permission object. - - - -## Examples - This example shows how to define a permission class for use with code access security. All of the necessary permission interfaces are implemented. +> You must implement this interface for any new permission object. + + + +## Examples + This example shows how to define a permission class for use with code access security. All of the necessary permission interfaces are implemented. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet1"::: + ]]> @@ -149,20 +148,19 @@ The XML encoding to use to reconstruct the security object. Reconstructs a security object with a specified state from an XML encoding. - and methods to make the objects security-encodable. - - - -## Examples - The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet6"::: + and methods to make the objects security-encodable. + + + +## Examples + The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet6"::: + ]]> @@ -218,20 +216,19 @@ Creates an XML encoding of the security object and its current state. An XML encoding of the security object, including any state information. - and methods to make the objects security-encodable. - - - -## Examples - The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet7"::: + and methods to make the objects security-encodable. + + + +## Examples + The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet7"::: + ]]> diff --git a/xml/System.Security/SecureString.xml b/xml/System.Security/SecureString.xml index c18c23128b5..863bda55620 100644 --- a/xml/System.Security/SecureString.xml +++ b/xml/System.Security/SecureString.xml @@ -133,13 +133,11 @@ The following example demonstrates how to use a object. It then calls the method to add an array of characters to it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/Overview/Ctor2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/vb/ctor2.vb" id="Snippet2"::: The following example creates a object from the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor3.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/Overview/Ctor3.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/vb/Ctor3.vb" id="Snippet3"::: @@ -216,7 +214,6 @@ The following example demonstrates how to use a object by passing its constructor a pointer to a character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.security.securestring.ctor2/cpp/ctor1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/.ctor/ctor1.cs" id="Snippet1"::: ]]> @@ -294,13 +291,11 @@ The following example demonstrates how to use a , , , , and methods affect the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xAt/VB/xat.vb" id="Snippet1"::: The following example demonstrates how the and methods can be used to collect the characters in a password. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xchar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xChar/VB/xchar.vb" id="Snippet1"::: @@ -370,7 +365,6 @@ The following example demonstrates how to use a , , , , and methods affect the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xAt/VB/xat.vb" id="Snippet1"::: @@ -574,7 +568,6 @@ The following example demonstrates how to use a , , , , and methods affect the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xAt/VB/xat.vb" id="Snippet1"::: @@ -774,7 +767,6 @@ The following example demonstrates how to use a and methods can be used to collect the characters in a password. After the password is collected, it is made read-only. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xchar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xChar/VB/xchar.vb" id="Snippet1"::: @@ -851,13 +843,11 @@ The following example demonstrates how to use a , , , , and methods affect the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xAt/VB/xat.vb" id="Snippet1"::: The following example demonstrates how the and methods can be used to collect the characters in a password. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xchar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xChar/VB/xchar.vb" id="Snippet1"::: @@ -939,7 +929,6 @@ The following example demonstrates how to use a , , , , and methods affect the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xAt/VB/xat.vb" id="Snippet1"::: diff --git a/xml/System.Security/SecurityElement.xml b/xml/System.Security/SecurityElement.xml index 5d13ed3573e..56268a4d8e2 100644 --- a/xml/System.Security/SecurityElement.xml +++ b/xml/System.Security/SecurityElement.xml @@ -87,37 +87,36 @@ Represents the XML object model for encoding security objects. This class cannot be inherited. - ` and ``. - - It is strongly suggested that attribute based XML representation is used to express security elements and their values. This means properties of an element are expressed as attributes and property values are expressed as attribute values. Avoid nesting text within tags. For any `text` representation a representation of type `` is usually available. Using this attribute-based XML representation increases readability and allows easy WMI portability of the resulting XML serialization. - - An attribute name must be one character or longer, and cannot be `null`. If element-based value representation is used, elements with a text string that is `null` are represented in the `` form; otherwise, text is delimited by the `` and `` tokens. Both forms can be combined with attributes, which are shown if present. - - The tags, attributes, and text of elements, if present, are always case-sensitive. The XML form contains quotations and escapes where necessary. String values that include characters invalid for use in XML result in an . These rules apply to all properties and methods. - + ` and ``. + + It is strongly suggested that attribute based XML representation is used to express security elements and their values. This means properties of an element are expressed as attributes and property values are expressed as attribute values. Avoid nesting text within tags. For any `text` representation a representation of type `` is usually available. Using this attribute-based XML representation increases readability and allows easy WMI portability of the resulting XML serialization. + + An attribute name must be one character or longer, and cannot be `null`. If element-based value representation is used, elements with a text string that is `null` are represented in the `` form; otherwise, text is delimited by the `` and `` tokens. Both forms can be combined with attributes, which are shown if present. + + The tags, attributes, and text of elements, if present, are always case-sensitive. The XML form contains quotations and escapes where necessary. String values that include characters invalid for use in XML result in an . These rules apply to all properties and methods. + > [!NOTE] -> For performance reasons, character validity is only checked when the element is encoded into XML text form, and not on every set of a property or method. Static methods allow explicit checking where needed. - - - -## Examples - The following example shows the use of members of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet1"::: +> For performance reasons, character validity is only checked when the element is encoded into XML text form, and not on every set of a property or method. Static methods allow explicit checking where needed. + + + +## Examples + The following example shows the use of members of the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet1"::: + ]]> @@ -181,20 +180,19 @@ The tag name of an XML element. Initializes a new instance of the class with the specified tag. - to remove invalid characters from the string. - - - -## Examples - The following code shows the use of the constructor to create a new object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet2"::: + to remove invalid characters from the string. + + + +## Examples + The following code shows the use of the constructor to create a new object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet2"::: + ]]> The parameter is . @@ -260,11 +258,11 @@ The text content within the element. Initializes a new instance of the class with the specified tag and text. - The parameter is . @@ -325,29 +323,28 @@ The value of the attribute. Adds a name/value attribute to an XML element. - to remove invalid characters from the string. - - There is no support for quoted strings, so strings for name/value pairs should not contain quotes or other characters requiring quoting. - - - -## Examples - The following code shows the use of the method to add a name/value attribute to an XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet4"::: + to remove invalid characters from the string. + + There is no support for quoted strings, so strings for name/value pairs should not contain quotes or other characters requiring quoting. + + + +## Examples + The following code shows the use of the method to add a name/value attribute to an XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet4"::: + ]]> The parameter or parameter is . - The parameter or parameter is invalid in XML. - - -or- - + The parameter or parameter is invalid in XML. + + -or- + An attribute with the name specified by the parameter already exists. @@ -403,20 +400,19 @@ The child element to add. Adds a child element to the XML element. - method to add a child element to the XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet5"::: + method to add a child element to the XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet5"::: + ]]> The parameter is . @@ -482,24 +478,23 @@ Finds an attribute by name in an XML element. The value associated with the named attribute, or if no attribute with exists. - text -``` - - - -## Examples - The following code shows the use of the method to find an attribute by name. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet13"::: + text +``` + + + +## Examples + The following code shows the use of the method to find an attribute by name. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet13"::: + ]]> The parameter is . @@ -555,24 +550,23 @@ Gets or sets the attributes of an XML element as name/value pairs. The object for the attribute values of the XML element. - as a name/value pair. - - Names and values in attributes should contain only valid XML attribute characters. Use to remove invalid characters from the string. - - There is no support for quoted strings, so strings for name/value pairs should not contain quotes or other characters requiring quoting. - - - -## Examples - The following code shows the use of the property to get an attribute of an XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet15"::: + as a name/value pair. + + Names and values in attributes should contain only valid XML attribute characters. Use to remove invalid characters from the string. + + There is no support for quoted strings, so strings for name/value pairs should not contain quotes or other characters requiring quoting. + + + +## Examples + The following code shows the use of the property to get an attribute of an XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet15"::: + ]]> The name or value of the object is invalid. @@ -629,20 +623,19 @@ Gets or sets the array of child elements of the XML element. The ordered child elements of the XML element as security elements. - contains both and , will appear first. - - - -## Examples - The following code shows the use of the property to get the array of child elements of the XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet14"::: + contains both and , will appear first. + + + +## Examples + The following code shows the use of the property to get the array of child elements of the XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet14"::: + ]]> A child of the XML parent node is . @@ -703,11 +696,11 @@ Creates and returns an identical copy of the current object. A copy of the current object. - and properties. - + and properties. + ]]> @@ -774,22 +767,21 @@ if the tag, attribute names and values, child elements, and text fields in the current XML element are identical to their counterparts in the parameter; otherwise, . - method to compare two XML elements. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet22"::: + method to compare two XML elements. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet22"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet22"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet22"::: + ]]> @@ -854,12 +846,12 @@ Replaces invalid XML characters in a string with their valid XML equivalent. The input string with invalid characters replaced. - . If invalid characters are used in a without being escaped, an is thrown. - - The following table shows the invalid XML characters and their escaped equivalents. + . If invalid characters are used in a without being escaped, an is thrown. + + The following table shows the invalid XML characters and their escaped equivalents. | Invalid XML character | Replaced with | |-----------------------|---------------| @@ -867,15 +859,14 @@ | `>` | `>` | | `"` | `"` | | `'` | `'` | -| `&` | `&` | +| `&` | `&` | + +## Examples + The following code shows the use of the method to replace invalid XML characters in a string with their valid XML equivalent. This code example is part of a larger example provided for the class. -## Examples - The following code shows the use of the method to replace invalid XML characters in a string with their valid XML equivalent. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet19"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet19"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet19"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet19"::: + ]]> @@ -939,13 +930,13 @@ Creates a security element from an XML-encoded string. A created from the XML. - Microsoft"` use "`Microsoft"`. - - Using single quotation marks can result in either an exception being thrown or, in some cases, the single quotation marks being treated as text in the string. - + Microsoft"` use "`Microsoft"`. + + Using single quotation marks can result in either an exception being thrown or, in some cases, the single quotation marks being treated as text in the string. + Evidence based security model is not supported on .NET Core and this method will return `null`. ]]> @@ -1017,20 +1008,19 @@ if the parameter is a valid XML attribute name; otherwise, . - method to determine whether a string is a valid attribute name. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet6"::: + method to determine whether a string is a valid attribute name. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet6"::: + ]]> @@ -1097,20 +1087,19 @@ if the parameter is a valid XML attribute value; otherwise, . - method to determine whether a string is a valid attribute value. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet7"::: + method to determine whether a string is a valid attribute value. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet7"::: + ]]> @@ -1177,20 +1166,19 @@ if the parameter is a valid XML tag; otherwise, . - before setting it. - - - -## Examples - The following code shows the use of the method to determine whether a string is a valid attribute tag. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet10"::: + before setting it. + + + +## Examples + The following code shows the use of the method to determine whether a string is a valid attribute tag. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet10"::: + ]]> @@ -1257,20 +1245,19 @@ if the parameter is a valid XML text element; otherwise, . - before setting it. - - - -## Examples - The following code shows the use of the method to determine whether a string is valid as XML element text. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet9"::: + before setting it. + + + +## Examples + The following code shows the use of the method to determine whether a string is valid as XML element text. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet9"::: + ]]> @@ -1335,25 +1322,24 @@ Finds a child by its tag name. The first child XML element with the specified tag value, or if no child element with exists. - `. - -``` - text1 - text2 -``` - - - -## Examples - The following code shows the use of the method to find a child by its tag name. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet17"::: + `. + +``` + text1 + text2 +``` + + + +## Examples + The following code shows the use of the method to find a child by its tag name. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet17"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet17"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet17"::: + ]]> The parameter is . @@ -1419,31 +1405,29 @@ Finds a child by its tag name and returns the contained text. The text contents of the first child element with the specified tag value. - text1 - text2 -``` - - - -## Examples - The following code shows the use of the method to find a child by its tag name and return the contained text. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet18"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.securityelement/vb/remarks.vb" id="Snippet1"::: + + With XML as follows, `SearchForTextOfTag("second")` would return "text2". + +``` + text1 + text2 +``` + + + +## Examples + The following code shows the use of the method to find a child by its tag name and return the contained text. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet18"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet18"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet18"::: + ]]> @@ -1505,28 +1489,27 @@ Gets or sets the tag name of an XML element. The tag name of an XML element. - text -``` - - If this element has child elements, the children will replace `text`. - - Assign only valid XML tag strings to this property. Use to remove invalid characters from the string. - - - -## Examples - The following code shows the use of the property to get the tag name of an XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet11"::: + text +``` + + If this element has child elements, the children will replace `text`. + + Assign only valid XML tag strings to this property. Use to remove invalid characters from the string. + + + +## Examples + The following code shows the use of the property to get the tag name of an XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet11"::: + ]]> The tag is . @@ -1583,22 +1566,21 @@ Gets or sets the text within an XML element. The value of the text within an XML element. - to remove invalid characters from the string. - - If a contains both and , will appear first. - - - -## Examples - The following code shows the use of the property to get the text of an XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet12"::: + to remove invalid characters from the string. + + If a contains both and , will appear first. + + + +## Examples + The following code shows the use of the property to get the text of an XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet12"::: + ]]> The text is not valid in XML. @@ -1654,11 +1636,11 @@ Produces a string representation of an XML element and its constituent attributes, child elements, and text. The XML element and its contents. - diff --git a/xml/System.Text.RegularExpressions/Match.xml b/xml/System.Text.RegularExpressions/Match.xml index fcbd7c7c70f..5b96a920302 100644 --- a/xml/System.Text.RegularExpressions/Match.xml +++ b/xml/System.Text.RegularExpressions/Match.xml @@ -227,7 +227,6 @@ The following examples use the regular expression `Console\.Write(Line)?`. The r ## Examples The following example attempts to match a regular expression pattern against a sample string. The example uses the property to store information that is retrieved by the match for display to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Groups/snippet8.cs" interactive="try-dotnet" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/regex match, nextmatch, groups, captures/vb/snippet8.vb" id="Snippet8"::: @@ -294,7 +293,6 @@ The following examples use the regular expression `Console\.Write(Line)?`. The r ## Examples The following example uses the method to capture regular expression matches beyond the first match. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/regex match, nextmatch, groups, captures/cpp/snippet8.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/Match/Groups/snippet8.cs" interactive="try-dotnet" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/regex match, nextmatch, groups, captures/vb/snippet8.vb" id="Snippet8"::: diff --git a/xml/System.Text.RegularExpressions/MatchCollection.xml b/xml/System.Text.RegularExpressions/MatchCollection.xml index 3ee8714070c..30727b99502 100644 --- a/xml/System.Text.RegularExpressions/MatchCollection.xml +++ b/xml/System.Text.RegularExpressions/MatchCollection.xml @@ -124,7 +124,6 @@ ## Examples The following example illustrates the use of the class to interrogate a set of instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Regex_Words/CPP/words.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/MatchCollection/Overview/words.cs" interactive="try-dotnet" id="Snippet0"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Regex_Words/VB/words.vb" id="Snippet0"::: diff --git a/xml/System.Text.RegularExpressions/MatchEvaluator.xml b/xml/System.Text.RegularExpressions/MatchEvaluator.xml index fe842edbf9d..e26b38fa2f5 100644 --- a/xml/System.Text.RegularExpressions/MatchEvaluator.xml +++ b/xml/System.Text.RegularExpressions/MatchEvaluator.xml @@ -63,20 +63,19 @@ Represents the method that is called each time a regular expression match is found during a method operation. A string returned by the method that is represented by the delegate. - delegate method to perform a custom verification or manipulation operation for each match found by a replacement method such as . For each matched string, the method calls the delegate method with a object that represents the match. The delegate method performs whatever processing you prefer and returns a string that the method substitutes for the matched string. + + + +## Examples + The following code example uses the delegate to replace every matched group of characters with the number of the match occurrence. -## Remarks - You can use a delegate method to perform a custom verification or manipulation operation for each match found by a replacement method such as . For each matched string, the method calls the delegate method with a object that represents the match. The delegate method performs whatever processing you prefer and returns a string that the method substitutes for the matched string. - - - -## Examples - The following code example uses the delegate to replace every matched group of characters with the number of the match occurrence. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.text.regularexpressions.MatchEvaluator/CPP/regexreplace.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text.RegularExpressions/MatchEvaluator/Overview/regexreplace.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.text.regularexpressions.MatchEvaluator/VB/regexreplace.vb" id="Snippet1"::: - + ]]> diff --git a/xml/System.Text.RegularExpressions/Regex.xml b/xml/System.Text.RegularExpressions/Regex.xml index 1144af68573..917aec0f9af 100644 --- a/xml/System.Text.RegularExpressions/Regex.xml +++ b/xml/System.Text.RegularExpressions/Regex.xml @@ -3746,7 +3746,6 @@ For more details about `startat`, see the Remarks section of to encode Unicode characters outside of the ASCII range. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding Example/CPP/snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/Overview/snippet.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding Example/VB/snippet.vb" id="Snippet1"::: @@ -145,7 +144,6 @@ ## Examples The following example demonstrates how to create a new instance and display the name of the encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.ctor Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/.ctor/ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.ctor Example/VB/ctor.vb" id="Snippet1"::: @@ -268,7 +266,6 @@ ## Examples The following example demonstrates how to use the method to return the number of bytes required to encode a string using . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount2 Example/CPP/getbytecount-string.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetByteCount/getbytecount-string.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount2 Example/VB/getbytecount-string.vb" id="Snippet1"::: @@ -436,7 +433,6 @@ ## Examples The following example demonstrates how to use the method to return the number of bytes required to encode an array of Unicode characters using . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount1 Example/CPP/getbytecount-char[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetByteCount/getbytecount-char[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetByteCount1 Example/VB/getbytecount-char[]-int32-int32.vb" id="Snippet1"::: @@ -700,7 +696,6 @@ ## Examples The following example demonstrates how to use the method to encode a range of characters from a string and store the encoded characters in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes1 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetBytes/getbytes-string-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes1 Example/VB/getbytes-string-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -807,7 +802,6 @@ ## Examples The following example demonstrates how to use the method to encode a range of elements from a Unicode character array and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes2/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetBytes2/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1040,7 +1034,6 @@ ## Examples The following example demonstrates how to use the method to return the number of characters produced by decoding a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetCharCount/getcharcount-byte[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: @@ -1305,7 +1298,6 @@ ## Examples The following example demonstrates how to decode a range of elements from a byte array and store the result in a set of elements in a Unicode character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetChars/getchars-byte[]-int32-int32-char[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: @@ -1524,7 +1516,6 @@ ## Examples The following example demonstrates how to use the method to calculate the bytes required to encode a specified number of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetMaxByteCount/getmaxbytecount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxByteCount Example/VB/getmaxbytecount-int32.vb" id="Snippet1"::: @@ -1602,7 +1593,6 @@ ## Examples The following example demonstrates how to use the method to calculate the maximum number of characters needed to decode a specified number of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetMaxCharCount/getmaxcharcount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetMaxCharCount Example/VB/getmaxcharcount-int32.vb" id="Snippet1"::: @@ -1718,7 +1708,6 @@ ## Examples The following example demonstrates how to use the method to convert a byte array into a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetString1 Example/CPP/getstring-byte[].cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/ASCIIEncoding/GetString/getstring-byte[].cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.ASCIIEncoding.GetString1 Example/VB/getstring-byte[].vb" id="Snippet1"::: diff --git a/xml/System.Text/Decoder.xml b/xml/System.Text/Decoder.xml index d869e58dd73..720bd3c84ca 100644 --- a/xml/System.Text/Decoder.xml +++ b/xml/System.Text/Decoder.xml @@ -83,7 +83,6 @@ The method determines how many charac to convert two different byte arrays into a character array. One of the character's bytes spans the arrays. This is similar to what a object does internally when reading a stream. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Decoder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Decoder/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Decoder Example/VB/source.vb" id="Snippet1"::: ]]> @@ -147,7 +146,6 @@ The following example demonstrates the use of a to co ## Examples The following example demonstrates two techniques for initializing a new instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.ctor Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Decoder/.ctor/ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Decoder.ctor Example/VB/ctor.vb" id="Snippet1"::: @@ -809,7 +807,6 @@ The following example uses the method to c ## Examples The following code example demonstrates how to use the method to calculate the number of characters required to decode the specified range of bytes in the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Decoder/GetCharCount/getcharcount-byte[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Decoder.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: @@ -1161,7 +1158,6 @@ The following example uses the method to c ## Examples The following example demonstrates how to decode a range of elements from a byte array and store them in a Unicode character array. The method is used to calculate the number of characters needed to store the decoded elements in the array `bytes`. The method decodes the specified elements in the byte array and stores them in the new character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Decoder.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Decoder/GetChars/getchars-byte[]-int32-int32-char[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Decoder.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: diff --git a/xml/System.Text/DecoderExceptionFallback.xml b/xml/System.Text/DecoderExceptionFallback.xml index 906c98ef131..e097ca870a0 100644 --- a/xml/System.Text/DecoderExceptionFallback.xml +++ b/xml/System.Text/DecoderExceptionFallback.xml @@ -63,26 +63,25 @@ Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that cannot be converted to an input character. The fallback throws an exception instead of decoding the input byte sequence. This class cannot be inherited. - class. Specifically, the encoding type's `GetBytes` method encodes a character to a byte sequence, and the `GetChars` method decodes a byte sequence to a character. + + A decoding operation can fail if the input byte sequence cannot be mapped by the encoding. For example, an object cannot decode a byte sequence that yields a character having a code point value that is outside the range U+0000 to U+007F. + + In cases where an encoding or decoding conversion cannot be performed, the .NET Framework provides a failure-handling mechanism called a fallback. Your application can use the predefined .NET Framework decoder fallback, or it can create a custom decoder fallback derived from the and classes. + + The .NET Framework provides two predefined classes that implement different fallback strategies for handling decoding conversion failures. The class substitutes a string provided in place of any input byte sequence that cannot be converted. After the substitute string is emitted, the decoding operation continues converting the remainder of the input. In contrast, the class throws a when an invalid byte sequence is encountered. + + + +## Examples + The following code example demonstrates the and classes. -## Remarks - An encoding maps a Unicode character to an encoded sequence of bytes, which can subsequently be transferred to a physical medium, such as a disk, or over a communications link. Characters can be mapped in various ways, and a particular encoding is represented by a type derived from the class. Specifically, the encoding type's `GetBytes` method encodes a character to a byte sequence, and the `GetChars` method decodes a byte sequence to a character. - - A decoding operation can fail if the input byte sequence cannot be mapped by the encoding. For example, an object cannot decode a byte sequence that yields a character having a code point value that is outside the range U+0000 to U+007F. - - In cases where an encoding or decoding conversion cannot be performed, the .NET Framework provides a failure-handling mechanism called a fallback. Your application can use the predefined .NET Framework decoder fallback, or it can create a custom decoder fallback derived from the and classes. - - The .NET Framework provides two predefined classes that implement different fallback strategies for handling decoding conversion failures. The class substitutes a string provided in place of any input byte sequence that cannot be converted. After the substitute string is emitted, the decoding operation continues converting the remainder of the input. In contrast, the class throws a when an invalid byte sequence is encountered. - - - -## Examples - The following code example demonstrates the and classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/DecoderExceptionFallback/Overview/fallDecExc.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecExc/vb/fallDecExc.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecExc/vb/fallDecExc.vb" id="Snippet1"::: + ]]> Understanding Encodings @@ -171,11 +170,11 @@ Returns a decoder fallback buffer that throws an exception if it cannot convert a sequence of bytes to a character. A decoder fallback buffer that throws an exception when it cannot decode a byte sequence. - class, which is a subclass of the class. A object throws an exception whenever a sequence of bytes is passed to its method. - + class, which is a subclass of the class. A object throws an exception whenever a sequence of bytes is passed to its method. + ]]> @@ -280,11 +279,11 @@ Retrieves the hash code for this instance. The return value is always the same arbitrary value, and has no special significance. - method always returns the same value, the application should not use this value to distinguish one object from another. - + method always returns the same value, the application should not use this value to distinguish one object from another. + ]]> diff --git a/xml/System.Text/DecoderFallbackException.xml b/xml/System.Text/DecoderFallbackException.xml index ae7f270d243..5803a895783 100644 --- a/xml/System.Text/DecoderFallbackException.xml +++ b/xml/System.Text/DecoderFallbackException.xml @@ -69,15 +69,14 @@ The exception that is thrown when a decoder fallback operation fails. This class cannot be inherited. - and classes. -## Examples - The following code example demonstrates the and classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecExc/cpp/fallDecExc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/DecoderExceptionFallback/Overview/fallDecExc.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecExc/vb/fallDecExc.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecExc/vb/fallDecExc.vb" id="Snippet1"::: + ]]> @@ -133,11 +132,11 @@ Initializes a new instance of the class. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -186,11 +185,11 @@ An error message. Initializes a new instance of the class. A parameter specifies the error message. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -241,11 +240,11 @@ The exception that caused this exception. Initializes a new instance of the class. Parameters specify the error message and the inner exception that is the cause of this exception. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -298,11 +297,11 @@ The index position in of the byte that cannot be decoded. Initializes a new instance of the class. Parameters specify the error message, the array of bytes being decoded, and the index of the byte that cannot be decoded. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -351,11 +350,11 @@ Gets the input byte sequence that caused the exception. The input byte array that cannot be decoded. - property to get the position in the input byte array of the byte that cannot be decoded. - + property to get the position in the input byte array of the byte that cannot be decoded. + ]]> @@ -403,11 +402,11 @@ Gets the index position in the input byte sequence of the byte that caused the exception. The index position in the input byte array of the byte that cannot be decoded. The index position is zero-based. - property to retrieve the input byte array that contains the byte that cannot be decoded. - + property to retrieve the input byte array that contains the byte that cannot be decoded. + ]]> diff --git a/xml/System.Text/DecoderReplacementFallback.xml b/xml/System.Text/DecoderReplacementFallback.xml index 818918b7106..3ed787d0087 100644 --- a/xml/System.Text/DecoderReplacementFallback.xml +++ b/xml/System.Text/DecoderReplacementFallback.xml @@ -67,28 +67,27 @@ Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that cannot be converted to an output character. The fallback emits a user-specified replacement string instead of a decoded input byte sequence. This class cannot be inherited. - object cannot decode a byte value greater than 0x7F. If an input byte sequence cannot be converted to an output character, a object emits a replacement string into the output to represent the original input byte sequence. The conversion process then continues to decode the remainder of the original input. + + The replacement string used by a object is determined by the call to its class constructor. Two options are available: + +- Replacement with the default character. If you call the constructor, the replacement character is "?" (U+003F). + +- Replacement with a string of your choice. If you call the constructor, you provide the replacement string. + + This class is one of two .NET Framework classes that implement different fallback strategies for handling decoding conversion failures. The other class is the class, which throws a when an invalid byte sequence is encountered. + + + +## Examples + The following code example demonstrates the class. -## Remarks - A common reason for an encoding or decoding operation to fail is if the underlying encoding class does not provide a mapping between a character and an equivalent byte sequence. For example, an object cannot decode a byte value greater than 0x7F. If an input byte sequence cannot be converted to an output character, a object emits a replacement string into the output to represent the original input byte sequence. The conversion process then continues to decode the remainder of the original input. - - The replacement string used by a object is determined by the call to its class constructor. Two options are available: - -- Replacement with the default character. If you call the constructor, the replacement character is "?" (U+003F). - -- Replacement with a string of your choice. If you call the constructor, you provide the replacement string. - - This class is one of two .NET Framework classes that implement different fallback strategies for handling decoding conversion failures. The other class is the class, which throws a when an invalid byte sequence is encountered. - - - -## Examples - The following code example demonstrates the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackDecRpl/cpp/fallDecRpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/DecoderReplacementFallback/Overview/fallDecRpl.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecRpl/vb/fallDecRpl.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackDecRpl/vb/fallDecRpl.vb" id="Snippet1"::: + ]]> @@ -144,11 +143,11 @@ Initializes a new instance of the class. - object is "?". - + object is "?". + ]]> @@ -195,11 +194,11 @@ A string that is emitted in a decoding operation in place of an input byte sequence that cannot be decoded. Initializes a new instance of the class using a specified replacement string. - object. A commonly used value is the Unicode "Replacement Character" (U+FFFD), which is specifically intended to replace an incoming character having a value that is unknown or unrepresentable in Unicode. - + object. A commonly used value is the Unicode "Replacement Character" (U+FFFD), which is specifically intended to replace an incoming character having a value that is unknown or unrepresentable in Unicode. + ]]> @@ -400,11 +399,11 @@ Retrieves the hash code for the value of the object. The hash code of the value of the object. - object is the value of its property. - + object is the value of its property. + ]]> diff --git a/xml/System.Text/Encoder.xml b/xml/System.Text/Encoder.xml index 44b03ef06e8..3b1b3d9c2e4 100644 --- a/xml/System.Text/Encoder.xml +++ b/xml/System.Text/Encoder.xml @@ -85,7 +85,6 @@ A object maintains state information between successi . Next, the array of characters is encoded using an . -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder Example/CPP/snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoder/Overview/snippet.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder Example/VB/snippet.vb" id="Snippet1"::: ]]> @@ -148,7 +147,6 @@ The following example demonstrates how to convert an array of Unicode characters ## Examples The following example demonstrates two techniques for initializing a new instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.ctor Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoder/.ctor/ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder.ctor Example/VB/ctor.vb" id="Snippet1"::: @@ -779,7 +777,6 @@ The following example demonstrates how to convert an array of Unicode characters The following code example demonstrates how to use the method to return the number of bytes required to encode an array of characters using a Unicode . -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoder/GetByteCount/getbytecount-char[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder.GetByteCount Example/VB/getbytecount-char[]-int32-int32.vb" id="Snippet1"::: @@ -1024,7 +1021,6 @@ If your application is to convert many segments of an input stream, consider usi ## Examples The following example demonstrates how to encode a range of elements from a character array and store the encoded bytes in a range of elements in a byte array. The method is used to determine the size of the array required by . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoder.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoder/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoder.GetBytes Example/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: diff --git a/xml/System.Text/EncoderExceptionFallback.xml b/xml/System.Text/EncoderExceptionFallback.xml index f81fb780759..cdb0158d924 100644 --- a/xml/System.Text/EncoderExceptionFallback.xml +++ b/xml/System.Text/EncoderExceptionFallback.xml @@ -63,26 +63,25 @@ Provides a failure-handling mechanism, called a fallback, for an input character that cannot be converted to an output byte sequence. The fallback throws an exception if an input character cannot be converted to an output byte sequence. This class cannot be inherited. - class. Specifically, the encoding type's `GetBytes` method encodes a character to a byte sequence, and the `GetChars` method decodes a byte sequence to a character. + + An encoding operation can fail if the input character cannot be represented by the encoding. For example, a object cannot encode a character that yields a Unicode code point value that is outside the range U+0000 to U+007F. + + In cases where an encoding or decoding conversion cannot be performed, the .NET Framework provides a failure-handling mechanism called a fallback. Your application can use the predefined .NET Framework encoder fallback, or it can create a custom encoder fallback derived from the and classes. + + The .NET Framework provides two predefined classes that implement different fallback strategies for handling encoding conversion failures. The class substitutes a string provided for any input character that cannot be converted. The substitute string is encoded in place of the invalid character, and then the encoding operation continues converting the remainder of the input. In contrast, the class throws a when an invalid character is encountered. + + + +## Examples + The following code example demonstrates the and classes. -## Remarks - An encoding maps a Unicode character to an encoded sequence of bytes, which can subsequently be transferred to a physical medium, such as a disk, or over a communications link. Characters can be mapped in various ways, and a particular encoding is represented by a type derived from the class. Specifically, the encoding type's `GetBytes` method encodes a character to a byte sequence, and the `GetChars` method decodes a byte sequence to a character. - - An encoding operation can fail if the input character cannot be represented by the encoding. For example, a object cannot encode a character that yields a Unicode code point value that is outside the range U+0000 to U+007F. - - In cases where an encoding or decoding conversion cannot be performed, the .NET Framework provides a failure-handling mechanism called a fallback. Your application can use the predefined .NET Framework encoder fallback, or it can create a custom encoder fallback derived from the and classes. - - The .NET Framework provides two predefined classes that implement different fallback strategies for handling encoding conversion failures. The class substitutes a string provided for any input character that cannot be converted. The substitute string is encoded in place of the invalid character, and then the encoding operation continues converting the remainder of the input. In contrast, the class throws a when an invalid character is encountered. - - - -## Examples - The following code example demonstrates the and classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncoderExceptionFallback/Overview/fallEncExc.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncExc/vb/fallEncExc.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncExc/vb/fallEncExc.vb" id="Snippet1"::: + ]]> Understanding Encodings @@ -171,11 +170,11 @@ Returns an encoder fallback buffer that throws an exception if it cannot convert a character sequence to a byte sequence. An encoder fallback buffer that throws an exception when it cannot encode a character sequence. - class, which is a subclass of the class. An object throws an exception whenever characters are passed to its method. - + class, which is a subclass of the class. An object throws an exception whenever characters are passed to its method. + ]]> @@ -280,11 +279,11 @@ Retrieves the hash code for this instance. The return value is always the same arbitrary value, and has no special significance. - method always returns the same value, the application should not use this value to distinguish one instance of the class from another. - + method always returns the same value, the application should not use this value to distinguish one instance of the class from another. + ]]> diff --git a/xml/System.Text/EncoderFallbackException.xml b/xml/System.Text/EncoderFallbackException.xml index 334e1c213a3..93dd2de32ee 100644 --- a/xml/System.Text/EncoderFallbackException.xml +++ b/xml/System.Text/EncoderFallbackException.xml @@ -69,15 +69,14 @@ The exception that is thrown when an encoder fallback operation fails. This class cannot be inherited. - and classes. -## Examples - The following code example demonstrates the and classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncExc/cpp/fallEncExc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncoderExceptionFallback/Overview/fallEncExc.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncExc/vb/fallEncExc.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncExc/vb/fallEncExc.vb" id="Snippet1"::: + ]]> @@ -133,11 +132,11 @@ Initializes a new instance of the class. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -186,11 +185,11 @@ An error message. Initializes a new instance of the class. A parameter specifies the error message. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -241,11 +240,11 @@ The exception that caused this exception. Initializes a new instance of the class. Parameters specify the error message and the inner exception that is the cause of this exception. - property for this exception is set to COR_E_ARGUMENT (0x80070057). - + property for this exception is set to COR_E_ARGUMENT (0x80070057). + ]]> @@ -428,11 +427,11 @@ Gets the index position in the input buffer of the character that caused the exception. The index position in the input buffer of the character that cannot be encoded. - diff --git a/xml/System.Text/EncoderReplacementFallback.xml b/xml/System.Text/EncoderReplacementFallback.xml index b0a8e1e7833..3e9121d530b 100644 --- a/xml/System.Text/EncoderReplacementFallback.xml +++ b/xml/System.Text/EncoderReplacementFallback.xml @@ -67,30 +67,29 @@ Provides a failure handling mechanism, called a fallback, for an input character that cannot be converted to an output byte sequence. The fallback uses a user-specified replacement string instead of the original input character. This class cannot be inherited. - object cannot encode a character having a Unicode code point value that is outside the range U+0000 to U+007F. If the input character cannot be converted to an output byte sequence, a object substitutes a specified replacement string for the original input character. The conversion process encodes the replacement string and then continues to process the remainder of the original input. + + The replacement string used by an object is determined by the call to its class constructor. Two options are available: + +- Replacement with the default character. If you call the constructor, the replacement character is "?" (U+003F). + +- Replacement with a string of your choice. If you call the constructor, you provide the replacement string. + + If you choose a fallback string to use with this class, make sure that the string is composed entirely of characters that can be encoded in the target encoding. Otherwise, a recursive fallback results, causing an . + + This class is one of two .NET Framework classes that implement different fallback strategies for handling encoding conversion failures. The other class is the class, which throws an when an invalid character is encountered. + + + +## Examples + The following example demonstrates the class. -## Remarks - A common reason for an encoding or decoding operation to fail is if the underlying encoding class does not provide a mapping between a character and an equivalent byte sequence. For example, an object cannot encode a character having a Unicode code point value that is outside the range U+0000 to U+007F. If the input character cannot be converted to an output byte sequence, a object substitutes a specified replacement string for the original input character. The conversion process encodes the replacement string and then continues to process the remainder of the original input. - - The replacement string used by an object is determined by the call to its class constructor. Two options are available: - -- Replacement with the default character. If you call the constructor, the replacement character is "?" (U+003F). - -- Replacement with a string of your choice. If you call the constructor, you provide the replacement string. - - If you choose a fallback string to use with this class, make sure that the string is composed entirely of characters that can be encoded in the target encoding. Otherwise, a recursive fallback results, causing an . - - This class is one of two .NET Framework classes that implement different fallback strategies for handling encoding conversion failures. The other class is the class, which throws an when an invalid character is encountered. - - - -## Examples - The following example demonstrates the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncoderReplacementFallback/Overview/fallEncRpl.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncRpl/vb/fallEncRpl.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncRpl/vb/fallEncRpl.vb" id="Snippet1"::: + ]]> @@ -146,11 +145,11 @@ Initializes a new instance of the class. - object is "?". - + object is "?". + ]]> @@ -198,13 +197,13 @@ A string that is converted in an encoding operation in place of an input character that cannot be encoded. Initializes a new instance of the class using a specified replacement string. - object. You application must provide a `replacement` value that contains only characters that can be encoded in the target encoding. Otherwise, a recursive fallback results, causing an . For example, the fallback provided for an object cannot include the character "¿" (U+00BF) because that character is itself not a valid ASCII character. - - As a result of this, U+FFFD, which is a good choice for a fallback string for , is not generally a good choice for this class. Also, the null character (U+0000) cannot be used in the fallback string. - + object. You application must provide a `replacement` value that contains only characters that can be encoded in the target encoding. Otherwise, a recursive fallback results, causing an . For example, the fallback provided for an object cannot include the character "¿" (U+00BF) because that character is itself not a valid ASCII character. + + As a result of this, U+FFFD, which is a good choice for a fallback string for , is not generally a good choice for this class. Also, the null character (U+0000) cannot be used in the fallback string. + ]]> @@ -366,11 +365,11 @@ if the parameter specifies an object and the replacement string of that object is equal to the replacement string of this object; otherwise, . - object is the value of its property. - + object is the value of its property. + ]]> @@ -418,11 +417,11 @@ Retrieves the hash code for the value of the object. The hash code of the value of the object. - object is the value of its property. - + object is the value of its property. + ]]> diff --git a/xml/System.Text/Encoding.xml b/xml/System.Text/Encoding.xml index ed59e24cd76..9e36efb5add 100644 --- a/xml/System.Text/Encoding.xml +++ b/xml/System.Text/Encoding.xml @@ -91,7 +91,6 @@ The following example converts a string from one encoding to another. > [!NOTE] > The `byte[]` array is the only type in this example that contains the encoded data. The .NET `Char` and `String` types are themselves Unicode, so the call decodes the data back to Unicode. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/CPP/convert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/Overview/convert.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/VB/convert.vb" id="Snippet1"::: ]]> @@ -360,7 +359,6 @@ The following example converts a string from one encoding to another. The following example demonstrates the effect of the ASCII encoding on characters that are outside the ASCII range. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.ASCII Example/CPP/ascii.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/ASCII/ascii.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.ASCII Example/VB/ascii.vb" id="Snippet1"::: @@ -430,13 +428,11 @@ The following example demonstrates the effect of the ASCII encoding on character ## Examples The following example reads a text file with a UTF-16 encoding using the big endian byte order. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.BigEndianUnicode/CPP/bigendianunicode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/bigendianunicode.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.BigEndianUnicode/VB/bigendianunicode.vb" id="Snippet1"::: The following example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/getbytes_chararr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/VB/getbytes_chararr.vb" id="Snippet1"::: @@ -504,7 +500,6 @@ The following example demonstrates the effect of the ASCII encoding on character ## Examples The following example retrieves the different names for each encoding and displays the encodings with one or more names that are different from . It displays but does not compare against it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BodyName/names.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Names/VB/names.vb" id="Snippet1"::: @@ -631,7 +626,6 @@ The following example demonstrates the effect of the ASCII encoding on character ## Examples The following example retrieves the different names for each encoding and displays the encodings with one or more names that are different from . It displays but does not compare against it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BodyName/names.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Names/VB/names.vb" id="Snippet1"::: @@ -708,7 +702,6 @@ The following example demonstrates the effect of the ASCII encoding on character ## Examples The following example converts a Unicode-encoded string to an ASCII-encoded string. Because the ASCII encoding object returned by the property uses replacement fallback and the Pi character is not part of the ASCII character set, the Pi character is replaced with a question mark, as the output from the example shows. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/CPP/convert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/Overview/convert.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Convert Example/VB/convert.vb" id="Snippet1"::: @@ -1118,7 +1111,6 @@ The returned 's and . It displays but does not compare against it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BodyName/names.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Names/VB/names.vb" id="Snippet1"::: @@ -1195,7 +1187,6 @@ The returned 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and 's and method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncoderReplacementFallback/Overview/fallEncRpl.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncRpl/vb/fallEncRpl.vb" id="Snippet1"::: @@ -3870,7 +3841,6 @@ In .NET 5 and later versions, the code page name `utf-7` is not supported. ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/sys.txt.fallbackEncRpl/cpp/fallEncRpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncoderReplacementFallback/Overview/fallEncRpl.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/sys.txt.fallbackEncRpl/vb/fallEncRpl.vb" id="Snippet1"::: @@ -3953,7 +3923,6 @@ In .NET 5 and later versions, the code page name `utf-7` is not supported. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -4080,7 +4049,6 @@ In .NET 5 and later versions, the code page name `utf-7` is not supported. ## Examples The following example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/getbytes_chararr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/VB/getbytes_chararr.vb" id="Snippet1"::: @@ -4170,7 +4138,6 @@ In .NET 5 and later versions, the code page name `utf-7` is not supported. ## Examples The following example encodes a string into an array of bytes, and then decodes the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetChars/CPP/getchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetCharCount/getchars.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetChars/VB/getchars.vb" id="Snippet1"::: @@ -4272,7 +4239,6 @@ In .NET 5 and later versions, the code page name `utf-7` is not supported. ## Examples The following example determines the byte order of the encoding based on the preamble. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetPreamble Example/CPP/preamble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetPreamble/preamble.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetPreamble Example/VB/preamble.vb" id="Snippet1"::: @@ -4683,7 +4649,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example retrieves the different names for each encoding and displays the encodings with one or more names that are different from . It displays but does not compare against it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BodyName/names.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Names/VB/names.vb" id="Snippet1"::: @@ -4874,7 +4839,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -4931,7 +4895,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -4988,7 +4951,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -5045,7 +5007,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -5164,7 +5125,6 @@ The goal is to save this file, then open and decode it as a binary stream. ## Examples The following example checks the values of the Boolean properties of each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/CPP/isprops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/GetEncodings/isprops.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.IsProps/VB/isprops.vb" id="Snippet1"::: @@ -5501,7 +5461,6 @@ Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, ## Examples The following example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/getbytes_chararr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/VB/getbytes_chararr.vb" id="Snippet1"::: @@ -5570,7 +5529,6 @@ Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, ## Examples The following example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/getbytes_chararr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/VB/getbytes_chararr.vb" id="Snippet1"::: @@ -5640,7 +5598,6 @@ Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, ## Examples The following example determines the number of bytes required to encode a character array, encodes the characters, and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BigEndianUnicode/getbytes_chararr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.GetBytes_CharArr/VB/getbytes_chararr.vb" id="Snippet1"::: @@ -5810,13 +5767,11 @@ Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, ## Examples The following example includes the in an HTML header. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.WebName/CPP/webname.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/WebName/webname.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.WebName/VB/webname.vb" id="Snippet1"::: The following example retrieves the different names for each encoding and displays the encodings with one or more names that are different from . It displays but does not compare against it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.Names/CPP/names.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/BodyName/names.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.Names/VB/names.vb" id="Snippet1"::: @@ -5878,7 +5833,6 @@ Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, ## Examples The following example determines the Windows code page that most closely corresponds to each encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.Encoding.CodePage/CPP/codepage.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/Encoding/WindowsCodePage/codepage.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.Encoding.CodePage/VB/codepage.vb" id="Snippet1"::: diff --git a/xml/System.Text/EncodingInfo.xml b/xml/System.Text/EncodingInfo.xml index db117d447c3..27af0549c49 100644 --- a/xml/System.Text/EncodingInfo.xml +++ b/xml/System.Text/EncodingInfo.xml @@ -54,22 +54,21 @@ Provides basic information about an encoding. - class. The method returns an array of this type. + + This class is intended to provide minimal information about an encoding. To obtain additional information, the application should use the method to get an instance of the class, which contains more comprehensive information about the encoding it represents. + + + +## Examples + The following example uses the method to retrieve an object for each encoding supported by the .NET Framework. It then displays the value of each encoding's , , and property and compares them with the corresponding names. -## Remarks - This class is primarily used by the class. The method returns an array of this type. - - This class is intended to provide minimal information about an encoding. To obtain additional information, the application should use the method to get an instance of the class, which contains more comprehensive information about the encoding it represents. - - - -## Examples - The following example uses the method to retrieve an object for each encoding supported by the .NET Framework. It then displays the value of each encoding's , , and property and compares them with the corresponding names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: + ]]> @@ -148,20 +147,19 @@ Gets the code page identifier of the encoding. The code page identifier of the encoding. - . - - - -## Examples - The following code example retrieves the different names for each encoding and compares them with the equivalent names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp" id="Snippet1"::: + . + + + +## Examples + The following code example retrieves the different names for each encoding and compares them with the equivalent names. + :::code language="csharp" source="~/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: + ]]> @@ -205,20 +203,19 @@ Gets the human-readable description of the encoding. The human-readable description of the encoding. - property. Your applications should use for a name to pass to . - - - -## Examples - The following code example retrieves the different names for each encoding and compares them with the equivalent names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp" id="Snippet1"::: + property. Your applications should use for a name to pass to . + + + +## Examples + The following code example retrieves the different names for each encoding and compares them with the equivalent names. + :::code language="csharp" source="~/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: + ]]> @@ -275,11 +272,11 @@ if is a object and is equal to the current object; otherwise, . - objects are equal if their properties are equal. - + objects are equal if their properties are equal. + ]]> @@ -329,15 +326,14 @@ Returns a object that corresponds to the current object. A object that corresponds to the current object. - names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp" id="Snippet1"::: + names. + :::code language="csharp" source="~/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: + ]]> @@ -384,11 +380,11 @@ Returns the hash code for the current object. A 32-bit signed integer hash code. - method is not suitable for distinguishing one object from another. If your application needs a unique hash code, it should override the method. - + method is not suitable for distinguishing one object from another. If your application needs a unique hash code, it should override the method. + ]]> @@ -431,22 +427,21 @@ Gets the name registered with the Internet Assigned Numbers Authority (IANA) for the encoding. The IANA name for the encoding. - . This name is the same as the name represented by the property. When its value is the name of a standard, the actual implementation of the encoding may not conform in full to that standard. Your applications should use for a human-readable name. - - The method gets a complete list of supported encodings, uniquely distinguished by code page. If your application retrieves encodings using the property, note that some duplicate encodings are retrieved. For more about handling these duplicates, see the description of . - + . This name is the same as the name represented by the property. When its value is the name of a standard, the actual implementation of the encoding may not conform in full to that standard. Your applications should use for a human-readable name. + + The method gets a complete list of supported encodings, uniquely distinguished by code page. If your application retrieves encodings using the property, note that some duplicate encodings are retrieved. For more about handling these duplicates, see the description of . + For a list of supported names, see [Character Sets](https://www.iana.org/assignments/character-sets/character-sets.xhtml) on the [IANA website](https://www.iana.org). - -## Examples - The following code example retrieves the different names for each encoding and compares them with the equivalent names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.EncodingInfo/CPP/encodinginfo.cpp" id="Snippet1"::: + +## Examples + The following code example retrieves the different names for each encoding and compares them with the equivalent names. + :::code language="csharp" source="~/snippets/csharp/System.Text/EncodingInfo/Overview/encodinginfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.EncodingInfo/VB/encodinginfo.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Text/StringBuilder.xml b/xml/System.Text/StringBuilder.xml index cde9833f26e..1d5e59862ae 100644 --- a/xml/System.Text/StringBuilder.xml +++ b/xml/System.Text/StringBuilder.xml @@ -79,7 +79,6 @@ class. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Overview/StringBuilder.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Overview/StringBuilder.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StringBuilder/VB/StringBuilder.vb" id="Snippet1"::: @@ -159,7 +158,6 @@ The following example shows how to call many of the methods defined by the constructor with no parameters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet1"::: @@ -229,7 +227,6 @@ The following example shows how to call many of the methods defined by the constructor with a specified capacity. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet3"::: @@ -295,7 +292,6 @@ The following example shows how to call many of the methods defined by the constructor with the specified string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet4"::: @@ -369,7 +365,6 @@ The following example shows how to call many of the methods defined by the constructor with a specified capacity and maximum capacity. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet5"::: @@ -449,7 +444,6 @@ The following example shows how to call many of the methods defined by the constructor with an initial string and a specified capacity. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet7"::: @@ -529,7 +523,6 @@ The following example shows how to call many of the methods defined by the constructor with the specified string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/CPP/constructors.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/.ctor/constructors.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/.ctor/constructors.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.StringBuilder.Constructors/VB/Form1.vb" id="Snippet6"::: @@ -2497,7 +2490,6 @@ The following example shows how to call many of the methods defined by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendFormat/appfmt.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendFormat/appfmt.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendformat/VB/appfmt.vb" id="Snippet1"::: @@ -2626,7 +2618,6 @@ The following example shows how to call many of the methods defined by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendFormat/appfmt.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendFormat/appfmt.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendformat/VB/appfmt.vb" id="Snippet1"::: @@ -2984,7 +2975,6 @@ The index of a format item is less than 0 (zero), or greater than or equal to th ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendFormat/appfmt.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendFormat/appfmt.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendformat/VB/appfmt.vb" id="Snippet1"::: @@ -3321,7 +3311,6 @@ The index of a format item is less than 0 (zero), or greater than or equal to th ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendFormat/appfmt.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendFormat/appfmt.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendformat/VB/appfmt.vb" id="Snippet1"::: @@ -3577,7 +3566,6 @@ The index of a format item is less than 0 (zero), or greater than or equal to th ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendformat/CPP/appfmt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendFormat/appfmt.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendFormat/appfmt.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendformat/VB/appfmt.vb" id="Snippet1"::: @@ -4579,7 +4567,6 @@ The index of a format item is less than 0 (zero), or greater than or equal to th ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.appendline/CPP/al.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/AppendLine/al.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/AppendLine/al.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.appendline/VB/al.vb" id="Snippet1"::: @@ -4823,7 +4810,6 @@ The index of a format item is less than 0 (zero), or greater than or equal to th ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.ensurecapacity/VB/cap.vb" id="Snippet1"::: @@ -5087,7 +5073,6 @@ The following example instantiates a object wit ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.copyto2/CPP/ct2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/CopyTo/ct2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/CopyTo/ct2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.copyto2/VB/ct2.vb" id="Snippet1"::: @@ -5167,7 +5152,6 @@ The following example instantiates a object wit ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.ensurecapacity/VB/cap.vb" id="Snippet1"::: @@ -5297,7 +5281,6 @@ The `Equals` method performs an ordinal comparison to determine whether the char ## Examples The following code uses the method to check whether two objects are equal. The method is called repeatedly after small changes are made to each object, and the results are displayed to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.ensurecapacity/VB/cap.vb" id="Snippet1"::: @@ -5389,7 +5372,6 @@ foreach (ReadOnlyMemory chunk in sb.GetChunks()) ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.insert/CPP/insert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Insert/insert.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Insert/insert.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.insert/VB/insert.vb" id="Snippet1"::: @@ -6804,7 +6786,6 @@ The existing characters are shifted to make room for the character sequence in t ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.ensurecapacity/CPP/cap.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Capacity/cap.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Capacity/cap.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.ensurecapacity/VB/cap.vb" id="Snippet1"::: @@ -6936,7 +6917,6 @@ In .NET Core and in the .NET Framework 4.0 and later versions, when you instanti ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.remove/CPP/remove.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Remove/remove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Remove/remove.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.remove/VB/remove.vb" id="Snippet1"::: @@ -6964,7 +6944,6 @@ In .NET Core and in the .NET Framework 4.0 and later versions, when you instanti ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringbuilder.replace/CPP/replace.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Replace/replace.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Replace/replace.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringbuilder.replace/VB/replace.vb" id="Snippet1"::: @@ -7494,7 +7473,6 @@ In .NET Core and in the .NET Framework 4.0 and later versions, when you instanti ## Examples The following example demonstrates calling the method. This example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StringBuilder/cpp/StringBuilder.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Text/StringBuilder/Overview/StringBuilder.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System.Text/StringBuilder/Overview/StringBuilder.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StringBuilder/VB/StringBuilder.vb" id="Snippet5"::: diff --git a/xml/System.Text/UTF32Encoding.xml b/xml/System.Text/UTF32Encoding.xml index ac1e306372c..f2f6053a918 100644 --- a/xml/System.Text/UTF32Encoding.xml +++ b/xml/System.Text/UTF32Encoding.xml @@ -105,7 +105,6 @@ ## Examples The following example demonstrates the behavior of objects with and without error detection enabled. It creates a byte array whose last four bytes represent an invalid surrogate pair; the high surrogate U+D8FF is followed by an U+01FF, which is outside the range of low surrogates (0xDC00 through 0xDFFF). Without error detection, the UTF32 decoder uses replacement fallback to replace the invalid surrogate pair with REPLACEMENT CHARACTER (U+FFFD). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/CPP/errordetection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/Overview/errordetection.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/VB/ErrorDetection.vb" id="Snippet1"::: @@ -190,7 +189,6 @@ ## Examples The following example retrieves and displays the byte order mark for different instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/.ctor/getpreamble.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/VB/GetPreamble.vb" id="Snippet1"::: @@ -252,7 +250,6 @@ ## Examples The following example retrieves and displays the byte order mark for different instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/.ctor/getpreamble.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/VB/GetPreamble.vb" id="Snippet1"::: @@ -318,7 +315,6 @@ ## Examples The following example demonstrates the behavior of , both with error detection enabled and without. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/CPP/errordetection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/Overview/errordetection.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.ErrorDetection/VB/ErrorDetection.vb" id="Snippet1"::: @@ -397,7 +393,6 @@ ## Examples The following example creates objects using different parameter values and then checks them for equality. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.Equals/CPP/equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/Equals/equals.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.Equals/VB/equals.vb" id="Snippet1"::: @@ -855,7 +850,6 @@ ## Examples The following example determines the number of bytes required to encode three characters from a character array, then encodes the characters and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_CharArr/CPP/getbytes_chararr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetBytes/getbytes_chararr.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_CharArr/VB/GetBytes_CharArr.vb" id="Snippet1"::: @@ -964,7 +958,6 @@ ## Examples The following example determines the number of bytes required to encode a string, then encodes the string and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/CPP/getbytes_string.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetBytes/getbytes_string.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/VB/GetBytes_String.vb" id="Snippet1"::: @@ -1158,7 +1151,6 @@ ## Examples The following example encodes a string into an array of bytes, and then decodes the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetCharCount/getchars.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/VB/GetChars.vb" id="Snippet1"::: @@ -1365,7 +1357,6 @@ ## Examples The following example encodes a string into an array of bytes, and then decodes the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetCharCount/getchars.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/VB/GetChars.vb" id="Snippet1"::: @@ -1455,7 +1446,6 @@ ## Examples The following example uses an encoder and a decoder to encode a string into an array of bytes, and then decode the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/CPP/encdec.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetDecoder/encdec.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/VB/EncDec.vb" id="Snippet1"::: @@ -1521,7 +1511,6 @@ ## Examples The following example uses an encoder and a decoder to encode a string into an array of bytes, and then decode the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/CPP/encdec.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetDecoder/encdec.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.EncDec/VB/EncDec.vb" id="Snippet1"::: @@ -1637,7 +1626,6 @@ ## Examples The following example determines the number of bytes required to encode a string, then encodes the string and displays the resulting bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/CPP/getbytes_string.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetBytes/getbytes_string.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetBytes_String/VB/GetBytes_String.vb" id="Snippet1"::: @@ -1719,7 +1707,6 @@ ## Examples The following example encodes a string into an array of bytes, and then decodes the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/CPP/getchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/GetCharCount/getchars.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetChars/VB/GetChars.vb" id="Snippet1"::: @@ -1813,7 +1800,6 @@ ## Examples The following code example retrieves and displays the byte order mark for different instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/CPP/getpreamble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF32Encoding/.ctor/getpreamble.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF32Encoding.GetPreamble/VB/GetPreamble.vb" id="Snippet1"::: diff --git a/xml/System.Text/UTF7Encoding.xml b/xml/System.Text/UTF7Encoding.xml index 3b3959ee35b..91ee5e3f7d1 100644 --- a/xml/System.Text/UTF7Encoding.xml +++ b/xml/System.Text/UTF7Encoding.xml @@ -86,7 +86,6 @@ ## Examples The following code example demonstrates how to use a to encode a string of Unicode characters and store them in a byte array. Notice that when the byte array is decoded back to a string, no data is lost. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding Example/CPP/snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/Overview/snippet.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding Example/VB/snippet.vb" id="Snippet1"::: @@ -164,7 +163,6 @@ ## Examples The following code example demonstrates how to create a new instance and display the name of the encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor1 Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/.ctor/ctor.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor1 Example/VB/ctor.vb" id="Snippet1"::: @@ -232,7 +230,6 @@ ## Examples The following code example demonstrates how to create a new instance that allows optional characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor2 Example/CPP/ctor-boolean.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/.ctor/ctor-boolean.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.ctor2 Example/VB/ctor-boolean.vb" id="Snippet1"::: @@ -382,7 +379,6 @@ ## Examples The following code example demonstrates how to use the method to return the number of bytes required to encode a character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetByteCount/getbytecount-char[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/VB/getbytecount-char[]-int32-int32.vb" id="Snippet1"::: @@ -548,7 +544,6 @@ ## Examples The following code example demonstrates how to use the method to return the number of bytes required to encode an array of Unicode characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/CPP/getbytecount-char[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetByteCount/getbytecount-char[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetByteCount Example/VB/getbytecount-char[]-int32-int32.vb" id="Snippet1"::: @@ -753,7 +748,6 @@ ## Examples The following code example demonstrates how to use the method to encode a range of characters from a and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -863,7 +857,6 @@ ## Examples The following code example demonstrates how to use the method to encode a range of elements from a Unicode character array, and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetBytes Example/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1054,7 +1047,6 @@ ## Examples The following code example demonstrates how to use the method to return the number of characters produced by decoding a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetCharCount/getcharcount-byte[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: @@ -1260,7 +1252,6 @@ ## Examples The following code example demonstrates how to use the method to decode a range of elements in a byte array and store the result in a character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetChars/getchars-byte[]-int32-int32-char[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: @@ -1346,7 +1337,6 @@ ## Examples The following code example demonstrates how to use the method to obtain a decoder to convert the UTF-7 encoded bytes into a sequence of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetDecoder Example/CPP/getdecoder-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetDecoder/getdecoder-.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetDecoder Example/VB/getdecoder-.vb" id="Snippet1"::: @@ -1411,7 +1401,6 @@ ## Examples The following code example demonstrates how to use the method to obtain an encoder to convert a sequence of characters into a UTF-7 encoded sequence of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetEncoder Example/CPP/getencoder-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetEncoder/getencoder-.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetEncoder Example/VB/getencoder-.vb" id="Snippet1"::: @@ -1542,7 +1531,6 @@ ## Examples The following code example demonstrates how to use the method to return the maximum number of bytes required to encode a specified number of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetMaxByteCount/getmaxbytecount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxByteCount Example/VB/getmaxbytecount-int32.vb" id="Snippet1"::: @@ -1627,7 +1615,6 @@ ## Examples The following code example demonstrates how to use the method to return the maximum number of characters produced by decoding a specified number of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetMaxCharCount/getmaxcharcount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.GetMaxCharCount Example/VB/getmaxcharcount-int32.vb" id="Snippet1"::: @@ -1720,7 +1707,6 @@ ## Examples The following code example encodes a string into an array of bytes, and then decodes the bytes back into a string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF7Encoding.getstring/CPP/getstring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF7Encoding/GetString/getstring.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF7Encoding.getstring/VB/getstring.vb" id="Snippet1"::: diff --git a/xml/System.Text/UTF8Encoding.xml b/xml/System.Text/UTF8Encoding.xml index fa109725ba7..4601e1cd32c 100644 --- a/xml/System.Text/UTF8Encoding.xml +++ b/xml/System.Text/UTF8Encoding.xml @@ -95,7 +95,6 @@ ## Examples The following example uses a object to encode a string of Unicode characters and store them in a byte array. The Unicode string includes two characters, Pi (U+03A0) and Sigma (U+03A3), that are outside the ASCII character range. When the encoded byte array is decoded back to a string, the Pi and Sigma characters are still present. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding Example/CPP/snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/Overview/snippet.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding Example/VB/snippet.vb" id="Snippet1"::: @@ -172,7 +171,6 @@ ## Examples The following example creates a new instance and displays its name. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor1 Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/.ctor/ctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor1 Example/VB/ctor.vb" id="Snippet1"::: @@ -238,7 +236,6 @@ ## Examples The following example creates a new instance and specifies that a Unicode byte order mark prefix should be emitted by the method. The method then returns the Unicode byte order mark prefix. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor2 Example/CPP/ctor-boolean.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/.ctor/ctor-boolean.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor2 Example/VB/ctor-boolean.vb" id="Snippet1"::: @@ -307,7 +304,6 @@ ## Examples The following example creates a new instance, specifying that the method should not emit a Unicode byte order mark prefix, and an exception should be thrown when an invalid encoding is detected. The behavior of this constructor is compared to the default constructor, which does not throw an exception when an invalid encoding is detected. The two instances encode a character array that contains two high surrogates (U+D801 and U+D802) in a row, which is an invalid character sequence; a high surrogate should always be followed by a low surrogate. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor3 Example/CPP/ctor-boolean-boolean.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/.ctor/ctor-boolean-boolean.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.ctor3 Example/VB/ctor-boolean-boolean.vb" id="Snippet1"::: @@ -386,7 +382,6 @@ ## Examples The following example uses the method to test whether the current object is equal to a different object. Four objects are created and compared and the results of the comparisons are displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CPP/equals-object.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/Equals/equals-object.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/VB/equals-object.vb" id="Snippet1"::: @@ -998,7 +993,6 @@ ## Examples The following example uses the method to encode a range of characters from a string and stores the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetBytes/getbytes-string-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes3 Example/VB/getbytes-string-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1110,7 +1104,6 @@ ## Examples The following example uses the method to encode a range of elements from a Unicode character array and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetBytes1 Example/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1357,7 +1350,6 @@ ## Examples The following example uses the method to return the number of characters produced by decoding a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetCharCount/getcharcount-byte[]-int32-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: @@ -1623,7 +1615,6 @@ ## Examples The following example uses the method to decode a range of elements in a byte array and store the result in a character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetChars/getchars-byte[]-int32-int32-char[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: @@ -1715,7 +1706,6 @@ ## Examples The following example uses the method to obtain a UTF-8 decoder. The decoder converts a sequence of bytes into a sequence of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CPP/getdecoder-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetDecoder/getdecoder-.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/VB/getdecoder-.vb" id="Snippet1"::: @@ -1783,7 +1773,6 @@ ## Examples The following example uses the method to obtain an encoder to convert a sequence of characters into a UTF-8 encoded sequence of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CPP/getencoder-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetEncoder/getencoder-.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/VB/getencoder-.vb" id="Snippet1"::: @@ -1843,7 +1832,6 @@ ## Examples The following example uses the method to return a hash code for instances. Notice that the hash code returned by this method depends on the constructor used to create the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetHashCode Example/CPP/gethashcode-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetHashCode/gethashcode-.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetHashCode Example/VB/gethashcode-.vb" id="Snippet1"::: @@ -1916,7 +1904,6 @@ ## Examples The following example uses the method to return the maximum number of bytes required to encode a specified number of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetMaxByteCount/getmaxbytecount-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/VB/getmaxbytecount-int32.vb" id="Snippet1"::: @@ -2002,7 +1989,6 @@ ## Examples The following example uses the method to return the maximum number of characters produced by decoding a specified number of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetMaxCharCount/getmaxcharcount-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/VB/getmaxcharcount-int32.vb" id="Snippet1"::: @@ -2094,7 +2080,6 @@ ## 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 language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/CPP/getpreamble-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UTF8Encoding/GetPreamble/getpreamble-.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetPreamble Example/VB/getpreamble-.vb" id="Snippet1"::: diff --git a/xml/System.Text/UnicodeEncoding.xml b/xml/System.Text/UnicodeEncoding.xml index 29d0f06f82e..6fcd7ab1e86 100644 --- a/xml/System.Text/UnicodeEncoding.xml +++ b/xml/System.Text/UnicodeEncoding.xml @@ -113,7 +113,6 @@ ## Examples The following example demonstrates how to encode a string of Unicode characters into a byte array by using a object. The byte array is decoded into a string to demonstrate that there is no loss of data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding Example/CPP/snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/Overview/snippet.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding Example/VB/snippet.vb" id="Snippet1"::: @@ -195,7 +194,6 @@ ## Examples The following example demonstrates how to create a new instance and display the name of the encoding. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor Example/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/.ctor/ctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor Example/VB/ctor.vb" id="Snippet1"::: @@ -263,7 +261,6 @@ ## Examples The following example demonstrates how to create a new instance specifying whether to support little endian or big endian byte ordering and the Unicode byte order mark. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/CPP/ctor-boolean-boolean.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/.ctor/ctor-boolean-boolean.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/VB/ctor-boolean-boolean.vb" id="Snippet1"::: @@ -332,7 +329,6 @@ ## Examples The following example demonstrates the behavior of , both with error detection enabled and without. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ErrorDetection/CPP/errordetection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/.ctor/errordetection.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ErrorDetection/VB/errordetection.vb" id="Snippet1"::: @@ -390,7 +386,6 @@ ## Examples The following example demonstrates how to return the value of and display it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.CharSize Example/CPP/charsize.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/CharSize/charsize.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.CharSize Example/VB/charsize.vb" id="Snippet1"::: @@ -470,7 +465,6 @@ ## Examples The following example demonstrates how to use the method to test whether the current object is equal to a different object. Five objects are created and compared, and the results of the comparisons are displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/CPP/ctor-boolean-boolean.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/.ctor/ctor-boolean-boolean.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.ctor2 Example/VB/ctor-boolean-boolean.vb" id="Snippet1"::: @@ -976,7 +970,6 @@ ## Examples The following example demonstrates how to use the method to encode a range of characters from a and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes3 Example/CPP/getbytes-string-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetBytes/getbytes-string-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes3 Example/VB/getbytes-string-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1087,7 +1080,6 @@ ## Examples The following example demonstrates how to encode a range of elements from a Unicode character array and store the encoded bytes in a range of elements in a byte array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes1 Example/CPP/getbytes-char[]-int32-int32-byte[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetBytes/getbytes-char[]-int32-int32-byte[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetBytes1 Example/VB/getbytes-char[]-int32-int32-byte[]-int32.vb" id="Snippet1"::: @@ -1286,7 +1278,6 @@ ## Examples The following example demonstrates how to use the method to return the number of characters produced by decoding a range of elements in a byte array using . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetCharCount/getcharcount-byte[]-int32-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: @@ -1498,7 +1489,6 @@ ## Examples The following example demonstrates how to use the method to decode a range of elements in a byte array and store the result in a character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetChars/getchars-byte[]-int32-int32-char[]-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: @@ -1590,7 +1580,6 @@ ## Examples The following example uses an encoder and a decoder to encode a string into an array of bytes, and then decode the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/CPP/encdec.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetDecoder/encdec.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/VB/encdec.vb" id="Snippet1"::: @@ -1663,7 +1652,6 @@ ## Examples The following example uses an encoder and a decoder to encode a string into an array of bytes, and then decode the bytes into an array of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/CPP/encdec.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetDecoder/encdec.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.EncDec/VB/encdec.vb" id="Snippet1"::: @@ -1785,7 +1773,6 @@ ## Examples The following example demonstrates how to use the method to return the maximum number of bytes required to encode a specified number of characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetMaxByteCount/getmaxbytecount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxByteCount Example/VB/getmaxbytecount-int32.vb" id="Snippet1"::: @@ -1871,7 +1858,6 @@ ## Examples The following example demonstrates how to use the method to return the maximum number of characters produced by decoding a specified number of bytes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetMaxCharCount/getmaxcharcount-int32.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetMaxCharCount Example/VB/getmaxcharcount-int32.vb" id="Snippet1"::: @@ -1967,7 +1953,6 @@ ## Examples The following example demonstrates how to use the method to retrieve the Unicode byte order mark in big endian or little endian byte order for an instance of a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetPreamble Example/CPP/getpreamble-.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Text/UnicodeEncoding/GetPreamble/getpreamble-.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UnicodeEncoding.GetPreamble Example/VB/getpreamble-.vb" id="Snippet1"::: diff --git a/xml/System.Threading/AbandonedMutexException.xml b/xml/System.Threading/AbandonedMutexException.xml index 79d57cdd8a0..3b4e5fb73f8 100644 --- a/xml/System.Threading/AbandonedMutexException.xml +++ b/xml/System.Threading/AbandonedMutexException.xml @@ -84,7 +84,6 @@ > [!NOTE] > The call to the method is interrupted by one of the abandoned mutexes. The other abandoned mutex could still cause an to be thrown by subsequent wait methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/CPP/koax.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/AbandonedMutexException/Overview/koax.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/VB/koax.vb" id="Snippet1"::: @@ -654,7 +653,6 @@ > [!NOTE] > The call to is interrupted by one of the abandoned mutexes. The other abandoned mutex could still cause an to be thrown by subsequent wait methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/CPP/koax.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/AbandonedMutexException/Overview/koax.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.AbandonedMutexException/VB/koax.vb" id="Snippet1"::: diff --git a/xml/System.Threading/ApartmentState.xml b/xml/System.Threading/ApartmentState.xml index ad24f5ff9cd..f2899077d78 100644 --- a/xml/System.Threading/ApartmentState.xml +++ b/xml/System.Threading/ApartmentState.xml @@ -54,24 +54,22 @@ Specifies the apartment state of a . - property of the thread to one of the values of the enumeration. Because a given thread can only initialize a COM apartment once, you cannot change the apartment type after the first call to the unmanaged code. - - For more information, see , [Managed and Unmanaged Threading](https://msdn.microsoft.com/library/db425c20-4b2f-4433-bf96-76071c7881e5), and [Advanced COM Interoperability](https://msdn.microsoft.com/library/3ada36e5-2390-4d70-b490-6ad8de92f2fb). - - - -## Examples - The following code example demonstrates how to set the apartment state of a thread. - + property of the thread to one of the values of the enumeration. Because a given thread can only initialize a COM apartment once, you cannot change the apartment type after the first call to the unmanaged code. + + For more information, see , [Managed and Unmanaged Threading](/previous-versions/dotnet/netframework-4.0/5s8ee185(v=vs.100)), and [Advanced COM Interoperability](/previous-versions/dotnet/netframework-4.0/bd9cdfyx(v=vs.100)). + +## Examples + The following code example demonstrates how to set the apartment state of a thread. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ApartmentState/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ApartmentState/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.ApartmentState/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.ApartmentState/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Threading/AutoResetEvent.xml b/xml/System.Threading/AutoResetEvent.xml index 6efeac22bcb..51552ecfdde 100644 --- a/xml/System.Threading/AutoResetEvent.xml +++ b/xml/System.Threading/AutoResetEvent.xml @@ -90,7 +90,6 @@ The following example shows how to use to After the threads are released from the first , they wait on another that was created in the non-signaled state. All three threads block, so the method must be called three times to release them all. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/simplerisbetter.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/AutoResetEvent/Overview/simplerisbetter.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/VB/simplerisbetter.vb" id="Snippet3"::: @@ -161,7 +160,6 @@ After the threads are released from the first method, to give the second thread a chance to execute. Otherwise, on a single-processor computer `Main` would write many values between any two read operations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/AutoResetEvent/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.AutoResetEvent/VB/class1.vb" id="Snippet1"::: diff --git a/xml/System.Threading/EventResetMode.xml b/xml/System.Threading/EventResetMode.xml index 260cd15c1b7..af5936640d0 100644 --- a/xml/System.Threading/EventResetMode.xml +++ b/xml/System.Threading/EventResetMode.xml @@ -51,17 +51,16 @@ Indicates whether an is reset automatically or manually after receiving a signal. - method overload to allow the main thread to signal a blocked thread and then wait until the thread finishes a task. + + The example starts five threads and allows them to block on an created with the AutoReset flag, then releases one thread each time the user presses the ENTER key. The example then queues another five threads and releases them all using an created with the ManualReset flag. -## Examples - The following code example uses the method overload to allow the main thread to signal a blocked thread and then wait until the thread finishes a task. - - The example starts five threads and allows them to block on an created with the AutoReset flag, then releases one thread each time the user presses the ENTER key. The example then queues another five threads and releases them all using an created with the ManualReset flag. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventResetMode/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Threading/EventWaitHandle.xml b/xml/System.Threading/EventWaitHandle.xml index 8a836999702..0f063d873ce 100644 --- a/xml/System.Threading/EventWaitHandle.xml +++ b/xml/System.Threading/EventWaitHandle.xml @@ -83,7 +83,6 @@ The class allows threads to communicate The example starts five threads and allows them to block on an created with the flag, then releases one thread each time the user presses the Enter key. The example then queues another five threads and releases them all using an created with the flag. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventResetMode/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: @@ -167,7 +166,6 @@ The class allows threads to communicate The example starts five threads and allows them to block on an created with the flag, then releases one thread each time the user presses the Enter key. The example then queues another five threads and releases them all using an created with the flag. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventResetMode/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: @@ -462,7 +460,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the event is opened with the rights required to wait on it and signal it. If you run the compiled example from a third command window, the example runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventWaitHandle/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/VB/source.vb" id="Snippet1"::: @@ -571,7 +568,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions have been read, using the method, and changed, the event is opened with the rights required to wait on it and signal it. If you run the compiled example from a third command window, the example runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventWaitHandle/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/VB/source.vb" id="Snippet1"::: @@ -750,7 +746,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the event is opened with the rights required to wait on it and signal it. If you run the compiled example from a third command window, the example runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventWaitHandle/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/VB/source.vb" id="Snippet1"::: @@ -931,7 +926,6 @@ There was some other error. The `HResult` property may provide more information. The example starts five threads and allows them to block on an created with the flag, then releases one thread each time the user presses the Enter key. The example then queues another five threads and releases them all using an created with the flag. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventResetMode/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: @@ -990,7 +984,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, using the method, the event is opened with the rights required to wait on it and signal it. If you run the compiled example from a third command window, the example runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventWaitHandle/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.EventWaitHandle.ctor named 5/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/Interlocked.xml b/xml/System.Threading/Interlocked.xml index b418458b428..0b5a99cdae5 100644 --- a/xml/System.Threading/Interlocked.xml +++ b/xml/System.Threading/Interlocked.xml @@ -86,7 +86,6 @@ ## Examples The following code example shows a thread-safe resource locking mechanism. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Interlocked/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/VB/class1.vb" id="Snippet1"::: @@ -738,7 +737,6 @@ > [!NOTE] > The method, introduced in version 2.0 of the .NET Framework, provides a more convenient way to accumulate thread-safe running totals for integers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked CompareExchange0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Interlocked/CompareExchange/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Interlocked CompareExchange0/VB/source.vb" id="Snippet1"::: @@ -1811,7 +1809,6 @@ If `comparand` and the object in `location1` are equal by reference, then `value ## Examples The following code example shows a thread-safe resource locking mechanism. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Interlocked/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Interlocked.Exchange Int32 Example/VB/class1.vb" id="Snippet1"::: diff --git a/xml/System.Threading/LockCookie.xml b/xml/System.Threading/LockCookie.xml index b9ac638b7c5..a670352bd16 100644 --- a/xml/System.Threading/LockCookie.xml +++ b/xml/System.Threading/LockCookie.xml @@ -63,23 +63,20 @@ Defines the lock that implements single-writer/multiple-reader semantics. This is a value type. - . It then uses the to downgrade to a reader lock again. + + This code is part of a larger example provided for the class. -## Examples - The following example shows how to request a reader lock, upgrade the reader lock to a writer lock, and save the . It then uses the to downgrade to a reader lock again. - - This code is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet5"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet5"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: + ]]> This type is thread safe. diff --git a/xml/System.Threading/ManualResetEvent.xml b/xml/System.Threading/ManualResetEvent.xml index 7623cf6269b..f652f645054 100644 --- a/xml/System.Threading/ManualResetEvent.xml +++ b/xml/System.Threading/ManualResetEvent.xml @@ -59,40 +59,39 @@ Represents a thread synchronization event that, when signaled, must be reset manually. This class cannot be inherited. - , and for thread interaction (or thread signaling). For more information, see the [Thread interaction, or signaling](/dotnet/standard/threading/overview-of-synchronization-primitives#thread-interaction-or-signaling) section of the [Overview of synchronization primitives](/dotnet/standard/threading/overview-of-synchronization-primitives) article. +## Remarks - When a thread begins an activity that must complete before other threads proceed, it calls [ManualResetEvent.Reset](xref:System.Threading.EventWaitHandle.Reset%2A) to put `ManualResetEvent` in the non-signaled state. This thread can be thought of as controlling the `ManualResetEvent`. Threads that call [ManualResetEvent.WaitOne](xref:System.Threading.WaitHandle.WaitOne%2A) block, awaiting the signal. When the controlling thread completes the activity, it calls [ManualResetEvent.Set](xref:System.Threading.EventWaitHandle.Set%2A) to signal that the waiting threads can proceed. All waiting threads are released. + You use `ManualResetEvent`, , and for thread interaction (or thread signaling). For more information, see the [Thread interaction, or signaling](/dotnet/standard/threading/overview-of-synchronization-primitives#thread-interaction-or-signaling) section of the [Overview of synchronization primitives](/dotnet/standard/threading/overview-of-synchronization-primitives) article. - Once it has been signaled, `ManualResetEvent` remains signaled until it is manually reset by calling the method. That is, calls to return immediately. + When a thread begins an activity that must complete before other threads proceed, it calls [ManualResetEvent.Reset](xref:System.Threading.EventWaitHandle.Reset%2A) to put `ManualResetEvent` in the non-signaled state. This thread can be thought of as controlling the `ManualResetEvent`. Threads that call [ManualResetEvent.WaitOne](xref:System.Threading.WaitHandle.WaitOne%2A) block, awaiting the signal. When the controlling thread completes the activity, it calls [ManualResetEvent.Set](xref:System.Threading.EventWaitHandle.Set%2A) to signal that the waiting threads can proceed. All waiting threads are released. + + Once it has been signaled, `ManualResetEvent` remains signaled until it is manually reset by calling the method. That is, calls to return immediately. + + You can control the initial state of a `ManualResetEvent` by passing a Boolean value to the constructor: `true` if the initial state is signaled, and `false` otherwise. + + `ManualResetEvent` can also be used with the `static` and methods. + + Beginning with the .NET Framework version 2.0, derives from the class. A is functionally equivalent to an created with . - You can control the initial state of a `ManualResetEvent` by passing a Boolean value to the constructor: `true` if the initial state is signaled, and `false` otherwise. - - `ManualResetEvent` can also be used with the `static` and methods. - - Beginning with the .NET Framework version 2.0, derives from the class. A is functionally equivalent to an created with . - > [!NOTE] -> Unlike the class, the class provides access to named system synchronization events. +> Unlike the class, the class provides access to named system synchronization events. - Beginning with the .NET Framework version 4.0, the class is a lightweight alternative to . - - - -## Examples - The following example demonstrates how works. The example starts with a in the unsignaled state (that is, `false` is passed to the constructor). The example creates three threads, each of which blocks on the by calling its method. When the user presses the **Enter** key, the example calls the method, which releases all three threads. Contrast this with the behavior of the class, which releases threads one at a time, resetting automatically after each release. - - Pressing the **Enter** key again demonstrates that the remains in the signaled state until its method is called: The example starts two more threads. These threads do not block when they call the method, but instead run to completion. - - Pressing the **Enter** key again causes the example to call the method and to start one more thread, which blocks when it calls . Pressing the **Enter** key one final time calls to release the last thread, and the program ends. + Beginning with the .NET Framework version 4.0, the class is a lightweight alternative to . + + + +## Examples + The following example demonstrates how works. The example starts with a in the unsignaled state (that is, `false` is passed to the constructor). The example creates three threads, each of which blocks on the by calling its method. When the user presses the **Enter** key, the example calls the method, which releases all three threads. Contrast this with the behavior of the class, which releases threads one at a time, resetting automatically after each release. + + Pressing the **Enter** key again demonstrates that the remains in the signaled state until its method is called: The example starts two more threads. These threads do not block when they call the method, but instead run to completion. + + Pressing the **Enter** key again causes the example to call the method and to start one more thread, which blocks when it calls . Pressing the **Enter** key one final time calls to release the last thread, and the program ends. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ManualResetEvent/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ManualResetEvent/VB/source.vb" id="Snippet1"::: + ]]> This class is thread safe. @@ -149,11 +148,11 @@ to set the initial state signaled; to set the initial state to nonsignaled. Initializes a new instance of the class with a Boolean value indicating whether to set the initial state to signaled. - is signaled (that is, if it is created by passing `true` for `initialState`), threads that wait on the do not block. If the initial state is nonsignaled, threads block until the method is called. - + is signaled (that is, if it is created by passing `true` for `initialState`), threads that wait on the do not block. If the initial state is nonsignaled, threads block until the method is called. + ]]> @@ -219,7 +218,7 @@ method is called. ]]> diff --git a/xml/System.Threading/Monitor.xml b/xml/System.Threading/Monitor.xml index fda694888a8..2dcb4b80a36 100644 --- a/xml/System.Threading/Monitor.xml +++ b/xml/System.Threading/Monitor.xml @@ -144,7 +144,6 @@ ## Examples The following example demonstrates how to use the `Enter` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Monitor/Enter/monitor2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MonitorExmpl2/VB/monitor2.vb" id="Snippet1"::: @@ -303,7 +302,6 @@ ## Examples The following example demonstrates how to use the `Exit` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Monitor/Enter/monitor2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MonitorExmpl2/VB/monitor2.vb" id="Snippet1"::: @@ -637,7 +635,6 @@ ## Examples The following code example demonstrates how to use the `TryEnter` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MonitorExmpl2/CPP/monitor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Monitor/Enter/monitor2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MonitorExmpl2/VB/monitor2.vb" id="Snippet1"::: diff --git a/xml/System.Threading/Mutex.xml b/xml/System.Threading/Mutex.xml index 043248780c8..ab4659ef967 100644 --- a/xml/System.Threading/Mutex.xml +++ b/xml/System.Threading/Mutex.xml @@ -185,7 +185,6 @@ ## Examples The following code example shows how a local object is used to synchronize access to a protected resource. The thread that creates the mutex does not own it initially. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/class13.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/VB/class1.vb" id="Snippet1"::: @@ -252,7 +251,6 @@ ## Examples The following code example shows how a local object is used to synchronize access to a protected resource. The thread that creates the owns it initially. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 1Arg Ctor Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex 1Arg Ctor Example/VB/class1.vb" id="Snippet1"::: @@ -349,7 +347,6 @@ The constructor overload used in this example cannot tell the calling thread whether initial ownership of the named mutex was granted. You should not use this constructor to request initial ownership unless you can be certain that the thread will create the named mutex. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 2Arg Ctor Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/class11.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex 2Arg Ctor Example/VB/class1.vb" id="Snippet1"::: @@ -485,7 +482,6 @@ There was some other error. The `HResult` property may provide more information. ## Examples The following code example shows how a named mutex is used to signal between processes or threads. Run this program from two or more command windows. Each process creates a object that represents the named mutex "MyMutex". The named mutex is a system object. In this example, its lifetime is bounded by the lifetimes of the objects that represent it. The named mutex is created when the first process creates its local object, and destroyed when all the objects that represent it have been released. The named mutex is initially owned by the first process. The second process and any subsequent processes wait for earlier processes to release the named mutex. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex 3Arg Ctor Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/class12.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex 3Arg Ctor Example/VB/class1.vb" id="Snippet1"::: @@ -623,7 +619,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/VB/source.vb" id="Snippet1"::: @@ -728,7 +723,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/VB/source.vb" id="Snippet1"::: @@ -830,7 +824,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/VB/source.vb" id="Snippet1"::: @@ -920,7 +913,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/VB/source.vb" id="Snippet1"::: @@ -1052,7 +1044,6 @@ There was some other error. The `HResult` property may provide more information. ## Examples The following example shows how a local object is used to synchronize access to a protected resource. The thread that creates the mutex does not own it initially. The method is used to release the mutex when it is no longer needed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/class13.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex Default Ctor Example/VB/class1.vb" id="Snippet1"::: @@ -1116,7 +1107,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Mutex/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Mutex.ctor named 4/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/ParameterizedThreadStart.xml b/xml/System.Threading/ParameterizedThreadStart.xml index f821ca9a38d..5b39bd19359 100644 --- a/xml/System.Threading/ParameterizedThreadStart.xml +++ b/xml/System.Threading/ParameterizedThreadStart.xml @@ -88,7 +88,6 @@ > [!NOTE] > The Visual Basic and C# compilers infer the delegate from the signatures of the `DoWork` and `DoMoreWork` methods, and call the correct constructor. Thus, there is no explicit constructor call in the code. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ParameterizedThreadStart/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/ReaderWriterLock.xml b/xml/System.Threading/ReaderWriterLock.xml index 63bda1412e9..b596e6bf407 100644 --- a/xml/System.Threading/ReaderWriterLock.xml +++ b/xml/System.Threading/ReaderWriterLock.xml @@ -97,7 +97,6 @@ ## Examples The following example demonstrates how to use a to protect a shared resource, an integer value named `resource`, that is read concurrently and written exclusively by multiple threads. Note that the is declared at the class level so that it is visible to all threads. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet1"::: @@ -156,10 +155,8 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -252,13 +249,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -425,13 +419,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -581,13 +572,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -662,13 +650,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -779,7 +764,6 @@ ## Examples The following code example demonstrates how to use `IsReaderLockHeld` to avoid deadlocks. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ReaderWriterLock/IsReaderLockHeld/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/VB/source.vb" id="Snippet1"::: @@ -844,7 +828,6 @@ ## Examples The following code example demonstrates that when an attempt is made to acquire a reader lock on a thread that has a writer lock, `ReaderWriterLock` does not grant the reader lock but instead increments the lock count on the writer lock. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ReaderWriterLock/IsReaderLockHeld/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock.IsWriterLockHeld/VB/source.vb" id="Snippet1"::: @@ -912,13 +895,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -992,13 +972,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet3"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -1073,13 +1050,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -1161,13 +1135,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -1262,13 +1233,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet5"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: @@ -1414,13 +1382,10 @@ This code is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet2"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet6"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/CPP/source.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/LockCookie/Overview/source.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ReaderWriterLock/VB/source.vb" id="Snippet7"::: diff --git a/xml/System.Threading/RegisteredWaitHandle.xml b/xml/System.Threading/RegisteredWaitHandle.xml index 2c49a62fa66..ed83f43c047 100644 --- a/xml/System.Threading/RegisteredWaitHandle.xml +++ b/xml/System.Threading/RegisteredWaitHandle.xml @@ -61,23 +61,22 @@ Represents a handle that has been registered when calling . This class cannot be inherited. - to determine why a callback method is called, and how to unregister a task if the callback occurred because the wait handle was signaled. + + The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc`, and the wait handle is an . + + The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object so that the callback method has access to the . + + In addition to specifying `TaskInfo` as the object to pass to the callback method, the call to the method specifies the that the task will wait for, a delegate that represents the `WaitProc` callback method, a one second time-out interval, and multiple callbacks. + + When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a time-out occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping additional callbacks. In the case of a time-out, the task continues to wait. The `WaitProc` method ends by printing a message to the console. -## Examples - The following example shows how to use a to determine why a callback method is called, and how to unregister a task if the callback occurred because the wait handle was signaled. - - The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc`, and the wait handle is an . - - The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object so that the callback method has access to the . - - In addition to specifying `TaskInfo` as the object to pass to the callback method, the call to the method specifies the that the task will wait for, a delegate that represents the `WaitProc` callback method, a one second time-out interval, and multiple callbacks. - - When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a time-out occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping additional callbacks. In the case of a time-out, the task continues to wait. The `WaitProc` method ends by printing a message to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/RegisteredWaitHandle/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: + ]]> This type is thread safe. @@ -167,28 +166,27 @@ if the function succeeds; otherwise, . - is successfully unregistered. If a callback method is in progress when executes, `waitObject` is not signaled until the callback method completes. In particular, if a callback method executes , `waitObject` is not signaled until that callback method completes. - - - -## Examples - The following example shows how to use the method to unregister a task if a callback occurred because the wait handle was signaled. - - The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc`, and the wait handle is an . - - The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object so that the callback method has access to the . - - In addition to specifying `TaskInfo` as the object to pass to the callback method, the call to the method specifies the that the task will wait for, a delegate that represents the `WaitProc` callback method, a one second time-out interval, and multiple callbacks. - - When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a time-out occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping additional callbacks. In the case of a time-out, the task continues to wait. The `WaitProc` method ends by printing a message to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp" id="Snippet1"::: + is successfully unregistered. If a callback method is in progress when executes, `waitObject` is not signaled until the callback method completes. In particular, if a callback method executes , `waitObject` is not signaled until that callback method completes. + + + +## Examples + The following example shows how to use the method to unregister a task if a callback occurred because the wait handle was signaled. + + The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc`, and the wait handle is an . + + The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object so that the callback method has access to the . + + In addition to specifying `TaskInfo` as the object to pass to the callback method, the call to the method specifies the that the task will wait for, a delegate that represents the `WaitProc` callback method, a one second time-out interval, and multiple callbacks. + + When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a time-out occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping additional callbacks. In the case of a time-out, the task continues to wait. The `WaitProc` method ends by printing a message to the console. + :::code language="csharp" source="~/snippets/csharp/System.Threading/RegisteredWaitHandle/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: + ]]> The managed thread pool diff --git a/xml/System.Threading/Semaphore.xml b/xml/System.Threading/Semaphore.xml index fe9df5c4e5c..2ca6f2c6f56 100644 --- a/xml/System.Threading/Semaphore.xml +++ b/xml/System.Threading/Semaphore.xml @@ -81,7 +81,6 @@ ## Examples The following code example creates a semaphore with a maximum count of three and an initial count of zero. The example starts five threads, which block waiting for the semaphore. The main thread uses the method overload to increase the semaphore count to its maximum, allowing three threads to enter the semaphore. Each thread uses the method to wait for one second, to simulate work, and then calls the method overload to release the semaphore. Each time the semaphore is released, the previous semaphore count is displayed. Console messages track semaphore use. The simulated work interval is increased slightly for each thread, to make the output easier to read. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore2/VB/source.vb" id="Snippet1"::: @@ -167,7 +166,6 @@ ## Examples The following example creates a semaphore with a maximum count of three and an initial count of zero. The example starts five threads, which block waiting for the semaphore. The main thread uses the method overload to increase the semaphore count to its maximum, allowing three threads to enter the semaphore. Each thread uses the method to wait for one second, to simulate work, and then calls the method overload to release the semaphore. Each time the semaphore is released, the previous semaphore count is displayed. Console messages track semaphore use. The simulated work interval is increased slightly for each thread, to make the output easier to read. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore2/VB/source.vb" id="Snippet1"::: @@ -258,7 +256,6 @@ ## Examples The following code example demonstrates the cross-process behavior of a named semaphore. The example creates a named semaphore with a maximum count of five and an initial count of five. The program makes three calls to the method. Thus, if you run the compiled example from two command windows, the second copy will block on the third call to . Release one or more entries in the first copy of the program to unblock the second. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 3/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 3/VB/source.vb" id="Snippet1"::: @@ -368,7 +365,6 @@ There was some other error. The `HResult` property may provide more information. ## Examples The following code example demonstrates the cross-process behavior of a named semaphore. The example creates a named semaphore with a maximum count of five and an initial count of two. That is, it reserves three entries for the thread that calls the constructor. If `createNew` is `false`, the program makes three calls to the method. Thus, if you run the compiled example from two command windows, the second copy will block on the third call to . Release one or more entries in the first copy of the program to unblock the second. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 4/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 4/VB/source.vb" id="Snippet1"::: @@ -501,7 +497,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the semaphore is opened with the rights required to enter and release. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/VB/source.vb" id="Snippet1"::: @@ -615,7 +610,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the semaphore is opened with the rights required to enter and release. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/VB/source.vb" id="Snippet1"::: @@ -721,7 +715,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the semaphore is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/VB/source.vb" id="Snippet1"::: @@ -804,7 +797,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, the semaphore is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/VB/source.vb" id="Snippet1"::: @@ -952,7 +944,6 @@ There was some other error. The `HResult` property may provide more information. Each time the semaphore is released, the previous semaphore count is displayed. Console messages track semaphore use. The simulated work interval is increased slightly for each thread, to make the output easier to read. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore2/VB/source.vb" id="Snippet1"::: @@ -1035,7 +1026,6 @@ There was some other error. The `HResult` property may provide more information. Each time the semaphore is released, the previous semaphore count is displayed. Console messages track semaphore use. The simulated work interval is increased slightly for each thread, to make the output easier to read. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore2/VB/source.vb" id="Snippet1"::: @@ -1101,7 +1091,6 @@ There was some other error. The `HResult` property may provide more information. After the permissions are changed, using the method, the semaphore is opened with the rights required to enter and release. If you run the compiled example from a third command window, it runs using the new permissions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Semaphore/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Semaphore.ctor named 5a/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/SemaphoreFullException.xml b/xml/System.Threading/SemaphoreFullException.xml index fb960cfa727..dbaa17f81ab 100644 --- a/xml/System.Threading/SemaphoreFullException.xml +++ b/xml/System.Threading/SemaphoreFullException.xml @@ -93,7 +93,6 @@ ## Examples The following code example shows how a programming error in one thread can lead to a in another thread: Two threads enter a semaphore. The second thread releases the semaphore twice, while the first thread is still executing its task. When the first thread finishes and releases the semaphore, the semaphore count is already full and an exception is thrown. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.SemaphoreFullException/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/SemaphoreFullException/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.SemaphoreFullException/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/Thread.xml b/xml/System.Threading/Thread.xml index bfdf373abc4..5619e4a4e7e 100644 --- a/xml/System.Threading/Thread.xml +++ b/xml/System.Threading/Thread.xml @@ -155,7 +155,6 @@ ## Examples The following example shows the syntax for creating and using a delegate with a static method and an instance method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ParameterizedThreadStart/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/ParameterizedThreadStart/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/VB/source.vb" id="Snippet1"::: @@ -227,14 +226,12 @@ ## Examples The following code example shows how to create a thread that executes a static method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/.ctor/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/.ctor/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.ctor/VB/source.vb" id="Snippet1"::: The following code example shows how to create a thread that executes an instance method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ctor2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/.ctor/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/.ctor/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.ctor2/VB/source.vb" id="Snippet1"::: @@ -601,7 +598,6 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ ## Examples The following code example shows how to pass information to a thread that is being aborted. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Abort/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Abort/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/VB/source.vb" id="Snippet1"::: @@ -677,7 +673,6 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -686,7 +681,6 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ The following code example demonstrates how to use a data slot to store thread-specific information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/VB/source.vb" id="Snippet1"::: @@ -763,7 +757,6 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -775,7 +768,6 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ > [!NOTE] > The example code does not use the method, because the method allocates the slot if it has not already been allocated. If the method is used, it should be called in the main thread at program startup. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateNamedDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateNamedDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/VB/source.vb" id="Snippet1"::: @@ -857,7 +849,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following code example demonstrates how to set the apartment state of a thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.ApartmentState/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ApartmentState/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/ApartmentState/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.ApartmentState/VB/source.vb" id="Snippet1"::: @@ -932,7 +923,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following example demonstrates the use of the and methods to divide a block of code into critical and non-critical regions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/BeginCriticalRegion/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/BeginCriticalRegion/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/VB/source.vb" id="Snippet1"::: @@ -1002,7 +992,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following example demonstrates the use of the and methods to notify a host that a block of code depends on the identity of a physical operating system thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/BeginThreadAffinity/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/BeginThreadAffinity/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/VB/source.vb" id="Snippet1"::: @@ -1112,7 +1101,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following example shows the threading statement that allows the user interface of a Windows Forms application to display in the culture that is set in Control Panel. Additional code is needed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Culture/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/CurrentCulture/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/CurrentCulture/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Culture/VB/source.vb" id="Snippet1"::: @@ -1186,7 +1174,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following code example shows how to set and retrieve the principal of a thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.CurrentPrincipal/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/CurrentPrincipal/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/CurrentPrincipal/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.CurrentPrincipal/VB/source.vb" id="Snippet1"::: @@ -1336,7 +1323,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR The following code example shows the threading statement that allows the user interface of a Windows Forms to display in the culture that is set in Control Panel. Additional code is needed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Culture/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/CurrentCulture/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/CurrentCulture/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Culture/VB/source.vb" id="Snippet1"::: @@ -1474,7 +1460,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following example demonstrates the use of the and methods to divide a block of code into critical and non-critical regions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/BeginCriticalRegion/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/BeginCriticalRegion/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.BeginCriticalRegion/VB/source.vb" id="Snippet1"::: @@ -1544,7 +1529,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR ## Examples The following example demonstrates the use of the and methods to notify a host that a block of code depends on the identity of a physical operating system thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/BeginThreadAffinity/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/BeginThreadAffinity/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.BeginThreadAffinity/VB/source.vb" id="Snippet1"::: @@ -1735,7 +1719,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -1744,7 +1727,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR The following example demonstrates how to use a named data slot to store thread-specific information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateNamedDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateNamedDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/VB/source.vb" id="Snippet1"::: @@ -1810,7 +1792,6 @@ You can specify the COM threading model for a C++ application using the [/CLRTHR After the thread is started, the method is used again. This time it throws because the thread has already been started. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/GetApartmentState/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/GetApartmentState/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/vb/source.vb" id="Snippet1"::: @@ -1998,7 +1979,6 @@ The value is not guaranteed to be a zero-based processor number. The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -2007,7 +1987,6 @@ The value is not guaranteed to be a zero-based processor number. The following example demonstrates how to use a data slot to store thread-specific information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DataSlot/VB/source.vb" id="Snippet1"::: @@ -2070,7 +2049,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following code example shows how to retrieve the name and ID of the `AppDomain` in which the thread is running. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Domain/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/GetDomain/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/GetDomain/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Domain/VB/source.vb" id="Snippet1"::: @@ -2130,7 +2108,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following code example shows how to retrieve the name and ID of the `AppDomain` in which the thread is running. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Domain/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/GetDomain/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/GetDomain/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Domain/VB/source.vb" id="Snippet1"::: @@ -2254,7 +2231,6 @@ The value is not guaranteed to be a zero-based processor number. The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -2263,7 +2239,6 @@ The value is not guaranteed to be a zero-based processor number. The following example demonstrates how to use a named data slot to store thread-specific information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateNamedDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateNamedDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/VB/source.vb" id="Snippet1"::: @@ -2329,7 +2304,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following code example shows the behavior of a running thread when it is interrupted and subsequently gets blocked. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Interrupt/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Interrupt/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/VB/source.vb" id="Snippet1"::: @@ -2464,7 +2438,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following example contrasts the behavior of foreground and background threads. It creates a foreground thread and a background thread. The foreground thread keeps the process running until completes its `for` loop and terminates. However, as the output from the example shows, because the foreground thread has finished execution, the process is terminated before the background thread has completed execution. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsBackground/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/IsBackground/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/IsBackground/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.IsBackground/VB/source.vb" id="Snippet1"::: @@ -2529,7 +2502,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following code example shows how to determine whether a thread is from the thread pool. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.IsThreadPoolThread/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/IsThreadPoolThread/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/IsThreadPoolThread/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.IsThreadPoolThread/VB/source.vb" id="Snippet1"::: @@ -2757,7 +2729,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following code example demonstrates how to use a `TimeSpan` value with the `Join` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Timespan/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Join/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Join/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Timespan/VB/source.vb" id="Snippet1"::: @@ -3234,7 +3205,6 @@ The value is not guaranteed to be a zero-based processor number. After the thread is started, the method is used again. This time it throws because the thread has already been started. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/GetApartmentState/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/GetApartmentState/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/vb/source.vb" id="Snippet1"::: @@ -3388,7 +3358,6 @@ The value is not guaranteed to be a zero-based processor number. The following example shows how to use a field that is marked with to hold thread-specific information. This technique provides better performance than the technique that is shown in the second example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateDataSlot/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateDataSlot/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.DoNotUseDataSlots/vb/source.vb" id="Snippet1"::: @@ -3397,7 +3366,6 @@ The value is not guaranteed to be a zero-based processor number. The following example demonstrates how to use a named data slot to store thread-specific information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/AllocateNamedDataSlot/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/AllocateNamedDataSlot/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.NamedDataSlot/VB/source.vb" id="Snippet1"::: @@ -3485,7 +3453,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following example uses the method to block the application's main thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/thread.sleep/cpp/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Sleep/example.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Sleep/example.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/thread.sleep/vb/example.vb" id="Snippet1"::: @@ -3555,7 +3522,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following example uses the method overload to block the application's main thread five times, for two seconds each time. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/thread.sleep_timespan/cpp/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Sleep/example1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Sleep/example1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/thread.sleep_timespan/vb/example.vb" id="Snippet1"::: @@ -3706,7 +3672,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following example creates and starts a thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ThreadStart/CPP/threadstart.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Start/threadstart.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/Start/threadstart.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ThreadStart/VB/threadstart.vb" id="Snippet1"::: @@ -3784,7 +3749,6 @@ The value is not guaranteed to be a zero-based processor number. ## Examples The following example creates a delegate with a static method and an instance method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ParameterizedThreadStart/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/ParameterizedThreadStart/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/VB/source.vb" id="Snippet1"::: @@ -4130,7 +4094,6 @@ When you call the `Suspend` method on a thread, the system notes that a thread s ## Examples The following code example demonstrates accessing the `ThreadState` of a thread. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.threading.thread.threadstate/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/ThreadState/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/ThreadState/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.threading.thread.threadstate/vb/source.vb" id="Snippet1"::: @@ -4203,7 +4166,6 @@ When you call the `Suspend` method on a thread, the system notes that a thread s After the thread is started, the method is used again. This time it throws because the thread has already been started. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/GetApartmentState/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Threading/Thread/GetApartmentState/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Thread.GetSetTrySetApartmentState/vb/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/ThreadAbortException.xml b/xml/System.Threading/ThreadAbortException.xml index 0319fd6e9dc..71e607515ff 100644 --- a/xml/System.Threading/ThreadAbortException.xml +++ b/xml/System.Threading/ThreadAbortException.xml @@ -59,41 +59,40 @@ The exception that is thrown when a call is made to the method. This class cannot be inherited. - method to destroy a thread, the common language runtime throws a on .NET Framework. is a special exception that can be caught, but it will automatically be raised again at the end of the `catch` block. When this exception is raised, the runtime executes all the `finally` blocks before ending the thread. Because the thread can do an unbounded computation in the `finally` blocks or call to cancel the abort, there is no guarantee that the thread will ever end. If you want to wait until the aborted thread has ended, you can call the method. is a blocking call that does not return until the thread actually stops executing. - + method to destroy a thread, the common language runtime throws a on .NET Framework. is a special exception that can be caught, but it will automatically be raised again at the end of the `catch` block. When this exception is raised, the runtime executes all the `finally` blocks before ending the thread. Because the thread can do an unbounded computation in the `finally` blocks or call to cancel the abort, there is no guarantee that the thread will ever end. If you want to wait until the aborted thread has ended, you can call the method. is a blocking call that does not return until the thread actually stops executing. + > [!NOTE] > **.NET Core and .NET 5+ only:** Even though this type exists in .NET Core and .NET 5+, since is not supported, the common language runtime won't ever throw . > [!NOTE] -> When the common language runtime (CLR) stops background threads after all foreground threads in a managed executable have ended, it does not use . Therefore, you cannot use to detect when background threads are being terminated by the CLR. - - uses `HRESULT COR_E_THREADABORTED`, which has the value `0x80131530`. - +> When the common language runtime (CLR) stops background threads after all foreground threads in a managed executable have ended, it does not use . Therefore, you cannot use to detect when background threads are being terminated by the CLR. + + uses `HRESULT COR_E_THREADABORTED`, which has the value `0x80131530`. + > [!NOTE] > The value of the inherited property is always `null`. + +## Examples + The following example demonstrates aborting a thread. The thread that receives the `ThreadAbortException` uses the method to cancel the abort request and continue executing. -## Examples - The following example demonstrates aborting a thread. The thread that receives the `ThreadAbortException` uses the method to cancel the abort request and continue executing. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ThreadAbEx/CPP/threadabex.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadAbortException/Overview/threadabex.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ThreadAbEx/VB/threadabex.vb" id="Snippet1"::: - - This code produces the following output: - -``` -Thread - working. -Main - aborting my thread. -Thread - caught ThreadAbortException - resetting. -Exception message: Thread was being aborted. -Thread - still alive and working. -Thread - finished working. -Main ending. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ThreadAbEx/VB/threadabex.vb" id="Snippet1"::: + + This code produces the following output: + +``` +Thread - working. +Main - aborting my thread. +Thread - caught ThreadAbortException - resetting. +Exception message: Thread was being aborted. +Thread - still alive and working. +Thread - finished working. +Main ending. +``` + ]]> @@ -147,20 +146,19 @@ Main ending. Gets an object that contains application-specific information related to the thread abort. An object containing application-specific information. - method. The exact content and usage of this object is application defined; it is typically used to convey information that is meaningful to the thread being aborted. - - - -## Examples - The following code example shows how to pass information to a thread that is being aborted. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/CPP/source.cpp" id="Snippet1"::: + method. The exact content and usage of this object is application defined; it is typically used to convey information that is meaningful to the thread being aborted. + + + +## Examples + The following code example shows how to pass information to a thread that is being aborted. + :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Abort/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Abort2/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Threading/ThreadInterruptedException.xml b/xml/System.Threading/ThreadInterruptedException.xml index 31d29df4eda..9f28dc2132e 100644 --- a/xml/System.Threading/ThreadInterruptedException.xml +++ b/xml/System.Threading/ThreadInterruptedException.xml @@ -59,24 +59,23 @@ The exception that is thrown when a is interrupted while it is in a waiting state. - states until it is destroyed. Calling when a thread is in the state will cause a to be thrown in the target thread. If the thread is not in the state, the exception is not thrown until the thread enters that state. If the thread never blocks, it could complete without ever being interrupted. + + uses the HRESULT COR_E_THREADINTERRUPTED, which has the value 0x80131519. + + For a list of initial property values for an instance of , see the constructors. + + + +## Examples + The following code example shows the behavior of a running thread when it is interrupted and subsequently gets blocked. -## Remarks - After a thread is created, it is in one or more states until it is destroyed. Calling when a thread is in the state will cause a to be thrown in the target thread. If the thread is not in the state, the exception is not thrown until the thread enters that state. If the thread never blocks, it could complete without ever being interrupted. - - uses the HRESULT COR_E_THREADINTERRUPTED, which has the value 0x80131519. - - For a list of initial property values for an instance of , see the constructors. - - - -## Examples - The following code example shows the behavior of a running thread when it is interrupted and subsequently gets blocked. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Interrupt/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/VB/source.vb" id="Snippet1"::: + ]]> @@ -129,16 +128,16 @@ Initializes a new instance of the class with default properties. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The localized error message string.| - + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The localized error message string.| + ]]> Pausing and interrupting threads @@ -184,16 +183,16 @@ The error message that explains the reason for the exception. Initializes a new instance of the class with a specified error message. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The error message string.| - + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The error message string.| + ]]> Pausing and Resuming Threads @@ -254,11 +253,11 @@ The that contains contextual information about the source or destination. Initializes a new instance of the class with serialized data. - Pausing and Resuming Threads @@ -306,18 +305,18 @@ The exception that is the cause of the current exception. If the parameter is not , the current exception is raised in a block that handles the inner exception. Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. - - The following table shows the initial property values for an instance of . - -|Property|Value| -|--------------|-----------| -||The inner exception reference.| -||The error message string.| - + property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. + + The following table shows the initial property values for an instance of . + +|Property|Value| +|--------------|-----------| +||The inner exception reference.| +||The error message string.| + ]]> Pausing and Resuming Threads diff --git a/xml/System.Threading/ThreadPool.xml b/xml/System.Threading/ThreadPool.xml index 636a7ec553a..14fee295f78 100644 --- a/xml/System.Threading/ThreadPool.xml +++ b/xml/System.Threading/ThreadPool.xml @@ -108,7 +108,6 @@ ## Examples In the following example, the main application thread queues a method named `ThreadProc` to execute on a thread pool thread, sleeps for one second, and then exits. The `ThreadProc` method simply displays a message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadPool/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/VB/source.vb" id="Snippet1"::: @@ -450,7 +449,6 @@ If a thread pool implementation may have different types of work items, the coun ## Examples The following code example shows how to retrieve a count of the maximum and available number of threads in the thread pool. A work item is queued that uses `FileStream` to asynchronously write to two files. The callback methods are timed to overlap. A worker thread handles the work item and, depending on the speed and number of processors on the computer, one or two completion port threads handle the write operations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetAvailableThreads/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadPool/GetAvailableThreads/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetAvailableThreads/VB/source.vb" id="Snippet1"::: @@ -525,7 +523,6 @@ If a thread pool implementation may have different types of work items, the coun ## Examples The following example sets the minimum number of worker threads to four, and preserves the original value for the minimum number of asynchronous I/O completion threads. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetSetMinThreads/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadPool/GetMinThreads/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool.GetSetMinThreads/VB/source.vb" id="Snippet1"::: @@ -647,7 +644,6 @@ The method overload to queue a task, which is represented by the `ThreadProc` method, to execute when a thread becomes available. No task information is supplied with this overload. Therefore, the information that is available to the `ThreadProc` method is limited to the object the method belongs to. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadPool/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem0/VB/source.vb" id="Snippet1"::: ]]> @@ -732,7 +728,6 @@ The following example uses the class during construction. Each object signals the provided event object when its calculation is complete, which allows the primary thread to block execution with until all five `Fibonacci` objects have calculated a result. The `Main` method then displays each `Fibonacci` result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem1/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadPool/QueueUserWorkItem/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool QueueUserWorkItem1/VB/source.vb" id="Snippet1"::: @@ -1208,7 +1203,6 @@ The following example uses the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a time-out occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping additional callbacks. In the case of a time-out, the task continues to wait. The `WaitProc` method ends by printing a message to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/RegisteredWaitHandle/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: @@ -1372,7 +1366,6 @@ The following example uses the delegate, see the method overload. For more information about thread creation, see [Creating Threads and Passing Data at Start Time](/dotnet/standard/threading/creating-threads-and-passing-data-at-start-time). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadStart2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadStart/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadStart2/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/ThreadStateException.xml b/xml/System.Threading/ThreadStateException.xml index 09ef9f62144..84b795296c1 100644 --- a/xml/System.Threading/ThreadStateException.xml +++ b/xml/System.Threading/ThreadStateException.xml @@ -66,32 +66,31 @@ The exception that is thrown when a is in an invalid for the method call. - states until it terminates. `ThreadStateException` is thrown by methods that cannot perform the requested operation due to the current state of a thread. For example, trying to restart an aborted thread by calling on a thread that has terminated throws a . + + uses the HRESULT COR_E_THREADSTATE, which has the value 0x80131520. + + For a list of initial property values for an instance of , see the constructors. + + + +## Examples + The following example demonstrates an error that causes the system to throw a `ThreadStateException`. -## Remarks - Once a thread is created, it is in at least one of the states until it terminates. `ThreadStateException` is thrown by methods that cannot perform the requested operation due to the current state of a thread. For example, trying to restart an aborted thread by calling on a thread that has terminated throws a . - - uses the HRESULT COR_E_THREADSTATE, which has the value 0x80131520. - - For a list of initial property values for an instance of , see the constructors. - - - -## Examples - The following example demonstrates an error that causes the system to throw a `ThreadStateException`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ThreadStEx/CPP/threadstex.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadStateException/Overview/threadstex.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ThreadStEx/VB/threadstex.vb" id="Snippet1"::: - - This code produces the following output: - -``` -In main. Attempting to restart myThread. - Working thread... - Caught: Thread is running or terminated. Cannot restart. -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ThreadStEx/VB/threadstex.vb" id="Snippet1"::: + + This code produces the following output: + +``` +In main. Attempting to restart myThread. + Working thread... + Caught: Thread is running or terminated. Cannot restart. +``` + ]]> @@ -146,18 +145,18 @@ In main. Attempting to restart myThread. Initializes a new instance of the class with default properties. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The localized error message string.| - + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The localized error message string.| + ]]> @@ -203,18 +202,18 @@ In main. Attempting to restart myThread. The error message that explains the reason for the exception. Initializes a new instance of the class with a specified error message. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The error message string.| - + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The error message string.| + ]]> @@ -274,11 +273,11 @@ In main. Attempting to restart myThread. The that contains contextual information about the source or destination. Initializes a new instance of the class with serialized data. - XML and SOAP Serialization @@ -327,18 +326,18 @@ In main. Attempting to restart myThread. The exception that is the cause of the current exception. If the parameter is not , the current exception is raised in a block that handles the inner exception. Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. - - The following table shows the initial property values for an instance of . - -|Property|Value| -|--------------|-----------| -||The inner exception reference.| -||The error message string.| - + property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. + + The following table shows the initial property values for an instance of . + +|Property|Value| +|--------------|-----------| +||The inner exception reference.| +||The error message string.| + ]]> diff --git a/xml/System.Threading/Timeout.xml b/xml/System.Threading/Timeout.xml index 6b8772a5042..0b5ef8442ee 100644 --- a/xml/System.Threading/Timeout.xml +++ b/xml/System.Threading/Timeout.xml @@ -60,20 +60,19 @@ Contains constants that specify infinite time-out intervals. This class cannot be inherited. - is used by methods that accept an integer `millisecondsTimeout` parameter, such as , , and . is used by methods that accept a `timeout` parameter of type , such as , , and . + + + +## Examples + The following example shows a thread going to sleep for an infinite time and subsequently being woken up. -## Remarks - The members of this class are used to specify infinite time-out intervals in threading operations. is used by methods that accept an integer `millisecondsTimeout` parameter, such as , , and . is used by methods that accept a `timeout` parameter of type , such as , , and . - - - -## Examples - The following example shows a thread going to sleep for an infinite time and subsequently being woken up. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Thread/Interrupt/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Thread.Interrupt/VB/source.vb" id="Snippet1"::: + ]]> This type is thread safe. @@ -124,13 +123,13 @@ A constant used to specify an infinite waiting period, for threading methods that accept an parameter. - and , this value is used to suspend the thread indefinitely. However, in most cases, we recommend that you use other classes, such as , , , or instead, to synchronize threads or manage resources. - - The value of this field is -1 (0xFFFFFFFF). - + and , this value is used to suspend the thread indefinitely. However, in most cases, we recommend that you use other classes, such as , , , or instead, to synchronize threads or manage resources. + + The value of this field is -1 (0xFFFFFFFF). + ]]> @@ -181,13 +180,13 @@ A constant used to specify an infinite waiting period, for methods that accept a parameter. - , such as and , this value is used to suspend the thread indefinitely. However, in most cases, we recommend that you use other classes, such as , , , or instead, to synchronize threads or manage resources. - - The value of this field is -00:00:00.0010000, or -1 millisecond. - + , such as and , this value is used to suspend the thread indefinitely. However, in most cases, we recommend that you use other classes, such as , , , or instead, to synchronize threads or manage resources. + + The value of this field is -00:00:00.0010000, or -1 millisecond. + ]]> diff --git a/xml/System.Threading/Timer.xml b/xml/System.Threading/Timer.xml index 6f758f56efc..aff33bbd1b8 100644 --- a/xml/System.Threading/Timer.xml +++ b/xml/System.Threading/Timer.xml @@ -314,7 +314,6 @@ The following example defines a `StatusChecker` class that includes a `CheckStat ## Examples The following code example shows how to create a `TimerCallback` delegate and initialize a new instance of the `Timer` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer/VB/source.vb" id="Snippet1"::: @@ -490,7 +489,6 @@ The following example defines a `StatusChecker` class that includes a `CheckStat ## Examples The following code example shows how to create a `TimerCallback` delegate and initialize a new instance of the `Timer` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer2/CPP/source2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer2/VB/source2.vb" id="Snippet1"::: @@ -707,7 +705,6 @@ The following example defines a `StatusChecker` class that includes a `CheckStat ## Examples The following code example demonstrates how to start a `Timer` and, after a set number of invocations, change its period. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer/VB/source.vb" id="Snippet1"::: @@ -866,7 +863,6 @@ The following example defines a `StatusChecker` class that includes a `CheckStat ## Examples The following code example demonstrates how to start a `Timer` and, after a set number of invocations, change its period. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer2/CPP/source2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer2/VB/source2.vb" id="Snippet1"::: @@ -1023,7 +1019,6 @@ The following example defines a `StatusChecker` class that includes a `CheckStat ## Examples The following code example shows how to free the resources held by a `Timer`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Threading/TimerCallback.xml b/xml/System.Threading/TimerCallback.xml index 809649f3d3d..f22998f9673 100644 --- a/xml/System.Threading/TimerCallback.xml +++ b/xml/System.Threading/TimerCallback.xml @@ -68,25 +68,24 @@ An object containing application-specific information relevant to the method invoked by this delegate, or . Represents the method that handles calls from a . - . This method does not execute in the thread that created the timer; it executes in a separate thread pool thread that is provided by the system. The `TimerCallback` delegate invokes the method once after the start time elapses, and continues to invoke it once per timer interval until the method is called, or until the method is called with the interval value . - + . This method does not execute in the thread that created the timer; it executes in a separate thread pool thread that is provided by the system. The `TimerCallback` delegate invokes the method once after the start time elapses, and continues to invoke it once per timer interval until the method is called, or until the method is called with the interval value . + > [!NOTE] -> Callbacks can occur after the method overload has been called, because the timer queues callbacks for execution by thread pool threads. You can use the method overload to wait until all callbacks have completed. - - The timer delegate is specified when the timer is constructed, and cannot be changed. The start time for a `Timer` is passed in the `dueTime` parameter of the `Timer` constructors, and the period is passed in the `period` parameter. For an example that demonstrates creating and using a `TimerCallback` delegate, see . +> Callbacks can occur after the method overload has been called, because the timer queues callbacks for execution by thread pool threads. You can use the method overload to wait until all callbacks have completed. + + The timer delegate is specified when the timer is constructed, and cannot be changed. The start time for a `Timer` is passed in the `dueTime` parameter of the `Timer` constructors, and the period is passed in the `period` parameter. For an example that demonstrates creating and using a `TimerCallback` delegate, see . + + + +## Examples + The following code example shows how to create the delegate used with the `Timer` class. - - -## Examples - The following code example shows how to create the delegate used with the `Timer` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.Timer/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/Timer/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.Timer/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Threading/WaitHandle.xml b/xml/System.Threading/WaitHandle.xml index 7be7c3ff707..7081d68c011 100644 --- a/xml/System.Threading/WaitHandle.xml +++ b/xml/System.Threading/WaitHandle.xml @@ -109,7 +109,6 @@ ## Examples The following code example shows how two threads can do background tasks while the Main thread waits for the tasks to complete using the static and methods of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/WaitHandle/Overview/WaitHandle.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/WaitHandle/VB/WaitHandle.vb" id="Snippet1"::: @@ -656,7 +655,6 @@ Application code does not call this method; it is automatically invoked during g The example starts five threads, allows them to block on an created with the flag, and then releases one thread each time the user presses the ENTER key. The example then queues another five threads and releases them all using an created with the flag. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/EventResetMode/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.SignalAndWait/VB/source.vb" id="Snippet1"::: @@ -959,7 +957,6 @@ Calling `Dispose` allows the resources used by the method returns when the wait t ## Examples The following code example shows how to use the thread pool to asynchronously create and write to a group of files. Each write operation is queued as a work item and signals when it is finished. The main thread waits for all the items to signal and then exits. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll2/CPP/source2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/WaitHandle/WaitAll/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAll2/VB/source2.vb" id="Snippet1"::: @@ -1347,7 +1343,6 @@ The maximum value for `timeout` is method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/WaitHandle/cpp/WaitHandle.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/WaitHandle/Overview/WaitHandle.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/WaitHandle/VB/WaitHandle.vb" id="Snippet1"::: @@ -1734,7 +1728,6 @@ The maximum number of the wait handles is 64, and 63 if the current thread is in ## Examples The following code example demonstrates how to use the thread pool to simultaneously search for a file on multiple disks. For space considerations, only the root directory of each disk is searched. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny2/CPP/source2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/WaitHandle/WaitAny/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.WaitHandle.WaitAny2/VB/source2.vb" id="Snippet1"::: @@ -1829,7 +1822,6 @@ The maximum value for `timeout` is method overload behaves when it is called within a synchronization domain. First, a thread waits with `exitContext` set to `false` and blocks until the wait timeout expires. A second thread executes after the first thread terminates and waits with `exitContext` set to `true`. The call to signal the wait handle for this second thread is not blocked, and the thread completes before the wait timeout. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.threading.waithandle.waitone4/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/WaitHandle/WaitOne/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.threading.waithandle.waitone4/vb/source.vb" id="Snippet1"::: @@ -2232,7 +2221,6 @@ The maximum value for `timeout` is if the timed out; if it was signaled. Represents a method to be called when a is signaled or times out. - represents a callback method that you want to execute when a registered wait handle times out or is signaled. Create the delegate by passing your callback method to the constructor. Your method must have the signature shown here. - - Create the registered wait handle by passing the delegate and a to . Your callback method executes each time the times out or is signaled. - - + represents a callback method that you want to execute when a registered wait handle times out or is signaled. Create the delegate by passing your callback method to the constructor. Your method must have the signature shown here. + + Create the registered wait handle by passing the delegate and a to . Your callback method executes each time the times out or is signaled. + + > [!NOTE] -> Visual Basic users can omit the constructor, and simply use the `AddressOf` operator when passing the callback method to . Visual Basic automatically calls the correct delegate constructor. - - If you want to pass information to your callback method, create an object that contains the necessary information and pass it to when you create the registered wait handle. Each time your callback method executes, the `state` parameter contains this object. - - For more information about using callback methods to synchronize thread pool threads, see [The managed thread pool](/dotnet/standard/threading/the-managed-thread-pool). - - +> Visual Basic users can omit the constructor, and simply use the `AddressOf` operator when passing the callback method to . Visual Basic automatically calls the correct delegate constructor. + + If you want to pass information to your callback method, create an object that contains the necessary information and pass it to when you create the registered wait handle. Each time your callback method executes, the `state` parameter contains this object. + + For more information about using callback methods to synchronize thread pool threads, see [The managed thread pool](/dotnet/standard/threading/the-managed-thread-pool). + + + +## Examples + The following example shows how to use the delegate to represent a callback method that is executed when a wait handle is signaled. + + The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc` and the wait handle is an . + + The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object, so that the callback method has access to the . + + In addition to the `TaskInfo` object, the call to the method specifies the the task waits on, a delegate that represents the `WaitProc` callback method, a one-second timeout interval, and multiple callbacks. + + When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a timeout occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping further callbacks. In the case of a timeout, the task continues waiting. The `WaitProc` method ends by printing a message to the console. -## Examples - The following example shows how to use the delegate to represent a callback method that is executed when a wait handle is signaled. - - The example also shows how to use the method to execute a specified callback method when a specified wait handle is signaled. In this example, the callback method is `WaitProc` and the wait handle is an . - - The example defines a `TaskInfo` class to hold the information that is passed to the callback when it executes. The example creates a `TaskInfo` object and assigns it some string data. The that is returned by the method is assigned to the `Handle` field of the `TaskInfo` object, so that the callback method has access to the . - - In addition to the `TaskInfo` object, the call to the method specifies the the task waits on, a delegate that represents the `WaitProc` callback method, a one-second timeout interval, and multiple callbacks. - - When the main thread signals the by calling its method, the delegate is invoked. The `WaitProc` method tests to determine whether a timeout occurred. If the callback was invoked because the wait handle was signaled, the `WaitProc` method unregisters the , stopping further callbacks. In the case of a timeout, the task continues waiting. The `WaitProc` method ends by printing a message to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/RegisteredWaitHandle/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadPool RegisterWaitForSingleObject0/VB/source.vb" id="Snippet1"::: + ]]> Threads and Threading diff --git a/xml/System.Timers/ElapsedEventArgs.xml b/xml/System.Timers/ElapsedEventArgs.xml index 026e79a5630..202ba284e33 100644 --- a/xml/System.Timers/ElapsedEventArgs.xml +++ b/xml/System.Timers/ElapsedEventArgs.xml @@ -48,16 +48,15 @@ Provides data for the event. - object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. -## Examples - The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: + ]]> @@ -132,21 +131,20 @@ Gets the date/time when the event was raised. The time the event was raised. - event is raised on a thread, so the event-handling method might run on one thread at the same time that a call to the method runs on another thread. This might result in the event being raised after the method is called. This race condition cannot be prevented simply by comparing the property with the time when the method is called, because the event-handling method might already be executing when the method is called, or might begin executing between the moment when the method is called and the moment when the stop time is saved. If it is critical to prevent the thread that calls the method from proceeding while the event-handling method is still executing, use a more robust synchronization mechanism such as the class or the method. Code that uses the method can be found in the example for the method. - - - -## Examples - The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: + event is raised on a thread, so the event-handling method might run on one thread at the same time that a call to the method runs on another thread. This might result in the event being raised after the method is called. This race condition cannot be prevented simply by comparing the property with the time when the method is called, because the event-handling method might already be executing when the method is called, or might begin executing between the moment when the method is called and the moment when the stop time is saved. If it is critical to prevent the thread that calls the method from proceeding while the event-handling method is still executing, use a more robust synchronization mechanism such as the class or the method. Code that uses the method can be found in the example for the method. + + + +## Examples + The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. + :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Timers/ElapsedEventHandler.xml b/xml/System.Timers/ElapsedEventHandler.xml index e08a79af437..8421bfbf81e 100644 --- a/xml/System.Timers/ElapsedEventHandler.xml +++ b/xml/System.Timers/ElapsedEventHandler.xml @@ -60,21 +60,20 @@ An object that contains the event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example sets up an event handler for the event, creates a timer, and starts the timer. The event handler has the same signature as the delegate. The event handler displays the property each time it is raised. -## Remarks - When you create an delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example sets up an event handler for the event, creates a timer, and starts the timer. The event handler has the same signature as the delegate. The event handler displays the property each time it is raised. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventHandler/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventHandler/Overview/source.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Timer Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Timer Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Timers/Timer.xml b/xml/System.Timers/Timer.xml index f099995690b..93cc2e5bfe8 100644 --- a/xml/System.Timers/Timer.xml +++ b/xml/System.Timers/Timer.xml @@ -189,7 +189,6 @@ ## Examples The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: @@ -358,7 +357,6 @@ ## Examples The following example creates a whose event fires after 1.5 seconds. Its event handler then displays "Hello World!" on the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/Timer/AutoReset/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/Timer/AutoReset/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Timer.Timer1 Example/VB/source.vb" id="Snippet1"::: @@ -589,7 +587,6 @@ ## Examples The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: @@ -680,7 +677,6 @@ ## Examples The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: @@ -841,7 +837,6 @@ ## Examples The following example instantiates a object that fires its event every two seconds (2000 milliseconds), sets up an event handler for the event, and starts the timer. The event handler displays the value of the property each time it is raised. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.timers.timer/cpp/timer1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Timers/ElapsedEventArgs/Overview/timer1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System.Timers/ElapsedEventArgs/Overview/timer1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.timers.timer/vb/timer1.vb" id="Snippet1"::: diff --git a/xml/System.Windows.Data/RelativeSource.xml b/xml/System.Windows.Data/RelativeSource.xml index 2f1ab2ec0ac..12569221c39 100644 --- a/xml/System.Windows.Data/RelativeSource.xml +++ b/xml/System.Windows.Data/RelativeSource.xml @@ -33,27 +33,27 @@ Implements a markup extension that describes the location of the binding source relative to the position of the binding target. - property. This is the property type of that property. is simultaneously a markup extension implementation and a data object. When the extension returns itself (see ), the relevant information is contained in the data. The main purpose of the markup extension is to allow a variable-argument constructor syntax in attribute form, so that the mode can be defined inline with the two extra arguments for ancestor type and level that the other modes do not require. - - For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf/advanced/relativesource-markupextension). - -## Examples - The following example shows a style trigger that creates a that reports a validation error message. Using the property, the value of the setter binds to the error content of the current (the using the style). For more information on this example, see [How to: Implement Binding Validation](/dotnet/framework/wpf/data/how-to-implement-binding-validation). - - :::code language="xaml" source="~/snippets/csharp/System.Windows/Setter/Value/Window1.xaml" id="Snippet5"::: - - The following example shows the definition of a custom control called `NumericUpDown`. The property of the is bound to the `Value` of the object that is the `TemplatedParent`, which is the `NumericUpDown` control that this is applied to in this case. - + property. This is the property type of that property. is simultaneously a markup extension implementation and a data object. When the extension returns itself (see ), the relevant information is contained in the data. The main purpose of the markup extension is to allow a variable-argument constructor syntax in attribute form, so that the mode can be defined inline with the two extra arguments for ancestor type and level that the other modes do not require. + + For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf/advanced/relativesource-markupextension). + +## Examples + The following example shows a style trigger that creates a that reports a validation error message. Using the property, the value of the setter binds to the error content of the current (the using the style). For more information on this example, see [How to: Implement Binding Validation](/dotnet/framework/wpf/data/how-to-implement-binding-validation). + + :::code language="xaml" source="~/snippets/csharp/System.Windows/Setter/Value/Window1.xaml" id="Snippet5"::: + + The following example shows the definition of a custom control called `NumericUpDown`. The property of the is bound to the `Value` of the object that is the `TemplatedParent`, which is the `NumericUpDown` control that this is applied to in this case. + :::code language="xaml" source="~/snippets/csharp/System.Windows/FrameworkElement/DefaultStyleKey/themes/generic.xaml" id="Snippetrelativesource"::: - - The following returns the second encountered on the upward path starting at the target element of the binding. - + + The following returns the second encountered on the upward path starting at the target element of the binding. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Data/BindingOperations/SetBinding/Window1.xaml.cs" id="Snippetrelativesource"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/BindConversion/visualbasic/window1.xaml.vb" id="Snippetrelativesource"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/BindConversion/visualbasic/window1.xaml.vb" id="Snippetrelativesource"::: + ]]> @@ -150,18 +150,18 @@ The ordinal position of the desired ancestor among all ancestors of the given type. Initializes a new instance of the class with an initial mode and additional tree-walking qualifiers for finding the desired relative source. - . Do not use this signature for the other values. - -## Examples - The following returns the second encountered on the upward path starting at the target element of the binding. - + +## Examples + The following returns the second encountered on the upward path starting at the target element of the binding. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Data/BindingOperations/SetBinding/Window1.xaml.cs" id="Snippetrelativesource"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/BindConversion/visualbasic/window1.xaml.vb" id="Snippetrelativesource"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/BindConversion/visualbasic/window1.xaml.vb" id="Snippetrelativesource"::: + ]]> @@ -198,23 +198,23 @@ Gets or sets the level of ancestor to look for, in mode. Use 1 to indicate the one nearest to the binding target element. The ancestor level. Use 1 to indicate the one nearest to the binding target element. - property is not set explicitly, setting the or the property will implicitly lock the property value to . - - +If the property is not set explicitly, setting the or the property will implicitly lock the property value to . + + ## XAML Text Usage For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf/advanced/relativesource-markupextension). - -## Examples - The following returns the second encountered on the upward path starting at the target element of the binding. - + +## Examples + The following returns the second encountered on the upward path starting at the target element of the binding. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Data/BindingOperations/SetBinding/Window1.xaml.cs" id="Snippetrelativesource"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/BindConversion/visualbasic/window1.xaml.vb" id="Snippetrelativesource"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/BindConversion/visualbasic/window1.xaml.vb" id="Snippetrelativesource"::: + ]]> @@ -253,23 +253,23 @@ For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf Gets or sets the type of ancestor to look for. The type of ancestor. The default value is . - property is not set explicitly, setting the or the property will implicitly lock the property value to . - - +If the property is not set explicitly, setting the or the property will implicitly lock the property value to . + + ## XAML Text Usage For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf/advanced/relativesource-markupextension). - -## Examples - The following returns the second encountered on the upward path starting at the target element of the binding. - + +## Examples + The following returns the second encountered on the upward path starting at the target element of the binding. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Data/BindingOperations/SetBinding/Window1.xaml.cs" id="Snippetrelativesource"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/BindConversion/visualbasic/window1.xaml.vb" id="Snippetrelativesource"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/BindConversion/visualbasic/window1.xaml.vb" id="Snippetrelativesource"::: + ]]> The is not in the mode. @@ -315,15 +315,15 @@ For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf Gets or sets a value that describes the location of the binding source relative to the position of the binding target. One of the values. The default value is . - or the and the properties will implicitly lock this property value to . - - -## XAML Text Usage - For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf/advanced/relativesource-markupextension). - + or the and the properties will implicitly lock this property value to . + + +## XAML Text Usage + For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf/advanced/relativesource-markupextension). + ]]> This property is immutable after initialization. Instead of changing the on this instance, create a new or use a different static instance. @@ -357,15 +357,15 @@ For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf Gets a static value that is used to return a constructed for the mode. A static . - values, , , or , can produce a that is wholly static, containing no unique private values. All uses of the static property can share the same object, eliminating the need to allocate separate objects for each use. Therefore, using the static property reduces memory usage. - - -## XAML Text Usage - For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf/advanced/relativesource-markupextension). - + values, , , or , can produce a that is wholly static, containing no unique private values. All uses of the static property can share the same object, eliminating the need to allocate separate objects for each use. Therefore, using the static property reduces memory usage. + + +## XAML Text Usage + For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf/advanced/relativesource-markupextension). + ]]> @@ -402,11 +402,11 @@ For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf Returns an object that should be set as the value on the target object's property for this markup extension. For , this is another , using the appropriate source for the specified mode. Another . - is simultaneously a markup extension implementation and a data object. When the extension returns itself, the relevant information is contained in the data. The main purpose of the markup extension is to allow a variable-argument constructor syntax in attribute form so that the mode can be defined inline, with the two extra arguments for ancestor type and level that the other modes do not require. - + is simultaneously a markup extension implementation and a data object. When the extension returns itself, the relevant information is contained in the data. The main purpose of the markup extension is to allow a variable-argument constructor syntax in attribute form so that the mode can be defined inline, with the two extra arguments for ancestor type and level that the other modes do not require. + ]]> @@ -437,20 +437,20 @@ For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf Gets a static value that is used to return a constructed for the mode. A static . - values, , , or , can produce a that is wholly static, containing no unique private values. All uses of the static property can share the same object, eliminating the need to allocate separate objects for each use. Therefore, using the static property reduces memory usage. - - -## XAML Text Usage + values, , , or , can produce a that is wholly static, containing no unique private values. All uses of the static property can share the same object, eliminating the need to allocate separate objects for each use. Therefore, using the static property reduces memory usage. + + +## XAML Text Usage For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf/advanced/relativesource-markupextension). - -## Examples - The following example shows a style trigger that creates a that reports a validation error message. The value of the setter binds to the error content of the current (the using the style) using the property. See [How to: Implement Binding Validation](/dotnet/framework/wpf/data/how-to-implement-binding-validation) for more information on this example. - - :::code language="xaml" source="~/snippets/csharp/System.Windows/Setter/Value/Window1.xaml" id="Snippet5"::: - + +## Examples + The following example shows a style trigger that creates a that reports a validation error message. The value of the setter binds to the error content of the current (the using the style) using the property. See [How to: Implement Binding Validation](/dotnet/framework/wpf/data/how-to-implement-binding-validation) for more information on this example. + + :::code language="xaml" source="~/snippets/csharp/System.Windows/Setter/Value/Window1.xaml" id="Snippet5"::: + ]]> @@ -491,11 +491,11 @@ For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf if the property value has changed from its default; otherwise, . - property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are either developing a designer for the or developing your own control incorporating the . - + property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are either developing a designer for the or developing your own control incorporating the . + ]]> @@ -534,13 +534,13 @@ For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf if the property value has changed from its default; otherwise, . - property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are either developing a designer for the or developing your own control incorporating the . - - For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/framework/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). - + property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are either developing a designer for the or developing your own control incorporating the . + + For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/desktop/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). + ]]> @@ -633,20 +633,20 @@ For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf Gets a static value that is used to return a constructed for the mode. A static . - values, , , or , can produce a that is wholly static, containing no unique private values. All uses of the static property can share the same object, eliminating the need to allocate separate objects for each use. Therefore, using the static property reduces memory usage. - - -## XAML Text Usage + values, , , or , can produce a that is wholly static, containing no unique private values. All uses of the static property can share the same object, eliminating the need to allocate separate objects for each use. Therefore, using the static property reduces memory usage. + + +## XAML Text Usage For XAML information, see [RelativeSource MarkupExtension](/dotnet/framework/wpf/advanced/relativesource-markupextension). - -## Examples - The following example shows the definition of a custom control called `NumericUpDown`. The property of the is bound to the `Value` of the object that is the `TemplatedParent`, which is the `NumericUpDown` control that this is applied to in this case. - + +## Examples + The following example shows the definition of a custom control called `NumericUpDown`. The property of the is bound to the `Value` of the object that is the `TemplatedParent`, which is the `NumericUpDown` control that this is applied to in this case. + :::code language="xaml" source="~/snippets/csharp/System.Windows/FrameworkElement/DefaultStyleKey/themes/generic.xaml" id="Snippetrelativesource"::: - + ]]> diff --git a/xml/System.Windows.Forms.Design.Behavior/SnapLine.xml b/xml/System.Windows.Forms.Design.Behavior/SnapLine.xml index 765b5c24e70..d4ce4adeb5f 100644 --- a/xml/System.Windows.Forms.Design.Behavior/SnapLine.xml +++ b/xml/System.Windows.Forms.Design.Behavior/SnapLine.xml @@ -42,37 +42,37 @@ Represents the horizontal and vertical line segments that are dynamically created in the user interface (UI) to assist in the design-time layout of controls in a container. This class cannot be inherited. - class and related types help support the Snapline mode. - - Snaplines are generated dynamically and automatically as a control edge moves near another control or near the boundaries of its container. This can occur when a control is added from the toolbox, or moved or resized by mouse operations or keyboard commands. Controls typically have both horizontal and vertical snaplines defined; for rectangular controls, these typically extend from all four edges. - - The class uses only a few properties to describe each snapline, as shown in the following table. - -|Property|Description| -|--------------|-----------------| -||Specifies the location and direction of the line with respect to its associated control. Typically, only snaplines of similar types will auto-align to each other.| -||Specifies the distance in pixels from the origin, which is the upper-left corner of the control, to where the snapline starts.| -||Specifies the relative importance of the snapline. During any given layout decision point, only the snaplines that are active and have the highest priority are displayed.| -||Defines custom categories of snaplines. This is an optional string.| -| and |Indicates whether a snapline has horizontal or vertical orientation, respectively.| - - The class stores snaplines for its corresponding control type in the property. This base class handling of snaplines will suffice for the majority of controls, as it defines the , , , and snaplines, which are aligned along the edges of the control. When you are developing a custom control, if this default organization does not suffice, override the property of the class derived from . For example, you may want to align the horizontal snaplines of text-based controls, such as labels, with the top and base lines of the text (instead of the top and bottom edges of the control). - - The class cannot be derived from. - - There is extensive support for this feature in Visual Studio, see [Walkthrough: Arranging Controls on Windows Forms Using Snaplines](/dotnet/framework/winforms/controls/walkthrough-arranging-controls-on-windows-forms-using-snaplines). - + class and related types help support the Snapline mode. + + Snaplines are generated dynamically and automatically as a control edge moves near another control or near the boundaries of its container. This can occur when a control is added from the toolbox, or moved or resized by mouse operations or keyboard commands. Controls typically have both horizontal and vertical snaplines defined; for rectangular controls, these typically extend from all four edges. + + The class uses only a few properties to describe each snapline, as shown in the following table. + +|Property|Description| +|--------------|-----------------| +||Specifies the location and direction of the line with respect to its associated control. Typically, only snaplines of similar types will auto-align to each other.| +||Specifies the distance in pixels from the origin, which is the upper-left corner of the control, to where the snapline starts.| +||Specifies the relative importance of the snapline. During any given layout decision point, only the snaplines that are active and have the highest priority are displayed.| +||Defines custom categories of snaplines. This is an optional string.| +| and |Indicates whether a snapline has horizontal or vertical orientation, respectively.| + + The class stores snaplines for its corresponding control type in the property. This base class handling of snaplines will suffice for the majority of controls, as it defines the , , , and snaplines, which are aligned along the edges of the control. When you are developing a custom control, if this default organization does not suffice, override the property of the class derived from . For example, you may want to align the horizontal snaplines of text-based controls, such as labels, with the top and base lines of the text (instead of the top and bottom edges of the control). + + The class cannot be derived from. + + There is extensive support for this feature in Visual Studio, see [Walkthrough: Arranging Controls on Windows Forms Using Snaplines](/dotnet/desktop/winforms/controls/walkthrough-arranging-controls-on-windows-forms-using-snaplines). + ]]> @@ -89,11 +89,11 @@ Initializes a new instance of the class. - property of the class. - + property of the class. + ]]> @@ -136,11 +136,11 @@ The position of the snapline, in pixels, relative to the upper-left origin of the owning control. Initializes a new instance of the class using the specified snapline type and offset. - property to `null` and the property to . - + property to `null` and the property to . + ]]> @@ -188,11 +188,11 @@ A used to specify a programmer-defined category of snaplines. Initializes a new instance of the class using the specified snapline type, offset, and filter name. - property to . - + property to . + ]]> @@ -240,11 +240,11 @@ The of the snapline. Initializes a new instance of the class using the specified snapline type, offset, and priority. - property to `null`. - + property to `null`. + ]]> @@ -295,11 +295,11 @@ The of the snapline. Initializes a new instance of the class using the specified snapline type, offset, filter name, and priority. - @@ -341,11 +341,11 @@ The number of pixels to change the snapline offset by. Adjusts the property of the snapline. - property value. - + property value. + ]]> @@ -393,13 +393,13 @@ Gets the programmer-defined filter category associated with this snapline. A that defines the filter category. The default is . - property is used to define custom categories of snaplines. Only snaplines with the same filter name are able to snap to each other. This property can be used in custom control designers to expose different categories of snaplines depending upon the state of the control or the type of operation being performed. For example, round controls could offer a custom snapline with the filter value of "Center". - - This property is initialized during construction and cannot be changed thereafter. - + property is used to define custom categories of snaplines. Only snaplines with the same filter name are able to snap to each other. This property can be used in custom control designers to expose different categories of snaplines depending upon the state of the control or the type of operation being performed. For example, round controls could offer a custom snapline with the filter value of "Center". + + This property is initialized during construction and cannot be changed thereafter. + ]]> @@ -437,11 +437,11 @@ if the snapline is horizontal; otherwise, . - , , , and . - + , , , and . + ]]> @@ -478,11 +478,11 @@ if the snapline is vertical; otherwise, . - , , and . - + , , and . + ]]> @@ -524,13 +524,13 @@ Gets the number of pixels that the snapline is offset from the origin of the associated control. The offset, in pixels, of the snapline. - property is initialized at construction time, but it can be changed thereafter with the method. - + property is initialized at construction time, but it can be changed thereafter with the method. + ]]> @@ -572,15 +572,15 @@ Gets a value indicating the relative importance of the snapline. A that represents the priority category of a snapline. - property establishes categories of importance for the snaplines associated with a control. - - The Windows Forms Designer uses this property to determine which snaplines to display during a control addition, resize, or move operation. For more information, see the enumeration. - - This property is initialized during construction and cannot be changed thereafter. - + property establishes categories of importance for the snaplines associated with a control. + + The Windows Forms Designer uses this property to determine which snaplines to display during a control addition, resize, or move operation. For more information, see the enumeration. + + This property is initialized during construction and cannot be changed thereafter. + ]]> @@ -663,13 +663,13 @@ Gets the type of a snapline, which indicates the general location and orientation. A that represents the orientation and general location, relative to control edges, of a snapline. - property to direct snap alignment operations. Typically only snaplines that are similarly oriented can snap to each other. For example, two snaplines of type can snap together, but a and a snapline cannot. - - This property is initialized during construction and cannot be changed thereafter. - + property to direct snap alignment operations. Typically only snaplines that are similarly oriented can snap to each other. For example, two snaplines of type can snap together, but a and a snapline cannot. + + This property is initialized during construction and cannot be changed thereafter. + ]]> @@ -708,11 +708,11 @@ Returns a string representation of the current snapline. A that represents the current . - diff --git a/xml/System.Windows.Forms.Integration/ElementHost.xml b/xml/System.Windows.Forms.Integration/ElementHost.xml index f952d926503..ae621e2dae7 100644 --- a/xml/System.Windows.Forms.Integration/ElementHost.xml +++ b/xml/System.Windows.Forms.Integration/ElementHost.xml @@ -134,7 +134,7 @@ if the control adjusts its size to closely fit its contents; otherwise, . The default is . To be added. - AutoSize Property Overview + AutoSize Property Overview diff --git a/xml/System.Windows.Forms/Application.xml b/xml/System.Windows.Forms/Application.xml index e5dca371ae4..6403037a089 100644 --- a/xml/System.Windows.Forms/Application.xml +++ b/xml/System.Windows.Forms/Application.xml @@ -241,7 +241,7 @@ Gets the default color mode (dark mode) for the application. To be added. - This is the ; which either has been set by or its default value . + This is the ; which either has been set by or its default value . If it has been set to , then the actual color mode is determined by the system settings (which can be retrieved by the static (shared in VB) property. @@ -491,7 +491,7 @@ ## Remarks When you run a Windows Form, it creates the new form, which then waits for events to handle. Each time the form handles an event, it processes all the code associated with that event. All other events wait in the queue. While your code handles the event, your application does not respond. For example, the window does not repaint if another window is dragged on top. - If you call in your code, your application can handle the other events. For example, if you have a form that adds data to a and add to your code, your form repaints when another window is dragged over it. If you remove from your code, your form will not repaint until the click event handler of the button is finished executing. For more information on messaging, see [User Input in Windows Forms](/dotnet/framework/winforms/user-input-in-windows-forms). + If you call in your code, your application can handle the other events. For example, if you have a form that adds data to a and add to your code, your form repaints when another window is dragged over it. If you remove from your code, your form will not repaint until the click event handler of the button is finished executing. For more information on messaging, see [User Input in Windows Forms](/dotnet/desktop/winforms/user-input-in-windows-forms). Unlike Visual Basic 6.0, the method does not call the method. @@ -1797,12 +1797,12 @@ Sets the default color mode (dark mode) for the application. - You should use this method to set the default color mode (dark mode) for the application. Set it before creating any UI elements to ensure that the correct color mode - is used. You can set it to dark mode (), light mode () + You should use this method to set the default color mode (dark mode) for the application. Set it before creating any UI elements to ensure that the correct color mode + is used. You can set it to dark mode (), light mode () or to the system setting (). - If you set it to , the actual color mode is determined by the Windows system settings. If the system setting is changed, + If you set it to , the actual color mode is determined by the Windows system settings. If the system setting is changed, the application will not automatically adapt to the new setting. diff --git a/xml/System.Windows.Forms/AutoSizeMode.xml b/xml/System.Windows.Forms/AutoSizeMode.xml index c5b76db3d8b..195fd6c77f3 100644 --- a/xml/System.Windows.Forms/AutoSizeMode.xml +++ b/xml/System.Windows.Forms/AutoSizeMode.xml @@ -22,25 +22,25 @@ Specifies how a control will behave when its property is enabled. - property enabled but which have no - - `AutoSizeMode` property. The and properties are respected, but the current value of the property is ignored. - - - -## Examples - The following code example shows a form created using code that automatically resizes to fit its contents. When ran, the form will display a , a for entering a URL, and a for displaying that URL inside of the user's default Web browser. The code example uses a to lay out the contained controls one after the other, and sets the and to grow and shrink to fit the contents of its form. - + property enabled but which have no + + `AutoSizeMode` property. The and properties are respected, but the current value of the property is ignored. + + + +## Examples + The following code example shows a form created using code that automatically resizes to fit its contents. When ran, the form will display a , a for entering a URL, and a for displaying that URL inside of the user's default Web browser. The code example uses a to lay out the contained controls one after the other, and sets the and to grow and shrink to fit the contents of its form. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/AutoSizeMode/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Form.AutoSize/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Form.AutoSize/VB/Form1.vb" id="Snippet1"::: + ]]> - AutoSize Property Overview + AutoSize Property Overview diff --git a/xml/System.Windows.Forms/AutoValidate.xml b/xml/System.Windows.Forms/AutoValidate.xml index 4a1247198d4..e5b92ed4123 100644 --- a/xml/System.Windows.Forms/AutoValidate.xml +++ b/xml/System.Windows.Forms/AutoValidate.xml @@ -22,21 +22,21 @@ Determines how a control validates its data when it loses user input focus. - to determine how to validate its data. This type of validation is called implicit validation, because it occurs without the application developer having to make an explicit call to or . - - The property corresponding to this value will have different defaults based on the type of control. For more information, see [User Input Validation in Windows Forms](/dotnet/framework/winforms/user-input-validation-in-windows-forms). - - - -## Examples - The following code example turns off implicit validation for a form and all of its contained controls, and instead manually performs validation of all of the form's children when a mouse button is clicked. - + to determine how to validate its data. This type of validation is called implicit validation, because it occurs without the application developer having to make an explicit call to or . + + The property corresponding to this value will have different defaults based on the type of control. For more information, see [User Input Validation in Windows Forms](/dotnet/desktop/winforms/user-input-validation-in-windows-forms). + + + +## Examples + The following code example turns off implicit validation for a form and all of its contained controls, and instead manually performs validation of all of the form's children when a mouse button is clicked. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/AutoValidate/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidateChildren/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidateChildren/VB/Form1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/BindingNavigator.xml b/xml/System.Windows.Forms/BindingNavigator.xml index 69ea74e245b..053f29e3962 100644 --- a/xml/System.Windows.Forms/BindingNavigator.xml +++ b/xml/System.Windows.Forms/BindingNavigator.xml @@ -94,7 +94,7 @@ ]]> - BindingNavigator Control (Windows Forms) + BindingNavigator Control (Windows Forms) @@ -459,7 +459,7 @@ ## Examples - The following code example demonstrates how to use a control to move through a data set. The set is contained in a , which is bound to a control with a component. This code example is part of a larger example provided in [How to: Move Through a DataSet with the Windows Forms BindingNavigator Control](/dotnet/framework/winforms/controls/move-through-a-dataset-with-wf-bindingnavigator-control). + The following code example demonstrates how to use a control to move through a data set. The set is contained in a , which is bound to a control with a component. This code example is part of a larger example provided in [How to: Move Through a DataSet with the Windows Forms BindingNavigator Control](/dotnet/desktop/winforms/controls/move-through-a-dataset-with-wf-bindingnavigator-control). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/BindingNavigator/Overview/form1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataNavigator/VB/form1.vb" id="Snippet1"::: diff --git a/xml/System.Windows.Forms/BindingSource.xml b/xml/System.Windows.Forms/BindingSource.xml index 0813575867e..5dc2dd08414 100644 --- a/xml/System.Windows.Forms/BindingSource.xml +++ b/xml/System.Windows.Forms/BindingSource.xml @@ -90,7 +90,7 @@ component serves many purposes. First, it simplifies binding controls on a form to data by providing currency management, change notification, and other services between Windows Forms controls and data sources. This is accomplished by attaching the component to your data source using the property. For complex binding scenarios you can optionally set the property to a specific column or list in the data source. You then bind controls to the . All further interaction with the data is accomplished with calls to the component. For examples on how the can simplify the binding process, see [How to: Bind Windows Forms Controls to DBNull Database Values](/dotnet/framework/winforms/controls/how-to-bind-windows-forms-controls-to-dbnull-database-values) and [How to: Handle Errors and Exceptions that Occur with Databinding](/dotnet/framework/winforms/controls/how-to-handle-errors-and-exceptions-that-occur-with-databinding). Navigation and updating of the data source is accomplished through methods such as , , and . Operations such as sorting and filtering are handled through the and properties. For more information on using sorting and filtering with the , see [How to: Sort and Filter ADO.NET Data with the Windows Forms BindingSource Component](/dotnet/framework/winforms/controls/sort-and-filter-ado-net-data-with-wf-bindingsource-component). + The component serves many purposes. First, it simplifies binding controls on a form to data by providing currency management, change notification, and other services between Windows Forms controls and data sources. This is accomplished by attaching the component to your data source using the property. For complex binding scenarios you can optionally set the property to a specific column or list in the data source. You then bind controls to the . All further interaction with the data is accomplished with calls to the component. For examples on how the can simplify the binding process, see [How to: Bind Windows Forms Controls to DBNull Database Values](/dotnet/desktop/winforms/controls/how-to-bind-windows-forms-controls-to-dbnull-database-values) and [How to: Handle Errors and Exceptions that Occur with Databinding](/dotnet/desktop/winforms/controls/how-to-handle-errors-and-exceptions-that-occur-with-databinding). Navigation and updating of the data source is accomplished through methods such as , , and . Operations such as sorting and filtering are handled through the and properties. For more information on using sorting and filtering with the , see [How to: Sort and Filter ADO.NET Data with the Windows Forms BindingSource Component](/dotnet/desktop/winforms/controls/sort-and-filter-ado-net-data-with-wf-bindingsource-component). In addition, the component can act as a strongly typed data source. Typically the type of the underlying data source is fixed through one of the following mechanisms: @@ -98,7 +98,7 @@ - Set the property to a list, single object, or type. - Both of these mechanisms create a strongly-typed list. For more information on how to use the to bind to a type, see [How to: Bind a Windows Forms Control to a Type](/dotnet/framework/winforms/controls/how-to-bind-a-windows-forms-control-to-a-type). You can also use the to bind your controls to a factory object. For more information on how to do this, see [How to: Bind a Windows Forms Control to a Factory Object](/dotnet/framework/winforms/controls/how-to-bind-a-windows-forms-control-to-a-factory-object). + Both of these mechanisms create a strongly-typed list. For more information on how to use the to bind to a type, see [How to: Bind a Windows Forms Control to a Type](/dotnet/desktop/winforms/controls/how-to-bind-a-windows-forms-control-to-a-type). You can also use the to bind your controls to a factory object. For more information on how to do this, see [How to: Bind a Windows Forms Control to a Factory Object](/dotnet/desktop/winforms/controls/how-to-bind-a-windows-forms-control-to-a-factory-object). > [!NOTE] > Because a handles both simple and complex data sources, terminology is problematic. Within this class documentation, the term *list* refers to a data collection within the hosted data source, and *item* denotes a single element. When discussing functionality associated with complex data sources, the equivalent terms *table* and *row* are used. @@ -129,7 +129,7 @@ - BindingSource Component + BindingSource Component @@ -355,7 +355,7 @@ ## Examples - The following code example uses a component to bind a list to a control. New items are added to the list by the event handler. This code example is part of a larger example provided in [How to: Customize Item Addition with the Windows Forms BindingSource](/dotnet/framework/winforms/controls/how-to-customize-item-addition-with-the-windows-forms-bindingsource). + The following code example uses a component to bind a list to a control. New items are added to the list by the event handler. This code example is part of a larger example provided in [How to: Customize Item Addition with the Windows Forms BindingSource](/dotnet/desktop/winforms/controls/how-to-customize-item-addition-with-the-windows-forms-bindingsource). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataConnector.AddingNew/CPP/form1.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/AddingNewEventArgs/Overview/form1.cs" id="Snippet8"::: @@ -419,7 +419,7 @@ ## Examples - The following code example uses a component to bind a list to a control. New items are added to the list by the event handler. This code example is part of a larger example provided in [How to: Customize Item Addition with the Windows Forms BindingSource](/dotnet/framework/winforms/controls/how-to-customize-item-addition-with-the-windows-forms-bindingsource). + The following code example uses a component to bind a list to a control. New items are added to the list by the event handler. This code example is part of a larger example provided in [How to: Customize Item Addition with the Windows Forms BindingSource](/dotnet/desktop/winforms/controls/how-to-customize-item-addition-with-the-windows-forms-bindingsource). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataConnector.AddingNew/CPP/form1.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/AddingNewEventArgs/Overview/form1.cs" id="Snippet7"::: @@ -1417,7 +1417,7 @@ ## Examples - The following code example assigns a list of customers to the of a component. This code example is part of a larger example provided at [How to: Raise Change Notifications Using the BindingSource ResetItem Method](/dotnet/framework/winforms/controls/how-to-raise-change-notifications-using-the-bindingsource-resetitem-method). + The following code example assigns a list of customers to the of a component. This code example is part of a larger example provided at [How to: Raise Change Notifications Using the BindingSource ResetItem Method](/dotnet/desktop/winforms/controls/how-to-raise-change-notifications-using-the-bindingsource-resetitem-method). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataConnector.ResetItem/CPP/form1.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/BindingSource/DataSource/form1.cs" id="Snippet6"::: @@ -3511,7 +3511,7 @@ ## Examples - The following code example uses a component to bind an array list, which does not provide change notification. An item is removed from the list, and the bound controls are notified of the change by calling the method. This code example is part of a larger example provided in [How to: Reflect Data Source Updates in a Windows Forms Control with the BindingSource](/dotnet/framework/winforms/controls/reflect-data-source-updates-in-a-wf-control-with-the-bindingsource). + The following code example uses a component to bind an array list, which does not provide change notification. An item is removed from the list, and the bound controls are notified of the change by calling the method. This code example is part of a larger example provided in [How to: Reflect Data Source Updates in a Windows Forms Control with the BindingSource](/dotnet/desktop/winforms/controls/reflect-data-source-updates-in-a-wf-control-with-the-bindingsource). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataConnector.ResetBindings/CPP/form1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/BindingSource/ResetBindings/form1.cs" id="Snippet3"::: @@ -3599,7 +3599,7 @@ ## Examples - The following code example uses a component to bind a list to a control. The list does not raise change notifications, so the method on the is used to raise the event. This code example is part of a larger example provided in [How to: Raise Change Notifications Using the BindingSource ResetItem Method](/dotnet/framework/winforms/controls/how-to-raise-change-notifications-using-the-bindingsource-resetitem-method). + The following code example uses a component to bind a list to a control. The list does not raise change notifications, so the method on the is used to raise the event. This code example is part of a larger example provided in [How to: Raise Change Notifications Using the BindingSource ResetItem Method](/dotnet/desktop/winforms/controls/how-to-raise-change-notifications-using-the-bindingsource-resetitem-method). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataConnector.ResetItem/CPP/form1.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/BindingSource/DataSource/form1.cs" id="Snippet7"::: diff --git a/xml/System.Windows.Forms/ButtonRenderer.xml b/xml/System.Windows.Forms/ButtonRenderer.xml index b8ff7e694b5..d9a95eda918 100644 --- a/xml/System.Windows.Forms/ButtonRenderer.xml +++ b/xml/System.Windows.Forms/ButtonRenderer.xml @@ -33,24 +33,24 @@ Provides methods used to render a button control with or without visual styles. This class cannot be inherited. - class provides a set of `static` methods that can be used to render a button control. Rendering a control refers to drawing the user interface of a control. To draw a button, use one of the methods. These methods provide a variety of options, such as drawing text or an image on the button. - - If visual styles are enabled in the operating system and visual styles are applied to the current application, will draw the button with the current visual style. Otherwise, will draw the button with the classic Windows style. This is useful if you are drawing a custom control that should automatically match the current visual style setting of the operating system. - - This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - - - -## Examples - The following code example demonstrates how to create a custom control that uses the method to draw a button. When the button is clicked, the control draws a smaller button inside the bounds of the original button, and the control uses the method to paint over the rest of the original button. - + class provides a set of `static` methods that can be used to render a button control. Rendering a control refers to drawing the user interface of a control. To draw a button, use one of the methods. These methods provide a variety of options, such as drawing text or an image on the button. + + If visual styles are enabled in the operating system and visual styles are applied to the current application, will draw the button with the current visual style. Otherwise, will draw the button with the classic Windows style. This is useful if you are drawing a custom control that should automatically match the current visual style setting of the operating system. + + This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + + + +## Examples + The following code example demonstrates how to create a custom control that uses the method to draw a button. When the button is clicked, the control draws a smaller button inside the bounds of the original button, and the control uses the method to paint over the rest of the original button. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ButtonRenderer/cpp/form1.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ButtonRenderer/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ButtonRenderer/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ButtonRenderer/VB/form1.vb" id="Snippet0"::: + ]]> @@ -101,11 +101,11 @@ One of the values that specifies the visual state of the button. Draws a button control in the specified state and bounds. - @@ -147,11 +147,11 @@ One of the values that specifies the visual state of the button. Draws a button control in the specified state and bounds, and with an optional focus rectangle. - @@ -197,11 +197,11 @@ One of the values that specifies the visual state of the button. Draws a button control in the specified state and bounds, with the specified image, and with an optional focus rectangle. - @@ -261,20 +261,20 @@ One of the values that specifies the visual state of the button. Draws a button control in the specified state and bounds, with the specified text, and with an optional focus rectangle. - method in a custom control's method to draw a button in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. - + method in a custom control's method to draw a button in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ButtonRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ButtonRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ButtonRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ButtonRenderer/VB/form1.vb" id="Snippet2"::: + ]]> @@ -330,11 +330,11 @@ One of the values that specifies the visual state of the button. Draws a button control in the specified state and bounds, with the specified text and text formatting, and with an optional focus rectangle. - @@ -405,11 +405,11 @@ One of the values that specifies the visual state of the button. Draws a button control in the specified state and bounds, with the specified text and image, and with an optional focus rectangle. - @@ -476,11 +476,11 @@ One of the values that specifies the visual state of the button. Draws a button control in the specified state and bounds; with the specified text, text formatting, and image; and with an optional focus rectangle. - @@ -518,15 +518,15 @@ The control whose parent's background will be drawn. Draws the background of a control's parent in the specified area. - method to paint over an area of a custom control. This code example is part of a larger example provided for the class. - + method to paint over an area of a custom control. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ButtonRenderer/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ButtonRenderer/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ButtonRenderer/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ButtonRenderer/VB/form1.vb" id="Snippet4"::: + ]]> @@ -601,11 +601,11 @@ if the application state is used to determine rendering style; otherwise, . The default is . - property is `true`, the uses the setting from the property to determine the rendering style. If is `false`, the renderer will always render using visual styles. - + property is `true`, the uses the setting from the property to determine the rendering style. If is `false`, the renderer will always render using visual styles. + ]]> diff --git a/xml/System.Windows.Forms/CheckBox.xml b/xml/System.Windows.Forms/CheckBox.xml index 628bf1a7764..06a23479865 100644 --- a/xml/System.Windows.Forms/CheckBox.xml +++ b/xml/System.Windows.Forms/CheckBox.xml @@ -58,40 +58,40 @@ Represents a Windows . - to give the user an option, such as true/false or yes/no. The control can display an image or text or both. - - and controls have a similar function: they allow the user to choose from a list of options. controls let the user pick a combination of options. In contrast, controls allow a user to choose from mutually exclusive options. - - The property determines whether the appears as a typical or as a button. - - The property determines whether the control supports two or three states. Use the property to get or set the value of a two-state control and use the property to get or set the value of a three-state control. - + to give the user an option, such as true/false or yes/no. The control can display an image or text or both. + + and controls have a similar function: they allow the user to choose from a list of options. controls let the user pick a combination of options. In contrast, controls allow a user to choose from mutually exclusive options. + + The property determines whether the appears as a typical or as a button. + + The property determines whether the control supports two or three states. Use the property to get or set the value of a two-state control and use the property to get or set the value of a three-state control. + > [!NOTE] -> If the property is set to `true`, the property will return `true` for either a checked or indeterminate state. - - The property determines the style and appearance of the control. If the property is set to , the user's operating system determines the appearance of the control. - +> If the property is set to `true`, the property will return `true` for either a checked or indeterminate state. + + The property determines the style and appearance of the control. If the property is set to , the user's operating system determines the appearance of the control. + > [!NOTE] -> When the property is set to , the property is ignored and the control is displayed using the or alignment. If the property is set to one of the right alignments, the control is displayed using the alignment; otherwise, it is displayed using the alignment. - - The following describes an indeterminate state: You have a that determines if the selected text in a is bold. When you select text you can click the to bold the selection. Likewise, when you select some text, the displays whether the selected text is bold. If your selected text contains text that is bold and normal, the will have an indeterminate state. - - - -## Examples - The following code example creates and initializes a , gives it the appearance of a toggle button, sets to `false`, and adds it to a . - +> When the property is set to , the property is ignored and the control is displayed using the or alignment. If the property is set to one of the right alignments, the control is displayed using the alignment; otherwise, it is displayed using the alignment. + + The following describes an indeterminate state: You have a that determines if the selected text in a is bold. When you select text you can click the to bold the selection. Likewise, when you select some text, the displays whether the selected text is bold. If your selected text contains text that is bold and normal, the will have an indeterminate state. + + + +## Examples + The following code example creates and initializes a , gives it the appearance of a toggle button, sets to `false`, and adds it to a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/VB/source.vb" id="Snippet1"::: + ]]> - CheckBox Control (Windows Forms) + CheckBox Control (Windows Forms) @@ -117,20 +117,20 @@ Initializes a new instance of the class. - is instantiated, is set to `true`, is set to `false`, and is set to . - - - -## Examples - The following code example creates and initializes a , gives it the appearance of a toggle button, sets to `false`, and adds it to a . - + is instantiated, is set to `true`, is set to `false`, and is set to . + + + +## Examples + The following code example creates and initializes a , gives it the appearance of a toggle button, sets to `false`, and adds it to a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -177,20 +177,20 @@ Gets or sets the value that determines the appearance of a control. One of the values. The default value is . - value is set to , the has a typical appearance. If the value is set to `Button`, the appears like a toggle button, which can be toggled to an up or down state. - - - -## Examples - The following code example creates and initializes a , gives it the appearance of a toggle button, sets to `false`, and adds it to a . - + value is set to , the has a typical appearance. If the value is set to `Button`, the appears like a toggle button, which can be toggled to an up or down state. + + + +## Examples + The following code example creates and initializes a , gives it the appearance of a toggle button, sets to `false`, and adds it to a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/VB/source.vb" id="Snippet1"::: + ]]> The value assigned is not one of the values. @@ -230,21 +230,21 @@ Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `CheckBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `CheckBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet139"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet139"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet139"::: + ]]> @@ -292,20 +292,20 @@ if the value or value and the appearance of the control are automatically changed on the event; otherwise, . The default value is . - is set to false, you will need to add code to update the or values in the event handler. - - - -## Examples - The following code example creates and initializes a , gives it the appearance of a toggle button, sets to `false`, and adds it to a . - + is set to false, you will need to add code to update the or values in the event handler. + + + +## Examples + The following code example creates and initializes a , gives it the appearance of a toggle button, sets to `false`, and adds it to a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckBox Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -355,15 +355,15 @@ Gets or sets the horizontal and vertical alignment of the check mark on a control. One of the values. The default value is . - property alternates between `true` and `false` with alternating clicks of the control and the alternates between the `MiddleRight` and `MiddleLeft` values of . This example shows how the property values change as the property changes and the control is checked. This example requires that a , and have all been instantiated on a form and that the label is large enough to display three lines of text, as well as a reference to the namespace. This code should be called in the event handler of the control. - + property alternates between `true` and `false` with alternating clicks of the control and the alternates between the `MiddleRight` and `MiddleLeft` values of . This example shows how the property values change as the property changes and the control is checked. This example requires that a , and have all been instantiated on a form and that the label is large enough to display three lines of text, as well as a reference to the namespace. This code should be called in the event handler of the control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/CheckAlign/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/VB/source.vb" id="Snippet1"::: + ]]> The value assigned is not one of the enumeration values. @@ -419,22 +419,22 @@ Gets or set a value indicating whether the is in the checked state. - if the is in the checked state; otherwise, . The default value is . - + if the is in the checked state; otherwise, . The default value is . + Note: If the property is set to , the property will return for either a or . - portion of the control displays a check mark. If the property is set to `Button`, the control will appear sunken when is `true` and raised like a standard button when `false`. - -## Examples - The following code example displays the values of three properties in a label. The property alternates between `true` and `false` with alternating clicks of the control and the alternates between a value of `MiddleRight` and `MiddleLeft`. This example shows how the property values change as the property changes and the control is checked. This example requires that a , and have all been instantiated on a form and that the label is large enough to display three lines of text, as well as a reference to the namespace. This code should be called in the event handler of the control. - + +## Examples + The following code example displays the values of three properties in a label. The property alternates between `true` and `false` with alternating clicks of the control and the alternates between a value of `MiddleRight` and `MiddleLeft`. This example shows how the property values change as the property changes and the control is checked. This example requires that a , and have all been instantiated on a form and that the label is large enough to display three lines of text, as well as a reference to the namespace. This code should be called in the event handler of the control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/CheckAlign/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -474,21 +474,21 @@ Note: If the property Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `CheckBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `CheckBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet140"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet140"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet140"::: + ]]> @@ -543,28 +543,28 @@ Note: If the property Gets or sets the state of the . One of the enumeration values. The default value is . - property is set to `false`, the property value can only be set to `CheckState.Indeterminate` in code and not by user interaction. - - The following table describes the of the control in its different states for the `Normal` and `Button` style control . - -|CheckState|Appearance.Normal|Appearance.Button| -|----------------|-----------------------|-----------------------| -|`Checked`|The displays a check mark.|The control appears sunken.| -|`Unchecked`|The is empty.|The control appears raised.| -|`Indeterminate`|The displays a check mark and is shaded.|The control appears flat.| - - - -## Examples - The following code example displays the values of three properties in a label. The property alternates between `true` and `false` with alternating clicks of the control and the alternates between the `MiddleRight` and `MiddleLeft` values of . This example shows how the property values change as the property changes and the control is checked. This example requires that a , and have all been instantiated on a form and that the label is large enough to display three lines of text, as well as a reference to the namespace. This code should be called in the event handler of the control. - + property is set to `false`, the property value can only be set to `CheckState.Indeterminate` in code and not by user interaction. + + The following table describes the of the control in its different states for the `Normal` and `Button` style control . + +|CheckState|Appearance.Normal|Appearance.Button| +|----------------|-----------------------|-----------------------| +|`Checked`|The displays a check mark.|The control appears sunken.| +|`Unchecked`|The is empty.|The control appears raised.| +|`Indeterminate`|The displays a check mark and is shaded.|The control appears flat.| + + + +## Examples + The following code example displays the values of three properties in a label. The property alternates between `true` and `false` with alternating clicks of the control and the alternates between the `MiddleRight` and `MiddleLeft` values of . This example shows how the property values change as the property changes and the control is checked. This example requires that a , and have all been instantiated on a form and that the label is large enough to display three lines of text, as well as a reference to the namespace. This code should be called in the event handler of the control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/CheckAlign/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/VB/source.vb" id="Snippet1"::: + ]]> The value assigned is not one of the enumeration values. @@ -605,21 +605,21 @@ Note: If the property Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `CheckBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `CheckBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet141"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet141"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet141"::: + ]]> @@ -653,14 +653,14 @@ Note: If the property Creates a new accessibility object for the control. A new for the control. - method, it will be called when the property is referenced. - + method, it will be called when the property is referenced. + > [!NOTE] -> To get or set the property, you must add a reference to the `Accessibility` assembly installed with the .NET Framework. - +> To get or set the property, you must add a reference to the `Accessibility` assembly installed with the .NET Framework. + ]]> @@ -695,15 +695,15 @@ Note: If the property Gets the required creation parameters when the control handle is created. A that contains the required creation parameters when the handle to the control is created. - property of a derived class. The property is changed, which causes the button to display an rather than an . This example requires that you have a class that inherits from the class. - + property of a derived class. The property is changed, which causes the button to display an rather than an . This example requires that you have a class that inherits from the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/CreateParams/CPP/createparams.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/CreateParams/createparams.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CreateParams/VB/createparams.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CreateParams/VB/createparams.vb" id="Snippet3"::: + ]]> @@ -778,13 +778,13 @@ Note: If the property Occurs when the user double-clicks the control. - and enumerations are set to false for the control, and the event is not raised. - - This event is not relevant to this class. - + and enumerations are set to false for the control, and the event is not raised. + + This event is not relevant to this class. + ]]> @@ -829,13 +829,13 @@ Note: If the property Occurs when the user double-clicks the control. - and style bits are set to `false` for the control, and the event is not raised. - - This event is not relevant to this class. - + and style bits are set to `false` for the control, and the event is not raised. + + This event is not relevant to this class. + ]]> @@ -870,13 +870,13 @@ Note: If the property An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -915,13 +915,13 @@ Note: If the property An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -960,13 +960,13 @@ Note: If the property An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1005,15 +1005,15 @@ Note: If the property An that contains the event data. Raises the event. - method changes the property. If the property is set to `true`, subsequent clicks of the will result in cycling through all the values of the enumeration. Otherwise, switches between and . - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method changes the property. If the property is set to `true`, subsequent clicks of the will result in cycling through all the values of the enumeration. Otherwise, switches between and . + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1149,30 +1149,30 @@ Note: If the property if the character was processed as a mnemonic by the control; otherwise, . - method to determine whether the given character matches a mnemonic in the control's text. - - For example: - -```csharp -if (CanSelect && IsMnemonic(charCode, MyControl.Text) { - // Perform action associated with mnemonic. - } -``` - - This default implementation of the method simply returns `false` to indicate that the control has no mnemonic. - - - -## Examples - The following code example demonstrates an extension of the button class that overrides the method to exhibit custom behavior. The example also demonstrates the use of the and properties. To run this example, paste the following code after a form class, in the same file. Add a button of type `MnemonicButton` to the form. - + method to determine whether the given character matches a mnemonic in the control's text. + + For example: + +```csharp +if (CanSelect && IsMnemonic(charCode, MyControl.Text) { + // Perform action associated with mnemonic. + } +``` + + This default implementation of the method simply returns `false` to indicate that the control has no mnemonic. + + + +## Examples + The following code example demonstrates an extension of the button class that overrides the method to exhibit custom behavior. The example also demonstrates the use of the and properties. To run this example, paste the following code after a form class, in the same file. Add a button of type `MnemonicButton` to the form. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ProcessMnemonic/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/ProcessMnemonic/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProcessMnemonic/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProcessMnemonic/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1290,20 +1290,20 @@ if (CanSelect && IsMnemonic(charCode, MyControl.Text) { if the is able to display three check states; otherwise, . The default value is . - property is set to `false`, the property value can only be set to the `Indeterminate` value of in code and not by user interaction. - - - -## Examples - The following code example displays the values of three properties in a label. The property alternates between `true` and `false` with alternating clicks of the control and the alternates between the `MiddleRight` and `MiddleLeft` values of . This example shows how the property values change as the property changes and the control is checked. This code requires that a , and have all been instantiated on a form and that the label is large enough to display three lines of text, as well as a reference to the namespace. This code should be called in the event handler of the control. - + property is set to `false`, the property value can only be set to the `Indeterminate` value of in code and not by user interaction. + + + +## Examples + The following code example displays the values of three properties in a label. The property alternates between `true` and `false` with alternating clicks of the control and the alternates between the `MiddleRight` and `MiddleLeft` values of . This example shows how the property values change as the property changes and the control is checked. This code requires that a , and have all been instantiated on a form and that the label is large enough to display three lines of text, as well as a reference to the namespace. This code should be called in the event handler of the control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/CheckAlign/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckBox.CheckAlign Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/CheckBoxRenderer.xml b/xml/System.Windows.Forms/CheckBoxRenderer.xml index 63fac80f4a5..51ba9a8406f 100644 --- a/xml/System.Windows.Forms/CheckBoxRenderer.xml +++ b/xml/System.Windows.Forms/CheckBoxRenderer.xml @@ -33,24 +33,24 @@ Provides methods used to render a check box control with or without visual styles. This class cannot be inherited. - class provides a set of `static` methods that can be used to render a check box control. Rendering a control refers to drawing the user interface of a control. To draw a check box, use one of the methods. These methods provide a variety of options, such as drawing text or an image with the check box. - - If visual styles are enabled in the operating system and visual styles are applied to the current application, will draw the check box with the current visual style. Otherwise, will draw the check box with the classic Windows style. This is useful if you are drawing a custom control that should automatically match the current visual style setting of the operating system. - - This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - - - -## Examples - The following code example demonstrates how to write a custom control that uses the method to draw a check box that responds to mouse clicks. - + class provides a set of `static` methods that can be used to render a check box control. Rendering a control refers to drawing the user interface of a control. To draw a check box, use one of the methods. These methods provide a variety of options, such as drawing text or an image with the check box. + + If visual styles are enabled in the operating system and visual styles are applied to the current application, will draw the check box with the current visual style. Otherwise, will draw the check box with the classic Windows style. This is useful if you are drawing a custom control that should automatically match the current visual style setting of the operating system. + + This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + + + +## Examples + The following code example demonstrates how to write a custom control that uses the method to draw a check box that responds to mouse clicks. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.CheckBoxRenderer/cpp/form1.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBoxRenderer/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.CheckBoxRenderer/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.CheckBoxRenderer/VB/form1.vb" id="Snippet0"::: + ]]> @@ -101,11 +101,11 @@ One of the values that specifies the visual state of the check box. Draws a check box control in the specified state and location. - @@ -167,11 +167,11 @@ One of the values that specifies the visual state of the check box. Draws a check box control in the specified state and location, with the specified text, and with an optional focus rectangle. - @@ -229,20 +229,20 @@ One of the values that specifies the visual state of the check box. Draws a check box control in the specified state and location, with the specified text and text formatting, and with an optional focus rectangle. - method in a custom control's method to draw a check box in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. - + method in a custom control's method to draw a check box in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.CheckBoxRenderer/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBoxRenderer/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.CheckBoxRenderer/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.CheckBoxRenderer/VB/form1.vb" id="Snippet4"::: + ]]> @@ -315,11 +315,11 @@ One of the values that specifies the visual state of the check box. Draws a check box control in the specified state and location, with the specified text and image, and with an optional focus rectangle. - @@ -388,11 +388,11 @@ One of the values that specifies the visual state of the check box. Draws a check box control in the specified state and location; with the specified text, text formatting, and image; and with an optional focus rectangle. - @@ -465,20 +465,20 @@ Returns the size of the check box glyph. A that represents the size of the check box glyph. - method to determine the bounds of the check box text. This code example is part of a larger example provided for the class. - + method to determine the bounds of the check box text. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.CheckBoxRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBoxRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.CheckBoxRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.CheckBoxRenderer/VB/form1.vb" id="Snippet2"::: + ]]> @@ -554,11 +554,11 @@ if the application state is used to determine rendering style; otherwise, . The default is . - property is `true`, the uses the setting from the property to determine the rendering style. If is `false`, the renderer will always render using visual styles. - + property is `true`, the uses the setting from the property to determine the rendering style. If is `false`, the renderer will always render using visual styles. + ]]> diff --git a/xml/System.Windows.Forms/CheckedListBox.xml b/xml/System.Windows.Forms/CheckedListBox.xml index 809d3892e22..a721ef416b1 100644 --- a/xml/System.Windows.Forms/CheckedListBox.xml +++ b/xml/System.Windows.Forms/CheckedListBox.xml @@ -43,69 +43,69 @@ Displays a in which a check box is displayed to the left of each item. - and . - - To add objects to the list at run time, assign an array of object references with the method. The list then displays the default string value for each object. You can add individual items to the list with the method. - - The object supports three states through the enumeration: , , and . You must set the state of in the code because the user interface for a does not provide a mechanism to do so. - - If is `true`, the will recognize and expand tab characters in an item's text, creating columns. These tab stops are preset and cannot be changed. To use custom tab stops, set to `false`, set to `true`, and add the custom values to the collection. - + and . + + To add objects to the list at run time, assign an array of object references with the method. The list then displays the default string value for each object. You can add individual items to the list with the method. + + The object supports three states through the enumeration: , , and . You must set the state of in the code because the user interface for a does not provide a mechanism to do so. + + If is `true`, the will recognize and expand tab characters in an item's text, creating columns. These tab stops are preset and cannot be changed. To use custom tab stops, set to `false`, set to `true`, and add the custom values to the collection. + > [!NOTE] -> If the property is `false`, the property will be ignored and replaced with standard tab offsets. - - The class supports the following three indexed collections: - -|Collection|Encapsulating Class| -|----------------|-------------------------| -|All items contained in the control.|| -|Checked items (including items in an indeterminate state), which is a subset of the items contained in the control.|| -|Checked indexes, which is a subset of the indexes into the items collection. These indexes specify items in a checked or indeterminate state.|| - - The following three tables are examples of the three indexed collections that the class supports. - - The first table provides an example of the indexed collection of items in the control (all items contained in the control). - -|Index|Item|Check State| -|-----------|----------|-----------------| -|0|Object 1|| -|1|Object 2|| -|2|Object 3|| -|3|Object 4|| -|4|Object 5|| - - The second table provides an example of the indexed collection of the checked items. - -|Index|Item| -|-----------|----------| -|0|Object 2| -|1|Object 4| -|2|Object 5| - - The third table provides an example of the indexed collection of indexes of checked items. - -|Index|Index of Item| -|-----------|-------------------| -|0|1| -|1|3| -|2|4| - - - -## Examples - The following example illustrates how you can use the methods, properties, and collections of a . This is a complete sample ready to run once you have copied it to your project. You can check and uncheck items, use the text box to add items and once you have clicked the save button, clear the checked items. - +> If the property is `false`, the property will be ignored and replaced with standard tab offsets. + + The class supports the following three indexed collections: + +|Collection|Encapsulating Class| +|----------------|-------------------------| +|All items contained in the control.|| +|Checked items (including items in an indeterminate state), which is a subset of the items contained in the control.|| +|Checked indexes, which is a subset of the indexes into the items collection. These indexes specify items in a checked or indeterminate state.|| + + The following three tables are examples of the three indexed collections that the class supports. + + The first table provides an example of the indexed collection of items in the control (all items contained in the control). + +|Index|Item|Check State| +|-----------|----------|-----------------| +|0|Object 1|| +|1|Object 2|| +|2|Object 3|| +|3|Object 4|| +|4|Object 5|| + + The second table provides an example of the indexed collection of the checked items. + +|Index|Item| +|-----------|----------| +|0|Object 2| +|1|Object 4| +|2|Object 5| + + The third table provides an example of the indexed collection of indexes of checked items. + +|Index|Index of Item| +|-----------|-------------------| +|0|1| +|1|3| +|2|4| + + + +## Examples + The following example illustrates how you can use the methods, properties, and collections of a . This is a complete sample ready to run once you have copied it to your project. You can check and uncheck items, use the text box to add items and once you have clicked the save button, clear the checked items. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic CheckedListBox Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckedListBox Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic CheckedListBox Example/VB/source.vb" id="Snippet1"::: + ]]> - CheckedListBox Control (Windows Forms) + CheckedListBox Control (Windows Forms) @@ -131,11 +131,11 @@ Initializes a new instance of the class. - uses and the `ResizeRedraw` value of to specify that the control is redrawn when resized. - + uses and the `ResizeRedraw` value of to specify that the control is redrawn when resized. + ]]> @@ -181,22 +181,22 @@ Collection of checked indexes in this . The collection for the . - control. These indexes specify items in a checked or indeterminate state. - - - -## Examples - The following example enumerates the checked items in the to see what check state an item is in. The example demonstrates using the property to get the , and the property to get the . - - The first loop uses the method to get the of each checked item, given the index of the item. The second loop also uses , but uses the method to retrieve the index for the item. - + control. These indexes specify items in a checked or indeterminate state. + + + +## Examples + The following example enumerates the checked items in the to see what check state an item is in. The example demonstrates using the property to get the , and the property to get the . + + The first loop uses the method to get the of each checked item, given the index of the item. The second loop also uses , but uses the method to retrieve the index for the item. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/CheckedListBox/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox+CheckedIndexCollection/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet2"::: + ]]> @@ -243,38 +243,38 @@ Collection of checked items in this . The collection for the . - collection, representing only those items whose is `Checked` or `Indeterminate`. The indexes in this collection are in ascending order. - - - -## Examples - The following example enumerates the checked items in the to see what check state an item is in. The example demonstrates using the property to get the , and the property to get the . - - The first loop uses the method to get the of each checked item, given the index of the item. The second loop also uses , but uses the method to retrieve the index for the item. - - To run this example, perform the following steps: - -1. Create a new Windows Forms application. - -2. Add a and a to the form. - -3. Name the button `WhatIsChecked`, add a handler for its event, and copy in the code from the body of the following handler. - -4. Add some items to the . - -5. Run the example and check some of the check boxes in the list box. - -6. Click the button. - - You will see a series of message boxes that indicate which items were checked. - + collection, representing only those items whose is `Checked` or `Indeterminate`. The indexes in this collection are in ascending order. + + + +## Examples + The following example enumerates the checked items in the to see what check state an item is in. The example demonstrates using the property to get the , and the property to get the . + + The first loop uses the method to get the of each checked item, given the index of the item. The second loop also uses , but uses the method to retrieve the index for the item. + + To run this example, perform the following steps: + +1. Create a new Windows Forms application. + +2. Add a and a to the form. + +3. Name the button `WhatIsChecked`, add a handler for its event, and copy in the code from the body of the following handler. + +4. Add some items to the . + +5. Run the example and check some of the check boxes in the list box. + +6. Click the button. + + You will see a series of message boxes that indicate which items were checked. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/CheckedListBox/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox+CheckedIndexCollection/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet2"::: + ]]> @@ -322,22 +322,22 @@ if the check mark is applied immediately; otherwise, . The default is . - indicates whether the check box should be toggled whenever an item is selected. The default behavior is to change the selection on the first click, and then have the user click again to apply the check mark. In some instances, however, you might prefer have the item checked as soon as it is clicked. - - - -## Examples - The following code example demonstrates initializing a control by setting the , , and properties. The example populates the with controls and sets the to the property of the control. - - To run the example, paste the following code in a form containing a named `CheckedListBox1` and call the `InitializeCheckListBox` method from the form's constructor or Load method. - + indicates whether the check box should be toggled whenever an item is selected. The default behavior is to change the selection on the first click, and then have the user click again to apply the check mark. In some instances, however, you might prefer have the item checked as soon as it is clicked. + + + +## Examples + The following code example demonstrates initializing a control by setting the , , and properties. The example populates the with controls and sets the to the property of the control. + + To run the example, paste the following code in a form containing a named `CheckedListBox1` and call the `InitializeCheckListBox` method from the form's constructor or Load method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox+ObjectCollection/Add/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -391,23 +391,23 @@ Occurs when the user clicks the control. - event passes an to its event handler, so it only indicates that a click has occurred. If you need more specific mouse information (such as the button, number of clicks, wheel rotation, or location), use the and events, which pass a to the event handler. - - A double-click is determined by the mouse settings of the user's operating system. The user can adjust the amount of time that can pass between clicks during a double-click of a mouse button. The event is raised every time the user double-clicks a control. For example, if you have event-handling methods for the and events of a form, the events are raised when the form is double-clicked and both event-handling methods are called. If the user double-clicks a control that does not support the event, the event might be raised twice. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `CheckedListBox1`. Then ensure that the event handler is associated with the event. - + event passes an to its event handler, so it only indicates that a click has occurred. If you need more specific mouse information (such as the button, number of clicks, wheel rotation, or location), use the and events, which pass a to the event handler. + + A double-click is determined by the mouse settings of the user's operating system. The user can adjust the amount of time that can pass between clicks during a double-click of a mouse button. The event is raised every time the user double-clicks a control. For example, if you have event-handling methods for the and events of a form, the events are raised when the form is double-clicked and both event-handling methods are called. If the user double-clicks a control that does not support the event, the event might be raised twice. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `CheckedListBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet157"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet157"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet157"::: + ]]> @@ -440,14 +440,14 @@ Creates a new accessibility object for the control. A new for the control. - method, it will be called when the property is referenced. - + method, it will be called when the property is referenced. + > [!NOTE] -> To get or set the property, you must add a reference to the `Accessibility` assembly installed with the .NET Framework. - +> To get or set the property, you must add a reference to the `Accessibility` assembly installed with the .NET Framework. + ]]> @@ -513,21 +513,21 @@ Gets the required creation parameters when the control handle is created. A that contains the required parameters. - property should not be overridden and used to adjust the properties of your derived control. Properties such as the , , and should be set by the corresponding properties in your control such as , and . The should only be extended when you are wrapping a standard Windows control class or to set styles not provided by the Windows Forms namespace. For more information about creating control parameters, see the `CreateWindow` and `CreateWindowEx` functions and the `CREATESTRUCT` structure documentation in the Windows Platform SDK reference at . - - - -## Examples - The following code example extends the property of a derived class. The property is changed, which causes the button to display an rather than an . This example requires that you have a class that inherits from the class. - + + + +## Examples + The following code example extends the property of a derived class. The property is changed, which causes the button to display an rather than an . This example requires that you have a class that inherits from the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/CreateParams/CPP/createparams.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckBox/CreateParams/createparams.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CreateParams/VB/createparams.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CreateParams/VB/createparams.vb" id="Snippet3"::: + ]]> @@ -659,24 +659,24 @@ The property should not be o Gets or sets a string that specifies a property of the objects contained in the list box whose contents you want to display. A string that specifies the name of a property of the objects contained in the list box. The default is an empty string (""). - displays the default string for the items it contains. However, the can display diverse types of objects and you may want to change the displayed string by specifying the property. If the specified property does not exist, or the value of the property is an empty string (""), the results of the object's method are displayed instead. - - If the new value of the cannot be set, the previous value is maintained. - - - -## Examples - The following code example demonstrates initializing a control by setting the , , and properties. The example populates the with controls and sets the to the property of the control. - - To run the example, paste the following code in a form containing a named `CheckedListBox1` and call the `InitializeCheckListBox` method from the form's constructor or Load method. - + displays the default string for the items it contains. However, the can display diverse types of objects and you may want to change the displayed string by specifying the property. If the specified property does not exist, or the value of the property is an empty string (""), the results of the object's method are displayed instead. + + If the new value of the cannot be set, the previous value is maintained. + + + +## Examples + The following code example demonstrates initializing a control by setting the , , and properties. The example populates the with controls and sets the to the property of the control. + + To run the example, paste the following code in a form containing a named `CheckedListBox1` and call the `InitializeCheckListBox` method from the form's constructor or Load method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox+ObjectCollection/Add/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -765,13 +765,13 @@ The property should not be o Occurs when a visual aspect of an owner-drawn changes. This event is not relevant to this class. - . The event is raised only when the property is set to or . You can use this event to perform the tasks needed to draw items in the . If you have a variable-sized item (that is, is set to ), the event is raised before the item is drawn. You can create an event handler for the event to specify the size for the item that you are going to draw in your event handler for the event. - - This event is not relevant to this class. - + . The event is raised only when the property is set to or . You can use this event to perform the tasks needed to draw items in the . If you have a variable-sized item (that is, is set to ), the event is raised before the item is drawn. You can create an event handler for the event to specify the size for the item that you are going to draw in your event handler for the event. + + This event is not relevant to this class. + ]]> @@ -821,11 +821,11 @@ The property should not be o Gets a value indicating the mode for drawing elements of the . This property is not relevant to this class. Always a of . - @@ -862,17 +862,17 @@ The property should not be o if the item is checked; otherwise, . - returns `true` if the value of is `Checked` or `Indeterminate` for the item. To determine the specific state the item is in, use the method. - + returns `true` if the value of is `Checked` or `Indeterminate` for the item. To determine the specific state the item is in, use the method. + ]]> - The specified is less than zero. - - -or- - + The specified is less than zero. + + -or- + The specified is greater than or equal to the count of items in the list. @@ -909,28 +909,28 @@ The property should not be o Returns a value indicating the check state of the current item. One of the values. - method provides the ability to get the value of an item, given the index. If you never set the check state of an item to `Indeterminate`, then use the method. - - - -## Examples - The following example enumerates the checked items in the to see what check state an item is in. The example demonstrates using the method to set the check state of an item. The example also demonstrates using the property to get the and the property to get the . - - The first loop uses the method to get the of each checked item, given the index of the item. The second loop also uses , but uses the method to retrieve the index for the item. - + method provides the ability to get the value of an item, given the index. If you never set the check state of an item to `Indeterminate`, then use the method. + + + +## Examples + The following example enumerates the checked items in the to see what check state an item is in. The example demonstrates using the method to set the check state of an item. The example also demonstrates using the property to get the and the property to get the . + + The first loop uses the method to get the of each checked item, given the index of the item. The second loop also uses , but uses the method to retrieve the index for the item. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/CheckedListBox/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox+CheckedIndexCollection/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet2"::: + ]]> - The specified is less than zero. - - -or- - + The specified is less than zero. + + -or- + The specified is greater than or equal to the count of items in the list. @@ -969,21 +969,21 @@ The property should not be o Occurs when the checked state of an item changes. - event occurs. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `CheckedListBox1`. Then ensure that the event handler is associated with the event. - + event occurs. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `CheckedListBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet156"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet156"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet156"::: + ]]> @@ -1033,13 +1033,13 @@ The property should not be o Gets the height of the item area. The height, in pixels, of the item area. - and override to return `base.ItemHeight+2`. - + and override to return `base.ItemHeight+2`. + ]]> @@ -1101,22 +1101,22 @@ The property should not be o Gets the collection of items in this . The collection representing the items in the . - property enables you to obtain a reference to the list of items that are currently stored in a control. With this reference, you can add items, remove items, and obtain a count of the items in the collection. For more information on the tasks that can be performed with the item collection, see the class reference topics. - - - -## Examples - The following example enumerates the checked items in the to see what check state an item is in. The example uses the property to get the to retrieve the index of an item using the method. The example also demonstrates using the property to get the , and the property to get the . - - The first loop uses the method to get the of each checked item, given the index of the item. The second loop also uses , but uses the method to retrieve the index for the item. - + property enables you to obtain a reference to the list of items that are currently stored in a control. With this reference, you can add items, remove items, and obtain a count of the items in the collection. For more information on the tasks that can be performed with the item collection, see the class reference topics. + + + +## Examples + The following example enumerates the checked items in the to see what check state an item is in. The example uses the property to get the to retrieve the index of an item using the method. The example also demonstrates using the property to get the , and the property to get the . + + The first loop uses the method to get the of each checked item, given the index of the item. The second loop also uses , but uses the method to retrieve the index for the item. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/CheckedListBox/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox+CheckedIndexCollection/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet2"::: + ]]> @@ -1164,15 +1164,15 @@ The property should not be o Occurs when an owner-drawn is created and the sizes of the list items are determined. This event is not relevant to this class. - event. The event is raised only when the property is set to . - - The maximum height of a item is 255 pixels. - - This event is not relevant to this class. - + event. The event is raised only when the property is set to . + + The maximum height of a item is 255 pixels. + + This event is not relevant to this class. + ]]> @@ -1217,21 +1217,21 @@ The property should not be o Occurs when the user clicks the control with the mouse. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `CheckedListBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `CheckedListBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet158"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet158"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet158"::: + ]]> @@ -1299,15 +1299,15 @@ The property should not be o An that contains the event data. Raises the event. - method selects or clears the check box of the item that is clicked. If the property is set to `true`, the check box is switched from a selected or cleared state the first time the item is clicked. Otherwise, the check box is switched only if the item is already selected. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method selects or clears the check box of the item that is clicked. If the property is set to `true`, the check box is switched from a selected or cleared state the first time the item is clicked. Otherwise, the check box is switched only if the item is already selected. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1345,13 +1345,13 @@ The property should not be o The object with the details. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1389,13 +1389,13 @@ The property should not be o An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1433,13 +1433,13 @@ The property should not be o An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1477,13 +1477,13 @@ The property should not be o An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1521,15 +1521,15 @@ The property should not be o The that was raised. Raises the event. - property is not set to , the method switches the check state of the item currently selected. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + property is not set to , the method switches the check state of the item currently selected. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1567,13 +1567,13 @@ The property should not be o A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1611,13 +1611,13 @@ The property should not be o An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1669,13 +1669,13 @@ The property should not be o Gets or sets padding within the . This property is not relevant to this class. A representing the control's internal spacing characteristics. - that are reasonably close to Windows user interface guidelines. Some adjustments might still be necessary for particular applications. - - This property is not relevant to this class. - + that are reasonably close to Windows user interface guidelines. Some adjustments might still be necessary for particular applications. + + This property is not relevant to this class. + ]]> @@ -1735,22 +1735,22 @@ The property should not be o Gets or sets a value specifying the selection mode. Either the or value of . - property determines whether one item in the list box can be selected or no items can be selected. For objects, multiple selection is not supported. You can set the mode to one item or no items. - - - -## Examples - The following code example demonstrates initializing a control by setting the to allow one item in the list to be selected. - - To run the example, paste the following code in a form containing a named `CheckedListBox1` and call the `InitializeCheckListBox` method from the form's constructor or Load method. - + property determines whether one item in the list box can be selected or no items can be selected. For objects, multiple selection is not supported. You can set the mode to one item or no items. + + + +## Examples + The following code example demonstrates initializing a control by setting the to allow one item in the list to be selected. + + To run the example, paste the following code in a form containing a named `CheckedListBox1` and call the `InitializeCheckListBox` method from the form's constructor or Load method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox+ObjectCollection/Add/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/VB/form1.vb" id="Snippet1"::: + ]]> An attempt was made to assign a value that is not a value of or . @@ -1791,28 +1791,28 @@ The property should not be o to set the item as checked; otherwise, . Sets for the item at the specified index to . - value to `Checked`. A value of `false` sets to `Unchecked`. - - - -## Examples - The following example enumerates the items in the and checks every other item in the list. The example demonstrates using the and methods to set the check state of an item. For every other item that is to be checked, is called to set the to `Indeterminate`, while is called on the other item to set the checked state to `Checked`. - - The example also demonstrates using the property to get the to get the of items. - + value to `Checked`. A value of `false` sets to `Unchecked`. + + + +## Examples + The following example enumerates the items in the and checks every other item in the list. The example demonstrates using the and methods to set the check state of an item. For every other item that is to be checked, is called to set the to `Indeterminate`, while is called on the other item to set the checked state to `Checked`. + + The example also demonstrates using the property to get the to get the of items. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/CheckedListBox/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox+CheckedIndexCollection/Overview/source.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet3"::: + ]]> - The index specified is less than zero. - - -or- - + The index specified is less than zero. + + -or- + The index is greater than the count of items in the list. @@ -1848,30 +1848,30 @@ The property should not be o One of the values. Sets the check state of the item at the specified index. - method raises the event. - - Items whose is set to `Indeterminate` appear with a check mark in the check box, but the box is grayed to indicate the indeterminate status of the checked item. - - - -## Examples - The following example enumerates the items in the and checks every other item in the list. The example demonstrates using the and methods to set the check state of an item. For every other item that is to be checked, is called to set the to `Indeterminate`, while is called on the other item to set the checked state to `Checked`. - - The example also demonstrates using the property to get the to get the of items. - + method raises the event. + + Items whose is set to `Indeterminate` appear with a check mark in the check box, but the box is grayed to indicate the indeterminate status of the checked item. + + + +## Examples + The following example enumerates the items in the and checks every other item in the list. The example demonstrates using the and methods to set the check state of an item. For every other item that is to be checked, is called to set the to `Indeterminate`, while is called on the other item to set the checked state to `Checked`. + + The example also demonstrates using the property to get the to get the of items. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/CheckedListBox/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox+CheckedIndexCollection/Overview/source.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/CheckedListBox/VB/source.vb" id="Snippet3"::: + ]]> - The specified is less than zero. - - -or- - + The specified is less than zero. + + -or- + The is greater than or equal to the count of items in the list. The is not one of the values. @@ -1911,17 +1911,17 @@ The property should not be o if the check box has a flat appearance; otherwise, . The default is . - control by setting the , , and properties. The example populates the with controls and sets the to the property of the control. - - To run the example, paste the following code in a form containing a named `CheckedListBox1` and call the `InitializeCheckListBox` method from the form's constructor or Load method. - + control by setting the , , and properties. The example populates the with controls and sets the to the property of the control. + + To run the example, paste the following code in a form containing a named `CheckedListBox1` and call the `InitializeCheckListBox` method from the form's constructor or Load method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox+ObjectCollection/Add/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PropertyGridExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1960,13 +1960,13 @@ The property should not be o if the class should be used to perform text rendering for compatibility with versions 1.0 and 1.1. of the .NET Framework; otherwise, . The default is . - class and .NET Framework 1.0 and .NET Framework 1.1 applications that perform custom text rendering using the class. In most cases, if your application is not being upgraded from .NET Framework 1.0 or .NET Framework 1.1, it is recommended that you leave `UseCompatibleTextRendering` set to the default value of `false`. - - The GDI based class was introduced in the .NET Framework 2.0 to improve performance, make text look better, and improve support for international fonts. In earlier versions of the .NET Framework, the GDI+ based class was used to perform all text rendering. GDI calculates character spacing and word wrapping differently from GDI+. In a Windows Forms application that uses the class to render text, this could cause the text for controls that use to appear different from the other text in the application. To resolve this incompatibility, you can set the `UseCompatibleTextRendering` property to `true` for a specific control. To set `UseCompatibleTextRendering` to `true` for all supported controls in the application, call the method with a parameter of `true`. - + class and .NET Framework 1.0 and .NET Framework 1.1 applications that perform custom text rendering using the class. In most cases, if your application is not being upgraded from .NET Framework 1.0 or .NET Framework 1.1, it is recommended that you leave `UseCompatibleTextRendering` set to the default value of `false`. + + The GDI based class was introduced in the .NET Framework 2.0 to improve performance, make text look better, and improve support for international fonts. In earlier versions of the .NET Framework, the GDI+ based class was used to perform all text rendering. GDI calculates character spacing and word wrapping differently from GDI+. In a Windows Forms application that uses the class to render text, this could cause the text for controls that use to appear different from the other text in the application. To resolve this incompatibility, you can set the `UseCompatibleTextRendering` property to `true` for a specific control. To set `UseCompatibleTextRendering` to `true` for all supported controls in the application, call the method with a parameter of `true`. + ]]> @@ -2010,15 +2010,15 @@ The property should not be o Gets or sets a string that specifies the property of the data source from which to draw the value. A string that specifies the property of the data source from which to draw the value. - property in cases where you bind data. - - You can clear the property by setting the property to an empty string ("") or `null`. - - Setting a new property raises the and events. - + property in cases where you bind data. + + You can clear the property by setting the property to an empty string ("") or `null`. + + Setting a new property raises the and events. + ]]> The specified property cannot be found on the object specified by the property. @@ -2129,16 +2129,16 @@ The property should not be o The Windows to process. Processes Windows messages. - method to handle operating system messages identified in the structure. The WM_ACTIVATEAPP operating system message is handled in this example to know when another application is becoming active. Refer to the Platform SDK documentation reference located at to understand the available , , and values. Actual constant values can be found in the Windows.h header file included in the Platform SDK (Core SDK section) download, which is also available at . -The following code example demonstrates overriding the method to handle operating system messages identified in the structure. The WM_ACTIVATEAPP operating system message is handled in this example to know when another application is becoming active. Refer to the Platform SDK documentation reference located at to understand the available , , and values. Actual constant values can be found in the Windows.h header file included in the Platform SDK (Core SDK section) download, which is also available at . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Control.WndProc/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox/WndProc/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Control.WndProc/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Control.WndProc/VB/form1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/Clipboard.xml b/xml/System.Windows.Forms/Clipboard.xml index 69bb3d691ca..3cd4ed3ba5c 100644 --- a/xml/System.Windows.Forms/Clipboard.xml +++ b/xml/System.Windows.Forms/Clipboard.xml @@ -34,48 +34,48 @@ Provides methods to place data on and retrieve data from the system Clipboard. This class cannot be inherited. - class, see the class. - - Call to put data on the Clipboard, replacing its current contents. To place a persistent copy of the data on the Clipboard, set the `copy` parameter to `true`. - + class, see the class. + + Call to put data on the Clipboard, replacing its current contents. To place a persistent copy of the data on the Clipboard, set the `copy` parameter to `true`. + > [!NOTE] -> To place data on the Clipboard in multiple formats, use the class or an implementation. Place data on the Clipboard in multiple formats to maximize the possibility that a target application, whose format requirements you might not know, can successfully retrieve the data. - - Call to retrieve data from the Clipboard. The data is returned as an object that implements the interface. Use the methods specified by and fields in to extract the data from the object. If you do not know the format of the data you retrieved, call the method of the interface to get a list of all formats that data is stored in. Then call the method of the interface, and specify a format that your application can use. - - In .NET Framework 2.0, the class provides additional methods that make it easier to work with the system Clipboard. Call the method to remove all data from the Clipboard. To add data of a particular format to the Clipboard, replacing the existing data, call the appropriate `Set`*Format* method, such as , or call the method to specify the format. To retrieve data of a particular format from the Clipboard, first call the appropriate `Contains`*Format* method (such as ) method to determine whether the Clipboard contains data in that format, and then call the appropriate `Get`*Format* method (such as ) to retrieve the data if the Clipboard contains it. To specify the format in these operations, call the and methods instead. - +> To place data on the Clipboard in multiple formats, use the class or an implementation. Place data on the Clipboard in multiple formats to maximize the possibility that a target application, whose format requirements you might not know, can successfully retrieve the data. + + Call to retrieve data from the Clipboard. The data is returned as an object that implements the interface. Use the methods specified by and fields in to extract the data from the object. If you do not know the format of the data you retrieved, call the method of the interface to get a list of all formats that data is stored in. Then call the method of the interface, and specify a format that your application can use. + + In .NET Framework 2.0, the class provides additional methods that make it easier to work with the system Clipboard. Call the method to remove all data from the Clipboard. To add data of a particular format to the Clipboard, replacing the existing data, call the appropriate `Set`*Format* method, such as , or call the method to specify the format. To retrieve data of a particular format from the Clipboard, first call the appropriate `Contains`*Format* method (such as ) method to determine whether the Clipboard contains data in that format, and then call the appropriate `Get`*Format* method (such as ) to retrieve the data if the Clipboard contains it. To specify the format in these operations, call the and methods instead. + > [!NOTE] -> All Windows-based applications share the system Clipboard, so the contents are subject to change when you switch to another application. -> -> An object must be serializable for it to be put on the Clipboard. If you pass a non-serializable object to a Clipboard method, the method will fail without throwing an exception. See for more information on serialization. If your target application requires a very specific data format, the headers added to the data in the serialization process may prevent the application from recognizing your data. To preserve your data format, add your data as a array to a and pass the to the method. -> -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. -> +> All Windows-based applications share the system Clipboard, so the contents are subject to change when you switch to another application. +> +> An object must be serializable for it to be put on the Clipboard. If you pass a non-serializable object to a Clipboard method, the method will fail without throwing an exception. See for more information on serialization. If your target application requires a very specific data format, the headers added to the data in the serialization process may prevent the application from recognizing your data. To preserve your data format, add your data as a array to a and pass the to the method. +> +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. +> > Special considerations may be necessary when using the metafile format with the Clipboard. Due to a limitation in the current implementation of the class, the metafile format used by the .NET Framework may not be recognized by applications that use an older metafile format. In this case, you must interoperate with the Win32 Clipboard application programming interfaces (APIs). - - - -## Examples - The following code example uses methods to place data on and retrieve it from the system Clipboard. This code assumes `button1`, `button2`, `textBox1`, and `textBox2` have been created and placed on the form. - - The `button1_Click` method calls to take selected text from the text box and place it on the system Clipboard. - - The `button2_Click` method calls to retrieve data from the system Clipboard. The code uses and to extract the data returned and displays the data in `textBox2`. - + + + +## Examples + The following code example uses methods to place data on and retrieve it from the system Clipboard. This code assumes `button1`, `button2`, `textBox1`, and `textBox2` have been created and placed on the form. + + The `button1_Click` method calls to take selected text from the text box and place it on the system Clipboard. + + The `button2_Click` method calls to retrieve data from the system Clipboard. The code uses and to extract the data returned and displays the data in `textBox2`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Clipboard Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic Clipboard Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic Clipboard Example/VB/source.vb" id="Snippet1"::: + ]]> - Additional Security Considerations in Windows Forms + Additional Security Considerations in Windows Forms @@ -104,22 +104,22 @@ Removes all data from the Clipboard. - [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet1"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -154,22 +154,22 @@ if there is audio data on the Clipboard; otherwise, . - method. - + method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following code example demonstrates the use of this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet20"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -211,26 +211,26 @@ if there is data on the Clipboard that is in the specified or can be converted to that format; otherwise, . - class contains pre-defined format names that you can use with this method. - - Use this method to determine whether the Clipboard contains data in the specified format or a compatible format before retrieving it with the method. - + class contains pre-defined format names that you can use with this method. + + Use this method to determine whether the Clipboard contains data in the specified format or a compatible format before retrieving it with the method. + > [!NOTE] -> Data can be converted to another format if it was stored specifying that conversion is allowed, and if the requested format is compatible with the stored format. For example, data stored as Unicode can be converted to text. -> -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> Data can be converted to another format if it was stored specifying that conversion is allowed, and if the requested format is compatible with the stored format. For example, data stored as Unicode can be converted to text. +> +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet10"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -268,24 +268,24 @@ if there is a file drop list on the Clipboard; otherwise, . - method. - + method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet30"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -323,22 +323,22 @@ if there is image data on the Clipboard; otherwise, . - method. - + method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet40"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet40"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet40"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -388,24 +388,24 @@ if there is text data on the Clipboard; otherwise, . - format on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 and Windows 2000. Otherwise, this method checks for the presence of data in the format. - - Use this method to determine whether the Clipboard contains text data before retrieving it with the method. - + format on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 and Windows 2000. Otherwise, this method checks for the presence of data in the format. + + Use this method to determine whether the Clipboard contains text data before retrieving it with the method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates an overload of the method that is similar to this overload. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates an overload of the method that is similar to this overload. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -448,22 +448,22 @@ if there is text data on the Clipboard in the value specified for ; otherwise, . - method. - + method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -503,24 +503,24 @@ Retrieves an audio stream from the Clipboard. A containing audio data or if the Clipboard does not contain any data in the format. - method to determine whether the Clipboard contains audio data before retrieving it with this method. - - Use the method to add audio data to the Clipboard. - + method to determine whether the Clipboard contains audio data before retrieving it with this method. + + Use the method to add audio data to the Clipboard. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet20"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -568,28 +568,28 @@ Retrieves data from the Clipboard in the specified format. An representing the Clipboard data or if the Clipboard does not contain any data that is in the specified or can be converted to that format. - method to determine whether the Clipboard contains data in the specified format or a compatible format before retrieving it with this method. - - If this method cannot find data in the specified format, it attempts to convert the data to the format. If the data cannot be converted to the specified format, or if the data was stored with automatic conversion set to `false`, this method returns `null`. - + method to determine whether the Clipboard contains data in the specified format or a compatible format before retrieving it with this method. + + If this method cannot find data in the specified format, it attempts to convert the data to the format. If the data cannot be converted to the specified format, or if the data was stored with automatic conversion set to `false`, this method returns `null`. + > [!NOTE] -> Data can be converted to another format if it was stored specifying that conversion is allowed, and if the requested format is compatible with the stored format. For example, data stored as Unicode can be converted to text. -> -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - Use the method to add data to the Clipboard in a particular format. - - - -## Examples - The following example demonstrates this member. - +> Data can be converted to another format if it was stored specifying that conversion is allowed, and if the requested format is compatible with the stored format. For example, data stored as Unicode can be converted to text. +> +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + Use the method to add data to the Clipboard in a particular format. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet10"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -629,29 +629,29 @@ Retrieves the data that is currently on the system Clipboard. An that represents the data currently on the Clipboard, or if there is no data on the Clipboard. - . Then you can use methods of the interface to extract the data in its proper data type. - - This method attempts to get the data ten times in 100-millisecond intervals, and throws an if all attempts are unsuccessful. - + . Then you can use methods of the interface to extract the data in its proper data type. + + This method attempts to get the data ten times in 100-millisecond intervals, and throws an if all attempts are unsuccessful. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following code example uses methods to place data on and retrieve it from the system Clipboard. This code assumes `button1`, `button2`, `textBox1`, and `textBox2` have been placed on the form. - - The `button1_Click` method calls to take selected text from the text box and place it on the system Clipboard. - - The `button2_Click` method calls to retrieve data from the system Clipboard. The code uses and to extract the data returned. The data is displayed in `textBox2`. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following code example uses methods to place data on and retrieve it from the system Clipboard. This code assumes `button1`, `button2`, `textBox1`, and `textBox2` have been placed on the form. + + The `button1_Click` method calls to take selected text from the text box and place it on the system Clipboard. + + The `button2_Click` method calls to retrieve data from the system Clipboard. The code uses and to extract the data returned. The data is displayed in `textBox2`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Clipboard Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic Clipboard Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic Clipboard Example/VB/source.vb" id="Snippet1"::: + ]]> Data could not be retrieved from the Clipboard. This typically occurs when the Clipboard is being used by another process. @@ -689,28 +689,28 @@ Retrieves a collection of file names from the Clipboard. A containing file names or if the Clipboard does not contain any data that is in the format or can be converted to that format. - array. This method converts this array to a and returns the collection. - - Use the method to determine whether the Clipboard contains a file drop list before retrieving it with this method. - - Use the method to add a file drop list to the Clipboard. - + array. This method converts this array to a and returns the collection. + + Use the method to determine whether the Clipboard contains a file drop list before retrieving it with this method. + + Use the method to add a file drop list to the Clipboard. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet30"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -749,24 +749,24 @@ Retrieves an image from the Clipboard. An representing the Clipboard image data or if the Clipboard does not contain any data that is in the format or can be converted to that format. - method to determine whether the Clipboard contains image data before retrieving it with this method. - - Use the method to add image data to the Clipboard. - + method to determine whether the Clipboard contains image data before retrieving it with this method. + + Use the method to add image data to the Clipboard. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet40"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet40"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet40"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -816,26 +816,26 @@ Retrieves text data from the Clipboard in the or format, depending on the operating system. The Clipboard text data or if the Clipboard does not contain data in the or format, depending on the operating system. - format on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 and Windows 2000. Otherwise, this method returns text data in the format. - - Use the method to determine whether the Clipboard contains text data before retrieving it with this method. - - Use the method to add text data to the Clipboard. - + format on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 and Windows 2000. Otherwise, this method returns text data in the format. + + Use the method to determine whether the Clipboard contains text data before retrieving it with this method. + + Use the method to add text data to the Clipboard. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates an overload of the method that is similar to this overload. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates an overload of the method that is similar to this overload. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -875,24 +875,24 @@ Retrieves text data from the Clipboard in the format indicated by the specified value. The Clipboard text data or if the Clipboard does not contain data in the specified format. - method to determine whether the Clipboard contains text data before retrieving it with this method. - - Use the method to add text data to the Clipboard. - + method to determine whether the Clipboard contains text data before retrieving it with this method. + + Use the method to add text data to the Clipboard. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -945,22 +945,22 @@ A array containing the audio data. Clears the Clipboard and then adds a array in the format after converting it to a . - method to determine whether the Clipboard contains audio data before retrieving it with the method. - + method to determine whether the Clipboard contains audio data before retrieving it with the method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates an overload of the method that is similar to this overload. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates an overload of the method that is similar to this overload. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet20"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -1001,22 +1001,22 @@ A containing the audio data. Clears the Clipboard and then adds a in the format. - method to determine whether the Clipboard contains audio data before retrieving it with the method. - + method to determine whether the Clipboard contains audio data before retrieving it with the method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet20"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -1059,26 +1059,26 @@ An representing the data to add. Clears the Clipboard and then adds data in the specified format. - method to determine whether the Clipboard contains data in that format before retrieving it with the method. - + method to determine whether the Clipboard contains data in that format before retrieving it with the method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet10"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -1176,27 +1176,27 @@ The data to place on the Clipboard. Clears the Clipboard and then places nonpersistent data on it. - if all attempts are unsuccessful. - + if all attempts are unsuccessful. + > [!NOTE] -> An object must be serializable for it to be put on the Clipboard. If you pass a non-serializable object to this method, it will fail without throwing an exception. See for more information on serialization. -> -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following code example uses to place nonpersistent text data onto the system Clipboard. In the `button1_Click` method, the selected text is copied from `textBox1` and pasted on the Clipboard. In the `button2_Click` method, the information is retrieved from the Clipboard and displayed in `textBox2`. This code assumes `button1`, `button2`, `textBox1`, and `textBox2` have been created and placed on a form. - +> An object must be serializable for it to be put on the Clipboard. If you pass a non-serializable object to this method, it will fail without throwing an exception. See for more information on serialization. +> +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following code example uses to place nonpersistent text data onto the system Clipboard. In the `button1_Click` method, the selected text is copied from `textBox1` and pasted on the Clipboard. In the `button2_Click` method, the information is retrieved from the Clipboard and displayed in `textBox2`. This code assumes `button1`, `button2`, `textBox1`, and `textBox2` have been created and placed on a form. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Clipboard Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic Clipboard Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic Clipboard Example/VB/source.vb" id="Snippet1"::: + ]]> Data could not be placed on the Clipboard. This typically occurs when the Clipboard is being used by another process. @@ -1247,33 +1247,33 @@ if you want data to remain on the Clipboard after this application exits; otherwise, . Clears the Clipboard and then places data on it and specifies whether the data should remain after the application exits. - if all attempts are unsuccessful. - + if all attempts are unsuccessful. + > [!NOTE] -> An object must be serializable for it to be put on the Clipboard. If you pass a non-serializable object to this method, it will fail without throwing an exception. See for more information on serialization. -> -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following method is run in an application. It places a persistent copy of the selected text data in the text box on the system Clipboard. This code assumes `button1`, `textBox1`, and `textBox2` have been created and placed on a form. - +> An object must be serializable for it to be put on the Clipboard. If you pass a non-serializable object to this method, it will fail without throwing an exception. See for more information on serialization. +> +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following method is run in an application. It places a persistent copy of the selected text data in the text box on the system Clipboard. This code assumes `button1`, `textBox1`, and `textBox2` have been created and placed on a form. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Clipboard.SetDataObject1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/SetDataObject/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic Clipboard.SetDataObject1 Example/VB/source.vb" id="Snippet1"::: - - In a different application, the following method retrieves the text from the system Clipboard and pastes the text into `textBox2`. This code assumes `button2` and `textBox2` have been created and placed on a form. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic Clipboard.SetDataObject1 Example/VB/source.vb" id="Snippet1"::: + + In a different application, the following method retrieves the text from the system Clipboard and pastes the text into `textBox2`. This code assumes `button2` and `textBox2` have been created and placed on a form. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic Clipboard.SetDataObject1 Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/SetDataObject/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic Clipboard.SetDataObject1 Example/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic Clipboard.SetDataObject1 Example/VB/source.vb" id="Snippet2"::: + ]]> Data could not be placed on the Clipboard. This typically occurs when the Clipboard is being used by another process. @@ -1321,28 +1321,28 @@ The number of milliseconds to pause between attempts. Clears the Clipboard and then attempts to place data on it the specified number of times and with the specified delay between attempts, optionally leaving the data on the Clipboard after the application exits. - [!NOTE] -> An object must be serializable for it to be put on the Clipboard. If you pass a non-serializable object to this method, it will fail without throwing an exception. See for more information on serialization. -> -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - +> An object must be serializable for it to be put on the Clipboard. If you pass a non-serializable object to this method, it will fail without throwing an exception. See for more information on serialization. +> +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + ]]> The current thread is not in single-threaded apartment (STA) mode. Add the to your application's method. is . - is less than zero. - - -or- - + is less than zero. + + -or- + is less than zero. Data could not be placed on the Clipboard. This typically occurs when the Clipboard is being used by another process. @@ -1380,26 +1380,26 @@ A containing the file names. Clears the Clipboard and then adds a collection of file names in the format. - array. This method converts `filePaths` to a array before adding it to the Clipboard. - - To retrieve a file drop list from the Clipboard, first use the method to determine whether the Clipboard contains data in that format before retrieving it with the method. - + array. This method converts `filePaths` to a array before adding it to the Clipboard. + + To retrieve a file drop list from the Clipboard, first use the method to determine whether the Clipboard contains data in that format before retrieving it with the method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet30"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -1407,12 +1407,12 @@ is . - does not contain any strings. - - -or- - - At least one of the strings in is , contains only white space, contains one or more invalid characters as defined by , is , contains a colon (:), or exceeds the system-defined maximum length. - + does not contain any strings. + + -or- + + At least one of the strings in is , contains only white space, contains one or more invalid characters as defined by , is , contains a colon (:), or exceeds the system-defined maximum length. + See the property of the for more information. @@ -1448,22 +1448,22 @@ The to add to the Clipboard. Clears the Clipboard and then adds an in the format. - method to determine whether the Clipboard contains image data before retrieving it with the method. - + method to determine whether the Clipboard contains image data before retrieving it with the method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet40"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet40"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet40"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -1516,24 +1516,24 @@ The text to add to the Clipboard. Clears the Clipboard and then adds text data in the or format, depending on the operating system. - format on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 and Windows 2000. Otherwise, this method adds text data in the format. - - To retrieve text data from the Clipboard, first use the method to determine whether the Clipboard contains text data before retrieving it with the method. - + format on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 and Windows 2000. Otherwise, this method adds text data in the format. + + To retrieve text data from the Clipboard, first use the method to determine whether the Clipboard contains text data before retrieving it with the method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates an overload of the method that is similar to this overload. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates an overload of the method that is similar to this overload. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. @@ -1576,22 +1576,22 @@ One of the values. Clears the Clipboard and then adds text data in the format indicated by the specified value. - method to determine whether the Clipboard contains text data before retrieving it with the method. - + method to determine whether the Clipboard contains text data before retrieving it with the method. + > [!NOTE] -> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. - - - -## Examples - The following example demonstrates this member. - +> The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. + + + +## Examples + The following example demonstrates this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Clipboard/Clear/form1.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Clipboard/vb/form1.vb" id="Snippet50"::: + ]]> The Clipboard could not be cleared. This typically occurs when the Clipboard is being used by another process. diff --git a/xml/System.Windows.Forms/ComboBoxRenderer.xml b/xml/System.Windows.Forms/ComboBoxRenderer.xml index 32671c32f15..91e2ad656ea 100644 --- a/xml/System.Windows.Forms/ComboBoxRenderer.xml +++ b/xml/System.Windows.Forms/ComboBoxRenderer.xml @@ -33,24 +33,24 @@ Provides methods used to render a combo box control with visual styles. This class cannot be inherited. - class provides a set of `static` methods that can be used to render a combo box control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a combo box, use the method to draw the text box and the method to draw the drop-down arrow. - - If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, and will draw the combo box with the current visual style. Otherwise, these methods will throw an . To determine whether the members of this class can be used, you can check the value of the property. - - This class wraps the functionality of a that is set to one of the elements exposed by the and classes. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - - - -## Examples - The following code example demonstrates how to create a custom control that uses the and methods to draw a combo box that responds to mouse clicks. - + class provides a set of `static` methods that can be used to render a combo box control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a combo box, use the method to draw the text box and the method to draw the drop-down arrow. + + If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, and will draw the combo box with the current visual style. Otherwise, these methods will throw an . To determine whether the members of this class can be used, you can check the value of the property. + + This class wraps the functionality of a that is set to one of the elements exposed by the and classes. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + + + +## Examples + The following code example demonstrates how to create a custom control that uses the and methods to draw a combo box that responds to mouse clicks. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/cpp/form1.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ComboBoxRenderer/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/VB/form1.vb" id="Snippet0"::: + ]]> @@ -90,30 +90,30 @@ One of the values that specifies the visual state of the drop-down arrow. Draws a drop-down arrow with the current visual style of the operating system. - property returns `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw a drop-down arrow in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw a drop-down arrow in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ComboBoxRenderer/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/VB/form1.vb" id="Snippet4"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -159,21 +159,21 @@ One of the values that specifies the visual state of the text box. Draws a text box in the specified state and bounds. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -228,21 +228,21 @@ One of the values that specifies the visual state of the text box. Draws a text box in the specified state and bounds, with the specified text. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -299,30 +299,30 @@ One of the values that specifies the visual state of the text box. Draws a text box in the specified state and bounds, with the specified text and text bounds. - property returns `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw a text box. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw a text box. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ComboBoxRenderer/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/VB/form1.vb" id="Snippet4"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -373,21 +373,21 @@ One of the values that specifies the visual state of the text box. Draws a text box in the specified state and bounds, with the specified text and text formatting. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -440,21 +440,21 @@ One of the values that specifies the visual state of the text box. Draws a text box in the specified state and bounds, with the specified text, text formatting, and text bounds. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -485,20 +485,20 @@ if the user has enabled visual styles in the operating system and visual styles are applied to the client area of application windows; otherwise, . - or methods will throw an . - - - -## Examples - The following code example uses the property to determine whether to use the methods. This code example is part of a larger example provided for the class. - + or methods will throw an . + + + +## Examples + The following code example uses the property to determine whether to use the methods. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ComboBoxRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/VB/form1.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Windows.Forms/ContainerControl.xml b/xml/System.Windows.Forms/ContainerControl.xml index 0a3e0938411..235b7915db7 100644 --- a/xml/System.Windows.Forms/ContainerControl.xml +++ b/xml/System.Windows.Forms/ContainerControl.xml @@ -42,18 +42,18 @@ Provides focus-management functionality for controls that can function as a container for other controls. - represents a control that can function as a container for other controls and provides focus management. Controls that inherit from this class can track the active control they contain, even when the focus moves somewhere within a different container. - - objects provide a logical boundary for contained controls. The container control can capture the TAB key press and move focus to the next control in the collection. - + represents a control that can function as a container for other controls and provides focus management. Controls that inherit from this class can track the active control they contain, even when the focus moves somewhere within a different container. + + objects provide a logical boundary for contained controls. The container control can capture the TAB key press and move focus to the next control in the collection. + > [!NOTE] -> The container control does not receive focus; the focus is always set to the first child control in the collection of contained controls. - - You do not typically inherit directly from the class. , , and classes inherit from . - +> The container control does not receive focus; the focus is always set to the first child control in the collection of contained controls. + + You do not typically inherit directly from the class. , , and classes inherit from . + ]]> @@ -86,15 +86,15 @@ Initializes a new instance of the class. - class and implements the interface. Implementation is added to the property and the method. - + class and implements the interface. Implementation is added to the property and the method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/IContainerControl Implementation/CPP/mycontainercontrol.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContainerControl/.ctor/mycontainercontrol.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/IContainerControl Implementation/VB/mycontainercontrol.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/IContainerControl Implementation/VB/mycontainercontrol.vb" id="Snippet1"::: + ]]> @@ -156,22 +156,22 @@ Gets or sets the active control on the container control. The that is currently active on the . - property activates or retrieves the active control on the container control. - - In order to receive a valid value from this property, the object that calls it must either contain or be contained in the control it is calling. If one form tries to call another form's properties, it will receive an undefined value. In this case, you need to define your own communication mechanism between the forms to pass this data. - - - -## Examples - The following code example inherits from the class and implements the interface. Implementation is added to the property and the method. - + property activates or retrieves the active control on the container control. + + In order to receive a valid value from this property, the object that calls it must either contain or be contained in the control it is calling. If one form tries to call another form's properties, it will receive an undefined value. In this case, you need to define your own communication mechanism between the forms to pass this data. + + + +## Examples + The following code example inherits from the class and implements the interface. Implementation is added to the property and the method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/IContainerControl Implementation/CPP/mycontainercontrol.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContainerControl/.ctor/mycontainercontrol.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/IContainerControl Implementation/VB/mycontainercontrol.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/IContainerControl Implementation/VB/mycontainercontrol.vb" id="Snippet1"::: + ]]> The assigned could not be activated. @@ -271,13 +271,13 @@ Gets or sets the dimensions that the control was designed to. A containing the dots per inch (DPI) or size that the control was designed to. - property represents the DPI or font setting of the screen that the control was scaled to or designed for. Specifically, at design time this property will be set by the Windows Forms designer to the value your monitor is currently using. Then, when the form loads at run time, if the property is different from the , the method will be called to perform scaling of the control and all of its children. Afterwards, will be updated to reflect the new scaling size. - - For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/framework/winforms/automatic-scaling-in-windows-forms). - + property represents the DPI or font setting of the screen that the control was scaled to or designed for. Specifically, at design time this property will be set by the Windows Forms designer to the value your monitor is currently using. Then, when the form loads at run time, if the property is different from the , the method will be called to perform scaling of the control and all of its children. Afterwards, will be updated to reflect the new scaling size. + + For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms). + ]]> The width or height of the value is less than 0 when setting this value. @@ -313,13 +313,13 @@ Gets the scaling factor between the current and design-time automatic scaling dimensions. A containing the scaling ratio between the current and design-time scaling automatic scaling dimensions. - property represents the scaling factor between the and properties. This value is calculated when it is required. For example, if is (192, 144) and is (96, 96) then the is (2.0, 1.5). - - For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/framework/winforms/automatic-scaling-in-windows-forms). - + property represents the scaling factor between the and properties. This value is calculated when it is required. For example, if is (192, 144) and is (96, 96) then the is (2.0, 1.5). + + For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms). + ]]> @@ -376,13 +376,13 @@ Gets or sets the automatic scaling mode of the control. An that represents the current scaling mode. The default is . - property specifies the current automatic scaling mode of this control. Scaling by is useful if you want to have a control or form stretch or shrink according to the size of the fonts in the operating system, and should be used when the absolute size of the control or form does not matter. Scaling by is useful when you want to size a control or form relative to the screen. For example, you may want to use dots per inch (DPI) scaling on a control displaying a chart or other graphic so that it always occupies a certain percentage of the screen. - - For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/framework/winforms/automatic-scaling-in-windows-forms). - + property specifies the current automatic scaling mode of this control. Scaling by is useful if you want to have a control or form stretch or shrink according to the size of the fonts in the operating system, and should be used when the absolute size of the control or form does not matter. Scaling by is useful when you want to size a control or form relative to the screen. For example, you may want to use dots per inch (DPI) scaling on a control displaying a chart or other graphic so that it always occupies a certain percentage of the screen. + + For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms). + ]]> An value that is not valid was used to set this property. @@ -432,21 +432,21 @@ Gets or sets a value that indicates whether controls in this container will be automatically validated when the focus changes. An enumerated value that indicates whether contained controls are implicitly validated on focus change. The default is . - will differ for each control. For more details on implicit validation, see [User Input Validation in Windows Forms](/dotnet/framework/winforms/user-input-validation-in-windows-forms). - - Setting this property to a new value will raise the event. - - - -## Examples - The following code example turns off implicit validation for a form and all of its contained controls, and instead manually performs validation of all of the form's children when a mouse button is clicked. - + will differ for each control. For more details on implicit validation, see [User Input Validation in Windows Forms](/dotnet/desktop/winforms/user-input-validation-in-windows-forms). + + Setting this property to a new value will raise the event. + + + +## Examples + The following code example turns off implicit validation for a form and all of its contained controls, and instead manually performs validation of all of the form's children when a mouse button is clicked. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/AutoValidate/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidateChildren/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidateChildren/VB/Form1.vb" id="Snippet1"::: + ]]> An value that is not valid was used to set this property. @@ -495,18 +495,18 @@ Occurs when the property changes. - - - - + + + + ]]> @@ -579,13 +579,13 @@ in all cases. - class can enable native IME support by overriding this property to return `true`. However, the application is then responsible for making sure that there are no conflicts between the native IME and the Windows Forms IME. This scenario is not supported. - + class can enable native IME support by overriding this property to return `true`. However, the application is then responsible for making sure that there are no conflicts between the native IME and the Windows Forms IME. This scenario is not supported. + ]]> @@ -655,21 +655,21 @@ Gets the current run-time dimensions of the screen. A containing the current dots per inch (DPI) or size of the screen. - property represents the reference dimensions on the current screen. In contrast, the property represents the design-time reference dimensions of the design environment for the current control, while the property is the ratio of the two. - - The interpretation of the dimension value depends on the property in the following ways: - -- If the mode is , this property represents the resolution of the screen, in dots per inch. - -- If the mode is , this property represents the average font character size in pixels. - - If the property is set to , is set equal to . - - For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/framework/winforms/automatic-scaling-in-windows-forms). - + property represents the reference dimensions on the current screen. In contrast, the property represents the design-time reference dimensions of the design environment for the current control, while the property is the ratio of the two. + + The interpretation of the dimension value depends on the property in the following ways: + +- If the mode is , this property represents the resolution of the screen, in dots per inch. + +- If the mode is , this property represents the average font character size in pixels. + + If the property is set to , is set equal to . + + For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms). + ]]> A Win32 device context could not be created for the current screen. @@ -742,13 +742,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -825,15 +825,15 @@ An that contains the event data. Raises the event. - will cause the layout to be recalculated and reapplied to the contained controls if the property has a value of . - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + will cause the layout to be recalculated and reapplied to the contained controls if the property has a value of . + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1007,19 +1007,19 @@ Gets the form that the container control is assigned to. The that the container control is assigned to. This property will return null if the control is hosted inside of Internet Explorer or in another hosting context where there is no parent form. - property of `Form1` to `true` and make it the of `Form2`. Next, create a button, `button1`, on each form. When the button on the parent form is clicked, the event handler displays the child form. When the button on the child form is clicked, the event handler displays the property of its parent form. Use the following two code segments to overwrite `button1` event handlers in both forms. - + property of `Form1` to `true` and make it the of `Form2`. Next, create a button, `button1`, on each form. When the button on the parent form is clicked, the event handler displays the child form. When the button on the child form is clicked, the event handler displays the property of its parent form. Use the following two code segments to overwrite `button1` event handlers in both forms. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ParentForm2/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContainerControl/ParentForm/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ParentForm2/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ParentForm2/VB/form1.vb" id="Snippet1"::: + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ParentForm2/CPP/form2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContainerControl/ParentForm/form2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ParentForm2/VB/form2.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ParentForm2/VB/form2.vb" id="Snippet2"::: + ]]> @@ -1057,15 +1057,15 @@ Performs scaling of the container control and its children. - method is typically only required after programmatic changes to the layout during run time. is implicitly called from the method. - - is recursive; each child control, if it is a container, will have its version of this method called when the container's version executes. - - For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/framework/winforms/automatic-scaling-in-windows-forms). - + method is typically only required after programmatic changes to the layout during run time. is implicitly called from the method. + + is recursive; each child control, if it is a container, will have its version of this method called when the container's version executes. + + For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms). + ]]> @@ -1258,11 +1258,11 @@ if a control is selected; otherwise, . - property set to `false` cannot be selected, so the next available control will be selected. - + property set to `false` cannot be selected, so the next available control will be selected. + ]]> @@ -1401,20 +1401,20 @@ if the control is successfully activated; otherwise, . - class and implement the interface. Implementation is added to the property and the method. - + class and implement the interface. Implementation is added to the property and the method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/IContainerControl Implementation/CPP/mycontainercontrol.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContainerControl/.ctor/mycontainercontrol.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/IContainerControl Implementation/VB/mycontainercontrol.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/IContainerControl Implementation/VB/mycontainercontrol.vb" id="Snippet1"::: + ]]> @@ -1447,11 +1447,11 @@ When overridden by a derived class, updates which button is the default button. - class does not provide an implementation for the method. Classes that inherit this method must implement to update the default button. - + class does not provide an implementation for the method. Classes that inherit this method must implement to update the default button. + ]]> @@ -1500,11 +1500,11 @@ if validation is successful; otherwise, . If called from the or event handlers, this method will always return . - method validates the last child control that is not validated and its ancestors up through, but not including, the current container control. This overloaded version always performs validation, regardless of the value of the property of the control's parent. Therefore use it to unconditionally force validation. - + method validates the last child control that is not validated and its ancestors up through, but not including, the current container control. This overloaded version always performs validation, regardless of the value of the property of the control's parent. Therefore use it to unconditionally force validation. + ]]> @@ -1543,15 +1543,15 @@ if validation is successful; otherwise, . If called from the or event handlers, this method will always return . - method validates the last child control that is not validated and its ancestors up through, but not including, the current container control. This overloaded version performs validation based on the following conditions: - -- If the `checkAutoValidate` parameter is `true`, validation always occurs for child controls that are not validated. - -- If the `checkAutoValidate` parameter is `false`, validation occurs only if the property of the control's parent is enabled. - + method validates the last child control that is not validated and its ancestors up through, but not including, the current container control. This overloaded version performs validation based on the following conditions: + +- If the `checkAutoValidate` parameter is `true`, validation always occurs for child controls that are not validated. + +- If the `checkAutoValidate` parameter is `false`, validation occurs only if the property of the control's parent is enabled. + ]]> @@ -1611,23 +1611,23 @@ if all of the children validated successfully; otherwise, . If called from the or event handlers, this method will always return . - will descend a control's hierarchy and examine each control to see if it supports validation. If the control can be selected by the user and its property is `true`, will cause the event to occur. If any of the controls cancel the event, this method will return `false`; otherwise, it will return `true`. - - If a control is bound to a data source, and the event occurs, it will cause the control to push its current data back to the data source. - - Calling is equivalent to calling with a of . - - - -## Examples - The following code example turns off implicit validation for a form and all of its contained controls, and instead manually performs validation of all of the form's children when a mouse button is clicked. - + will descend a control's hierarchy and examine each control to see if it supports validation. If the control can be selected by the user and its property is `true`, will cause the event to occur. If any of the controls cancel the event, this method will return `false`; otherwise, it will return `true`. + + If a control is bound to a data source, and the event occurs, it will cause the control to push its current data back to the data source. + + Calling is equivalent to calling with a of . + + + +## Examples + The following code example turns off implicit validation for a form and all of its contained controls, and instead manually performs validation of all of the form's children when a mouse button is clicked. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/AutoValidate/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidateChildren/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidateChildren/VB/Form1.vb" id="Snippet1"::: + ]]> @@ -1673,27 +1673,27 @@ if all of the children validated successfully; otherwise, . If called from the or event handlers, this method will always return . - will examine all the children of the current control, causing the event to occur on a control if it meets the criteria spelled out by . - - You may use several parameters at once by combining them with a bitwise OR operator. Combining parameters with a bitwise OR operator will result in a logical AND operation. For example, calling `ValidateChildren(ValidationConstraints.ImmediateChildren | ValidationConstraints.Enabled)` will only raise the event on controls that are both immediate children of the container AND are enabled. - - Regardless of which parameters you specify for this method, a control must have its property set to `true` in order for its event to occur. You should also set the property of the control or of the control's container to `false` if you want validation to happen only when you call , and not when the user shifts focus from the control. - - If a control is bound to a data source, and the event occurs, it will cause the control to push its current data back to the data source. - - You cannot achieve the opposite effect of a parameter by applying a bitwise negation operator. For example, if you supply the negative value of the field to , it will not validate all children that are not visible on the container. Supplying any negative parameter to will have no effect on the container or its children. - - - -## Examples - The following code example will only cause the event to occur for immediate children of the form whose property is `true`. - + will examine all the children of the current control, causing the event to occur on a control if it meets the criteria spelled out by . + + You may use several parameters at once by combining them with a bitwise OR operator. Combining parameters with a bitwise OR operator will result in a logical AND operation. For example, calling `ValidateChildren(ValidationConstraints.ImmediateChildren | ValidationConstraints.Enabled)` will only raise the event on controls that are both immediate children of the container AND are enabled. + + Regardless of which parameters you specify for this method, a control must have its property set to `true` in order for its event to occur. You should also set the property of the control or of the control's container to `false` if you want validation to happen only when you call , and not when the user shifts focus from the control. + + If a control is bound to a data source, and the event occurs, it will cause the control to push its current data back to the data source. + + You cannot achieve the opposite effect of a parameter by applying a bitwise negation operator. For example, if you supply the negative value of the field to , it will not validate all children that are not visible on the container. Supplying any negative parameter to will have no effect on the container or its children. + + + +## Examples + The following code example will only cause the event to occur for immediate children of the form whose property is `true`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContainerControl/ValidateChildren/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidateChildrenWithConstraints/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidateChildrenWithConstraints/VB/Form1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/ContextMenuStrip.xml b/xml/System.Windows.Forms/ContextMenuStrip.xml index 652d1d9b1bb..35b6e395bd8 100644 --- a/xml/System.Windows.Forms/ContextMenuStrip.xml +++ b/xml/System.Windows.Forms/ContextMenuStrip.xml @@ -78,7 +78,7 @@ - ContextMenuStrip Control + ContextMenuStrip Control diff --git a/xml/System.Windows.Forms/Control.xml b/xml/System.Windows.Forms/Control.xml index 76b850351fd..0f84babdd1b 100644 --- a/xml/System.Windows.Forms/Control.xml +++ b/xml/System.Windows.Forms/Control.xml @@ -108,7 +108,7 @@ , classes, or from the other Windows Forms provided controls. For more information about authoring custom controls, see [Developing Custom Windows Forms Controls with the .NET Framework](/dotnet/framework/winforms/controls/developing-custom-windows-forms-controls). + To create your own control class, inherit from the , classes, or from the other Windows Forms provided controls. For more information about authoring custom controls, see [Developing Custom Windows Forms Controls with the .NET Framework](/dotnet/desktop/winforms/controls/developing-custom-windows-forms-controls). The class implements very basic functionality required by classes that display information to the user. It handles user input through the keyboard and pointing devices. It handles message routing and security. It defines the bounds of a control (its position and size), although it does not implement painting. It provides a window handle (`hWnd`). @@ -129,7 +129,7 @@ To identify Windows Forms controls from a separate process, use a standard `SendMessage` call to pass the WM_GETCONTROLNAME message. WM_GETCONTROLNAME is independent of the language and Windows hierarchy. For more information, see the "Recommended Solution for Windows Forms" topic in [Automating Windows Forms](https://learn.microsoft.com/previous-versions/dotnet/articles/ms996405(v=msdn.10)). - Use the property to synchronize access to the control from multiple threads. For more information about multithreaded Windows Forms controls, see [How to: Make Thread-Safe Calls to Windows Forms Controls](/dotnet/framework/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls). + Use the property to synchronize access to the control from multiple threads. For more information about multithreaded Windows Forms controls, see [How to: Make Thread-Safe Calls to Windows Forms Controls](/dotnet/desktop/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls). ]]> @@ -2625,7 +2625,7 @@ The following table lists Windows Forms controls and which event ( and properties represent the width and height of the client area of the control. You can use this property to obtain the size of the client area of the control for tasks such as drawing on the surface of the control. - For more information about drawing on controls, see [Rendering a Windows Forms Control](/dotnet/framework/winforms/controls/rendering-a-windows-forms-control). + For more information about drawing on controls, see [Rendering a Windows Forms Control](/dotnet/desktop/winforms/controls/rendering-a-windows-forms-control). > [!NOTE] -> You cannot bind application settings to this property. For more information on application settings, see [Application Settings Overview](/dotnet/framework/winforms/advanced/application-settings-overview). +> You cannot bind application settings to this property. For more information on application settings, see [Application Settings Overview](/dotnet/desktop/winforms/advanced/application-settings-overview). @@ -9026,7 +9026,7 @@ MyControl.Font = New Font(MyControl.Font, _ > [!NOTE] > An exception might be thrown if the thread that should process the message is no longer active. - For more information about multithreaded Windows Forms controls, see [How to: Use a Background Thread to Search for Files](/dotnet/framework/winforms/controls/how-to-use-a-background-thread-to-search-for-files) and [How to: Make Thread-Safe Calls to Windows Forms Controls](/dotnet/framework/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls). + For more information about multithreaded Windows Forms controls, see [How to: Use a Background Thread to Search for Files](/dotnet/desktop/winforms/controls/how-to-use-a-background-thread-to-search-for-files) and [How to: Make Thread-Safe Calls to Windows Forms Controls](/dotnet/desktop/winforms/controls/how-to-make-thread-safe-calls-to-windows-forms-controls). ]]> @@ -16126,7 +16126,7 @@ MyControl.Font = New Font(MyControl.Font, _ ## Remarks The event is raised when the control is redrawn. It passes an instance of to the method(s) that handles the event. - When creating a new custom control or an inherited control with a different visual appearance, you must provide code to render the control by overriding the method. For more information, see [Overriding the OnPaint Method](/dotnet/framework/winforms/controls/overriding-the-onpaint-method) and [Custom Control Painting and Rendering](/dotnet/framework/winforms/controls/custom-control-painting-and-rendering). + When creating a new custom control or an inherited control with a different visual appearance, you must provide code to render the control by overriding the method. For more information, see [Overriding the OnPaint Method](/dotnet/desktop/winforms/controls/overriding-the-onpaint-method) and [Custom Control Painting and Rendering](/dotnet/desktop/winforms/controls/custom-control-painting-and-rendering). For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). @@ -19968,7 +19968,7 @@ The following code example selects the specified When overriding in a derived class, be sure to call the base class's method so that the property is adjusted. - For more information about drawing on controls, see Rendering a Windows Forms Control. + For more information about drawing on controls, see Rendering a Windows Forms Control. diff --git a/xml/System.Windows.Forms/DataGrid.xml b/xml/System.Windows.Forms/DataGrid.xml index adf9e2eb6ce..de02c14693b 100644 --- a/xml/System.Windows.Forms/DataGrid.xml +++ b/xml/System.Windows.Forms/DataGrid.xml @@ -71,115 +71,115 @@ Displays ADO.NET data in a scrollable grid. - + This class is not available in .NET Core 3.1 and later versions. Use the control instead, which replaces and extends the control. - control instead. - The displays Web-like links to child tables. You can click on a link to navigate to the child table. When a child table is displayed, a back button appears in the caption that can be clicked to navigate back to the parent table. The data from the parent rows is displayed below the caption and above the column headers. You can hide the parent row information by clicking the button to the right of the back button. - - To display a table in the at run time, use the method to set the and properties to a valid data source. The following data sources are valid: - -- A - -- A - -- A - -- A - -- A single dimension array - -- Any component that implements the interface - -- Any component that implements the interface - - For more information about the class, see [DataSets, DataTables, and DataViews](/dotnet/framework/data/adonet/dataset-datatable-dataview/). - - You can create a grid that enables users to edit data but prevents them from adding new rows by using a as the data source and setting the property to `false`. - - Data sources are further managed by objects. For each table in a data source, a can be returned from the form's . For example, you can determine the number of rows contained by a data source by returning the associated object's property. - - To validate data, use the underlying objects that represent data and their events. For example, if the data comes from a in a , use the and events. - + The displays Web-like links to child tables. You can click on a link to navigate to the child table. When a child table is displayed, a back button appears in the caption that can be clicked to navigate back to the parent table. The data from the parent rows is displayed below the caption and above the column headers. You can hide the parent row information by clicking the button to the right of the back button. + + To display a table in the at run time, use the method to set the and properties to a valid data source. The following data sources are valid: + +- A + +- A + +- A + +- A + +- A single dimension array + +- Any component that implements the interface + +- Any component that implements the interface + + For more information about the class, see [DataSets, DataTables, and DataViews](/dotnet/framework/data/adonet/dataset-datatable-dataview/). + + You can create a grid that enables users to edit data but prevents them from adding new rows by using a as the data source and setting the property to `false`. + + Data sources are further managed by objects. For each table in a data source, a can be returned from the form's . For example, you can determine the number of rows contained by a data source by returning the associated object's property. + + To validate data, use the underlying objects that represent data and their events. For example, if the data comes from a in a , use the and events. + > [!NOTE] -> Because the number of columns can be customized (by adding or deleting members of the ) and the rows can be sorted by column, the and property values cannot be guaranteed to correspond to and indexes in a . Therefore you should avoid using those properties in the event to validate data. - - To determine which cell is selected, use the property. Change the value of any cell by using the property, which can take either the row and column indexes of the cell, or a single . Monitor the event to detect when the user selects another cell. - - To determine which part of the control the user clicked, use the method in the event. The method returns a object, which contains the row and column of a clicked area. - - To manage the appearance of the control at run time, several properties for setting the color and caption attributes are available, including the , , , and so on. - - The appearance of the displayed grid (or grids) can be further modified by creating objects and adding them to the , which is accessed through the property. For example, if the is set to a containing three objects, you can add three objects to the collection, one for each table. To synchronize each object with a , set the of the to the of the . For more information about binding to an array of objects, see the property. - - To create a customized view of a table, create an instance of a or class and add the object to the accessed through the property. Both classes inherit from . For each column style, set the to the of a column that you want to show in the grid. To hide a column, set its to something other than a valid . - - To format the text of a column, set the property of the to one of the values found in [Formatting Types](/dotnet/standard/base-types/formatting-types) and [Custom Date and Time Format Strings](/dotnet/standard/base-types/custom-date-and-time-format-strings). - - To bind the to a strongly typed array of objects, the object type must contain public properties. To create a that displays the array, set the property to `typename[]` where `typename` is replaced by the name of the object type. Also note that the property is case-sensitive; the type name must be matched exactly. See the property for an example. - - You can also bind the to an . A feature of the is that it can contain objects of multiple types, but the can only bind to such a list when all items in the list are of the same type as the first item. This means that all objects must either be of the same type, or they must inherit from the same class as the first item in the list. For example, if the first item in a list is a , the second item could be a (which inherits from ). If, on the other hand, the first item is a , the second object cannot be a . Further, the must have items in it when it is bound. An empty will result in an empty grid. In addition, the objects in the must contain public properties. When binding to an , set the of the to "ArrayList" (the type name). - - For each , you can set color and caption attributes that override the settings for the control. However, if those properties are not set, the settings for the control are used by default. The following properties can be overridden by properties: - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - - To customize the appearance of individual columns, add objects to the , which is accessed through the property of each . To synchronize each with a in the , set the to the of a . When constructing a , you can also set a formatting string that specifies how the column displays data. For example, you can specify that the column use a short-date format to display dates contained in the table. - +> Because the number of columns can be customized (by adding or deleting members of the ) and the rows can be sorted by column, the and property values cannot be guaranteed to correspond to and indexes in a . Therefore you should avoid using those properties in the event to validate data. + + To determine which cell is selected, use the property. Change the value of any cell by using the property, which can take either the row and column indexes of the cell, or a single . Monitor the event to detect when the user selects another cell. + + To determine which part of the control the user clicked, use the method in the event. The method returns a object, which contains the row and column of a clicked area. + + To manage the appearance of the control at run time, several properties for setting the color and caption attributes are available, including the , , , and so on. + + The appearance of the displayed grid (or grids) can be further modified by creating objects and adding them to the , which is accessed through the property. For example, if the is set to a containing three objects, you can add three objects to the collection, one for each table. To synchronize each object with a , set the of the to the of the . For more information about binding to an array of objects, see the property. + + To create a customized view of a table, create an instance of a or class and add the object to the accessed through the property. Both classes inherit from . For each column style, set the to the of a column that you want to show in the grid. To hide a column, set its to something other than a valid . + + To format the text of a column, set the property of the to one of the values found in [Formatting Types](/dotnet/standard/base-types/formatting-types) and [Custom Date and Time Format Strings](/dotnet/standard/base-types/custom-date-and-time-format-strings). + + To bind the to a strongly typed array of objects, the object type must contain public properties. To create a that displays the array, set the property to `typename[]` where `typename` is replaced by the name of the object type. Also note that the property is case-sensitive; the type name must be matched exactly. See the property for an example. + + You can also bind the to an . A feature of the is that it can contain objects of multiple types, but the can only bind to such a list when all items in the list are of the same type as the first item. This means that all objects must either be of the same type, or they must inherit from the same class as the first item in the list. For example, if the first item in a list is a , the second item could be a (which inherits from ). If, on the other hand, the first item is a , the second object cannot be a . Further, the must have items in it when it is bound. An empty will result in an empty grid. In addition, the objects in the must contain public properties. When binding to an , set the of the to "ArrayList" (the type name). + + For each , you can set color and caption attributes that override the settings for the control. However, if those properties are not set, the settings for the control are used by default. The following properties can be overridden by properties: + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + + To customize the appearance of individual columns, add objects to the , which is accessed through the property of each . To synchronize each with a in the , set the to the of a . When constructing a , you can also set a formatting string that specifies how the column displays data. For example, you can specify that the column use a short-date format to display dates contained in the table. + > [!CAUTION] -> Always create objects and add them to the before adding objects to the . When you add an empty with a valid value to the collection, objects are automatically generated for you. Consequently, an exception will be thrown if you try to add new objects with duplicate values to the . - +> Always create objects and add them to the before adding objects to the . When you add an empty with a valid value to the collection, objects are automatically generated for you. Consequently, an exception will be thrown if you try to add new objects with duplicate values to the . + > [!NOTE] -> The control replaces and adds functionality to the control; however, the control is retained for both backward compatibility and future use, if you choose. For more information, see [Differences Between the Windows Forms DataGridView and DataGrid Controls](/dotnet/framework/winforms/controls/differences-between-the-windows-forms-datagridview-and-datagrid-controls). - - - -## Examples - The following code example creates a Windows form, a containing two objects, and a that relates the two tables. To display the data, a control is then bound to the through the method. A button on the form changes the appearance of the grid by creating two objects and setting the of each object to a of one of the objects. The example also contains code in the event that uses the method to print the column, row, and part of the grid that has been clicked. - +> The control replaces and adds functionality to the control; however, the control is retained for both backward compatibility and future use, if you choose. For more information, see [Differences Between the Windows Forms DataGridView and DataGrid Controls](/dotnet/desktop/winforms/controls/differences-between-the-windows-forms-datagridview-and-datagrid-controls). + + + +## Examples + The following code example creates a Windows form, a containing two objects, and a that relates the two tables. To display the data, a control is then bound to the through the method. A button on the form changes the appearance of the grid by creating two objects and setting the of each object to a of one of the objects. The example also contains code in the event that uses the method to print the column, row, and part of the grid that has been clicked. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -207,18 +207,18 @@ This class is not available in .NET Core 3.1 and later versions. Use the Initializes a new instance of the class. - control, set the property to a valid source, such as a , , or . - - - -## Examples - The following code example creates a new and uses the method to set the and properties. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.DataGrid Example/VB/source.vb" id="Snippet1"::: - + control, set the property to a valid source, such as a , , or . + + + +## Examples + The following code example creates a new and uses the method to set the and properties. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.DataGrid Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -258,20 +258,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the if navigation is allowed; otherwise, . The default is . - property between the `true` and `false`. - + property between the `true` and `false`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_AllowNavigationChanged/CPP/mydatagrid_allownavigationchanged.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/AllowNavigation/mydatagrid_allownavigationchanged.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_AllowNavigationChanged/VB/mydatagrid_allownavigationchanged.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_AllowNavigationChanged/VB/mydatagrid_allownavigationchanged.vb" id="Snippet1"::: + ]]> @@ -297,20 +297,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the property has changed. - property is set to `false`, then no links to child tables are shown. - - - -## Examples - The following code example resets the property and raises the event. - + property is set to `false`, then no links to child tables are shown. + + + +## Examples + The following code example resets the property and raises the event. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_AllowNavigationChanged/CPP/mydatagrid_allownavigationchanged.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/AllowNavigation/mydatagrid_allownavigationchanged.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_AllowNavigationChanged/VB/mydatagrid_allownavigationchanged.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_AllowNavigationChanged/VB/mydatagrid_allownavigationchanged.vb" id="Snippet1"::: + ]]> @@ -344,26 +344,26 @@ This class is not available in .NET Core 3.1 and later versions. Use the if columns can be sorted; otherwise, . - property if there is a currently in effect for the control. - - If sorting is allowed, clicking on a column header will sort the table data by that column. - - You can also sort using an expression for a . See for details on creating a sort expression. - - If the is bound to a , you can set a custom sort for the table using the class's property. Similarly, if the is bound to a , each table in the can have a custom sort by setting the class's property. - - - -## Examples - The following code example toggles the property. - + property if there is a currently in effect for the control. + + If sorting is allowed, clicking on a column header will sort the table data by that column. + + You can also sort using an expression for a . See for details on creating a sort expression. + + If the is bound to a , you can set a custom sort for the table using the class's property. Similarly, if the is bound to a , each table in the can have a custom sort by setting the class's property. + + + +## Examples + The following code example toggles the property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.AllowSorting Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/AllowSorting/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.AllowSorting Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.AllowSorting Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -395,18 +395,18 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the background color of odd-numbered rows of the grid. A that represents the alternating background color. The default is the system color for windows (). - and the properties are set to the same color. Setting the property affects only even-numbered rows, while setting the affects only odd-numbered rows. - - - -## Examples - The following code example sets the to a value. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.AlternatingBackColor Example/VB/source.vb" id="Snippet1"::: - + and the properties are set to the same color. Setting the property affects only even-numbered rows, while setting the affects only odd-numbered rows. + + + +## Examples + The following code example sets the to a value. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.AlternatingBackColor Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -432,20 +432,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the button on a child table is clicked. - event. - + event. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_BackgroundColorChanged/CPP/mydatagrid_backgroundcolorchanged.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/BackButtonClick/mydatagrid_backgroundcolorchanged.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_BackgroundColorChanged/VB/mydatagrid_backgroundcolorchanged.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_BackgroundColorChanged/VB/mydatagrid_backgroundcolorchanged.vb" id="Snippet1"::: + ]]> @@ -472,22 +472,22 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the background color of even-numbered rows of the grid. A that represents the color of rows in the grid. The default is the system color for windows (). - property determines the color of rows in the grid, the determines the color of the nonrow area, which is only visible when the grid is scrolled to the bottom, or if only a few rows are contained in the grid. - - By default, both the and the properties are set to the same color. Setting the property affects only even-numbered rows, while setting the affects only odd-numbered rows. - - - -## Examples - The following code example sets both the and properties to different values. - + property determines the color of rows in the grid, the determines the color of the nonrow area, which is only visible when the grid is scrolled to the bottom, or if only a few rows are contained in the grid. + + By default, both the and the properties are set to the same color. Setting the property affects only even-numbered rows, while setting the affects only odd-numbered rows. + + + +## Examples + The following code example sets both the and properties to different values. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.BackColor Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/BackColor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.BackColor Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.BackColor Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -515,20 +515,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the color of the non-row area of the grid. A that represents the color of the grid's background. The default is the color. - determines the color of the nonrow area of the grid, which is only visible when no table is displayed by the , or if the grid is scrolled to the bottom, or if only a few rows are contained in the grid. - - - -## Examples - The following code example sets the , and properties. - + determines the color of the nonrow area of the grid, which is only visible when no table is displayed by the , or if the grid is scrolled to the bottom, or if only a few rows are contained in the grid. + + + +## Examples + The following code example sets the , and properties. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.BackgroundColor Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/BackgroundColor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.BackgroundColor Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.BackgroundColor Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -555,15 +555,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the has changed. - property value from yellow to red and raises the event. - + property value from yellow to red and raises the event. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_BackgroundColorChanged/CPP/mydatagrid_backgroundcolorchanged.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/BackButtonClick/mydatagrid_backgroundcolorchanged.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_BackgroundColorChanged/VB/mydatagrid_backgroundcolorchanged.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_BackgroundColorChanged/VB/mydatagrid_backgroundcolorchanged.vb" id="Snippet2"::: + ]]> @@ -633,11 +633,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the value of the property changes. - property is not meaningful for this control, although you can change its value and handle the event to detect the change. - + property is not meaningful for this control, although you can change its value and handle the event to detect the change. + ]]> @@ -705,11 +705,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the value of the property changes. - property is not meaningful for this control, although you can change its value and handle the event to detect the change. - + property is not meaningful for this control, although you can change its value and handle the event to detect the change. + ]]> @@ -746,20 +746,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the method is successful; otherwise, . - method will return `false`. - - - -## Examples - The following code example uses the method to test if editing is possible before changing a specified column and row. - + method will return `false`. + + + +## Examples + The following code example uses the method to test if editing is possible before changing a specified column and row. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.BeginEdit Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/BeginEdit/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.BeginEdit Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.BeginEdit Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -790,11 +790,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the Begins the initialization of a that is used on a form or used by another component. The initialization occurs at run time. - method ends the initialization. Using the and methods prevents the control from being used before it is fully initialized. - + method ends the initialization. Using the and methods prevents the control from being used before it is fully initialized. + ]]> @@ -836,13 +836,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the grid's border style. One of the enumeration values. The default is . - @@ -868,21 +868,21 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the has changed. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `DataGrid1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `DataGrid1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet194"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet194"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet194"::: + ]]> @@ -933,13 +933,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the background color of the caption area. A that represents the caption's background color. The default is color. - property of the control. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CaptionBackColor Example/VB/source.vb" id="Snippet1"::: - + property of the control. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CaptionBackColor Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -978,18 +978,18 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the font of the grid's caption. A that represents the caption's font. - encapsulates a Windows font and provides the methods for manipulating that font. - - - -## Examples - The following code example sets the caption's font using a object. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CaptionFont Example/VB/source.vb" id="Snippet1"::: - + encapsulates a Windows font and provides the methods for manipulating that font. + + + +## Examples + The following code example sets the caption's font using a object. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CaptionFont Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1018,13 +1018,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the foreground color of the caption area. A that represents the foreground color of the caption area. The default is . - property of the control. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CaptionForeColor Example/VB/source.vb" id="Snippet1"::: - + property of the control. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CaptionForeColor Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1063,15 +1063,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the text of the grid's window caption. A string to be displayed as the window caption of the grid. The default is an empty string (""). - . - + . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.CaptionText Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/CaptionText/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CaptionText Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CaptionText Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1109,18 +1109,18 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the caption is visible; otherwise, . The default is . - is `false`, the **Back** button, **ParentRow** button, and caption will not be seen. Because navigation is limited, links to child tables will also not be visible and will be set to `None`. - - - -## Examples - The following code example toggles the property. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CaptionVisible Example/VB/source.vb" id="Snippet1"::: - + is `false`, the **Back** button, **ParentRow** button, and caption will not be seen. Because navigation is limited, links to child tables will also not be visible and will be set to `None`. + + + +## Examples + The following code example toggles the property. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CaptionVisible Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1146,15 +1146,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the property has changed. - @@ -1190,18 +1190,18 @@ This class is not available in .NET Core 3.1 and later versions. Use the The number of the row to collapse. If set to -1, all rows are collapsed. Collapses child relations, if any exist for all rows, or for a specified row. - method to determine if a row is expanded. - - - -## Examples - The following code example collapses all rows in the control. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.Collapse Example/VB/source.vb" id="Snippet1"::: - + method to determine if a row is expanded. + + + +## Examples + The following code example collapses all rows in the control. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.Collapse Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1236,13 +1236,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the column headers are visible; otherwise, . The default is . - property. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ColumnHeadersVisible Example/VB/source.vb" id="Snippet1"::: - + property. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ColumnHeadersVisible Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1286,11 +1286,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the The that defines the location of the edited column. Informs the control when the user begins to edit the column at the specified location. - method enables the control to show a pencil in the row header. - + method enables the control to show a pencil in the row header. + ]]> @@ -1320,11 +1320,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the The used to edit the column. Informs the control when the user begins to edit a column using the specified control. - method enables the control to show a pencil in the row header. - + method enables the control to show a pencil in the row header. + ]]> @@ -1351,21 +1351,21 @@ This class is not available in .NET Core 3.1 and later versions. Use the Constructs a new instance of the accessibility object for this control. The for this control. - method. - - Only the following properties of the should be set: - -- - -- - -- - - All other properties are handled by the itself. - + method. + + Only the following properties of the should be set: + +- + +- + +- + + All other properties are handled by the itself. + ]]> @@ -1473,20 +1473,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets which cell has the focus. Not available at design time. The with the focus. - property will cause the grid to scroll and show the cell if it is not already visible. - - - -## Examples - The following code example shows how to set and get the current cell. - + property will cause the grid to scroll and show the cell if it is not already visible. + + + +## Examples + The following code example shows how to set and get the current cell. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.CurrentCell Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/CurrentCell/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CurrentCell Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CurrentCell Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1514,20 +1514,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the property has changed. - property. - - - -## Examples - The following code example demonstrates the use of this member. - + property. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_CaptionVisibleChanged/CPP/mydatagrid_captionvisiblechanged.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/CaptionVisibleChanged/mydatagrid_captionvisiblechanged.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_CaptionVisibleChanged/VB/mydatagrid_captionvisiblechanged.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_CaptionVisibleChanged/VB/mydatagrid_captionvisiblechanged.vb" id="Snippet2"::: + ]]> @@ -1564,24 +1564,24 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets index of the row that currently has focus. The zero-based index of the current row. - property to a value other than its current value scrolls the control so that the specified row is in view. - - The property enables you to iterate through a parent table's rows even if you are viewing the child table rows. For example, if you are viewing a child table, incrementing the will cause the to display the next set of records in the child table that are linked to the parent table. - - If the user is viewing a parent table, or a table with no child relations, then the property returns the zero-based index of the current row. - - - -## Examples - The following code example returns the . - + property to a value other than its current value scrolls the control so that the specified row is in view. + + The property enables you to iterate through a parent table's rows even if you are viewing the child table rows. For example, if you are viewing a child table, incrementing the will cause the to display the next set of records in the child table that are linked to the parent table. + + If the user is viewing a parent table, or a table with no child relations, then the property returns the zero-based index of the current row. + + + +## Examples + The following code example returns the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.CurrentRowIndex Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/CurrentRowIndex/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CurrentRowIndex Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.CurrentRowIndex Example/VB/source.vb" id="Snippet1"::: + ]]> There is no . @@ -1653,11 +1653,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the value of the property changes. - property is not meaningful for this control, although you can change its value and handle the event to detect the change. - + property is not meaningful for this control, although you can change its value and handle the event to detect the change. + ]]> @@ -1706,27 +1706,27 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the specific list in a for which the control displays a grid. A list in a . The default is an empty string (""). - contains multiple sources of data, you should set the to one of the sources. For example, if the is a or that contains three tables named `Customers`, `Orders`, and `OrderDetails`, you must specify one of the tables to bind to. If the or contains only one , you should set the to the of that . - - If the is set to a that contains objects, parent tables will appear with a plus sign (+) in each row header. Clicking the plus sign causes a node to appear that contains links to child tables. For example, if a contains two objects named `Customers` and `Orders`, setting the to the `Customers` table causes the to display a parent table with a plus sign visible on each row header. If the is set to `Orders`, however, the row headers will be blank. - - If the is a , , collection, or array, setting the property throws an exception. - + contains multiple sources of data, you should set the to one of the sources. For example, if the is a or that contains three tables named `Customers`, `Orders`, and `OrderDetails`, you must specify one of the tables to bind to. If the or contains only one , you should set the to the of that . + + If the is set to a that contains objects, parent tables will appear with a plus sign (+) in each row header. Clicking the plus sign causes a node to appear that contains links to child tables. For example, if a contains two objects named `Customers` and `Orders`, setting the to the `Customers` table causes the to display a parent table with a plus sign visible on each row header. If the is set to `Orders`, however, the row headers will be blank. + + If the is a , , collection, or array, setting the property throws an exception. + > [!NOTE] -> At run time, you must use the method to reset the property. However, the property alone can be reset at any time to a valid table name. - - - -## Examples - The following code example sets the and properties of a control. - +> At run time, you must use the method to reset the property. However, the property alone can be reset at any time to a valid table name. + + + +## Examples + The following code example sets the and properties of a control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.DataMember Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/DataMember/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.DataMember Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.DataMember Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1779,46 +1779,46 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the data source that the grid is displaying data for. An object that functions as a data source. - method to set the and properties. - - The following data sources are valid: - -- A - -- A - -- A - -- A - -- Any component that implements the interface - -- Any component that implements the interface - - See the class overview for more information on data sources. - - If the reference contains more than one table, you must set the property a string that specifies the table to bind to. For example, if the is a or that contains three tables named `Customers`, `Orders`, and `OrderDetails`, you must specify the table to bind to. - - Setting the to an object that does not implement the interface or an will cause the grid to throw an exception. - - You can create a grid that enables users to edit data but prevents them from adding new rows by using a as the data source and setting the property to `false`. - - To bind the to a strongly typed array of objects, the object type must contain public properties. To create a that displays the array, set the property to `typename` where `typename` is replaced by the name of the object type. Also note that the property is case-sensitive; the type name must be matched exactly. See the property for an example. - - You can also bind the to an . A feature of the is that it can contain objects of multiple types, but the can only bind to such a list when all items in the list are of the same type as the first item. This means that all objects must either be of the same type, or they must inherit from the same class as the first item in the list. For example, if the first item in a list is a , the second item could be a (which inherits from ). If, on the other hand, the first item is a , the second object cannot be a . Further, the must have items in it when it is bound. An empty will result in an empty grid. In addition, the objects in the must contain public properties. When binding to an , set the of the to "ArrayList" (the type name). - - - -## Examples - The following code example shows how to set the , and when needed, the , to bind a to both a and a . The example also shows how to return data sources from the . - + method to set the and properties. + + The following data sources are valid: + +- A + +- A + +- A + +- A + +- Any component that implements the interface + +- Any component that implements the interface + + See the class overview for more information on data sources. + + If the reference contains more than one table, you must set the property a string that specifies the table to bind to. For example, if the is a or that contains three tables named `Customers`, `Orders`, and `OrderDetails`, you must specify the table to bind to. + + Setting the to an object that does not implement the interface or an will cause the grid to throw an exception. + + You can create a grid that enables users to edit data but prevents them from adding new rows by using a as the data source and setting the property to `false`. + + To bind the to a strongly typed array of objects, the object type must contain public properties. To create a that displays the array, set the property to `typename` where `typename` is replaced by the name of the object type. Also note that the property is case-sensitive; the type name must be matched exactly. See the property for an example. + + You can also bind the to an . A feature of the is that it can contain objects of multiple types, but the can only bind to such a list when all items in the list are of the same type as the first item. This means that all objects must either be of the same type, or they must inherit from the same class as the first item in the list. For example, if the first item in a list is a , the second item could be a (which inherits from ). If, on the other hand, the first item is a , the second object cannot be a . Further, the must have items in it when it is bound. An empty will result in an empty grid. In addition, the objects in the must contain public properties. When binding to an , set the of the to "ArrayList" (the type name). + + + +## Examples + The following code example shows how to set the , and when needed, the , to bind a to both a and a . The example also shows how to return data sources from the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.DataSource Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/DataSource/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.DataSource Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.DataSource Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1848,20 +1848,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the property value has changed. - event occurs when the value changes, or when the of the changes. - - - -## Examples - The following code example demonstrates the use of this member. - + event occurs when the value changes, or when the of the changes. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.DataSourceChanged Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/DataSourceChanged/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.DataSourceChanged Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.DataSourceChanged Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1917,18 +1917,18 @@ This class is not available in .NET Core 3.1 and later versions. Use the to release both managed and unmanaged resources; to release only unmanaged resources. Disposes of the resources (other than memory) used by the . - when you are finished using the . The method leaves the in an unusable state. After calling , you must release all references to the so the memory it was occupying can be reclaimed by garbage collection. - - - -## Examples - The following code example uses the method to free resources. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.Dispose Example/VB/source.vb" id="Snippet1"::: - + when you are finished using the . The method leaves the in an unusable state. After calling , you must release all references to the so the memory it was occupying can be reclaimed by garbage collection. + + + +## Examples + The following code example uses the method to free resources. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.Dispose Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1967,20 +1967,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the editing operation ceases; otherwise, . - method returns `false` if the user is not editing (typing into) a cell. - - - -## Examples - The following code example uses the and methods to edit a value in a grid displayed by the control. - + method returns `false` if the user is not editing (typing into) a cell. + + + +## Examples + The following code example uses the and methods to edit a value in a grid displayed by the control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.EndEdit Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/EndEdit/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.EndEdit Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.EndEdit Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2011,11 +2011,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the Ends the initialization of a that is used on a form or used by another component. The initialization occurs at run time. - method starts the initialization. Using the and methods prevents the control from being used before it is fully initialized. - + method starts the initialization. Using the and methods prevents the control from being used before it is fully initialized. + ]]> @@ -2052,13 +2052,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the The number of the row to expand. If set to -1, all rows are expanded. Displays child relations, if any exist, for all rows or a specific row. - @@ -2096,20 +2096,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets the index of the first visible column in a grid. The index of a . - property to the cell that should be visible. - - - -## Examples - The following code example scrolls the grid if the first visible column is greater than five. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.FirstVisibleColumn Example/VB/source.vb" id="Snippet1"::: - + property to the cell that should be visible. + + + +## Examples + The following code example scrolls the grid if the first visible column is greater than five. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.FirstVisibleColumn Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2144,15 +2144,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the grid is displayed flat; otherwise, . The default is . - property and notifies the user of its status. - + property and notifies the user of its status. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/MyDataGridClass_FlatMode_ReadOnly/CPP/mydatagridclass_flatmode_readonly.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/FlatMode/mydatagridclass_flatmode_readonly.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_FlatMode_ReadOnly/VB/mydatagridclass_flatmode_readonly.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_FlatMode_ReadOnly/VB/mydatagridclass_flatmode_readonly.vb" id="Snippet1"::: + ]]> @@ -2178,15 +2178,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the has changed. - @@ -2213,15 +2213,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the foreground color (typically the color of the text) property of the control. A that represents the foreground color. The default is color. - @@ -2261,15 +2261,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets the of the cell specified by . A that defines the current cell's corners. - method to return a of a specified cell. - + method to return a of a specified cell. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.GetCellBounds1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/GetCellBounds/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.GetCellBounds1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.GetCellBounds1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2303,20 +2303,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets the of the cell specified by row and column number. A that defines the current cell's corners. - . - - - -## Examples - The following code example uses the method to return a of a specified cell. - + . + + + +## Examples + The following code example uses the method to return a of a specified cell. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.GetCellBounds Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/GetCellBounds/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.GetCellBounds Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.GetCellBounds Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2346,20 +2346,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets a that specifies the four corners of the selected cell. A that defines the current cell's corners. - . - - - -## Examples - The following code example gets the of the selected cell. - + . + + + +## Examples + The following code example gets the of the selected cell. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.GetCurrentCellBounds Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/GetCurrentCellBounds/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.GetCurrentCellBounds Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.GetCurrentCellBounds Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2441,20 +2441,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the color of the grid lines. A that represents the color of the grid lines. The default is the system color for controls (). - property is set to `DataGridLineStyle.None`. - - - -## Examples - The following code example sets the color of the grid's lines using a value passed to the method. - + property is set to `DataGridLineStyle.None`. + + + +## Examples + The following code example sets the color of the grid's lines using a value passed to the method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.GridLineColor Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/GridLineColor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.GridLineColor Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.GridLineColor Example/VB/source.vb" id="Snippet1"::: + ]]> The value is not set. @@ -2493,13 +2493,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the line style of the grid. One of the values. The default is . - property to show no lines. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.GridLineStyle Example/VB/source.vb" id="Snippet1"::: - + property to show no lines. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.GridLineStyle Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2556,13 +2556,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the background color of all row and column headers. A that represents the background color of row and column headers. The default is the system color for controls, . - While trying to set the property, a was passed. @@ -2592,11 +2592,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the font used for column headers. The that represents the header text. - , or creating your own control incorporating the . - + , or creating your own control incorporating the . + ]]> @@ -2623,13 +2623,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the foreground color of headers. A that represents the foreground color of the grid's column headers, including the column header text and the plus/minus glyphs. The default is color. - @@ -2671,20 +2671,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets information, such as row and column number of a clicked point on the grid, about the grid using a specific . A that contains specific information about the grid. - , in conjunction with the method of the control, is used to determine which part of a control the user has clicked. The contains the row, column, and part of the grid that was clicked. Additionally, the property returns a enumeration. - - The method takes an x and y argument supplied by the control's , , , , , and events. - - - -## Examples - The following code example uses the method in occurs when a user clicks on a grid. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.HitTest1 Example/VB/source.vb" id="Snippet1"::: - + , in conjunction with the method of the control, is used to determine which part of a control the user has clicked. The contains the row, column, and part of the grid that was clicked. Additionally, the property returns a enumeration. + + The method takes an x and y argument supplied by the control's , , , , , and events. + + + +## Examples + The following code example uses the method in occurs when a user clicks on a grid. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.HitTest1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2718,20 +2718,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets information, such as row and column number of a clicked point on the grid, using the x and y coordinate passed to the method. A that contains information about the clicked part of the grid. - , in conjunction with the method of the control, is used to determine which part of a control the user has clicked. The contains the row, column, and part of the grid that was clicked. Additionally, the property returns a enumeration. - - The method takes an x and y argument supplied by the control's , , , , , and events. - - - -## Examples - The following code example uses the method in an event that occurs when the user clicks in the grid. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.HitTest Example/VB/source.vb" id="Snippet1"::: - + , in conjunction with the method of the control, is used to determine which part of a control the user has clicked. The contains the row, column, and part of the grid that was clicked. Additionally, the property returns a enumeration. + + The method takes an x and y argument supplied by the control's , , , , , and events. + + + +## Examples + The following code example uses the method in an event that occurs when the user clicks in the grid. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.HitTest Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2795,15 +2795,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the node is expanded; otherwise, . - @@ -2836,20 +2836,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the row is selected; otherwise, . - , , and methods to manipulate the selection state of a particular row. - - - -## Examples - The following code example demonstrates the use of this member. - + , , and methods to manipulate the selection state of a particular row. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/CPP/mydatagridclass_resetheaderbackcolor.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/IsSelected/mydatagridclass_resetheaderbackcolor.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/VB/mydatagridclass_resetheaderbackcolor.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/VB/mydatagridclass_resetheaderbackcolor.vb" id="Snippet5"::: + ]]> @@ -2889,20 +2889,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the value of a specified . The value, typed as , of the cell. - to the specified row. - - - -## Examples - The following code example sets and gets the value of a cell by declaring a variable, setting its and values, then first changing, then returning, the value of the given cell. - + to the specified row. + + + +## Examples + The following code example sets and gets the value of a cell by declaring a variable, setting its and values, then first changing, then returning, the value of the given cell. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.this1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/Item/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.this1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.this1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2937,24 +2937,24 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the value of the cell at the specified the row and column. The value, typed as , of the cell. - to the specified row. - - - -## Examples - The following code example prints the value contained by the cell at the specified row and index. - + to the specified row. + + + +## Examples + The following code example prints the value contained by the cell at the specified row and index. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.this Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/Item/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.this Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.this Example/VB/source.vb" id="Snippet1"::: + ]]> - While getting or setting, the is out of range. - + While getting or setting, the is out of range. + While getting or setting, the is out of range. @@ -2980,11 +2980,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the color of the text that you can click to navigate to a child table. A that represents the color of text that is clicked to navigate to a child table. The default is . - , or creating your own control incorporating the . - + , or creating your own control incorporating the . + ]]> @@ -3087,20 +3087,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the user navigates to a new table. - event to reset individual column properties, such as width, as appropriate to the table. - - - -## Examples - The following code example demonstrates the use of this member. - + event to reset individual column properties, such as width, as appropriate to the table. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_AllowNavigationChanged/CPP/mydatagrid_allownavigationchanged.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/AllowNavigation/mydatagrid_allownavigationchanged.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_AllowNavigationChanged/VB/mydatagrid_allownavigationchanged.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_AllowNavigationChanged/VB/mydatagrid_allownavigationchanged.vb" id="Snippet2"::: + ]]> @@ -3127,18 +3127,18 @@ This class is not available in .NET Core 3.1 and later versions. Use the Navigates back to the table previously displayed in the grid. - @@ -3170,14 +3170,14 @@ This class is not available in .NET Core 3.1 and later versions. Use the The name of the child relation to navigate to. Navigates to the table specified by row and relation name. - @@ -3263,13 +3263,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3328,13 +3328,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3448,13 +3448,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3539,13 +3539,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3577,13 +3577,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3615,13 +3615,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3653,13 +3653,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the An containing the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3691,13 +3691,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the A that provides data about the event. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3729,13 +3729,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the A that contains data about the event. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3767,13 +3767,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the A that contains the event data. Raises the event, which repositions controls and updates scroll bars. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3805,13 +3805,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3843,20 +3843,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the A that contains data about the event. Raises the event. - @@ -3888,11 +3888,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains data about the event. Creates the event. - @@ -3924,11 +3924,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the A that contains data about the event. Raises the event. - @@ -3960,11 +3960,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the A that contains data about the event. Raises the event. - @@ -3996,11 +3996,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the A that contains data about the event. Raises the event. - @@ -4059,11 +4059,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the A which contains data about the event. Raises the event. - @@ -4095,11 +4095,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the A that contains information about the control to paint. Overrides to prevent painting the background of the control. - is a complex control, this override is implemented to have no action. Therefore, calling this method will have no effect. - + is a complex control, this override is implemented to have no action. Therefore, calling this method will have no effect. + ]]> @@ -4129,13 +4129,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -4195,13 +4195,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -4233,11 +4233,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the An that contains the event data. Raises the event. - @@ -4350,13 +4350,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the background color of parent rows. A that represents the color of parent rows. The default is the color. - property to a new color. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ParentRowsBackColor Example/VB/source.vb" id="Snippet1"::: - + property to a new color. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ParentRowsBackColor Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -4383,13 +4383,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the foreground color of parent rows. A that represents the foreground color of parent rows. The default is the color. - property to a new color. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ParentRowsForeColor Example/VB/source.vb" id="Snippet1"::: - + property to a new color. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ParentRowsForeColor Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -4430,13 +4430,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the way parent row labels are displayed. One of the values. The default is . - property. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ParentRowsLabelStyle Example/VB/source.vb" id="Snippet1"::: - + property. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ParentRowsLabelStyle Example/VB/source.vb" id="Snippet1"::: + ]]> The enumerator was not valid. @@ -4467,15 +4467,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the label style of the parent row is changed. - @@ -4509,13 +4509,13 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the parent rows are visible; otherwise, . The default is . - property. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ParentRowsVisible Example/VB/source.vb" id="Snippet1"::: - + property. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ParentRowsVisible Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -4541,15 +4541,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the property value changes. - @@ -4590,20 +4590,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the default width of the grid columns in pixels. The default width (in pixels) of columns in the grid. - and properties (either separately, or through the method), or the property will have no effect. - - The property cannot be set to a value less than 0. - - - -## Examples - The following code example sets the default column widths to a value passed to the method. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.PreferredColumnWidth Example/VB/source.vb" id="Snippet1"::: - + and properties (either separately, or through the method), or the property will have no effect. + + The property cannot be set to a value less than 0. + + + +## Examples + The following code example sets the default column widths to a value passed to the method. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.PreferredColumnWidth Example/VB/source.vb" id="Snippet1"::: + ]]> The property value is less than 0. @@ -4639,20 +4639,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the preferred row height for the control. The height of a row. - and properties (either separately, or through the method), or the property will have no effect. - - - -## Examples - The following code example first sets a new font, and sets the to the same height as the new font. - + and properties (either separately, or through the method), or the property will have no effect. + + + +## Examples + The following code example first sets a new font, and sets the to the same height as the new font. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.PreferredRowHeight Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/PreferredRowHeight/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.PreferredRowHeight Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.PreferredRowHeight Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -4685,11 +4685,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the , the key should be processed; otherwise, . - method to implement keyboard navigation of the grid. - + method to implement keyboard navigation of the grid. + ]]> @@ -4749,11 +4749,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the , if the key was consumed; otherwise, . - @@ -4816,22 +4816,22 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the grid is in read-only mode; otherwise, . The default is . - also has a property that can be set to true to prevent data from being edited, on a column-by-column basis. - - The can be set to true if you want to prohibit the user from editing the data directly in the . For example, you might want to let users to see all columns in a table, but allow them to edit specific fields only through controls on a different form. - - - -## Examples - The following code example toggles the property. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ReadOnly Example/VB/source.vb" id="Snippet1"::: - + also has a property that can be set to true to prevent data from being edited, on a column-by-column basis. + + The can be set to true if you want to prohibit the user from editing the data directly in the . For example, you might want to let users to see all columns in a table, but allow them to edit specific fields only through controls on a different form. + + + +## Examples + The following code example toggles the property. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.ReadOnly Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -4858,15 +4858,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the property value changes. - @@ -4894,20 +4894,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default color. - or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_ColorMembers/CPP/datagrid_10.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/ForeColor/datagrid_10.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: + ]]> @@ -4934,20 +4934,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default value. - or creating your own control incorporating the . - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_ColorMembers/CPP/datagrid_10.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/ForeColor/datagrid_10.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: + ]]> @@ -4973,20 +4973,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default value. - or creating your own control incorporating the . - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_ColorMembers/CPP/datagrid_10.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/ForeColor/datagrid_10.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: + ]]> @@ -5019,20 +5019,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default value. - or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_ColorMembers/CPP/datagrid_10.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/ForeColor/datagrid_10.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: + ]]> @@ -5059,20 +5059,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default value. - or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/CPP/mydatagridclass_resetheaderbackcolor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/IsSelected/mydatagridclass_resetheaderbackcolor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/VB/mydatagridclass_resetheaderbackcolor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/VB/mydatagridclass_resetheaderbackcolor.vb" id="Snippet1"::: + ]]> @@ -5099,20 +5099,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default value. - or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/CPP/mydatagridclass_resetheaderbackcolor.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/IsSelected/mydatagridclass_resetheaderbackcolor.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/VB/mydatagridclass_resetheaderbackcolor.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/VB/mydatagridclass_resetheaderbackcolor.vb" id="Snippet3"::: + ]]> @@ -5139,20 +5139,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default value. - or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/CPP/mydatagridclass_resetheaderbackcolor.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/IsSelected/mydatagridclass_resetheaderbackcolor.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/VB/mydatagridclass_resetheaderbackcolor.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/VB/mydatagridclass_resetheaderbackcolor.vb" id="Snippet2"::: + ]]> @@ -5179,20 +5179,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default value. - or creating your own control incorporating the . - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_ColorMembers/CPP/datagrid_10.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/ForeColor/datagrid_10.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: + ]]> @@ -5219,11 +5219,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default value. - or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. - + or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. + ]]> @@ -5250,11 +5250,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the Turns off selection for all rows that are selected. - , , and methods to manipulate the selection state of a particular row. - + , , and methods to manipulate the selection state of a particular row. + ]]> @@ -5281,20 +5281,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default value. - or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_ColorMembers/CPP/datagrid_10.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/ForeColor/datagrid_10.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: + ]]> @@ -5321,20 +5321,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Resets the property to its default value. - or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . You can use the method to determine whether the property value has changed from its default. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_ColorMembers/CPP/datagrid_10.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/ForeColor/datagrid_10.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: + ]]> @@ -5429,15 +5429,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the width of row headers. The width of row headers in the . The default is 35. - @@ -5463,15 +5463,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the user scrolls the control. - @@ -5501,20 +5501,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the The index of the row to select. Selects a specified row. - , , and methods to manipulate the selection state of a particular row. - - - -## Examples - The following code example demonstrates the use of this member. - + , , and methods to manipulate the selection state of a particular row. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/CPP/mydatagridclass_resetheaderbackcolor.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/IsSelected/mydatagridclass_resetheaderbackcolor.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/VB/mydatagridclass_resetheaderbackcolor.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MyDataGridClass_ResetHeaderBackColor/VB/mydatagridclass_resetheaderbackcolor.vb" id="Snippet4"::: + ]]> @@ -5541,20 +5541,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or sets the background color of selected rows. A that represents the background color of selected rows. The default is the color. - or creating your own control incorporating the . - - - -## Examples - The following code example demonstrates the use of this member. - + or creating your own control incorporating the . + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_ColorMembers/CPP/datagrid_10.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/ForeColor/datagrid_10.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_ColorMembers/VB/datagrid_10.vb" id="Snippet2"::: + ]]> @@ -5581,15 +5581,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets or set the foreground color of selected rows. A representing the foreground color of selected rows. The default is the color. - @@ -5621,24 +5621,24 @@ This class is not available in .NET Core 3.1 and later versions. Use the The string that specifies the table to bind to within the object returned by the property. Sets the and properties at run time. - method at run time to reset the property. - - See the property for more details about setting a valid data source. - - You can create a grid that enables users to edit data but prevents them from adding new rows by using a as the data source and setting the property to `false`. When the is a or , set the to an empty string (""). - - - -## Examples - The following code example sets the and to a , and a in the , respectively. - + method at run time to reset the property. + + See the property for more details about setting a valid data source. + + You can create a grid that enables users to edit data but prevents them from adding new rows by using a as the data source and setting the property to `false`. When the is a or , set the to an empty string (""). + + + +## Examples + The following code example sets the and to a , and a in the , respectively. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.SetDataBinding Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/SetDataBinding/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.SetDataBinding Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.SetDataBinding Example/VB/source.vb" id="Snippet1"::: + ]]> One or more of the arguments are invalid. @@ -5673,11 +5673,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has changed from its default; otherwise, . - or creating your own control incorporating the . - + or creating your own control incorporating the . + ]]> @@ -5706,11 +5706,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has changed from its default; otherwise, . - or creating your own control incorporating the . - + or creating your own control incorporating the . + ]]> @@ -5739,11 +5739,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has been changed from its default; otherwise, . - , or creating your own control incorporating the . - + , or creating your own control incorporating the . + ]]> @@ -5772,11 +5772,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has been changed from its default; otherwise, . - , or creating your own control incorporating the . - + , or creating your own control incorporating the . + ]]> @@ -5805,11 +5805,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has changed from its default; otherwise, . - or creating your own control incorporating the . - + or creating your own control incorporating the . + ]]> @@ -5838,11 +5838,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has changed from its default; otherwise, . - or creating your own control incorporating the . - + or creating your own control incorporating the . + ]]> @@ -5871,11 +5871,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has changed from its default; otherwise, . - or creating your own control incorporating the . - + or creating your own control incorporating the . + ]]> @@ -5904,11 +5904,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has changed from its default; otherwise, . - or creating your own control incorporating the . - + or creating your own control incorporating the . + ]]> @@ -5937,11 +5937,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has changed from its default; otherwise, . - or creating your own control incorporating the . - + or creating your own control incorporating the . + ]]> @@ -5971,11 +5971,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has been changed from its default; otherwise, . - , or creating your own control incorporating the . - + , or creating your own control incorporating the . + ]]> @@ -6004,11 +6004,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has been changed from its default; otherwise, . - , or creating your own control incorporating the . - + , or creating your own control incorporating the . + ]]> @@ -6037,11 +6037,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has changed from its default; otherwise, . - or creating your own control incorporating the . - + or creating your own control incorporating the . + ]]> @@ -6070,11 +6070,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has changed from its default; otherwise, . - or creating your own control incorporating the . - + or creating your own control incorporating the . + ]]> @@ -6103,11 +6103,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the if the property value has changed from its default; otherwise, . - or creating your own control incorporating the . - + or creating your own control incorporating the . + ]]> @@ -6133,15 +6133,15 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the button is clicked. - @@ -6234,35 +6234,35 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets the collection of objects for the grid. A that represents the collection of objects. - retrieved through the property to create customized views of each table displayed by the control. - - By default, the collection returned by property does not contain any objects. To create a set of customized views: - -1. Create a . - -2. Set the of the grid table object to the of the . - -3. Add objects, one for each grid column you want to show, to the returned by the property. - -4. Set the of each to the of a . - -5. Add the object to the collection returned by property. - + retrieved through the property to create customized views of each table displayed by the control. + + By default, the collection returned by property does not contain any objects. To create a set of customized views: + +1. Create a . + +2. Set the of the grid table object to the of the . + +3. Add objects, one for each grid column you want to show, to the returned by the property. + +4. Set the of each to the of a . + +5. Add the object to the collection returned by property. + > [!CAUTION] -> Always create objects and add them to the before adding objects to the . When you add an empty with a valid value to the collection, objects are automatically generated for you. Consequently, an exception will be thrown if you try to add new objects with duplicate values to the . - - - -## Examples - The following code example creates one for each found in a , and sets the of the to the of the . The is then added to the returned by the property. The example also prints the of each in the returned by the property of each in the . - +> Always create objects and add them to the before adding objects to the . When you add an empty with a valid value to the collection, objects are automatically generated for you. Consequently, an exception will be thrown if you try to add new objects with duplicate values to the . + + + +## Examples + The following code example creates one for each found in a , and sets the of the to the of the . The is then added to the returned by the property. The example also prints the of each in the returned by the property of each in the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DataGrid.TableStyles Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/TableStyles/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.TableStyles Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.TableStyles Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -6344,11 +6344,11 @@ This class is not available in .NET Core 3.1 and later versions. Use the Occurs when the value of the property changes. - property is not meaningful for this control, although you can change its value and handle the event to detect the change. - + property is not meaningful for this control, although you can change its value and handle the event to detect the change. + ]]> @@ -6378,20 +6378,20 @@ This class is not available in .NET Core 3.1 and later versions. Use the The index of the row to deselect. Unselects a specified row. - , , and methods to manipulate the selection state of a particular row. - - - -## Examples - The following code example demonstrates the use of this member. - + , , and methods to manipulate the selection state of a particular row. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DataGrid_UnSelect/CPP/datagrid_unselect.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGrid/UnSelect/datagrid_unselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_UnSelect/VB/datagrid_unselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DataGrid_UnSelect/VB/datagrid_unselect.vb" id="Snippet1"::: + ]]> @@ -6463,18 +6463,18 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets the number of visible columns. The number of columns visible in the viewport. The viewport is the rectangular area through which the grid is visible. The size of the viewport depends on the size of the control; if you allow users to resize the control, the viewport will also be affected. - @@ -6513,18 +6513,18 @@ This class is not available in .NET Core 3.1 and later versions. Use the Gets the number of rows visible. The number of rows visible in the viewport. The viewport is the rectangular area through which the grid is visible. The size of the viewport depends on the size of the control; if you allow users to resize the control, the viewport will also be affected. - control. - - - -## Examples - The following code example returns the number of rows visible in a control. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.VisibleRowCount Example/VB/source.vb" id="Snippet1"::: - + control. + + + +## Examples + The following code example returns the number of rows visible in a control. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DataGrid.VisibleRowCount Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridView.xml b/xml/System.Windows.Forms/DataGridView.xml index 6081c52b00b..558c67049a6 100644 --- a/xml/System.Windows.Forms/DataGridView.xml +++ b/xml/System.Windows.Forms/DataGridView.xml @@ -72,37 +72,37 @@ control provides a customizable table for displaying data. The class allows customization of cells, rows, columns, and borders through the use of properties such as , , , and . For more information, see [Basic Formatting and Styling in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/basic-formatting-and-styling-in-the-windows-forms-datagridview-control). + The control provides a customizable table for displaying data. The class allows customization of cells, rows, columns, and borders through the use of properties such as , , , and . For more information, see [Basic Formatting and Styling in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/basic-formatting-and-styling-in-the-windows-forms-datagridview-control). You can use a control to display data with or without an underlying data source. Without specifying a data source, you can create columns and rows that contain data and add them directly to the using the and properties. You can also use the collection to access objects and the property to read or write cell values directly. The indexer also provides direct access to cells. - As an alternative to populating the control manually, you can set the and properties to bind the to a data source and automatically populate it with data. For more information, see [Displaying Data in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/displaying-data-in-the-windows-forms-datagridview-control). + As an alternative to populating the control manually, you can set the and properties to bind the to a data source and automatically populate it with data. For more information, see [Displaying Data in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/displaying-data-in-the-windows-forms-datagridview-control). - When working with very large amounts of data, you can set the property to `true` to display a subset of the available data. Virtual mode requires the implementation of a data cache from which the control is populated. For more information, see [Data Display Modes in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/data-display-modes-in-the-windows-forms-datagridview-control). + When working with very large amounts of data, you can set the property to `true` to display a subset of the available data. Virtual mode requires the implementation of a data cache from which the control is populated. For more information, see [Data Display Modes in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/data-display-modes-in-the-windows-forms-datagridview-control). - For additional information about the features available in the control, see [DataGridView Control](/dotnet/framework/winforms/controls/datagridview-control-windows-forms). The following table provides direct links to common tasks. + For additional information about the features available in the control, see [DataGridView Control](/dotnet/desktop/winforms/controls/datagridview-control-windows-forms). The following table provides direct links to common tasks. -- [How to: Bind Data to the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-bind-data-to-the-windows-forms-datagridview-control) +- [How to: Bind Data to the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-bind-data-to-the-windows-forms-datagridview-control) -- [How to: Add ToolTips to Individual Cells in a Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/add-tooltips-to-individual-cells-in-a-wf-datagridview-control) +- [How to: Add ToolTips to Individual Cells in a Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/add-tooltips-to-individual-cells-in-a-wf-datagridview-control) -- [How to: Set Font and Color Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-set-font-and-color-styles-in-the-windows-forms-datagridview-control) +- [How to: Set Font and Color Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-set-font-and-color-styles-in-the-windows-forms-datagridview-control) -- [How to: Change the Type of a Windows Forms DataGridView Column Using the Designer](/dotnet/framework/winforms/controls/change-the-type-of-a-wf-datagridview-column-using-the-designer) +- [How to: Change the Type of a Windows Forms DataGridView Column Using the Designer](/dotnet/desktop/winforms/controls/change-the-type-of-a-wf-datagridview-column-using-the-designer) -- [How to: Bind Data to the Windows Forms DataGridView Control Using the Designer](/dotnet/framework/winforms/controls/bind-data-to-the-datagrid-using-the-designer) +- [How to: Bind Data to the Windows Forms DataGridView Control Using the Designer](/dotnet/desktop/winforms/controls/bind-data-to-the-datagrid-using-the-designer) -- [How to: Set Default Cell Styles and Data Formats for the Windows Forms DataGridView Control Using the Designer](/dotnet/framework/winforms/controls/default-cell-styles-datagridview) +- [How to: Set Default Cell Styles and Data Formats for the Windows Forms DataGridView Control Using the Designer](/dotnet/desktop/winforms/controls/default-cell-styles-datagridview) -- [How to: Format Data in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-format-data-in-the-windows-forms-datagridview-control) +- [How to: Format Data in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-format-data-in-the-windows-forms-datagridview-control) -- [Walkthrough: Validating Data in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/walkthrough-validating-data-in-the-windows-forms-datagridview-control) +- [Walkthrough: Validating Data in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/walkthrough-validating-data-in-the-windows-forms-datagridview-control) -- [How to: Customize Data Formatting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-data-formatting-in-the-windows-forms-datagridview-control) +- [How to: Customize Data Formatting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-data-formatting-in-the-windows-forms-datagridview-control) -- [Walkthrough: Creating a Master/Detail Form Using Two Windows Forms DataGridView Controls](/dotnet/framework/winforms/controls/creating-a-master-detail-form-using-two-datagridviews) +- [Walkthrough: Creating a Master/Detail Form Using Two Windows Forms DataGridView Controls](/dotnet/desktop/winforms/controls/creating-a-master-detail-form-using-two-datagridviews) -The control replaces and extends the control. For more information, see [Differences Between the Windows Forms DataGridView and DataGrid controls](/dotnet/framework/winforms/controls/differences-between-the-windows-forms-datagridview-and-datagrid-controls). +The control replaces and extends the control. For more information, see [Differences Between the Windows Forms DataGridView and DataGrid controls](/dotnet/desktop/winforms/controls/differences-between-the-windows-forms-datagridview-and-datagrid-controls). > [!NOTE] > The control inherits both the and properties from , but supports only the property. Using the property with the control has no effect. @@ -115,12 +115,12 @@ The control replaces and extends the - DataGridView Control (Windows Forms) - DataGridView Control Overview (Windows Forms) - Basic Formatting and Styling in the Windows Forms DataGridView Control - Displaying Data in the Windows Forms DataGridView Control - Data Display Modes in the Windows Forms DataGridView Control - Differences Between the Windows Forms DataGridView and DataGrid Controls + DataGridView Control (Windows Forms) + DataGridView Control Overview (Windows Forms) + Basic Formatting and Styling in the Windows Forms DataGridView Control + Displaying Data in the Windows Forms DataGridView Control + Data Display Modes in the Windows Forms DataGridView Control + Differences Between the Windows Forms DataGridView and DataGrid Controls @@ -172,7 +172,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -220,7 +220,7 @@ The control replaces and extends the Override this method when customizing the control and modifying how and when the current cell changes. For example, if you create a custom row type that merges multiple cells into single cells and you modify the navigation accordingly, you can override this method to provide accessibility support for your changes. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -283,7 +283,7 @@ The control replaces and extends the Override this method if you want to customize the appearance of the border on column header cells. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -346,7 +346,7 @@ The control replaces and extends the Override this property if you want to customize the appearance of the border on the upper-left header cell. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -396,7 +396,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -446,7 +446,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -496,7 +496,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -545,7 +545,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -595,7 +595,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -644,7 +644,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -694,7 +694,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -746,7 +746,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -796,7 +796,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -837,7 +837,7 @@ The control replaces and extends the [!NOTE] > The control does not support double buffering. If is set to `true` in a derived control, users will not receive visual feedback when resizing rows, columns, or headers or when reordering columns. @@ -850,7 +850,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -900,7 +900,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -943,7 +943,7 @@ The control replaces and extends the property value of . - For more information about user resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about user resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). > [!NOTE] > The control does not support double buffering. If is set to `true` in a derived control, users will not receive visual feedback when resizing rows, columns, or headers or when reordering columns. @@ -956,7 +956,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1006,7 +1006,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1040,7 +1040,7 @@ The control replaces and extends the control displays its cells using the styles indicated by the cell property, which inherits styles from other properties of type . For cells in rows with odd index numbers, the styles specified through the property override the styles specified through the , , and , and are overridden by the styles specified through the and properties. - For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). When getting this property, a with default values will be created if the property has not already been accessed. This can cause a performance impact when getting this property for many rows. Whenever possible, use a single to set this property for multiple rows. For more information, see [Best Practices for Scaling the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control). @@ -1053,8 +1053,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -1107,8 +1107,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -1158,8 +1158,8 @@ The control replaces and extends the - Best Practices for Scaling the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Best Practices for Scaling the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -1216,7 +1216,7 @@ The control replaces and extends the Setting the in the Windows Forms Designer automatically sets the property to `false` and generates code to add and bind a column for each property in the data source. The code that is generated at design-time is equivalent to the manually added code shown in the following example. It is not the same as the auto-generation of columns at run-time that occurs when the property is set to `true`. ## Examples - The following code example demonstrates how to add columns manually and bind them to a data source when you set to `false`. In this example, a control is bound to a list of `Task` business objects. Then, columns are added and are bound to `Task` properties through the property. This example is part of a larger example available in [How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List](/dotnet/framework/winforms/controls/access-objects-in-a-wf-datagridviewcomboboxcell-drop-down-list). + The following code example demonstrates how to add columns manually and bind them to a data source when you set to `false`. In this example, a control is bound to a list of `Task` business objects. Then, columns are added and are bound to `Task` properties through the property. This example is part of a larger example available in [How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List](/dotnet/desktop/winforms/controls/access-objects-in-a-wf-datagridviewcomboboxcell-drop-down-list). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoGenerateColumns/form1.cs" id="Snippet100"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewComboBoxObjectBinding/vb/form1.vb" id="Snippet100"::: @@ -1227,7 +1227,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1285,7 +1285,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1337,10 +1337,10 @@ The control replaces and extends the method. To set the column to automatically resize whenever its contents change, use the property or the column property. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ## Examples - The following code example uses this method to make the column width large enough to accommodate a new cell value. This example is part of a larger example available in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). + The following code example uses this method to make the column width large enough to accommodate a new cell value. This example is part of a larger example available in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewRowDemo.cpp" id="Snippet211"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewRowDemo.cs" id="Snippet211"::: @@ -1350,7 +1350,7 @@ The control replaces and extends the is not in the valid range of 0 to the number of columns minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1397,10 +1397,10 @@ The control replaces and extends the control replaces and extends the is not in the valid range of 0 to the number of columns minus 1. is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1462,7 +1462,7 @@ The control replaces and extends the class. If `fixedHeight` is `false`, the column width will be calculated with the expectation that you will call the or method next. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ]]> @@ -1474,7 +1474,7 @@ The control replaces and extends the is not in the valid range of 0 to the number of columns minus 1. is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1525,7 +1525,7 @@ The control replaces and extends the property value of . - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ## Examples The following code example demonstrates how to resize column headers and rows as a result of a button click. @@ -1536,7 +1536,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1581,13 +1581,13 @@ The control replaces and extends the property value of . - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ]]> is not in the valid range of 0 to the number of columns minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1632,11 +1632,11 @@ The control replaces and extends the class. If the `fixedColumnsWidth` or `fixedRowHeadersWidth` parameters are `false`, the height of the column headers will be calculated with the expectation that you will call the methods such as and next. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1683,13 +1683,13 @@ The control replaces and extends the class. If the `fixedColumnWidth` or `fixedRowHeadersWidth` parameters are `false`, the height of the column headers will be calculated with the expectation that you will call the methods such as and next. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ]]> is not in the valid range of 0 to the number of columns minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1738,10 +1738,10 @@ The control replaces and extends the method. To set the columns to automatically resize whenever their contents change, use the property or the column property. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ## Examples - The following code example resizes all columns to fit the contents of the columns and the column headers. This code example is part of a larger example provided in [How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/programmatically-resize-cells-to-fit-content-in-the-datagrid). + The following code example resizes all columns to fit the contents of the columns and the column headers. This code example is part of a larger example provided in [How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/programmatically-resize-cells-to-fit-content-in-the-datagrid). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ProgrammaticResizing/CPP/programmaticsizing.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumns/programmaticsizing.cs" id="Snippet3"::: @@ -1749,7 +1749,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1794,10 +1794,10 @@ The control replaces and extends the control replaces and extends the has the value or . is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1855,7 +1855,7 @@ The control replaces and extends the class. If `fixedHeight` is `false`, the column widths will be calculated with the expectation that you will call the or method next. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ]]> @@ -1865,7 +1865,7 @@ The control replaces and extends the has the value or . is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1919,10 +1919,10 @@ The control replaces and extends the property value of . - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ## Examples - The following code example resizes the third row in a to fit the column contents. This code example is part of a larger example provided in [How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/programmatically-resize-cells-to-fit-content-in-the-datagrid). + The following code example resizes the third row in a to fit the column contents. This code example is part of a larger example provided in [How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/programmatically-resize-cells-to-fit-content-in-the-datagrid). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ProgrammaticResizing/CPP/programmaticsizing.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumns/programmaticsizing.cs" id="Snippet4"::: @@ -1932,7 +1932,7 @@ The control replaces and extends the is not in the valid range of 0 to the number of rows minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -1981,10 +1981,10 @@ The control replaces and extends the to fit the column contents. This code example is part of a larger example provided in [How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/programmatically-resize-cells-to-fit-content-in-the-datagrid). + The following code example resizes the third row in a to fit the column contents. This code example is part of a larger example provided in [How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/programmatically-resize-cells-to-fit-content-in-the-datagrid). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ProgrammaticResizing/CPP/programmaticsizing.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumns/programmaticsizing.cs" id="Snippet4"::: @@ -1998,7 +1998,7 @@ The control replaces and extends the is not a valid value. is not in the valid range of 0 to the number of rows minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2046,7 +2046,7 @@ The control replaces and extends the class. If `fixedWidth` is `false`, the row height will be calculated with the expectation that you will call the or method next. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ]]> @@ -2056,7 +2056,7 @@ The control replaces and extends the is not a valid value. is not in the valid range of 0 to the number of rows minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2110,7 +2110,7 @@ The control replaces and extends the @@ -2118,7 +2118,7 @@ The control replaces and extends the has the value or . is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2165,10 +2165,10 @@ The control replaces and extends the control replaces and extends the has the value or is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2229,7 +2229,7 @@ The control replaces and extends the class. If the `fixedColumnHeadersHeight` or `fixedRowsHeight` parameters are `false`, the width of the row headers will be calculated with the expectation that you will call methods such as and next. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ]]> @@ -2237,7 +2237,7 @@ The control replaces and extends the has the value or . is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2286,7 +2286,7 @@ The control replaces and extends the class. If the `fixedColumnHeadersHeight` or `fixedRowHeight` parameters are `false`, the width of the row headers will be calculated with the expectation that you will call methods such as and next. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ]]> @@ -2296,7 +2296,7 @@ The control replaces and extends the has the value or . is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2347,10 +2347,10 @@ The control replaces and extends the property value of . - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ## Examples - The following code example demonstrates how to resize all rows based on non-header cell content. This code example is part of a larger example provided in [How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/programmatically-resize-cells-to-fit-content-in-the-datagrid). + The following code example demonstrates how to resize all rows based on non-header cell content. This code example is part of a larger example provided in [How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/programmatically-resize-cells-to-fit-content-in-the-datagrid). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ProgrammaticResizing/CPP/programmaticsizing.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumns/programmaticsizing.cs" id="Snippet7"::: @@ -2358,7 +2358,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2405,10 +2405,10 @@ The control replaces and extends the control replaces and extends the is not a valid value. has the value . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2468,7 +2468,7 @@ The control replaces and extends the class. If the `fixedWidth` parameter is `false`, the row heights will be calculated with the expectation that you will call the or method next. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ]]> @@ -2478,7 +2478,7 @@ The control replaces and extends the is not a valid value. has the value . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2528,7 +2528,7 @@ The control replaces and extends the class. If the `fixedWidth` parameter is `false`, the row heights will be calculated with the expectation that you will call the or method next. - For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about programmatic resizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ]]> @@ -2544,7 +2544,7 @@ The control replaces and extends the is less than 0. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2615,7 +2615,7 @@ The control replaces and extends the control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2673,16 +2673,16 @@ The control replaces and extends the property. The default value of this property is , indicating that the column inherits its behavior and its property value from the control. - Columns in fill mode divide the available control width in proportions indicated by their property values. The width available for fill mode is determined by subtracting the widths of all other columns from the width of the client area of the control. If this width is smaller than the combined values of all fill-mode columns, the horizontal scroll bar is displayed, all fill-mode columns are shown with their minimum widths, and user column-resizing is disabled. For more information about column fill mode, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). + Columns in fill mode divide the available control width in proportions indicated by their property values. The width available for fill mode is determined by subtracting the widths of all other columns from the width of the client area of the control. If this width is smaller than the combined values of all fill-mode columns, the horizontal scroll bar is displayed, all fill-mode columns are shown with their minimum widths, and user column-resizing is disabled. For more information about column fill mode, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). Only columns with a property value of `true` are resized automatically, and changing the visibility of a column does not cause resizing to occur. Additionally, when columns are set to automatically resize, the user cannot adjust the column widths with the mouse. To adjust column widths programmatically, use the or methods or set the column property. - For more information about content-based automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about content-based automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ## Examples - The following code example illustrates how to use this property in a master/detail scenario where two controls display data from two tables in a parent/child relationship. In this example, the column sizing mode for the master control is , and the column widths are programmatically initialized to fit the loaded values. The details control is set to an automatic column sizing mode so that columns will adjust automatically whenever the values change (for example, when the user changes the current row in the parent table). This example is part of a larger example available in [How to: Create a Master/Detail Form Using Two Windows Forms DataGridView Controls](/dotnet/framework/winforms/controls/create-a-master-detail-form-using-two-datagridviews). + The following code example illustrates how to use this property in a master/detail scenario where two controls display data from two tables in a parent/child relationship. In this example, the column sizing mode for the master control is , and the column widths are programmatically initialized to fit the loaded values. The details control is set to an automatic column sizing mode so that columns will adjust automatically whenever the values change (for example, when the user changes the current row in the parent table). This example is part of a larger example available in [How to: Create a Master/Detail Form Using Two Windows Forms DataGridView Controls](/dotnet/desktop/winforms/controls/create-a-master-detail-form-using-two-datagridviews). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoSizeColumnsMode/masterdetails.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMasterDetails/VB/masterdetails.vb" id="Snippet10"::: @@ -2697,7 +2697,7 @@ The control replaces and extends the and at least one visible column with an property value of is frozen. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2750,7 +2750,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2802,10 +2802,10 @@ The control replaces and extends the property value of . - For more information about content-based automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about content-based automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ## Examples - The following code example demonstrates how to set the row to automatically resize based on the contents of the row headers and all of the columns. This code example is part of a larger example provided in [How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/automatically-resize-cells-when-content-changes-in-the-datagrid). + The following code example demonstrates how to set the row to automatically resize based on the contents of the row headers and all of the columns. This code example is part of a larger example provided in [How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/automatically-resize-cells-when-content-changes-in-the-datagrid). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/CPP/autosizing.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoSizeRowsMode/autosizing.cs" id="Snippet9"::: @@ -2816,8 +2816,8 @@ The control replaces and extends the The specified value when setting this property is not a valid value. The specified value when setting this property is or and row headers are hidden. - DataGridView Control (Windows Forms) - How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control @@ -2858,7 +2858,7 @@ The control replaces and extends the control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2921,7 +2921,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -2973,7 +2973,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3021,7 +3021,7 @@ The control replaces and extends the property value that is less that 255. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3071,7 +3071,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3122,7 +3122,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3172,7 +3172,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3218,7 +3218,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3270,7 +3270,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3341,7 +3341,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3395,7 +3395,7 @@ The control replaces and extends the The specified value when setting this property is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3445,7 +3445,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3485,14 +3485,14 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3535,7 +3535,7 @@ The control replaces and extends the control in virtual mode. When the control is in edit mode, the `rowInEdit` variable holds the index of the row being edited, and the `customerInEdit` variable holds a reference to a Customer object corresponding to that row. When the user cancels out of edit mode, this object can be discarded. If the row the user was editing is the row for new records, however, the old Customer object is discarded and replaced with a new one so that the user can begin making edits again. This example is part of a larger example available in [Walkthrough: Implementing Virtual Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/implementing-virtual-mode-wf-datagridview-control). + The following code example illustrates how to handle this event for a control in virtual mode. When the control is in edit mode, the `rowInEdit` variable holds the index of the row being edited, and the `customerInEdit` variable holds a reference to a Customer object corresponding to that row. When the user cancels out of edit mode, this object can be discarded. If the row the user was editing is the row for new records, however, the old Customer object is discarded and replaced with a new one so that the user can begin making edits again. This example is part of a larger example available in [Walkthrough: Implementing Virtual Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/implementing-virtual-mode-wf-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.VirtualMode/CPP/virtualmode.cpp" id="Snippet170"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CancelRowEdit/virtualmode.cs" id="Snippet170"::: @@ -3543,7 +3543,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3573,7 +3573,7 @@ The control replaces and extends the if there is an editable cell selected; otherwise, . To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3621,7 +3621,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3678,7 +3678,7 @@ The control replaces and extends the The specified value when setting this property is not a valid value. The specified value when setting this property is . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3728,7 +3728,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3779,7 +3779,7 @@ The control replaces and extends the event handler in a Tic-Tac-Toe game implementation that uses image columns in a control. Unless the game is over or the cell has already been clicked, the event handler sets the cell value to one of two objects represented by the variables `x` and `o`. - This code is part of a larger example shown in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). + This code is part of a larger example shown in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet10"::: @@ -3787,7 +3787,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3842,7 +3842,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3892,7 +3892,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -3946,7 +3946,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4019,7 +4019,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4069,7 +4069,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4110,14 +4110,14 @@ The control replaces and extends the property in case it was previously set by a event handler. The event handler can clear the error text when the new cell value meets the validation criteria, but when the user reverts to the old cell value by pressing ESC, the event does not occur. This example is part of a larger example available in [Walkthrough: Validating Data in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/walkthrough-validating-data-in-the-windows-forms-datagridview-control). + The following code example illustrates how to handle this event to clear the row property in case it was previously set by a event handler. The event handler can clear the error text when the new cell value meets the validation criteria, but when the user reverts to the old cell value by pressing ESC, the event does not occur. This example is part of a larger example available in [Walkthrough: Validating Data in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/walkthrough-validating-data-in-the-windows-forms-datagridview-control). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellEndEdit/datavalidation.cs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewDataValidation/VB/datavalidation.vb" id="Snippet20"::: ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4167,7 +4167,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4217,7 +4217,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4288,8 +4288,8 @@ The control replaces and extends the - DataGridView Control (Windows Forms) - Best Practices for Scaling the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Best Practices for Scaling the Windows Forms DataGridView Control @@ -4339,7 +4339,7 @@ The control replaces and extends the property, the display properties of the object returned by the property are used to render the cell. - For more information about custom formatting using the event, see [How to: Customize Data Formatting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-data-formatting-in-the-windows-forms-datagridview-control). + For more information about custom formatting using the event, see [How to: Customize Data Formatting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-data-formatting-in-the-windows-forms-datagridview-control). To avoid performance penalties when handling this event, access the cell through the parameters of the event handler rather than accessing the cell directly. @@ -4374,9 +4374,9 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - How to: Customize Data Formatting in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + How to: Customize Data Formatting in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -4424,7 +4424,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4490,7 +4490,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4542,7 +4542,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4594,7 +4594,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4637,7 +4637,7 @@ The control replaces and extends the event handler in a Tic-Tac-Toe game implementation that uses image columns in a control. The event handler uses the cell value to determine the cursor and ToolTip to display. - This code is part of a larger example shown in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). + This code is part of a larger example shown in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet15"::: @@ -4645,7 +4645,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4688,7 +4688,7 @@ The control replaces and extends the event handler in a Tic-Tac-Toe game implementation that uses image columns in a control. The event handler resets the cursor and ToolTip, which are set in a event handler. - This code is part of a larger example shown in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). + This code is part of a larger example shown in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet15"::: @@ -4696,7 +4696,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4746,7 +4746,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4798,7 +4798,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -4836,7 +4836,7 @@ The control replaces and extends the or methods to paint other parts. You can also use the class to paint standard controls using the current theme. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). If you are using Visual Studio 2005, you also have access to a large library of standard images that you can use with the control. + You can handle this event to customize the appearance of cells in the control. You can paint entire cells yourself, or paint specific parts of cells and use the or methods to paint other parts. You can also use the class to paint standard controls using the current theme. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). If you are using Visual Studio 2005, you also have access to a large library of standard images that you can use with the control. When handling this event, you should access the cell through the parameters of the event handler, rather than access the cell directly. @@ -4845,7 +4845,7 @@ The control replaces and extends the control replaces and extends the - How to: Customize the Appearance of Cells in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + How to: Customize the Appearance of Cells in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -4937,8 +4937,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -4990,7 +4990,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5043,8 +5043,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -5120,8 +5120,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -5171,7 +5171,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5241,7 +5241,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5292,7 +5292,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5350,7 +5350,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5404,7 +5404,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5446,7 +5446,7 @@ The control replaces and extends the event. @@ -5466,9 +5466,9 @@ The control replaces and extends the - Best Practices for Scaling the Windows Forms DataGridView Control - Virtual Mode in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Best Practices for Scaling the Windows Forms DataGridView Control + Virtual Mode in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -5512,7 +5512,7 @@ The control replaces and extends the event to retrieve values from the data store for display in the control. - For more information about virtual mode, see [Virtual Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/virtual-mode-in-the-windows-forms-datagridview-control). + For more information about virtual mode, see [Virtual Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/virtual-mode-in-the-windows-forms-datagridview-control). For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). @@ -5530,8 +5530,8 @@ The control replaces and extends the - Virtual Mode in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Virtual Mode in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -5582,7 +5582,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5649,7 +5649,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5708,7 +5708,7 @@ The control replaces and extends the class. ## Examples - The following code example demonstrates how to enable copying in the control. This example is part of a larger example available in [How to: Enable Users to Copy Multiple Cells to the Clipboard from the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/enable-users-to-copy-multiple-cells-to-the-clipboard-datagridview). + The following code example demonstrates how to enable copying in the control. This example is part of a larger example available in [How to: Enable Users to Copy Multiple Cells to the Clipboard from the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/enable-users-to-copy-multiple-cells-to-the-clipboard-datagridview). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ClipboardCopyMode/datagridviewclipboarddemo.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewClipboardDemo/VB/datagridviewclipboarddemo.vb" id="Snippet10"::: @@ -5722,7 +5722,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5772,7 +5772,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5822,7 +5822,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5895,7 +5895,7 @@ The control replaces and extends the The specified value when setting this property is less than 0. When setting this property, the property has been set. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5942,7 +5942,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -5995,8 +5995,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -6046,7 +6046,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6100,7 +6100,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6150,7 +6150,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6200,7 +6200,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6248,7 +6248,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6298,7 +6298,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6362,7 +6362,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6412,7 +6412,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6464,7 +6464,7 @@ The control replaces and extends the property. To force column headers to inherit the values, you must set the values in the object to the default values indicated for the class. - For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). If visual styles are enabled and is set to `true`, all header cells except the are painted using the current theme and the values are ignored. @@ -6478,8 +6478,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -6530,8 +6530,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -6620,7 +6620,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6678,7 +6678,7 @@ The control replaces and extends the property value of . - For more information about header sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about header sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). > [!NOTE] > The control does not support double buffering. If is set to `true` in a derived control, users will not receive visual feedback when resizing rows, columns, or headers or when reordering columns. @@ -6692,7 +6692,7 @@ The control replaces and extends the The specified value when setting this property is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6742,7 +6742,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6793,7 +6793,7 @@ The control replaces and extends the The specified value when setting this property is and one or more columns have an property value of . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6843,7 +6843,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6893,7 +6893,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -6943,7 +6943,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7010,7 +7010,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7060,7 +7060,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7128,7 +7128,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7178,7 +7178,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7219,14 +7219,14 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7266,7 +7266,7 @@ The control replaces and extends the event, which you can handle to customize the type conversion. Otherwise, default type converters are used. Conversion errors may result in an exception if the event is not handled to prevent it. If the value is successfully converted, it is committed to the data store, raising the event for non-data-bound cells when the property value is `true`. If the value is successfully committed, the event occurs. ## Examples - The following code example calls the method within a event handler to raise the event. This code example is part of a larger example provided in [How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/disable-buttons-in-a-button-column-in-the-datagrid). + The following code example calls the method within a event handler to raise the event. This code example is part of a larger example provided in [How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/disable-buttons-in-a-button-column-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CommitEdit/form1.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DisabledButtons/VB/form1.vb" id="Snippet5"::: @@ -7281,7 +7281,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7311,7 +7311,7 @@ The control replaces and extends the Creates a new accessible object for the . A new for the . To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7347,7 +7347,7 @@ The control replaces and extends the Creates and returns a new . An empty . To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7384,7 +7384,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7420,7 +7420,7 @@ The control replaces and extends the Creates and returns a new . An empty . To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7501,8 +7501,8 @@ The control replaces and extends the - DataGridView Control (Windows Forms) - How to: Get and Set the Current Cell in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + How to: Get and Set the Current Cell in the Windows Forms DataGridView Control @@ -7549,14 +7549,14 @@ The control replaces and extends the property in a row-painting scenario. In the example, this property is used to store the row index of the current cell. When the user changes the current cell to a different row, the row is forced to repaint itself. - This code is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + This code is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet19"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet19"::: ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7597,14 +7597,14 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7653,14 +7653,14 @@ The control replaces and extends the event. In this example, the event handler calls the method to raise the event and determine the current value of a . This code example is part of a larger example provided in [How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/disable-buttons-in-a-button-column-in-the-datagrid). + The following code example demonstrates how to handle the event. In this example, the event handler calls the method to raise the event and determine the current value of a . This code example is part of a larger example provided in [How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/disable-buttons-in-a-button-column-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CommitEdit/form1.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DisabledButtons/VB/form1.vb" id="Snippet5"::: ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7708,7 +7708,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7748,7 +7748,7 @@ The control replaces and extends the , , or property changes. - Handling this event is useful, for example, to programmatically resize rows and columns based on content updates. For more information, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + Handling this event is useful, for example, to programmatically resize rows and columns based on content updates. For more information, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). @@ -7767,7 +7767,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7823,7 +7823,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7882,7 +7882,7 @@ The control replaces and extends the An error occurred in the data source and either there is no handler for the event or the handler has set the property to . The exception object can typically be cast to type . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -7932,7 +7932,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8005,9 +8005,9 @@ The control replaces and extends the property of the object returned by the property to `null` rather than using the default value of , which is appropriate for database data. - For more information, see [Displaying Data in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/displaying-data-in-the-windows-forms-datagridview-control). The following table provides direct links to common tasks related to the property. + For more information, see [Displaying Data in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/displaying-data-in-the-windows-forms-datagridview-control). The following table provides direct links to common tasks related to the property. - See [Walkthrough: Creating a Master/Detail Form Using Two Windows Forms DataGridView Controls](/dotnet/framework/winforms/controls/creating-a-master-detail-form-using-two-datagridviews) and [How to: Bind Objects to Windows Forms DataGridView Controls](/dotnet/framework/winforms/controls/how-to-bind-objects-to-windows-forms-datagridview-controls). + See [Walkthrough: Creating a Master/Detail Form Using Two Windows Forms DataGridView Controls](/dotnet/desktop/winforms/controls/creating-a-master-detail-form-using-two-datagridviews) and [How to: Bind Objects to Windows Forms DataGridView Controls](/dotnet/desktop/winforms/controls/how-to-bind-objects-to-windows-forms-datagridview-controls). ## Examples The following code example demonstrates how to initialize a simple data-bound . It also demonstrates how to set the property. @@ -8031,8 +8031,8 @@ The control replaces and extends the - DataGridView Control (Windows Forms) - Displaying Data in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Displaying Data in the Windows Forms DataGridView Control @@ -8082,7 +8082,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8132,7 +8132,7 @@ The control replaces and extends the - For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). When getting this property, a with default values will be created if the property has not already been accessed. This can cause a performance impact when getting this property for many rows. Whenever possible, use a single to set this property for multiple rows. For more information, see [Best Practices for Scaling the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control). @@ -8145,8 +8145,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -8199,8 +8199,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -8288,7 +8288,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8322,7 +8322,7 @@ The control replaces and extends the Returns the number of columns displayed to the user. The number of columns displayed to the user. To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8394,7 +8394,7 @@ The control replaces and extends the When overriding the property in a derived class, use the base class's property to extend the base implementation. Alternatively, you must provide all the implementation. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8428,7 +8428,7 @@ The control replaces and extends the Releases the unmanaged resources used by the and its child controls and optionally releases the managed resources. To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8484,14 +8484,14 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8551,7 +8551,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8603,7 +8603,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8658,7 +8658,7 @@ The control replaces and extends the The specified value when setting this property is not a valid value. The specified value when setting this property would cause the control to enter edit mode, but initialization of the editing cell value failed and either there is no handler for the event or the handler has set the property to . The exception object can typically be cast to type . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8708,7 +8708,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8759,7 +8759,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8819,7 +8819,7 @@ The control replaces and extends the The cell value could not be committed and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8864,7 +8864,7 @@ The control replaces and extends the The cell value could not be committed and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8934,7 +8934,7 @@ The control replaces and extends the property value of . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -8985,7 +8985,7 @@ The control replaces and extends the Gets the width of the portion of the column that is currently scrolled out of view. The width of the portion of the column that is scrolled out of view. To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9034,7 +9034,7 @@ The control replaces and extends the property value of . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9091,7 +9091,7 @@ The control replaces and extends the property value of . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9137,10 +9137,10 @@ The control replaces and extends the is immutable (meaning that you cannot adjust any of its properties), you can only assign the property a new object. However, you can base the new font on the existing font. - The control uses the value of the property as the default value of the properties of objects returned by the , , and properties. Changing the value automatically updates the , , and properties, changing the font for any cell that inherits the value. Header cells override the value by default, and you can override the value for specific rows, columns, and cells. For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + The control uses the value of the property as the default value of the properties of objects returned by the , , and properties. Changing the value automatically updates the , , and properties, changing the font for any cell that inherits the value. Header cells override the value by default, and you can override the value for specific rows, columns, and cells. For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). ## Examples - The following code example illustrates the use of this property. This example is part of a larger example available in [How to: Create an Unbound Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-create-an-unbound-windows-forms-datagridview-control). + The following code example illustrates the use of this property. This example is part of a larger example available in [How to: Create an Unbound Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-create-an-unbound-windows-forms-datagridview-control). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/Overview/simpleunbound.cs" id="Snippet30"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewSimpleUnbound/VB/simpleunbound.vb" id="Snippet30"::: @@ -9153,8 +9153,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -9213,7 +9213,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9267,7 +9267,7 @@ The control replaces and extends the is immutable (meaning that you cannot adjust any of its properties), you can only assign the property a new object. However, you can base the new font on the existing font. - The control uses the value of the property as the default value of the property of returned by the property. Changing the value automatically updates the property, changing the foreground text color for any cell that inherits the value. Header cells override the value by default, and you can override the value for specific rows, columns, and cells. For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + The control uses the value of the property as the default value of the property of returned by the property. Changing the value automatically updates the property, changing the foreground text color for any cell that inherits the value. Header cells override the value by default, and you can override the value for specific rows, columns, and cells. For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). ]]> @@ -9275,8 +9275,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -9334,7 +9334,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9408,7 +9408,7 @@ The control replaces and extends the control. In this example, if any cells are selected, their values are retrieved through the method and displayed in a control. - This code is part of a larger example illustrating the use of the Clipboard features of the control. This example is part of a larger example available in [How to: Enable Users to Copy Multiple Cells to the Clipboard from the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/enable-users-to-copy-multiple-cells-to-the-clipboard-datagridview). + This code is part of a larger example illustrating the use of the Clipboard features of the control. This example is part of a larger example available in [How to: Enable Users to Copy Multiple Cells to the Clipboard from the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/enable-users-to-copy-multiple-cells-to-the-clipboard-datagridview). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ClipboardCopyMode/datagridviewclipboarddemo.cs" id="Snippet16"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewClipboardDemo/VB/datagridviewclipboarddemo.vb" id="Snippet16"::: @@ -9417,7 +9417,7 @@ The control replaces and extends the includes the value . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9469,7 +9469,7 @@ The control replaces and extends the is less than -1 or greater than the number of rows in the control minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9508,7 +9508,7 @@ The control replaces and extends the class. ## Examples - The following code example demonstrates how to programmatically add selected content to the Clipboard. This example is part of a larger example available in [How to: Enable Users to Copy Multiple Cells to the Clipboard from the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/enable-users-to-copy-multiple-cells-to-the-clipboard-datagridview). + The following code example demonstrates how to programmatically add selected content to the Clipboard. This example is part of a larger example available in [How to: Enable Users to Copy Multiple Cells to the Clipboard from the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/enable-users-to-copy-multiple-cells-to-the-clipboard-datagridview). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ClipboardCopyMode/datagridviewclipboarddemo.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewClipboardDemo/VB/datagridviewclipboarddemo.vb" id="Snippet10"::: @@ -9523,7 +9523,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9561,7 +9561,7 @@ The control replaces and extends the To be added. is not in the valid range of 0 to the number of columns minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9599,7 +9599,7 @@ The control replaces and extends the To be added. is not in the valid range of 0 to the number of rows minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9647,7 +9647,7 @@ The control replaces and extends the property value that is less that 255. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9697,7 +9697,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9747,7 +9747,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9831,7 +9831,7 @@ The control replaces and extends the control replaces and extends the The specified value when setting this property is less than 0. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9850,7 +9850,7 @@ The control replaces and extends the Invalidates a cell in the , forcing it to be repainted. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9892,7 +9892,7 @@ The control replaces and extends the that is painted with a custom border when the mouse pointer rests on it. In the example, the cell is invalidated when the mouse pointer enters or leaves it. - This code is part of a larger example available in [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](/dotnet/framework/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior). + This code is part of a larger example available in [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](/dotnet/desktop/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/InvalidateCell/rollovercell.cs" id="Snippet220"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRolloverCell/VB/rollovercell.vb" id="Snippet220"::: @@ -9904,7 +9904,7 @@ The control replaces and extends the is . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -9946,7 +9946,7 @@ The control replaces and extends the . ## Examples - The following code example illustrates how to use this method in a custom cell type that changes a cell's appearance when the user rests the mouse pointer over it. This example is part of a larger example available in [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](/dotnet/framework/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior). + The following code example illustrates how to use this method in a custom cell type that changes a cell's appearance when the user rests the mouse pointer over it. This example is part of a larger example available in [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](/dotnet/desktop/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/InvalidateCell/rollovercell.cs" id="Snippet220"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRolloverCell/VB/rollovercell.vb" id="Snippet220"::: @@ -9960,7 +9960,7 @@ The control replaces and extends the is less than -1 or greater than the number of rows in the control minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10002,7 +10002,7 @@ The control replaces and extends the is not in the valid range of 0 to the number of columns minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10044,7 +10044,7 @@ The control replaces and extends the method in a row-painting scenario. In the example, the row is invalidated when the current cell changes, forcing the row to repaint itself. - This code is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + This code is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet19"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet19"::: @@ -10054,7 +10054,7 @@ The control replaces and extends the is not in the valid range of 0 to the number of rows minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10100,14 +10100,14 @@ The control replaces and extends the is `true` and the current cell hosts an editing control, you can retrieve it through the property. ## Examples - The following code example uses the property to determine whether to commit a cell value and raise the event from a handler for the event. This code example is part of a larger example provided in [How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/disable-buttons-in-a-button-column-in-the-datagrid). + The following code example uses the property to determine whether to commit a cell value and raise the event from a handler for the event. This code example is part of a larger example provided in [How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/disable-buttons-in-a-button-column-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CommitEdit/form1.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DisabledButtons/VB/form1.vb" id="Snippet5"::: ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10159,7 +10159,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10204,7 +10204,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10245,7 +10245,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10280,7 +10280,7 @@ The control replaces and extends the if the specified key is a regular input key; otherwise, . To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10361,7 +10361,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10427,7 +10427,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10481,7 +10481,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10531,7 +10531,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10585,7 +10585,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10636,7 +10636,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10677,14 +10677,14 @@ The control replaces and extends the implementation derived from the class overrides the method and uses the method to indicate a change to the control. - This example is part of a larger example shown in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/framework/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). + This example is part of a larger example shown in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/desktop/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/EditingControl/datagridviewcalendarcolumn.cs" id="Snippet310"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCalendarColumn/VB/datagridviewcalendarcolumn.vb" id="Snippet310"::: ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10729,7 +10729,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10774,7 +10774,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10819,7 +10819,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10863,7 +10863,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10907,7 +10907,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -10952,8 +10952,8 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -10997,7 +10997,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11042,7 +11042,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11088,7 +11088,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11132,7 +11132,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11176,7 +11176,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11220,7 +11220,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11264,7 +11264,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11308,7 +11308,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11357,7 +11357,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11401,7 +11401,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11450,7 +11450,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11499,7 +11499,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11548,7 +11548,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11597,7 +11597,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11647,7 +11647,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11696,7 +11696,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11745,7 +11745,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11794,7 +11794,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11843,7 +11843,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11892,7 +11892,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11941,7 +11941,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -11990,7 +11990,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12039,7 +12039,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12090,7 +12090,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12140,7 +12140,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12189,7 +12189,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12238,7 +12238,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12287,7 +12287,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12336,7 +12336,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12385,7 +12385,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12434,7 +12434,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12478,7 +12478,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12528,8 +12528,8 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -12575,8 +12575,8 @@ The control replaces and extends the - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -12625,7 +12625,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12674,7 +12674,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12723,7 +12723,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12773,7 +12773,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12822,7 +12822,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12872,7 +12872,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12922,7 +12922,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -12967,7 +12967,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13012,7 +13012,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13057,7 +13057,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13103,8 +13103,8 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -13149,7 +13149,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13193,7 +13193,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13238,7 +13238,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13283,7 +13283,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13328,7 +13328,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13372,7 +13372,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13416,7 +13416,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13461,8 +13461,8 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -13506,7 +13506,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13550,7 +13550,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13595,7 +13595,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13640,7 +13640,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13684,7 +13684,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13729,7 +13729,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13775,7 +13775,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13820,7 +13820,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13865,7 +13865,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13909,7 +13909,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -13953,7 +13953,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14002,7 +14002,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14042,7 +14042,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14089,7 +14089,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14133,7 +14133,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14177,7 +14177,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14222,8 +14222,8 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -14267,7 +14267,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14311,7 +14311,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14355,7 +14355,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14402,7 +14402,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14484,7 +14484,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14530,7 +14530,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14576,7 +14576,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14652,7 +14652,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14696,7 +14696,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14729,7 +14729,7 @@ The control replaces and extends the Raises the event. To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14780,7 +14780,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14830,7 +14830,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14880,7 +14880,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14924,7 +14924,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -14972,7 +14972,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15055,7 +15055,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15088,7 +15088,7 @@ The control replaces and extends the Raises the event. To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15133,7 +15133,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15205,7 +15205,7 @@ The control replaces and extends the method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. ## Examples - The following code example illustrates the use of this method. This example is part of a larger example available in [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](/dotnet/framework/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior). + The following code example illustrates the use of this method. This example is part of a larger example available in [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](/dotnet/desktop/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/InvalidateCell/rollovercell.cs" id="Snippet220"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRolloverCell/VB/rollovercell.vb" id="Snippet220"::: @@ -15215,7 +15215,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15259,7 +15259,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15303,7 +15303,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15379,7 +15379,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15424,7 +15424,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15483,7 +15483,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15528,7 +15528,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15572,7 +15572,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15649,7 +15649,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15693,7 +15693,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15739,8 +15739,8 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -15784,7 +15784,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15828,7 +15828,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15873,7 +15873,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15917,7 +15917,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -15962,7 +15962,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16007,7 +16007,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16052,7 +16052,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16084,7 +16084,7 @@ The control replaces and extends the A that contains information about the mouse and the header cell that was clicked. Raises the event. To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16116,7 +16116,7 @@ The control replaces and extends the A that contains information about the mouse and the header cell that was double-clicked. Raises the event. To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16160,7 +16160,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16205,8 +16205,8 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -16250,7 +16250,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16294,7 +16294,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16339,7 +16339,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16383,7 +16383,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16427,7 +16427,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16471,7 +16471,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16516,7 +16516,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16560,7 +16560,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16604,7 +16604,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16648,7 +16648,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16693,8 +16693,8 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -16738,7 +16738,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16785,7 +16785,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16830,7 +16830,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16874,7 +16874,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16918,7 +16918,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -16962,7 +16962,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17006,7 +17006,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17051,7 +17051,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17095,7 +17095,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class' method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17140,7 +17140,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17184,7 +17184,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17228,7 +17228,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17275,7 +17275,7 @@ The control replaces and extends the When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17361,7 +17361,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17422,7 +17422,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17466,7 +17466,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17507,7 +17507,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17595,7 +17595,7 @@ The control replaces and extends the When overriding this method, a control should return to indicate that it has processed the key. For keys that are not processed by the control, return the result of the base version of this method. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17637,7 +17637,7 @@ The control replaces and extends the The DELETE key would delete one or more rows, but an error in the data source prevents the deletion and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17691,7 +17691,7 @@ The control replaces and extends the When overriding this method, a control should return to indicate that it has processed the key. For keys that are not processed by the control, return the result of the base version of this method. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17727,7 +17727,7 @@ The control replaces and extends the To be added. The DOWN ARROW key would cause the control to enter edit mode, but the property of the new current cell does not indicate a class that derives from and implements . This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17763,7 +17763,7 @@ The control replaces and extends the To be added. The END key would cause the control to enter edit mode, but the property of the new current cell does not indicate a class that derives from and implements . This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17799,7 +17799,7 @@ The control replaces and extends the To be added. The ENTER key would cause the control to enter edit mode, but the property of the new current cell does not indicate a class that derives from and implements . This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17833,7 +17833,7 @@ The control replaces and extends the if the key was processed; otherwise, . To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17869,7 +17869,7 @@ The control replaces and extends the To be added. The F2 key would cause the control to enter edit mode, but the property of the current cell does not indicate a class that derives from and implements . The F2 key would cause the control to enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17937,7 +17937,7 @@ The control replaces and extends the To be added. The HOME key would cause the control to enter edit mode, but the property of the new current cell does not indicate a class that derives from and implements . This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -17971,7 +17971,7 @@ The control replaces and extends the if the key was processed; otherwise, . To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18017,7 +18017,7 @@ The control replaces and extends the When overriding this method, a control should return to indicate that it has processed the message. For messages that are not processed by the control, return the result of the base version of this method. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18063,7 +18063,7 @@ The control replaces and extends the When overriding this method, a control should return to indicate that it has processed the message. For messages that are not processed by the control, return the result of the base version of this method. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18099,7 +18099,7 @@ The control replaces and extends the To be added. The LEFT ARROW key would cause the control to enter edit mode, but the property of the new current cell does not indicate a class that derives from and implements . This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18135,7 +18135,7 @@ The control replaces and extends the To be added. The PAGE DOWN key would cause the control to enter edit mode, but the property of the new current cell does not indicate a class that derives from and implements . This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18171,7 +18171,7 @@ The control replaces and extends the To be added. The PAGE UP key would cause the control to enter edit mode, but the property of the new current cell does not indicate a class that derives from and implements . This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18217,7 +18217,7 @@ The control replaces and extends the The RIGHT ARROW key would cause the control to enter edit mode, but the property of the new current cell does not indicate a class that derives from and implements . This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18251,7 +18251,7 @@ The control replaces and extends the if the key was processed; otherwise, . To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18287,7 +18287,7 @@ The control replaces and extends the To be added. The TAB key would cause the control to enter edit mode, but the property of the new current cell does not indicate a class that derives from and implements . This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18323,7 +18323,7 @@ The control replaces and extends the To be added. The UP ARROW key would cause the control to enter edit mode, but the property of the new current cell does not indicate a class that derives from and implements . This action would commit a cell value or enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18359,7 +18359,7 @@ The control replaces and extends the To be added. The 0 key would cause the control to enter edit mode, but the property of the current cell does not indicate a class that derives from and implements . This action would cause the control to enter edit mode, but an error in the data source prevents the action and either there is no handler for the event or the handler has set the property to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18414,7 +18414,7 @@ The control replaces and extends the The specified value when setting this property is , the current cell is in edit mode, and the current cell contains changes that cannot be committed. The specified value when setting this property would cause the control to enter edit mode, but initialization of the editing cell value failed and either there is no handler for the event or the handler has set the property to . The exception object can typically be cast to type . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18464,7 +18464,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18502,7 +18502,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18594,7 +18594,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18664,7 +18664,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18741,7 +18741,7 @@ The control replaces and extends the is set to . When setting this property, the property is set. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18794,8 +18794,8 @@ The control replaces and extends the - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) @@ -18842,7 +18842,7 @@ The control replaces and extends the control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18904,7 +18904,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -18956,7 +18956,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19008,7 +19008,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19058,7 +19058,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19130,7 +19130,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19180,7 +19180,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19228,7 +19228,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19278,7 +19278,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19341,7 +19341,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19391,7 +19391,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19443,7 +19443,7 @@ The control replaces and extends the property. To force row headers to inherit the values, you must set the values in the object to the default values indicated for the class. - For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). ## Examples The following code example illustrates how to use this property in a with custom colors. Note how the property is set to so that the value is inherited from the object. @@ -19456,8 +19456,8 @@ The control replaces and extends the - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -19510,8 +19510,8 @@ The control replaces and extends the - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -19562,7 +19562,7 @@ The control replaces and extends the The specified value when setting this property is and the property is set to or . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19609,7 +19609,7 @@ The control replaces and extends the property in a row-painting scenario. In the example, the value of this property is used to calculate the bounds within which a custom background is drawn. - This code is part of a larger example available in[How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + This code is part of a larger example available in[How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet20"::: @@ -19618,7 +19618,7 @@ The control replaces and extends the The specified value when setting this property is less than the minimum width of 4 pixels or is greater than the maximum width of 32768 pixels. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19668,7 +19668,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19724,7 +19724,7 @@ The control replaces and extends the property. - For more information about header sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about header sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). > [!NOTE] > The control does not support double buffering. If is set to `true` in a derived control, users will not receive visual feedback when resizing rows, columns, or headers or when reordering columns. @@ -19738,7 +19738,7 @@ The control replaces and extends the The specified value when setting this property is not a valid value. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19788,7 +19788,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19829,14 +19829,14 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19893,7 +19893,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19950,7 +19950,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -19998,7 +19998,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20048,7 +20048,7 @@ The control replaces and extends the - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20098,19 +20098,19 @@ The control replaces and extends the - You can also use the class to paint standard controls using the current theme. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). If you are using Visual Studio 2005, you also have access to a large library of standard images that you can use with the control. + You can also use the class to paint standard controls using the current theme. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). If you are using Visual Studio 2005, you also have access to a large library of standard images that you can use with the control. For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). ## Examples - The following code example demonstrates how to use a handler for the event to paint textual content that spans the entire row below the normal cell values. This example is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + The following code example demonstrates how to use a handler for the event to paint textual content that spans the entire row below the normal cell values. This example is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet30"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20160,19 +20160,19 @@ The control replaces and extends the - You can also use the class to paint standard controls using the current theme. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). If you are using Visual Studio 2005, you also have access to a large library of standard images that you can use with the control. + You can also use the class to paint standard controls using the current theme. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). If you are using Visual Studio 2005, you also have access to a large library of standard images that you can use with the control. For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). ## Examples - The following code example demonstrates how to use a handler for the event to paint a gradient row background if the row is selected. This example is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + The following code example demonstrates how to use a handler for the event to paint a gradient row background if the row is selected. This example is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet20"::: ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20225,7 +20225,7 @@ this.dataGridView1.Rows.Add("five", "six", "seven", "eight");this.dataGridView1. Rows include style information in addition to cell values. For this reason, you might want to add or insert rows based on existing rows that you have already styled. You can do this using the , , , and methods. - You can also use the collection to modify the values in the control or to remove rows. You can modify values or remove rows regardless of whether the control is bound to an external data source. If there is a data source, the changes are made directly to the data source. You may still need to push the data source updates to a remote database, however. For more information, see [How to: Bind Data to the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-bind-data-to-the-windows-forms-datagridview-control). + You can also use the collection to modify the values in the control or to remove rows. You can modify values or remove rows regardless of whether the control is bound to an external data source. If there is a data source, the changes are made directly to the data source. You may still need to push the data source updates to a remote database, however. For more information, see [How to: Bind Data to the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-bind-data-to-the-windows-forms-datagridview-control). The following example shows you how to modify cell values programmatically. @@ -20279,7 +20279,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20339,7 +20339,7 @@ if (rowToDelete > -1) - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20373,7 +20373,7 @@ if (rowToDelete > -1) ## Remarks The control displays its cells using the styles indicated by the cell property, which inherits styles from other properties of type . For cells in all rows, excluding header cells, the styles specified through the property override the styles specified through the and properties, and are overridden by the styles specified through the , , and properties. - For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). When getting this property, a with default values will be created if the property has not already been accessed. This can cause a performance impact when getting this property for many rows. Whenever possible, use a single to set this property for multiple rows. For more information, see [Best Practices for Scaling the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control). @@ -20386,8 +20386,8 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -20440,8 +20440,8 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) - Cell Styles in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control @@ -20494,7 +20494,7 @@ if (rowToDelete > -1) - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20544,7 +20544,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20608,7 +20608,7 @@ if (rowToDelete > -1) ]]> The specified row when setting this property has its property set. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20664,7 +20664,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20714,7 +20714,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20764,7 +20764,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20814,7 +20814,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20866,7 +20866,7 @@ if (rowToDelete > -1) The specified value when setting this property is not a valid value. The value of this property cannot be set because the is unable to scroll due to a cell change that cannot be committed or canceled. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20910,7 +20910,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -20960,7 +20960,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21010,7 +21010,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21063,7 +21063,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21118,7 +21118,7 @@ if (rowToDelete > -1) - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21177,7 +21177,7 @@ if (rowToDelete > -1) The specified value when setting this property is not a valid value. The specified value when setting this property is or and the property of one or more columns is set to . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21218,7 +21218,7 @@ if (rowToDelete > -1) This member overrides . To be added. One or both of the width or height values exceeds the maximum value of 8,388,607. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21284,7 +21284,7 @@ if (rowToDelete > -1) This method was called for a reason other than the underlying data source being reset, and another thread is currently executing this method. The new current cell tried to enter edit mode, but its property does not indicate a class that derives from and implements . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21334,7 +21334,7 @@ if (rowToDelete > -1) -or- is less than 0 or greater than the number of rows in the control minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21378,7 +21378,7 @@ if (rowToDelete > -1) is less than 0 or greater than the number of columns in the control minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21422,7 +21422,7 @@ if (rowToDelete > -1) is less than 0 or greater than the number of rows in the control minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21458,7 +21458,7 @@ if (rowToDelete > -1) if a red glyph will appear in a cell that fails validation; otherwise, . The default is . To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21512,7 +21512,7 @@ if (rowToDelete > -1) - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21559,7 +21559,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21616,7 +21616,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21682,7 +21682,7 @@ if (rowToDelete > -1) -or- is not . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21727,7 +21727,7 @@ if (rowToDelete > -1) When the property has been set, this method works for data-bound columns only. Data-bound columns have had their property set. This causes the property to return `true`. - If your control contains both bound and unbound columns, you must implement virtual mode to maintain the values of the unbound columns when the control is sorted by a bound column. You can do this by setting the property to `true` and handling the event. If the column is editable, you should also handle the event. For more information about virtual mode, see [How to: Implement Virtual Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-implement-virtual-mode-in-the-windows-forms-datagridview-control). Sorting by unbound columns when the control is data-bound is not supported. + If your control contains both bound and unbound columns, you must implement virtual mode to maintain the values of the unbound columns when the control is sorted by a bound column. You can do this by setting the property to `true` and handling the event. If the column is editable, you should also handle the event. For more information about virtual mode, see [How to: Implement Virtual Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-implement-virtual-mode-in-the-windows-forms-datagridview-control). Sorting by unbound columns when the control is data-bound is not supported. ## Examples The following code example demonstrates how to use the in a programmatic sort. @@ -21753,7 +21753,7 @@ if (rowToDelete > -1) -or- The object specified by the property has a property value of . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21804,7 +21804,7 @@ if (rowToDelete > -1) For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). ## Examples - The following code example demonstrates how to use the in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). + The following code example demonstrates how to use the in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/SortCompare/form1.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: @@ -21816,8 +21816,8 @@ if (rowToDelete > -1) - DataGridView Control (Windows Forms) - How to: Customize Sorting in the Windows Forms DataGridView Control + DataGridView Control (Windows Forms) + How to: Customize Sorting in the Windows Forms DataGridView Control @@ -21869,7 +21869,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21933,7 +21933,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -21988,7 +21988,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22041,7 +22041,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22093,7 +22093,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22134,7 +22134,7 @@ if (rowToDelete > -1) This method has already been called for this control. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22174,7 +22174,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22224,7 +22224,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22274,7 +22274,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22333,7 +22333,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22382,7 +22382,7 @@ if (rowToDelete > -1) -or- is less than -1 or greater than the number of rows in the control minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22431,7 +22431,7 @@ if (rowToDelete > -1) -or- is less than zero or greater than the number of rows in the control minus one. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22481,7 +22481,7 @@ if (rowToDelete > -1) is not in the valid range of 0 to the number of rows in the control minus 1. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22532,7 +22532,7 @@ if (rowToDelete > -1) -or- is less than . - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22592,7 +22592,7 @@ if (rowToDelete > -1) is greater than the highest row index in the collection. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22640,7 +22640,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22690,7 +22690,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22740,7 +22740,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22793,7 +22793,7 @@ if (rowToDelete > -1) - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22828,7 +22828,7 @@ if (rowToDelete > -1) Gets the vertical scroll bar of the control. A representing the vertical scroll bar. To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22875,7 +22875,7 @@ if (rowToDelete > -1) Gets the number of pixels by which the control is scrolled vertically. The number of pixels by which the control is scrolled vertically. To be added. - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22918,7 +22918,7 @@ if (rowToDelete > -1) property is `true`, you create a with a set number of rows and columns and then handle the event to populate the cells. Virtual mode requires implementation of an underlying data cache to handle the population, editing, and deletion of cells based on actions of the user. For more information about implementing virtual mode, see [How to: Implement Virtual Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-implement-virtual-mode-in-the-windows-forms-datagridview-control). + Virtual mode is designed for use with very large stores of data. When the property is `true`, you create a with a set number of rows and columns and then handle the event to populate the cells. Virtual mode requires implementation of an underlying data cache to handle the population, editing, and deletion of cells based on actions of the user. For more information about implementing virtual mode, see [How to: Implement Virtual Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-implement-virtual-mode-in-the-windows-forms-datagridview-control). You must use virtual mode to maintain the values of unbound columns when the control is in bound mode. Sorting by unbound columns in bound mode is not supported. @@ -22930,7 +22930,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) @@ -22969,7 +22969,7 @@ if (rowToDelete > -1) ]]> - DataGridView Control (Windows Forms) + DataGridView Control (Windows Forms) diff --git a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnMode.xml b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnMode.xml index 1c93c13ef7f..58e5815addb 100644 --- a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnMode.xml +++ b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnMode.xml @@ -22,27 +22,27 @@ Defines values for specifying how the width of a column is adjusted. - control can resize its columns to make them fill the available horizontal width of the control or to make them display the full contents of all cells or of specified cells. - - With Fill mode, the preferred width of a column is determined by resizing all columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. With other modes, the preferred column width is the minimum width required to display the largest cell value from all cells or a subset of cells in that column, such as the subset of cells that are in currently displayed rows. Using a subset of cells to determine the new width is useful to avoid a performance penalty when working with many rows of data. - - Content-based automatic resizing prevents users from adjusting column widths with the mouse. User resizing is enabled in fill mode, however. - - This enumeration is used by the and properties of columns and the method. - - For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). For more information about column fill mode in particular, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). - - - -## Examples - The following code example illustrates the use of this enumeration to configure a fixed-width column. This example is part of a larger example available in [How to: Set the Sizing Modes of the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-set-the-sizing-modes-of-the-windows-forms-datagridview-control). - + control can resize its columns to make them fill the available horizontal width of the control or to make them display the full contents of all cells or of specified cells. + + With Fill mode, the preferred width of a column is determined by resizing all columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. With other modes, the preferred column width is the minimum width required to display the largest cell value from all cells or a subset of cells in that column, such as the subset of cells that are in currently displayed rows. Using a subset of cells to determine the new width is useful to avoid a performance penalty when working with many rows of data. + + Content-based automatic resizing prevents users from adjusting column widths with the mouse. User resizing is enabled in fill mode, however. + + This enumeration is used by the and properties of columns and the method. + + For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). For more information about column fill mode in particular, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). + + + +## Examples + The following code example illustrates the use of this enumeration to configure a fixed-width column. This example is part of a larger example available in [How to: Set the Sizing Modes of the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-set-the-sizing-modes-of-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewAutoSizeColumnMode/Overview/sizingscenarios.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewSizingScenarios/vb/sizingscenarios.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewSizingScenarios/vb/sizingscenarios.vb" id="Snippet10"::: + ]]> @@ -51,9 +51,9 @@ - Sizing Options in the Windows Forms DataGridView Control - Column Fill Mode in the Windows Forms DataGridView Control - How to: Set the Sizing Modes of the Windows Forms DataGridView Control + Sizing Options in the Windows Forms DataGridView Control + Column Fill Mode in the Windows Forms DataGridView Control + How to: Set the Sizing Modes of the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventArgs.xml b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventArgs.xml index a0dd3b18de9..aadd346fdef 100644 --- a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventArgs.xml @@ -29,22 +29,22 @@ Provides data for the event. - event is raised when the value of the property of a column in a control changes. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example illustrates the use of this type. This example is part of a larger example available in [How to: Manipulate Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-manipulate-columns-in-the-windows-forms-datagridview-control). - + event is raised when the value of the property of a column in a control changes. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example illustrates the use of this type. This example is part of a larger example available in [How to: Manipulate Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-manipulate-columns-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet180"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet180"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet180"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet180"::: + ]]> @@ -54,7 +54,7 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control @@ -97,7 +97,7 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control @@ -133,15 +133,15 @@ Gets the column with the property that changed. The with the property that changed. - @@ -149,7 +149,7 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control @@ -184,23 +184,23 @@ Gets the previous value of the property of the column. An value representing the previous value of the property of the . - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet280"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet280"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet280"::: + ]]> - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventHandler.xml b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventHandler.xml index 7a7a6cf94b0..d1851600107 100644 --- a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnModeEventHandler.xml @@ -39,13 +39,13 @@ A that contains the event data. Represents the method that will handle the event of a control. - event is raised when the value of the property of a column in a control changes. - - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - + event is raised when the value of the property of a column in a control changes. + + When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + ]]> @@ -54,6 +54,6 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsMode.xml b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsMode.xml index 886770349f7..774999d58b6 100644 --- a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsMode.xml +++ b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsMode.xml @@ -22,27 +22,27 @@ Defines values for specifying how the widths of columns are adjusted. - control can resize its columns to make them fill the available horizontal width of the control or to make them display the full contents of all cells or of specified cells. - - With mode, the preferred width of a column is determined by resizing all columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. With other modes, the preferred column width is the minimum width required to display the largest cell value from all cells or a subset of cells in that column, such as the subset of cells that are in currently displayed rows. Using a subset of cells to determine the new width is useful to avoid a performance penalty when working with many rows of data. - - Content-based automatic resizing prevents users from adjusting column widths with the mouse. User resizing is enabled in fill mode, however. - - This enumeration is used by the control property and method. - - For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). For more information about column fill mode in particular, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). - - - -## Examples - The following code example illustrates the use of this enumeration in a master/details scenario where two controls display data from two tables in a parent/child relationship. In this example, the column sizing mode for the master control is None and the column widths are programmatically initialized to fit the loaded values. The details control is set to an automatic sizing mode so that columns will adjust automatically whenever the values change (for example, when the user changes the current row in the parent table). This example is part of a larger example available in [How to: Create a Master/Detail Form Using Two Windows Forms DataGridView Controls](/dotnet/framework/winforms/controls/create-a-master-detail-form-using-two-datagridviews). - + control can resize its columns to make them fill the available horizontal width of the control or to make them display the full contents of all cells or of specified cells. + + With mode, the preferred width of a column is determined by resizing all columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. With other modes, the preferred column width is the minimum width required to display the largest cell value from all cells or a subset of cells in that column, such as the subset of cells that are in currently displayed rows. Using a subset of cells to determine the new width is useful to avoid a performance penalty when working with many rows of data. + + Content-based automatic resizing prevents users from adjusting column widths with the mouse. User resizing is enabled in fill mode, however. + + This enumeration is used by the control property and method. + + For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). For more information about column fill mode in particular, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). + + + +## Examples + The following code example illustrates the use of this enumeration in a master/details scenario where two controls display data from two tables in a parent/child relationship. In this example, the column sizing mode for the master control is None and the column widths are programmatically initialized to fit the loaded values. The details control is set to an automatic sizing mode so that columns will adjust automatically whenever the values change (for example, when the user changes the current row in the parent table). This example is part of a larger example available in [How to: Create a Master/Detail Form Using Two Windows Forms DataGridView Controls](/dotnet/desktop/winforms/controls/create-a-master-detail-form-using-two-datagridviews). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoSizeColumnsMode/masterdetails.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMasterDetails/VB/masterdetails.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMasterDetails/VB/masterdetails.vb" id="Snippet10"::: + ]]> @@ -51,8 +51,8 @@ - Sizing Options in the Windows Forms DataGridView Control - Column Fill Mode in the Windows Forms DataGridView Control + Sizing Options in the Windows Forms DataGridView Control + Column Fill Mode in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventArgs.xml b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventArgs.xml index f1fadd15871..603d7859ff3 100644 --- a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventArgs.xml @@ -29,23 +29,23 @@ Provides data for the event. - event is raised when the value of the property of the control changes. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates the use of this type. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + event is raised when the value of the property of the control changes. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates the use of this type. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet257"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet257"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet257"::: + ]]> @@ -55,7 +55,7 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control @@ -97,7 +97,7 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control @@ -133,16 +133,16 @@ Gets an array of the previous values of the column properties. An array of values representing the previous values of the column properties. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet257"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet257"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet257"::: + ]]> @@ -150,7 +150,7 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventHandler.xml b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventHandler.xml index 88b51b8dc5e..05af8a404cf 100644 --- a/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewAutoSizeColumnsModeEventHandler.xml @@ -39,13 +39,13 @@ A that contains the event data. Represents the method that will handle the event of a control. - event is raised when the value of the property of the control changes. - - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - + event is raised when the value of the property of the control changes. + + When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + ]]> @@ -54,6 +54,6 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewAutoSizeModeEventArgs.xml b/xml/System.Windows.Forms/DataGridViewAutoSizeModeEventArgs.xml index 8161cb7a369..2942f553ca9 100644 --- a/xml/System.Windows.Forms/DataGridViewAutoSizeModeEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewAutoSizeModeEventArgs.xml @@ -23,22 +23,22 @@ Provides data for the and events. - event is raised when the value of the property of the control changes. The event is raised when the value of the property changes. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates how to process the event. This code example is part of a larger example provided at [How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/automatically-resize-cells-when-content-changes-in-the-datagrid). - + event is raised when the value of the property of the control changes. The event is raised when the value of the property changes. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates how to process the event. This code example is part of a larger example provided at [How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/automatically-resize-cells-when-content-changes-in-the-datagrid). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/CPP/autosizing.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoSizeRowsMode/autosizing.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/VB/autosizing.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/VB/autosizing.vb" id="Snippet10"::: + ]]> @@ -49,7 +49,7 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control @@ -85,11 +85,11 @@ if the property was previously set to any value other than or the property was previously set to any value other than or ; otherwise, . Initializes a new instance of the class. - and events, pass in `true` for `previousModeAutoSized` if the already had an automatic resizing mode and the new mode is different. Otherwise, pass in `false` for `previousModeAutoSized`. - + and events, pass in `true` for `previousModeAutoSized` if the already had an automatic resizing mode and the new mode is different. Otherwise, pass in `false` for `previousModeAutoSized`. + ]]> @@ -99,7 +99,7 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control @@ -135,20 +135,20 @@ if the property was previously set to any value other than or the property was previously set to any value other than or ; otherwise, . - class is used with the and events, so this property relates specifically to the previous state of either the or property - - - -## Examples - The following code example uses the property to check the previous value for a . This code example is part of a larger example provided at [How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/automatically-resize-cells-when-content-changes-in-the-datagrid). - + class is used with the and events, so this property relates specifically to the previous state of either the or property + + + +## Examples + The following code example uses the property to check the previous value for a . This code example is part of a larger example provided at [How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/automatically-resize-cells-when-content-changes-in-the-datagrid). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/CPP/autosizing.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoSizeRowsMode/autosizing.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/VB/autosizing.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/VB/autosizing.vb" id="Snippet10"::: + ]]> @@ -158,7 +158,7 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewAutoSizeModeEventHandler.xml b/xml/System.Windows.Forms/DataGridViewAutoSizeModeEventHandler.xml index abcbc726052..ab83fc0350d 100644 --- a/xml/System.Windows.Forms/DataGridViewAutoSizeModeEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewAutoSizeModeEventHandler.xml @@ -39,22 +39,22 @@ A that contains the event data. Represents the method that will handle the or events of a . - event is raised when the value of the property of the control changes. The event is raised when the value of the property changes. - - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code demonstrates how to handle the event. - + event is raised when the value of the property of the control changes. The event is raised when the value of the property changes. + + When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code demonstrates how to handle the event. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/CPP/autosizing.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoSizeRowsMode/autosizing.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/VB/autosizing.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/VB/autosizing.vb" id="Snippet10"::: + ]]> @@ -65,6 +65,6 @@ - Resizing Columns and Rows in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewAutoSizeRowMode.xml b/xml/System.Windows.Forms/DataGridViewAutoSizeRowMode.xml index 6426fa2a3ef..d21e82a57ae 100644 --- a/xml/System.Windows.Forms/DataGridViewAutoSizeRowMode.xml +++ b/xml/System.Windows.Forms/DataGridViewAutoSizeRowMode.xml @@ -22,32 +22,32 @@ Defines values for specifying how the height of a row is adjusted. - control can resize its rows based on the preferred height of each row. The preferred row height is the minimum height required to display the largest cell value in that row. Different size modes let you indicate which cells are used to calculate the new heights (either header cells or non-header cells) and whether to resize all rows or only the rows that are currently displayed. Resizing a subset of rows is useful to avoid a performance penalty when working with many rows of data. - - Content-based automatic resizing prevents users from adjusting row heights with the mouse. - - This enumeration is used by the control method. - - For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). - - - -## Examples - The following code example resizes the third row in the control to fit the contents of its nonheader cells. This code example is part of a larger example provided in [How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/programmatically-resize-cells-to-fit-content-in-the-datagrid). - + control can resize its rows based on the preferred height of each row. The preferred row height is the minimum height required to display the largest cell value in that row. Different size modes let you indicate which cells are used to calculate the new heights (either header cells or non-header cells) and whether to resize all rows or only the rows that are currently displayed. Resizing a subset of rows is useful to avoid a performance penalty when working with many rows of data. + + Content-based automatic resizing prevents users from adjusting row heights with the mouse. + + This enumeration is used by the control method. + + For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + + + +## Examples + The following code example resizes the third row in the control to fit the contents of its nonheader cells. This code example is part of a larger example provided in [How to: Programmatically Resize Cells to Fit Content in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/programmatically-resize-cells-to-fit-content-in-the-datagrid). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ProgrammaticResizing/CPP/programmaticsizing.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumns/programmaticsizing.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ProgrammaticResizing/VB/programmaticsizing.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ProgrammaticResizing/VB/programmaticsizing.vb" id="Snippet4"::: + ]]> - Sizing Options in the Windows Forms DataGridView Control - How to: Programmatically Resize Cells To Fit Content in the Windows Forms DataGridView Control + Sizing Options in the Windows Forms DataGridView Control + How to: Programmatically Resize Cells To Fit Content in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewAutoSizeRowsMode.xml b/xml/System.Windows.Forms/DataGridViewAutoSizeRowsMode.xml index 0b24424b25f..30e4bcd155f 100644 --- a/xml/System.Windows.Forms/DataGridViewAutoSizeRowsMode.xml +++ b/xml/System.Windows.Forms/DataGridViewAutoSizeRowsMode.xml @@ -22,33 +22,33 @@ Defines values for specifying how the heights of rows are adjusted. - control can resize its rows based on the preferred height of each row. The preferred row height is the minimum height required to display the largest cell value in that row. Different size modes let you indicate which cells are used to calculate the new heights (either header cells or nonheader cells) and whether to resize all rows or only the rows that are currently displayed. Resizing a subset of rows is useful to avoid a performance penalty when working with many rows of data. - - Content-based automatic resizing prevents users from adjusting row heights with the mouse. - - This enumeration is used by the control property and method. - - For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). - - - -## Examples - The following code example sets rows to automatically resize their height whenever cell contents change. The new row height is determined from the contents of all rows and columns. This code example is part of a larger example provided in [How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/automatically-resize-cells-when-content-changes-in-the-datagrid). - + control can resize its rows based on the preferred height of each row. The preferred row height is the minimum height required to display the largest cell value in that row. Different size modes let you indicate which cells are used to calculate the new heights (either header cells or nonheader cells) and whether to resize all rows or only the rows that are currently displayed. Resizing a subset of rows is useful to avoid a performance penalty when working with many rows of data. + + Content-based automatic resizing prevents users from adjusting row heights with the mouse. + + This enumeration is used by the control property and method. + + For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + + + +## Examples + The following code example sets rows to automatically resize their height whenever cell contents change. The new row height is determined from the contents of all rows and columns. This code example is part of a larger example provided in [How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/automatically-resize-cells-when-content-changes-in-the-datagrid). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/CPP/autosizing.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoSizeRowsMode/autosizing.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/VB/autosizing.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.AutoSizing/VB/autosizing.vb" id="Snippet9"::: + ]]> - Sizing Options in the Windows Forms DataGridView Control - How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control + Sizing Options in the Windows Forms DataGridView Control + How to: Automatically Resize Cells When Content Changes in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewBand.xml b/xml/System.Windows.Forms/DataGridViewBand.xml index 38f0733ca3f..67a837deaa1 100644 --- a/xml/System.Windows.Forms/DataGridViewBand.xml +++ b/xml/System.Windows.Forms/DataGridViewBand.xml @@ -227,7 +227,7 @@ - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -571,7 +571,7 @@ ## Remarks Getting the value of the property automatically instantiates a new if the property has not previously been accessed. You must, therefore, use the property to determine whether the property is currently set to a instance. This is useful to determine which properties of the object returned by the property represent styles set specifically for the band. - For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). ]]> @@ -737,7 +737,7 @@ ## Remarks The implementation of this property in the class always returns `null` because this base class cannot contain elements. - For more information about style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information about style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). ]]> @@ -745,7 +745,7 @@ - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewButtonCell.xml b/xml/System.Windows.Forms/DataGridViewButtonCell.xml index e9fded1fa7f..2f9fd878f8a 100644 --- a/xml/System.Windows.Forms/DataGridViewButtonCell.xml +++ b/xml/System.Windows.Forms/DataGridViewButtonCell.xml @@ -50,7 +50,7 @@ ## Examples - The following code example demonstrates how to use a to perform actions on particular rows. You can use similar code when working with individual objects. In this example, a event handler first determines whether a click is on a button cell, then retrieves a business object associated with the row. This example is part of a larger example available in [How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List](/dotnet/framework/winforms/controls/access-objects-in-a-wf-datagridviewcomboboxcell-drop-down-list). + The following code example demonstrates how to use a to perform actions on particular rows. You can use similar code when working with individual objects. In this example, a event handler first determines whether a click is on a button cell, then retrieves a business object associated with the row. This example is part of a larger example available in [How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List](/dotnet/desktop/winforms/controls/access-objects-in-a-wf-datagridviewcomboboxcell-drop-down-list). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoGenerateColumns/form1.cs" id="Snippet100"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewComboBoxObjectBinding/vb/form1.vb" id="Snippet100"::: @@ -469,7 +469,7 @@ ]]> - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -517,7 +517,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -565,7 +565,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -611,7 +611,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -656,7 +656,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -702,7 +702,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -748,7 +748,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -801,7 +801,7 @@ - Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control + Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control @@ -856,7 +856,7 @@ - Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control + Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewButtonColumn.xml b/xml/System.Windows.Forms/DataGridViewButtonColumn.xml index aace3ec98f6..c3c65dda4b1 100644 --- a/xml/System.Windows.Forms/DataGridViewButtonColumn.xml +++ b/xml/System.Windows.Forms/DataGridViewButtonColumn.xml @@ -41,28 +41,28 @@ Hosts a collection of objects. - class is a specialized type of the class used to logically host cells that respond to simple user input. A has an associated in every that intersects it. Each cell supplies a user interface (UI) that is similar to a control. - - To display the same button text for every cell, set the property to `true` and set the property to the desired button text. - - The default sort mode for this column type is . - - To respond to user button clicks, handle the or event. In the event handler, you can use the property to determine whether the click occurred in the button column. You can use the property to determine whether the click occurred in a button cell and not on the column header. - + class is a specialized type of the class used to logically host cells that respond to simple user input. A has an associated in every that intersects it. Each cell supplies a user interface (UI) that is similar to a control. + + To display the same button text for every cell, set the property to `true` and set the property to the desired button text. + + The default sort mode for this column type is . + + To respond to user button clicks, handle the or event. In the event handler, you can use the property to determine whether the click occurred in the button column. You can use the property to determine whether the click occurred in a button cell and not on the column header. + > [!NOTE] -> When visual styles are enabled, the buttons in a button column are painted using a , and cell styles specified through properties such as have no effect. - - - -## Examples - The following code example demonstrates how to use a to perform actions on particular rows. In this example, a event handler first determines whether a click is on a button cell, then retrieves a business object associated with the row. This example is part of a larger example available in [How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List](/dotnet/framework/winforms/controls/access-objects-in-a-wf-datagridviewcomboboxcell-drop-down-list). - +> When visual styles are enabled, the buttons in a button column are painted using a , and cell styles specified through properties such as have no effect. + + + +## Examples + The following code example demonstrates how to use a to perform actions on particular rows. In this example, a event handler first determines whether a click is on a button cell, then retrieves a business object associated with the row. This example is part of a larger example available in [How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List](/dotnet/desktop/winforms/controls/access-objects-in-a-wf-datagridviewcomboboxcell-drop-down-list). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoGenerateColumns/form1.cs" id="Snippet100"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewComboBoxObjectBinding/vb/form1.vb" id="Snippet100"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewComboBoxObjectBinding/vb/form1.vb" id="Snippet100"::: + ]]> @@ -75,7 +75,7 @@ - How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control + How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control @@ -100,16 +100,16 @@ Initializes a new instance of the class to the default state. - |A new .| -|The property of the object returned by the property.|| - + |A new .| +|The property of the object returned by the property.|| + ]]> @@ -161,23 +161,23 @@ Gets or sets the template used to create new cells. A that all other cells in the column are modeled after. - class initializes this property to a newly created . - + class initializes this property to a newly created . + > [!CAUTION] -> Changing the properties of the cell template will not immediately affect the user interface (UI) of the column's existing cells. These changes are only apparent after the column is regenerated (for example, by sorting the column or through a call to the method). - - - -## Examples - The following code example demonstrates how to use a to view the sales an employee has made. A cell template is used to apply the same color to all buttons. This example is part of a larger example available in the class overview topic. - +> Changing the properties of the cell template will not immediately affect the user interface (UI) of the column's existing cells. These changes are only apparent after the column is regenerated (for example, by sorting the column or through a call to the method). + + + +## Examples + The following code example demonstrates how to use a to view the sales an employee has made. A cell template is used to apply the same color to all buttons. This example is part of a larger example available in the class overview topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/CPP/employees.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellContentClick/employees.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet10"::: + ]]> The specified value when setting this property could not be cast to a . @@ -215,11 +215,11 @@ Creates an exact copy of this column. An that represents the cloned . - The value of the property is . @@ -266,28 +266,28 @@ Gets or sets the column's default cell style. The to be applied as the default style. - returned by this property has an initial property value of . This value overrides the value specified in the property of the control, but may be overridden by other cell style properties. For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). - + returned by this property has an initial property value of . This value overrides the value specified in the property of the control, but may be overridden by other cell style properties. For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + > [!NOTE] -> When visual styles are enabled, the buttons in a button column are painted using a and cell styles specified through properties such as have no effect. - - - -## Examples - The following code example demonstrates the use of this property. - +> When visual styles are enabled, the buttons in a button column are painted using a and cell styles specified through properties such as have no effect. + + + +## Examples + The following code example demonstrates the use of this property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewButtonColumn/DefaultCellStyle/changecolumnalignment.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewContentAlignment/VB/changecolumnalignment.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewContentAlignment/VB/changecolumnalignment.vb" id="Snippet1"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -334,22 +334,22 @@ Gets or sets the flat-style appearance of the button cells in the column. A value indicating the appearance of the buttons in the column. The default is . - property specifies the appearance of the cells in the column. For more information, see the enumeration. - - Getting or setting this property gets or sets the property of the object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - - - -## Examples - The following code example demonstrates how to use a to view the sales an employee has made. This example is part of a larger example available in the class overview topic. - + property specifies the appearance of the cells in the column. For more information, see the enumeration. + + Getting or setting this property gets or sets the property of the object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + + + +## Examples + The following code example demonstrates how to use a to view the sales an employee has made. This example is part of a larger example available in the class overview topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/CPP/employees.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellContentClick/employees.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet10"::: + ]]> The value of the property is . @@ -397,22 +397,22 @@ Gets or sets the default text displayed on the button cell. A that contains the text. The default is . - contained in the column that has as a property value of `true` displays the property value on the cell's button. - - If there is an associated control, changing this property refreshes the column display. - - - -## Examples - The following code example demonstrates how to use a to view the sales an employee has made. The property is used to set the column header. This example is part of a larger example available in the class overview topic. - + contained in the column that has as a property value of `true` displays the property value on the cell's button. + + If there is an associated control, changing this property refreshes the column display. + + + +## Examples + The following code example demonstrates how to use a to view the sales an employee has made. The property is used to set the column header. This example is part of a larger example available in the class overview topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/CPP/employees.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellContentClick/employees.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet10"::: + ]]> When setting this property, the value of the property is . @@ -498,21 +498,21 @@ if the property value is displayed on buttons in the column; if the property value of each cell is displayed on its button. The default is . - of a button cell is displayed as the text on the button. The property allows you to either set the button text for each cell, or to use the property value for all of the button cells. - - Getting or setting this property gets or sets the property of the object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - - - -## Examples - The following code example demonstrates the use of this property. - + of a button cell is displayed as the text on the button. The property allows you to either set the button text for each cell, or to use the property value for all of the button cells. + + Getting or setting this property gets or sets the property of the object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + + + +## Examples + The following code example demonstrates the use of this property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellBeginEdit/datagridviewmisc.cs" id="Snippet010"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet010"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet010"::: + ]]> The value of the property is . @@ -522,7 +522,7 @@ - How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control + How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCell.xml b/xml/System.Windows.Forms/DataGridViewCell.xml index 6e6efc8c5ec..e18307c6910 100644 --- a/xml/System.Windows.Forms/DataGridViewCell.xml +++ b/xml/System.Windows.Forms/DataGridViewCell.xml @@ -54,7 +54,7 @@ ## Examples - The following code example illustrates the use of this type. For more information about this example, see [How to: Add ToolTips to Individual Cells in a Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/add-tooltips-to-individual-cells-in-a-wf-datagridview-control). + The following code example illustrates the use of this type. For more information about this example, see [How to: Add ToolTips to Individual Cells in a Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/add-tooltips-to-individual-cells-in-a-wf-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCell.ToolTipText/cpp/datagridviewcell.tooltiptext.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewCell/Overview/datagridviewcell.tooltiptext.cs" id="Snippet1"::: @@ -265,7 +265,7 @@ ## Examples - The following code example demonstrates how to use the method of the class to determine the available drawing area in a cell. This code example is part of a larger example provided in [How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/disable-buttons-in-a-button-column-in-the-datagrid). + The following code example demonstrates how to use the method of the class to determine the available drawing area in a cell. This code example is part of a larger example provided in [How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/disable-buttons-in-a-button-column-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CommitEdit/form1.cs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DisabledButtons/VB/form1.vb" id="Snippet20"::: @@ -319,7 +319,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -509,7 +509,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -554,7 +554,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -714,7 +714,7 @@ ## Examples - The following code example demonstrates how to override the property in a `CalendarCell` class that derives from . This example is part of a larger code example provided in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/framework/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). + The following code example demonstrates how to override the property in a `CalendarCell` class that derives from . This example is part of a larger code example provided in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/desktop/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/EditingControl/datagridviewcalendarcolumn.cs" id="Snippet200"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCalendarColumn/VB/datagridviewcalendarcolumn.vb" id="Snippet200"::: @@ -966,7 +966,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1091,7 +1091,7 @@ ## Examples - The following code example demonstrates how to override the property in a `CalendarCell` class that derives from . This example is part of a larger code example provided in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/framework/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). + The following code example demonstrates how to override the property in a `CalendarCell` class that derives from . This example is part of a larger code example provided in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/desktop/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/EditingControl/datagridviewcalendarcolumn.cs" id="Snippet200"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCalendarColumn/VB/datagridviewcalendarcolumn.vb" id="Snippet200"::: @@ -1152,7 +1152,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -2048,7 +2048,7 @@ that inherits its settings from the objects of the cell's parent row, column, and . For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + This method returns a that inherits its settings from the objects of the cell's parent row, column, and . For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). ]]> @@ -2235,7 +2235,7 @@ ## Remarks Getting the value of the property automatically instantiates a new if the property has not previously been accessed. Therefore, you must use the property to determine whether the property is currently set to a instance. This is useful to determine which properties of the object returned by the property represent styles set specifically for the cell. - For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). ]]> @@ -2323,7 +2323,7 @@ ## Remarks The control displays its cells using the styles indicated by the cell property, which inherits styles from other properties of type . The styles specified through the property override the styles specified through all other cell-style properties, but do not necessarily indicate all the styles that contribute to the cell's appearance. - For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). ]]> @@ -2404,7 +2404,7 @@ ## Examples - The following code example demonstrates how to override the method in a simple class that derives from the class. This example is part of a larger code example provided in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/framework/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). + The following code example demonstrates how to override the method in a simple class that derives from the class. This example is part of a larger code example provided in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/desktop/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/EditingControl/datagridviewcalendarcolumn.cs" id="Snippet200"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCalendarColumn/VB/datagridviewcalendarcolumn.vb" id="Snippet200"::: @@ -2510,7 +2510,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -2601,7 +2601,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -2652,7 +2652,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -2701,7 +2701,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -3113,7 +3113,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -3157,7 +3157,7 @@ ]]> - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -3210,7 +3210,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -3261,7 +3261,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -3312,7 +3312,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -3363,7 +3363,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -3414,7 +3414,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -4026,7 +4026,7 @@ ## Examples - The following code example illustrates the use of this method. This example is part of a larger example available in [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](/dotnet/framework/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior). + The following code example illustrates the use of this method. This example is part of a larger example available in [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](/dotnet/desktop/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/InvalidateCell/rollovercell.cs" id="Snippet220"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRolloverCell/VB/rollovercell.vb" id="Snippet220"::: @@ -4082,7 +4082,7 @@ ## Examples - The following code example illustrates the use of this method. This example is part of a larger example available in [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](/dotnet/framework/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior). + The following code example illustrates the use of this method. This example is part of a larger example available in [How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance](/dotnet/desktop/winforms/controls/customize-cells-and-columns-in-the-datagrid-by-extending-behavior). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/InvalidateCell/rollovercell.cs" id="Snippet220"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRolloverCell/VB/rollovercell.vb" id="Snippet220"::: @@ -4373,7 +4373,7 @@ method of a . This code example is part of a larger example provided in [How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/disable-buttons-in-a-button-column-in-the-datagrid). + The following code example demonstrates how to override the method of a . This code example is part of a larger example provided in [How to: Disable Buttons in a Button Column in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/disable-buttons-in-a-button-column-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CommitEdit/form1.cs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DisabledButtons/VB/form1.vb" id="Snippet20"::: @@ -4430,7 +4430,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -5114,7 +5114,7 @@ ## Remarks The control displays its cells using the styles indicated by the cell property, which inherits styles from other properties of type . The styles specified through the property override the styles specified through all other cell-style properties, but do not necessarily indicate all the styles that contribute to the cell's appearance. - For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). @@ -5255,7 +5255,7 @@ ## Examples - The following code example shows how to set the property within an event handler for the event. This example is part of a larger code example provided in [How to: Add ToolTips to Individual Cells in a Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/add-tooltips-to-individual-cells-in-a-wf-datagridview-control). + The following code example shows how to set the property within an event handler for the event. This example is part of a larger code example provided in [How to: Add ToolTips to Individual Cells in a Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/add-tooltips-to-individual-cells-in-a-wf-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCell.ToolTipText/cpp/datagridviewcell.tooltiptext.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewCell/Overview/datagridviewcell.tooltiptext.cs" id="Snippet1"::: @@ -5359,7 +5359,7 @@ ## Examples - The following code example shows how to update a cell's contents with the property. This example is part of a larger code example provided in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). + The following code example shows how to update a cell's contents with the property. This example is part of a larger code example provided in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewRowDemo.cpp" id="Snippet211"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewRowDemo.cs" id="Snippet211"::: diff --git a/xml/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventArgs.xml b/xml/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventArgs.xml index c0cd5ad5193..501898f6559 100644 --- a/xml/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventArgs.xml @@ -68,7 +68,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventHandler.xml b/xml/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventHandler.xml index 85c6a194a32..9a11f7cf5b3 100644 --- a/xml/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewCellContextMenuStripNeededEventHandler.xml @@ -79,6 +79,6 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCellErrorTextNeededEventArgs.xml b/xml/System.Windows.Forms/DataGridViewCellErrorTextNeededEventArgs.xml index 51250c5c87c..6759c0784e9 100644 --- a/xml/System.Windows.Forms/DataGridViewCellErrorTextNeededEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewCellErrorTextNeededEventArgs.xml @@ -63,7 +63,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCellErrorTextNeededEventHandler.xml b/xml/System.Windows.Forms/DataGridViewCellErrorTextNeededEventHandler.xml index 6af4fa9719a..3221bac817c 100644 --- a/xml/System.Windows.Forms/DataGridViewCellErrorTextNeededEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewCellErrorTextNeededEventHandler.xml @@ -74,6 +74,6 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCellEventArgs.xml b/xml/System.Windows.Forms/DataGridViewCellEventArgs.xml index 6e11398b978..f55b7767d31 100644 --- a/xml/System.Windows.Forms/DataGridViewCellEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewCellEventArgs.xml @@ -23,52 +23,52 @@ Provides data for events related to cell and row operations. - class provides data for the following events: - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - - - -## Examples - The following code example demonstrates using and event handlers to determine whether a cell can be clicked. The example updates each property value to advertise the current image layout. This code is part of a larger example shown in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). - + class provides data for the following events: + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + + + +## Examples + The following code example demonstrates using and event handlers to determine whether a cell can be clicked. The example updates each property value to advertise the current image layout. This code is part of a larger example shown in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet15"::: + ]]> @@ -104,10 +104,10 @@ Initializes a new instance of the class. To be added. - is less than -1. - - -or- - + is less than -1. + + -or- + is less than -1. @@ -144,14 +144,14 @@ Gets a value indicating the column index of the cell that the event occurs for. The index of the column containing the cell that the event occurs for. - @@ -189,14 +189,14 @@ Gets a value indicating the row index of the cell that the event occurs for. The index of the row containing the cell that the event occurs for. - diff --git a/xml/System.Windows.Forms/DataGridViewCellEventHandler.xml b/xml/System.Windows.Forms/DataGridViewCellEventHandler.xml index e0e565c7269..2764ad8e8d2 100644 --- a/xml/System.Windows.Forms/DataGridViewCellEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewCellEventHandler.xml @@ -39,54 +39,54 @@ A that contains the event data. Represents the method that will handle events related to cell and row operations. - handles the following events: - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates using and event handlers to determine whether a cell can be clicked. The example updates each to advertise the current image layout. This code is part of a larger example shown in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). - + handles the following events: + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + +- + + When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates using and event handlers to determine whether a cell can be clicked. The example updates each to advertise the current image layout. This code is part of a larger example shown in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet15"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewCellFormattingEventArgs.xml b/xml/System.Windows.Forms/DataGridViewCellFormattingEventArgs.xml index 4dcea347b47..cbcdf411f75 100644 --- a/xml/System.Windows.Forms/DataGridViewCellFormattingEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewCellFormattingEventArgs.xml @@ -29,36 +29,36 @@ Provides data for the event of a . - event to customize the conversion of a cell value into a format suitable for display or to customize the appearance of a cell depending on its state or value. - - The event occurs every time each cell is painted, so you should avoid lengthy processing when handling this event. This event also occurs when the cell is retrieved or its method is called. - - When you handle the event, the property is initialized with the cell value. If you provide custom conversion from the cell value to the display value, set the property to the converted value, ensuring that the new value is of the type specified by the cell property. To indicate that no further value formatting is necessary, set the property to `true`. - - When the event handler completes, if the is `null` or is not of the correct type, or the property is `false`, the is formatted using the , , , and properties of the cell style returned by the property, which is initialized using the cell property. - - Regardless of the value of the property, the display properties of the object returned by the property are used to render the cell. - - For more information about custom formatting using the event, see [How to: Customize Data Formatting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-data-formatting-in-the-windows-forms-datagridview-control). - - To avoid performance penalties when handling this event, access the cell through the parameters of the event handler rather than accessing the cell directly. - - To customize the conversion of a formatted, user-specified value into an actual cell value, handle the event. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates how to handle . - + event to customize the conversion of a cell value into a format suitable for display or to customize the appearance of a cell depending on its state or value. + + The event occurs every time each cell is painted, so you should avoid lengthy processing when handling this event. This event also occurs when the cell is retrieved or its method is called. + + When you handle the event, the property is initialized with the cell value. If you provide custom conversion from the cell value to the display value, set the property to the converted value, ensuring that the new value is of the type specified by the cell property. To indicate that no further value formatting is necessary, set the property to `true`. + + When the event handler completes, if the is `null` or is not of the correct type, or the property is `false`, the is formatted using the , , , and properties of the cell style returned by the property, which is initialized using the cell property. + + Regardless of the value of the property, the display properties of the object returned by the property are used to render the cell. + + For more information about custom formatting using the event, see [How to: Customize Data Formatting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-data-formatting-in-the-windows-forms-datagridview-control). + + To avoid performance penalties when handling this event, access the cell through the parameters of the event handler rather than accessing the cell directly. + + To customize the conversion of a formatted, user-specified value into an actual cell value, handle the event. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates how to handle . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BackgroundColor/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: + ]]> @@ -80,8 +80,8 @@ - Cell Styles in the Windows Forms DataGridView Control - How to: Customize Data Formatting in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control + How to: Customize Data Formatting in the Windows Forms DataGridView Control @@ -127,29 +127,29 @@ The style of the cell that caused the event. Initializes a new instance of the class. - property. For example, if a cell is formatting picture names as bitmaps, `value` is the that contains the picture name, and `desiredType` is a representing the type. - - If the event handler does not set the property to a type that can be displayed by the cell, the cell contents will be formatted using the , , and properties. - - - -## Examples - The following code example demonstrates how to use a . - + property. For example, if a cell is formatting picture names as bitmaps, `value` is the that contains the picture name, and `desiredType` is a representing the type. + + If the event handler does not set the property to a type that can be displayed by the cell, the cell contents will be formatted using the , , and properties. + + + +## Examples + The following code example demonstrates how to use a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BackgroundColor/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: + ]]> - is less than -1 - - -or- - + is less than -1 + + -or- + is less than -1. @@ -161,7 +161,7 @@ - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -201,29 +201,29 @@ Gets or sets the style of the cell that is being formatted. A that represents the display style of the cell being formatted. The default is the value of the cell's property. - property will change how the cell and its contents are displayed. To avoid performance penalties, use this property to change the cell styles rather than accessing the cell directly. - - For more information about cell styles, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control) - - - -## Examples - The following code example demonstrates how to use the property to color the background of cells that contain the string "Pink" to . - + property will change how the cell and its contents are displayed. To avoid performance penalties, use this property to change the cell styles rather than accessing the cell directly. + + For more information about cell styles, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control) + + + +## Examples + The following code example demonstrates how to use the property to color the background of cells that contain the string "Pink" to . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BackgroundColor/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -258,20 +258,20 @@ Gets the column index of the cell that is being formatted. The column index of the cell that is being formatted. - property to obtain an index into the property of a . - - - -## Examples - The following code example demonstrates how to use the property to retrieve column properties. - + property to obtain an index into the property of a . + + + +## Examples + The following code example demonstrates how to use the property to retrieve column properties. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BackgroundColor/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: + ]]> @@ -316,20 +316,20 @@ if the formatting for the cell value has been handled; otherwise, . The default value is . - event, set the property to `true` after setting the property if no further value formatting is required. If the property value is `false` when the event handler exits, the formatting will be applied to the value as indicated by the , , , and properties of the object returned by the property. - - - -## Examples - The following code example sets the property to `true` to signal that formatting for this cell is finished. - + event, set the property to `true` after setting the property if no further value formatting is required. If the property value is `false` when the event handler exits, the formatting will be applied to the value as indicated by the , , , and properties of the object returned by the property. + + + +## Examples + The following code example sets the property to `true` to signal that formatting for this cell is finished. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BackgroundColor/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: + ]]> @@ -374,20 +374,20 @@ Gets the row index of the cell that is being formatted. The row index of the cell that is being formatted. - property to obtain an index into the property of a . - - - -## Examples - The following code example demonstrates how to use the property to retrieve the cell being formatted. The cell reference is then used to set the cell's ToolTip text. - + property to obtain an index into the property of a . + + + +## Examples + The following code example demonstrates how to use the property to retrieve the cell being formatted. The cell reference is then used to set the cell's ToolTip text. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCell.ToolTipText/cpp/datagridviewcell.tooltiptext.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewCell/Overview/datagridviewcell.tooltiptext.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCell.ToolTipText/VB/datagridviewcell.tooltiptext.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCell.ToolTipText/VB/datagridviewcell.tooltiptext.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewCellFormattingEventHandler.xml b/xml/System.Windows.Forms/DataGridViewCellFormattingEventHandler.xml index 34b1a2bbdc4..da3b780b628 100644 --- a/xml/System.Windows.Forms/DataGridViewCellFormattingEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewCellFormattingEventHandler.xml @@ -39,45 +39,45 @@ A that contains the event data. Represents the method that will handle the event of a . - event to customize the conversion of a cell value into a format suitable for display or to customize the appearance of a cell depending on its state or value. - - The event occurs every time each cell is painted, so you should avoid lengthy processing when handling this event. This event also occurs when the cell is retrieved or its method is called. - - When you handle the event, the property is initialized with the cell value. If you provide custom conversion from the cell value to the display value, set the property to the converted value, ensuring that the new value is of the type specified by the cell property. To indicate that no further value formatting is necessary, set the property to `true`. - - When the event handler completes, if the is `null` or is not of the correct type, or the property is `false`, the is formatted using the , , , and properties of the cell style returned by the property, which is initialized using the cell property. - - Regardless of the value of the property, the display properties of the object returned by the property are used to render the cell. - - For more information about custom formatting using the event, see [How to: Customize Data Formatting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-data-formatting-in-the-windows-forms-datagridview-control). - - To avoid performance penalties when handling this event, access the cell through the parameters of the event handler rather than accessing the cell directly. - - To customize the conversion of a formatted, user-specified value into an actual cell value, handle the event. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates how to handle the event. - + event to customize the conversion of a cell value into a format suitable for display or to customize the appearance of a cell depending on its state or value. + + The event occurs every time each cell is painted, so you should avoid lengthy processing when handling this event. This event also occurs when the cell is retrieved or its method is called. + + When you handle the event, the property is initialized with the cell value. If you provide custom conversion from the cell value to the display value, set the property to the converted value, ensuring that the new value is of the type specified by the cell property. To indicate that no further value formatting is necessary, set the property to `true`. + + When the event handler completes, if the is `null` or is not of the correct type, or the property is `false`, the is formatted using the , , , and properties of the cell style returned by the property, which is initialized using the cell property. + + Regardless of the value of the property, the display properties of the object returned by the property are used to render the cell. + + For more information about custom formatting using the event, see [How to: Customize Data Formatting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-data-formatting-in-the-windows-forms-datagridview-control). + + To avoid performance penalties when handling this event, access the cell through the parameters of the event handler rather than accessing the cell directly. + + To customize the conversion of a formatted, user-specified value into an actual cell value, handle the event. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates how to handle the event. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BackgroundColor/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet1"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control - How to: Customize Data Formatting in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control + How to: Customize Data Formatting in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCellPaintingEventArgs.xml b/xml/System.Windows.Forms/DataGridViewCellPaintingEventArgs.xml index f2133cedabd..995adb7a22a 100644 --- a/xml/System.Windows.Forms/DataGridViewCellPaintingEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewCellPaintingEventArgs.xml @@ -29,19 +29,19 @@ Provides data for the event. - event is raised for each that is visible on a . To improve performance, set the properties in a to change the appearance of the cell instead of directly accessing a cell in the . If you manually paint the cell, set the property to `true`. If you do not set to `true`, the cell will paint over your customizations. - - - -## Examples - The following code example illustrates the use of this type. For more information, see [How to: Customize the Appearance of Cells in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-cells-in-the-datagrid). - + event is raised for each that is visible on a . To improve performance, set the properties in a to change the appearance of the cell instead of directly accessing a cell in the . If you manually paint the cell, set the property to `true`. If you do not set to `true`, the cell will paint over your customizations. + + + +## Examples + The following code example illustrates the use of this type. For more information, see [How to: Customize the Appearance of Cells in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-cells-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellPainting/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: + ]]> @@ -122,14 +122,14 @@ Initializes a new instance of the class. To be added. - is . - - -or- - - is . - - -or- - + is . + + -or- + + is . + + -or- + is . is not a valid bitwise combination of values. @@ -174,21 +174,21 @@ Gets the border style of the current . A that represents the border style of the . - by setting the properties of the property to one of the values. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + by setting the properties of the property to one of the values. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet302"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: + ]]> @@ -229,14 +229,14 @@ Get the bounds of the current . A that represents the bounds of the current . - @@ -277,19 +277,19 @@ Gets the cell style of the current . A that contains the cell style of the current . - by setting the properties of the property. - - - -## Examples - The following code example demonstrates the use of this member. - + by setting the properties of the property. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellPainting/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: + ]]> @@ -329,21 +329,21 @@ Gets the area of the that needs to be repainted. A that represents the area of the that needs to be repainted. - property represents the area of the that needs to be repainted. For example, if a user covers the entire with another window, and then uncovers it, then represents the entire . If a user covers a small area of the , and then uncovers it, then represents the small area that was covered. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + property represents the area of the that needs to be repainted. For example, if a user covers the entire with another window, and then uncovers it, then represents the entire . If a user covers a small area of the , and then uncovers it, then represents the small area that was covered. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet302"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: + ]]> @@ -382,19 +382,19 @@ Gets the column index of the current . The column index of the current . - property returns -1 when a row header cell is being painted. - - - -## Examples - The following code example demonstrates the use of this member. - + property returns -1 when a row header cell is being painted. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellPainting/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: + ]]> @@ -434,21 +434,21 @@ Gets a string that represents an error message for the current . A string that represents an error message for the current . - is a row header cell, the property is the same as the property of the . When the current cell is a data cell, is the same as the property of the . - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + is a row header cell, the property is the same as the property of the . When the current cell is a data cell, is the same as the property of the . + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet302"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: + ]]> @@ -491,21 +491,21 @@ Gets the formatted value of the current . The formatted value of the current . - property contains the value of the cell after the or property has been applied to it, and after the event has been handled. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + property contains the value of the cell after the or property has been applied to it, and after the event has been handled. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet302"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: + ]]> @@ -547,14 +547,14 @@ Gets the used to paint the current . The used to paint the current . - @@ -594,10 +594,10 @@ Paints the specified parts of the cell for the area in the specified bounds. To be added. - is less than -1 or greater than or equal to the number of rows in the control. - - -or- - + is less than -1 or greater than or equal to the number of rows in the control. + + -or- + is less than -1 or greater than or equal to the number of columns in the control. @@ -635,10 +635,10 @@ Paints the cell background for the area in the specified bounds. To be added. - is less than -1 or greater than or equal to the number of rows in the control. - - -or- - + is less than -1 or greater than or equal to the number of rows in the control. + + -or- + is less than -1 or greater than or equal to the number of columns in the control. @@ -673,10 +673,10 @@ Paints the cell content for the area in the specified bounds. To be added. - is less than -1 or greater than or equal to the number of rows in the control. - - -or- - + is less than -1 or greater than or equal to the number of rows in the control. + + -or- + is less than -1 or greater than or equal to the number of columns in the control. @@ -713,16 +713,16 @@ The cell parts that are to be painted. A bitwise combination of values specifying the parts to be painted. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet302"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: + ]]> @@ -760,19 +760,19 @@ Gets the row index of the current . The row index of the current . - property returns -1 when a column header is being painted. - - - -## Examples - The following code example demonstrates the use of this member. - + property returns -1 when a column header is being painted. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellPainting/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: + ]]> @@ -811,16 +811,16 @@ Gets the state of the current . A bitwise combination of values that specifies the state of the cell. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet302"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet302"::: + ]]> @@ -861,19 +861,19 @@ Gets the value of the current . The value of the current . - property contains the value of the cell before any formatting occurs. - - - -## Examples - The following code example demonstrates the use of this member. - + property contains the value of the cell before any formatting occurs. + + + +## Examples + The following code example demonstrates the use of this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellPainting/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewCellPaintingEventHandler.xml b/xml/System.Windows.Forms/DataGridViewCellPaintingEventHandler.xml index b72b0235884..8b847fa05ad 100644 --- a/xml/System.Windows.Forms/DataGridViewCellPaintingEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewCellPaintingEventHandler.xml @@ -39,27 +39,27 @@ A that contains the event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following example illustrates the use of this event to customize the appearance of all cells in a particular column. - - This code is part of a larger example available in [How to: Customize the Appearance of Cells in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-cells-in-the-datagrid). - + delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following example illustrates the use of this event to customize the appearance of all cells in a particular column. + + This code is part of a larger example available in [How to: Customize the Appearance of Cells in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-cells-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellPainting/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCellPainting/VB/form1.vb" id="Snippet10"::: + ]]> - How to: Customize the Appearance of Cells in the Windows Forms DataGridView Control + How to: Customize the Appearance of Cells in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCellStyle.xml b/xml/System.Windows.Forms/DataGridViewCellStyle.xml index 88943bfbb3a..53392c1b028 100644 --- a/xml/System.Windows.Forms/DataGridViewCellStyle.xml +++ b/xml/System.Windows.Forms/DataGridViewCellStyle.xml @@ -45,19 +45,19 @@ Represents the formatting and style information applied to individual cells within a control. - class lets you share style information across multiple cells, rows, columns, and row or column headers, avoiding the memory requirements of setting style properties on individual cells. For more information about classes that have a property of type and how they relate to each other, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). - - - -## Examples - The following code example demonstrates the effect of setting properties on multiple objects. This example sets the background color of cells in the by setting the property on the property. The background color is overridden on alternating rows because the property is set on the property. The example also determines the format of dates in the column named `Last Prepared` by setting the property on the column's property. - + class lets you share style information across multiple cells, rows, columns, and row or column headers, avoiding the memory requirements of setting style properties on individual cells. For more information about classes that have a property of type and how they relate to each other, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + + + +## Examples + The following code example demonstrates the effect of setting properties on multiple objects. This example sets the background color of cells in the by setting the property on the property. The background color is overridden on alternating rows because the property is set on the property. The example also determines the format of dates in the column named `Last Prepared` by setting the property on the column's property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AllowUserToAddRows/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet10"::: + ]]> @@ -75,8 +75,8 @@ - Cell Styles in the Windows Forms DataGridView Control - DataGridView Control Overview (Windows Forms) + Cell Styles in the Windows Forms DataGridView Control + DataGridView Control Overview (Windows Forms) @@ -87,7 +87,7 @@ Initializes a new instance of the class. - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -113,7 +113,7 @@ Initializes a new instance of the class using default property values. To be added. - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -145,7 +145,7 @@ is . - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -180,20 +180,20 @@ Gets or sets a value indicating the position of the cell content within a cell. One of the values. The default is . - The property value is not a valid value. - Data Formatting in the Windows Forms DataGridView Control - Cell Styles in the Windows Forms DataGridView Control + Data Formatting in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -225,17 +225,17 @@ The to apply to the current . Applies the specified to the current . - method applies the values of the properties that are set in the `dataGridViewCellStyle` parameter to the current . If a property is not set in `dataGridViewCellStyle`, the current retains its value of that property. - + method applies the values of the properties that are set in the `dataGridViewCellStyle` parameter to the current . If a property is not set in `dataGridViewCellStyle`, the current retains its value of that property. + ]]> is . - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -264,18 +264,18 @@ Gets or sets the background color of a cell. A that represents the background color of a cell. The default is . - by setting the property on the property. Note that the background color is overridden on alternating rows because the property is set on the property. This code example is part of a larger example provided for the class. - + by setting the property on the property. Note that the background color is overridden on alternating rows because the property is set on the property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AllowUserToAddRows/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -306,7 +306,7 @@ A that represents an exact copy of this cell style. To be added. - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -358,22 +358,22 @@ Gets or sets the value saved to the data source when the user enters a null value into a cell. The value saved to the data source when the user specifies a null cell value. The default is . - property. When the user commits the change, the underlying cell value is set to the value of the property or to `null` if is and the cell is a reference type. This conversion does not occur when you set the property programmatically. - + property. When the user commits the change, the underlying cell value is set to the value of the property or to `null` if is and the cell is a reference type. This conversion does not occur when you set the property programmatically. + > [!NOTE] -> The control does not display the property value for cell values equal to the property value when is set to a value other than or `null`. In this case, you can handle the event to display the property value. For more information, see the code example in this topic. - - - -## Examples - The following code example illustrates the use of this property. In this example, a event handler displays the value of the property when the cell value equals . - +> The control does not display the property value for cell values equal to the property value when is set to a value other than or `null`. In this case, you can handle the event to display the property value. For more information, see the code example in this topic. + + + +## Examples + The following code example illustrates the use of this property. In this example, a event handler displays the value of the property when the cell value equals . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BeginEdit/misc2.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc2/vb/misc2.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc2/vb/misc2.vb" id="Snippet50"::: + ]]> @@ -381,7 +381,7 @@ - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -417,7 +417,7 @@ if is a and has the same property values as this instance; otherwise, . To be added. - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -453,24 +453,24 @@ Gets or sets the font applied to the textual content of a cell. The applied to the cell text. The default is . - is immutable (its properties are read-only), you can modify this property only by assigning a new or existing to it; you cannot alter the properties of the returned object directly. - - - -## Examples - The following code example sets the font for column headers. To run this example, paste the code into a form that contains a named `GridView1`, and then call the `SetupUpDataGridView` and `PopulateDataGridView` methods from the form's constructor or method. Ensure all events are associated with their event-handling methods. - + is immutable (its properties are read-only), you can modify this property only by assigning a new or existing to it; you cannot alter the properties of the returned object directly. + + + +## Examples + The following code example sets the font for column headers. To run this example, paste the code into a form that contains a named `GridView1`, and then call the `SetupUpDataGridView` and `PopulateDataGridView` methods from the form's constructor or method. Ensure all events are associated with their event-handling methods. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/CPP/form1.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BackgroundColor/form1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewUnbound/VB/form1.vb" id="Snippet5"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -499,23 +499,23 @@ Gets or sets the foreground color of a cell. A that represents the foreground color of a cell. The default is . - property typically should specify a color that contrasts with the property. - - - -## Examples - The following code example demonstrates how to set the and properties for cells in alternating rows. This code example is part of a larger example provided for the class. - + property typically should specify a color that contrasts with the property. + + + +## Examples + The following code example demonstrates how to set the and properties for cells in alternating rows. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AllowUserToAddRows/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -562,24 +562,24 @@ Gets or sets the format string applied to the textual content of a cell. A string that indicates the format of the cell value. The default is . - property specifies how cell values are formatted as strings. For more information, see [Formatting Types](/dotnet/standard/base-types/formatting-types). - - - -## Examples - The following code example sets the format of dates in the column named `Last Fixed` to "Month, year" by setting the property on the column's property. This code example is part of a larger example provided for the class. - + property specifies how cell values are formatted as strings. For more information, see [Formatting Types](/dotnet/standard/base-types/formatting-types). + + + +## Examples + The following code example sets the format of dates in the column named `Last Fixed` to "Month, year" by setting the property on the column's property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AllowUserToAddRows/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: + ]]> - Data Formatting in the Windows Forms DataGridView Control - Cell Styles in the Windows Forms DataGridView Control + Data Formatting in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -619,7 +619,7 @@ An used for cell formatting. The default is . To be added. - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -689,16 +689,16 @@ if the value of the property is the default value; otherwise, . - property has been explicitly set without having to store its default value for comparison. This is useful because the property has a non-empty default value, unlike most other properties, which have default values such as `null`, , or . - + property has been explicitly set without having to store its default value for comparison. This is useful because the property has a non-empty default value, unlike most other properties, which have default values such as `null`, , or . + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -738,15 +738,15 @@ if the property is the default value; otherwise, . - property has been explicitly set without having to store its default value for comparison. This is useful because the property has a non-empty default value, unlike most other properties, which have default values such as `null`, , or . - + property has been explicitly set without having to store its default value for comparison. This is useful because the property has a non-empty default value, unlike most other properties, which have default values such as `null`, , or . + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -786,15 +786,15 @@ if the value of the property is the default value; otherwise, . - property has been explicitly set without having to store its default value for comparison. This is useful because the property has a non-empty default value, unlike most other properties, which have default values such as `null`, , or . - + property has been explicitly set without having to store its default value for comparison. This is useful because the property has a non-empty default value, unlike most other properties, which have default values such as `null`, , or . + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -838,24 +838,24 @@ Gets or sets the cell display value corresponding to a cell value of or . The object used to indicate a null value in a cell. The default is . - cell with this cell style has a value of or `null` or the user edits the cell and presses CTRL+0, the control displays the property value. When a user edits a cell with this cell style and enters the value of this property or presses CTRL+0, the control sets the cell value to the value of the property or to `null` if is and the cell is a reference type. This conversion does not occur when you set the property programmatically. - + cell with this cell style has a value of or `null` or the user edits the cell and presses CTRL+0, the control displays the property value. When a user edits a cell with this cell style and enters the value of this property or presses CTRL+0, the control sets the cell value to the value of the property or to `null` if is and the cell is a reference type. This conversion does not occur when you set the property programmatically. + > [!NOTE] -> The control does not display the property value for cell values equal to the property value when is set to a value other than or `null`. In this case, you can handle the event to display the property value. For more information, see the code example in this topic. - - This property takes any object, which enables you to specify a value with a type appropriate to the display type of the cell. For example, you can set this property to string values for use by text box cells or images for use by image cells. - - - -## Examples - The following code example illustrates the use of this property. In this example, a event handler displays the value of the property when the cell value equals . - +> The control does not display the property value for cell values equal to the property value when is set to a value other than or `null`. In this case, you can handle the event to display the property value. For more information, see the code example in this topic. + + This property takes any object, which enables you to specify a value with a type appropriate to the display type of the cell. For example, you can set this property to string values for use by text box cells or images for use by image cells. + + + +## Examples + The following code example illustrates the use of this property. In this example, a event handler displays the value of the property when the cell value equals . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BeginEdit/misc2.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc2/vb/misc2.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc2/vb/misc2.vb" id="Snippet50"::: + ]]> @@ -863,8 +863,8 @@ - How to: Format Data in the Windows Forms DataGridView Control - Cell Styles in the Windows Forms DataGridView Control + How to: Format Data in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -893,25 +893,25 @@ Gets or sets the space between the edge of a and its content. A that represents the space between the edge of a and its content. - property affects where the editing control of the is drawn. For example, if you set on a to a that has a value of 10 for its , , , and properties, the content of the cell is drawn in the middle of the cell with a space of 10 pixels between the edges of the text box and the edges of the cell. - - - -## Examples - The following code example illustrates the use of this property in a control that contains owner-drawn rows. Each row displays text that spans the entire width of the row underneath the regular cell content. The property is used to provide the extra space for this text. In the example, the extra height required is stored in a constant called `CUSTOM_CONTENT_HEIGHT`. - - This code example is part of a larger example. For the complete example, see [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + property affects where the editing control of the is drawn. For example, if you set on a to a that has a value of 10 for its , , , and properties, the content of the cell is drawn in the middle of the cell with a space of 10 pixels between the edges of the text box and the edges of the cell. + + + +## Examples + The following code example illustrates the use of this property in a control that contains owner-drawn rows. Each row displays text that spans the entire width of the row underneath the regular cell content. The property is used to provide the extra space for this text. In the example, the extra height required is stored in a constant called `CUSTOM_CONTENT_HEIGHT`. + + This code example is part of a larger example. For the complete example, see [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet10"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -940,18 +940,18 @@ Gets or sets the background color used by a cell when it is selected. A that represents the background color of a selected cell. The default is . - control intended primarily for display. In this example, the visual appearance of the control is customized in several ways, and the control is configured for limited interactivity. This example is part of a larger example available in the class overview. - + control intended primarily for display. In this example, the visual appearance of the control is customized in several ways, and the control is configured for limited interactivity. This example is part of a larger example available in the class overview. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AllowUserToAddRows/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -980,23 +980,23 @@ Gets or sets the foreground color used by a cell when it is selected. A that represents the foreground color of a selected cell. The default is . - property typically should specify a color that contrasts with the property. - - - -## Examples - The following code example illustrates the use of this property in a control intended primarily for display. In this example, the visual appearance of the control is customized in several ways, and the control is configured for limited interactivity. This example is part of a larger example available in the class overview. - + property typically should specify a color that contrasts with the property. + + + +## Examples + The following code example illustrates the use of this property in a control intended primarily for display. In this example, the visual appearance of the control is customized in several ways, and the control is configured for limited interactivity. This example is part of a larger example available in the class overview. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AllowUserToAddRows/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -1035,15 +1035,15 @@ Creates an exact copy of this . A that represents an exact copy of this cell style. - instance is cast to an interface. - + instance is cast to an interface. + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -1092,7 +1092,7 @@ An object that contains additional data. The default is . To be added. - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -1123,7 +1123,7 @@ A string indicating the current property settings of the . To be added. - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -1158,25 +1158,25 @@ Gets or sets a value indicating whether textual content in a cell is wrapped to subsequent lines or truncated when it is too long to fit on a single line. One of the values. The default is . - is for a cell that contains text, the cell displays the text on a single line, and displays any embedded newline characters as box characters. If is for a cell that contains text, the cell displays newline characters as line breaks, but also wraps any lines that exceed the width of the cell. - - - -## Examples - The following code example illustrates the use of this property. - + is for a cell that contains text, the cell displays the text on a single line, and displays any embedded newline characters as box characters. If is for a cell that contains text, the cell displays newline characters as line breaks, but also wraps any lines that exceed the width of the cell. + + + +## Examples + The following code example illustrates the use of this property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellBeginEdit/datagridviewmisc.cs" id="Snippet074"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet074"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet074"::: + ]]> The property value is not a valid value. - How to: Format Data in the Windows Forms DataGridView Control - Cell Styles in the Windows Forms DataGridView Control + How to: Format Data in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventArgs.xml b/xml/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventArgs.xml index d256fc7b424..ad02b2a8b5c 100644 --- a/xml/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventArgs.xml @@ -63,7 +63,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventHandler.xml b/xml/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventHandler.xml index 8cfa2607920..3e2622066e9 100644 --- a/xml/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewCellToolTipTextNeededEventHandler.xml @@ -75,6 +75,6 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCellValidatingEventArgs.xml b/xml/System.Windows.Forms/DataGridViewCellValidatingEventArgs.xml index 5d901c3bef7..ff1a0110eec 100644 --- a/xml/System.Windows.Forms/DataGridViewCellValidatingEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewCellValidatingEventArgs.xml @@ -29,22 +29,22 @@ Provides data for the event of a control. - event lets you cancel changes to the current cell when the new value is not valid. Use the property to determine the current value. To determine the state of the current cell, use the and properties to access the cell through the collection. To cancel the change, set the property to `true`. - - When this event is canceled in data-bound mode, the new value is not pushed to the underlying data source. When this event is canceled in virtual mode, the event will not be raised. - - - -## Examples - The following code example handles the event to ensure that only positive integers are entered by the user. This example is part of a larger example available in the reference topic. - + event lets you cancel changes to the current cell when the new value is not valid. Use the property to determine the current value. To determine the state of the current cell, use the and properties to access the cell through the collection. To cancel the change, set the property to `true`. + + When this event is canceled in data-bound mode, the new value is not pushed to the underlying data source. When this event is canceled in virtual mode, the event will not be raised. + + + +## Examples + The following code example handles the event to ensure that only positive integers are entered by the user. This example is part of a larger example available in the reference topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/CPP/virtual.cpp" id="Snippet40"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellValidating/virtual.cs" id="Snippet40"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet40"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet40"::: + ]]> @@ -92,14 +92,14 @@ Gets the column index of the cell that needs to be validated. A zero-based integer that specifies the column index of the cell that needs to be validated. - @@ -141,20 +141,20 @@ Gets the formatted contents of the cell that needs to be validated. A reference to the formatted value. - property value. This is the value that you can validate before it is parsed into the cell property value. - - - -## Examples - The following code example handles the event to ensure that only positive integers are entered by the user. This example is part of a larger example available in the reference topic. - + property value. This is the value that you can validate before it is parsed into the cell property value. + + + +## Examples + The following code example handles the event to ensure that only positive integers are entered by the user. This example is part of a larger example available in the reference topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/CPP/virtual.cpp" id="Snippet40"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellValidating/virtual.cs" id="Snippet40"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet40"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet40"::: + ]]> @@ -195,14 +195,14 @@ Gets the row index of the cell that needs to be validated. A zero-based integer that specifies the row index of the cell that needs to be validated. - diff --git a/xml/System.Windows.Forms/DataGridViewCellValueEventArgs.xml b/xml/System.Windows.Forms/DataGridViewCellValueEventArgs.xml index 8e8ffbf6b0d..a6185afea77 100644 --- a/xml/System.Windows.Forms/DataGridViewCellValueEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewCellValueEventArgs.xml @@ -29,22 +29,22 @@ Provides data for the and events of the control. - and events to implement virtual mode in the control. For more information about virtual mode, see [Virtual Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/virtual-mode-in-the-windows-forms-datagridview-control). - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example handles the event to store updates and new entries in a data store object. This example is part of a larger example available in the reference topic. - + and events to implement virtual mode in the control. For more information about virtual mode, see [Virtual Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/virtual-mode-in-the-windows-forms-datagridview-control). + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example handles the event to store updates and new entries in a data store object. This example is part of a larger example available in the reference topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/CPP/virtual.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellValidating/virtual.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet10"::: + ]]> @@ -52,7 +52,7 @@ - Virtual Mode in the Windows Forms DataGridView Control + Virtual Mode in the Windows Forms DataGridView Control @@ -84,10 +84,10 @@ Initializes a new instance of the class. To be added. - is less than 0. - - -or- - + is less than 0. + + -or- + is less than 0. @@ -126,20 +126,20 @@ Gets a value indicating the column index of the cell that the event occurs for. The index of the column containing the cell that the event occurs for. - property to reference the cell that the event occurs for. - - - -## Examples - The following code example demonstrates how to use the property to retrieve cell values from the data store. This example is part of a larger example provided in [How to: Implement Virtual Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-implement-virtual-mode-in-the-windows-forms-datagridview-control). - + property to reference the cell that the event occurs for. + + + +## Examples + The following code example demonstrates how to use the property to retrieve cell values from the data store. This example is part of a larger example provided in [How to: Implement Virtual Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-implement-virtual-mode-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.VirtualMode/CPP/virtualmode.cpp" id="Snippet120"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CancelRowEdit/virtualmode.cs" id="Snippet120"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.VirtualMode/VB/virtualmode.vb" id="Snippet120"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.VirtualMode/VB/virtualmode.vb" id="Snippet120"::: + ]]> @@ -178,20 +178,20 @@ Gets a value indicating the row index of the cell that the event occurs for. The index of the row containing the cell that the event occurs for. - property to reference the cell that the event occurs for. - - - -## Examples - The following code example handles the event to store updates and new entries in a data store object. This example is part of a larger example available in the reference topic. - + property to reference the cell that the event occurs for. + + + +## Examples + The following code example handles the event to store updates and new entries in a data store object. This example is part of a larger example available in the reference topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/CPP/virtual.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellValidating/virtual.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet10"::: + ]]> @@ -235,20 +235,20 @@ Gets or sets the value of the cell that the event occurs for. An representing the cell's value. - event to store updates and new entries in a data store object. This example is part of a larger example available in the reference topic. - + event to store updates and new entries in a data store object. This example is part of a larger example available in the reference topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/CPP/virtual.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellValidating/virtual.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet10"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewCellValueEventHandler.xml b/xml/System.Windows.Forms/DataGridViewCellValueEventHandler.xml index d114c86f94f..e038fddc6ee 100644 --- a/xml/System.Windows.Forms/DataGridViewCellValueEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewCellValueEventHandler.xml @@ -39,22 +39,22 @@ A that contains the event data. Represents the method that will handle the event or event of a . - control. For more information about virtual mode, see [Virtual Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/virtual-mode-in-the-windows-forms-datagridview-control). - - When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example handles the event to store updates and new entries in a data store object. This example is part of a larger example available in the reference topic. - + control. For more information about virtual mode, see [Virtual Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/virtual-mode-in-the-windows-forms-datagridview-control). + + When you create a delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example handles the event to store updates and new entries in a data store object. This example is part of a larger example available in the reference topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/CPP/virtual.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellValidating/virtual.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._Virtual/VB/virtual.vb" id="Snippet10"::: + ]]> @@ -62,6 +62,6 @@ - Virtual Mode in the Windows Forms DataGridView Control + Virtual Mode in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCheckBoxCell.xml b/xml/System.Windows.Forms/DataGridViewCheckBoxCell.xml index 95af568148d..439ff7c6c0d 100644 --- a/xml/System.Windows.Forms/DataGridViewCheckBoxCell.xml +++ b/xml/System.Windows.Forms/DataGridViewCheckBoxCell.xml @@ -245,7 +245,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -296,7 +296,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -994,7 +994,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1041,7 +1041,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1087,7 +1087,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1132,7 +1132,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1178,7 +1178,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1224,7 +1224,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1347,7 +1347,7 @@ - Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control + Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control @@ -1394,7 +1394,7 @@ - Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control + Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewCheckBoxColumn.xml b/xml/System.Windows.Forms/DataGridViewCheckBoxColumn.xml index aab49a832ee..7ffd86730c7 100644 --- a/xml/System.Windows.Forms/DataGridViewCheckBoxColumn.xml +++ b/xml/System.Windows.Forms/DataGridViewCheckBoxColumn.xml @@ -37,24 +37,24 @@ Hosts a collection of objects. - class is a specialized type of the class used to logically host cells that indicate binary state. A has an associated in every that intersects it. Each cell supplies a user interface (UI) that is similar to a control. - - The default sort mode for this column type is . - - Typically, check box cell values are intended either for storage, like any other data, or for performing bulk operations. If you want to respond immediately when users click a check box cell, you can handle the event, but this event occurs before the cell value is updated. If you need the new value at the time of the click, one option is to calculate what the expected value will be based on the current value. Another approach is to commit the change immediately, and handle the event to respond to it. To commit the change when the cell is clicked, you must handle the event. In the handler, if the current cell is a check box cell, call the method and pass in the value. - - - -## Examples - The following code example demonstrates how to use a to mark which employees are out of the office. This example is part of a larger example available in the class overview topic. - + class is a specialized type of the class used to logically host cells that indicate binary state. A has an associated in every that intersects it. Each cell supplies a user interface (UI) that is similar to a control. + + The default sort mode for this column type is . + + Typically, check box cell values are intended either for storage, like any other data, or for performing bulk operations. If you want to respond immediately when users click a check box cell, you can handle the event, but this event occurs before the cell value is updated. If you need the new value at the time of the click, one option is to calculate what the expected value will be based on the current value. Another approach is to commit the change immediately, and handle the event to respond to it. To commit the change when the cell is clicked, you must handle the event. In the handler, if the current cell is a check box cell, call the method and pass in the value. + + + +## Examples + The following code example demonstrates how to use a to mark which employees are out of the office. This example is part of a larger example available in the class overview topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/CPP/employees.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellContentClick/employees.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet20"::: + ]]> @@ -109,11 +109,11 @@ Initializes a new instance of the class to the default state. - constructor. - + constructor. + ]]> @@ -146,19 +146,19 @@ to display check boxes with three states; to display check boxes with two states. Initializes a new instance of the and configures it to display check boxes with two or three states. - |A new with its property initialized to the `threeState` parameter value.| -||The value of the `threeState` parameter.| -||| -|The property of the object returned by the property.|| -|The property of the object returned by the property.| if `threeState` is `true`; otherwise, `false`.| - + |A new with its property initialized to the `threeState` parameter value.| +||The value of the `threeState` parameter.| +||| +|The property of the object returned by the property.|| +|The property of the object returned by the property.| if `threeState` is `true`; otherwise, `false`.| + ]]> @@ -213,23 +213,23 @@ Gets or sets the template used to create new cells. A that all other cells in the column are modeled after. The default value is a new instance. - class initialize this property to a newly created . - + class initialize this property to a newly created . + > [!CAUTION] -> Changing the properties of the cell template will not immediately affect the user interface (UI) of the column's existing cells. These changes are only apparent after the column is regenerated (for example, by sorting the column or through a call to the method). - - - -## Examples - The following code example demonstrates how to use a to mark which employees are out of the office. The cell template is used to apply the same color to all cells in the check box column. This example is part of a larger example available in the class overview topic. - +> Changing the properties of the cell template will not immediately affect the user interface (UI) of the column's existing cells. These changes are only apparent after the column is regenerated (for example, by sorting the column or through a call to the method). + + + +## Examples + The following code example demonstrates how to use a to mark which employees are out of the office. The cell template is used to apply the same color to all cells in the check box column. This example is part of a larger example available in the class overview topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/CPP/employees.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellContentClick/employees.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet20"::: + ]]> The property is set to a value that is not of type . @@ -276,34 +276,34 @@ Gets or sets the column's default cell style. The to be applied as the default style. - returned by this property has the following initial property values: - -|`DataGridViewCellStyle` property|Default value| -|--------------------------------------|-------------------| -||| -|| if the initial property value is `true`; otherwise, `false`.| - - These values override the value specified in the property of the control, but may be overridden by other cell style properties. For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). - - If the property of the object returned by the property has a value of `false`, changing the property value to `true` automatically sets to . If has a value of , changing the property value to `false` automatically sets to `false`. - - - -## Examples - The following code example demonstrates the use of this property. - + returned by this property has the following initial property values: + +|`DataGridViewCellStyle` property|Default value| +|--------------------------------------|-------------------| +||| +|| if the initial property value is `true`; otherwise, `false`.| + + These values override the value specified in the property of the control, but may be overridden by other cell style properties. For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + + If the property of the object returned by the property has a value of `false`, changing the property value to `true` automatically sets to . If has a value of , changing the property value to `false` automatically sets to `false`. + + + +## Examples + The following code example demonstrates the use of this property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewButtonColumn/DefaultCellStyle/changecolumnalignment.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewContentAlignment/VB/changecolumnalignment.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewContentAlignment/VB/changecolumnalignment.vb" id="Snippet1"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -355,22 +355,22 @@ Gets or sets the underlying value corresponding to a cell value of , which appears as an unchecked box. An representing a value that the cells in this column will treat as a value. The default is . - , , and properties determine the associated values of these states as they occur in the underlying data source. - - Getting or setting this property gets or sets the property of the cell object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - - - -## Examples - The following code example uses a to track the status of office lighting. The property associates "turnedOff" with `false`, the property associates "turnedOn" with `true`, and the property associates "unknown" to indeterminate. - + , , and properties determine the associated values of these states as they occur in the underlying data source. + + Getting or setting this property gets or sets the property of the cell object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + + + +## Examples + The following code example uses a to track the status of office lighting. The property associates "turnedOff" with `false`, the property associates "turnedOn" with `true`, and the property associates "unknown" to indeterminate. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/cpp/trivaluevirtualcheckbox.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewCheckBoxCell/FalseValue/trivaluevirtualcheckbox.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/VB/trivaluevirtualcheckbox.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/VB/trivaluevirtualcheckbox.vb" id="Snippet0"::: + ]]> The value of the property is . @@ -427,22 +427,22 @@ Gets or sets the flat style appearance of the check box cells. A value indicating the appearance of cells in the column. The default is . - and call the method before . - - Getting or setting this property gets or sets the property of the cell object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - - - -## Examples - The following code example demonstrates how to use a to mark which employees are out of the office. This example is part of a larger example available in the class overview topic. - + and call the method before . + + Getting or setting this property gets or sets the property of the cell object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + + + +## Examples + The following code example demonstrates how to use a to mark which employees are out of the office. This example is part of a larger example available in the class overview topic. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/CPP/employees.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellContentClick/employees.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewColumn_AllColumns_Bound_Employees/VB/employees.vb" id="Snippet20"::: + ]]> The value of the property is . @@ -503,22 +503,22 @@ Gets or sets the underlying value corresponding to an indeterminate or cell value, which appears as a disabled checkbox. An representing a value that the cells in this column will treat as an indeterminate value. The default is . - , , and properties determine the associated values of these states as they occur in the underlying data source. - - Getting or setting this property gets or sets the property of the cell object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - - - -## Examples - The following code example uses a to track the status of office lighting. The property associates "turnedOff" with `false`, the property associates "turnedOn" with `true`, and the property associates "unknown" to indeterminate. - + , , and properties determine the associated values of these states as they occur in the underlying data source. + + Getting or setting this property gets or sets the property of the cell object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + + + +## Examples + The following code example uses a to track the status of office lighting. The property associates "turnedOff" with `false`, the property associates "turnedOn" with `true`, and the property associates "unknown" to indeterminate. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/cpp/trivaluevirtualcheckbox.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewCheckBoxCell/FalseValue/trivaluevirtualcheckbox.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/VB/trivaluevirtualcheckbox.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/VB/trivaluevirtualcheckbox.vb" id="Snippet0"::: + ]]> The value of the property is . @@ -576,24 +576,24 @@ if the hosted objects are able to have a third, indeterminate, state; otherwise, . The default is . - property of the cell object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - - If the property of the object returned by the property has a value of `false`, changing the property value to `true` automatically sets to . If has a value of , changing the property value to `false` automatically sets to `false`. - - - -## Examples - The following code example uses a to track the status of office lighting. The property associates "turnedOff" with `false`, the property associates "turnedOn" with `true`, and the property associates "unknown" to indeterminate. - + property of the cell object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + + If the property of the object returned by the property has a value of `false`, changing the property value to `true` automatically sets to . If has a value of , changing the property value to `false` automatically sets to `false`. + + + +## Examples + The following code example uses a to track the status of office lighting. The property associates "turnedOff" with `false`, the property associates "turnedOn" with `true`, and the property associates "unknown" to indeterminate. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/cpp/trivaluevirtualcheckbox.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewCheckBoxCell/FalseValue/trivaluevirtualcheckbox.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/VB/trivaluevirtualcheckbox.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/VB/trivaluevirtualcheckbox.vb" id="Snippet0"::: + ]]> The value of the property is . @@ -685,22 +685,22 @@ Gets or sets the underlying value corresponding to a cell value of , which appears as a checked box. An representing a value that the cell will treat as a value. The default is . - , , and properties determine the associated values of these states as they occur in the underlying data source. - - Getting or setting this property gets or sets the property of the cell object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - - - -## Examples - The following code example uses a to track the status of office lighting. The property associates "turnedOff" with `false`, the property associates "turnedOn" with `true`, and the property associates "unknown" to indeterminate. - + , , and properties determine the associated values of these states as they occur in the underlying data source. + + Getting or setting this property gets or sets the property of the cell object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + + + +## Examples + The following code example uses a to track the status of office lighting. The property associates "turnedOff" with `false`, the property associates "turnedOn" with `true`, and the property associates "unknown" to indeterminate. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/cpp/trivaluevirtualcheckbox.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewCheckBoxCell/FalseValue/trivaluevirtualcheckbox.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/VB/trivaluevirtualcheckbox.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewTrinaryVirtualCheckBox/VB/trivaluevirtualcheckbox.vb" id="Snippet0"::: + ]]> The value of the property is . diff --git a/xml/System.Windows.Forms/DataGridViewClipboardCopyMode.xml b/xml/System.Windows.Forms/DataGridViewClipboardCopyMode.xml index 06c4d03f2df..65c9175307f 100644 --- a/xml/System.Windows.Forms/DataGridViewClipboardCopyMode.xml +++ b/xml/System.Windows.Forms/DataGridViewClipboardCopyMode.xml @@ -22,19 +22,19 @@ Defines constants that indicate whether content is copied from a control to the Clipboard. - property to indicate whether users can copy the text values of selected cells to the Clipboard and whether row and column header text is included. - - - -## Examples - The following code example demonstrates how to enable copying in the control. For the complete example, see [How to: Enable Users to Copy Multiple Cells to the Clipboard from the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/enable-users-to-copy-multiple-cells-to-the-clipboard-datagridview). - + property to indicate whether users can copy the text values of selected cells to the Clipboard and whether row and column header text is included. + + + +## Examples + The following code example demonstrates how to enable copying in the control. For the complete example, see [How to: Enable Users to Copy Multiple Cells to the Clipboard from the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/enable-users-to-copy-multiple-cells-to-the-clipboard-datagridview). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ClipboardCopyMode/datagridviewclipboarddemo.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewClipboardDemo/VB/datagridviewclipboarddemo.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewClipboardDemo/VB/datagridviewclipboarddemo.vb" id="Snippet10"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewColumn.xml b/xml/System.Windows.Forms/DataGridViewColumn.xml index 67809ff17fa..b0c1eabc5e3 100644 --- a/xml/System.Windows.Forms/DataGridViewColumn.xml +++ b/xml/System.Windows.Forms/DataGridViewColumn.xml @@ -60,24 +60,24 @@ Represents a column in a control. - class represents a logical column in a control. You can retrieve columns through the collection of the control. - - Unlike a , which contains the actual collection of cells in a , is used mainly to adjust the appearance and behavior of the column user interface (UI), such as column width and cell style. For more information about cell styles, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). - - Types that derive from typically initialize the property to a new instance of a related type derived from the class. Any column properties that relate to the appearance or behavior of individual cells are wrappers for the corresponding properties of the template cell. Changing one of these properties on the column automatically changes the value on the cell template and on all cells in the column. To override the specified value for individual cells, set the cell values after you set the column value. - - - -## Examples - The following code example creates a Windows Form with a and a set of buttons. Each button label describes an operation related to a property, such as swapping the first and last column (using the property) or changing the text of a column header (using the property). Clicking a button changes the associated property of the . - + class represents a logical column in a control. You can retrieve columns through the collection of the control. + + Unlike a , which contains the actual collection of cells in a , is used mainly to adjust the appearance and behavior of the column user interface (UI), such as column width and cell style. For more information about cell styles, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + + Types that derive from typically initialize the property to a new instance of a related type derived from the class. Any column properties that relate to the appearance or behavior of individual cells are wrappers for the corresponding properties of the template cell. Changing one of these properties on the column automatically changes the value on the cell template and on all cells in the column. To override the specified value for individual cells, set the cell values after you set the column value. + + + +## Examples + The following code example creates a Windows Form with a and a set of buttons. Each button label describes an operation related to a property, such as swapping the first and last column (using the property) or changing the text of a column header (using the property). Clicking a button changes the associated property of the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet100"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet100"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet100"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet100"::: + ]]> @@ -157,11 +157,11 @@ An existing to use as a template. Initializes a new instance of the class using an existing as a template. - property to the value of the `cellTemplate` parameter. - + property to the value of the `cellTemplate` parameter. + ]]> @@ -213,44 +213,44 @@ Gets or sets the mode by which the column automatically adjusts its width. A value that determines whether the column will automatically adjust its width and how it will determine its preferred width. The default is . - property, which is the same as the value of the property for all values except , which indicates that the value is inherited from the property instead. - - When the property value is , the column is resized along with other columns in that mode. All fill-mode columns in the control divide the available space in proportions determined by their property values. The width available for fill mode is determined by subtracting the widths of all other columns from the width of the client area of the control. If this width is smaller than the combined values of all fill-mode columns, the horizontal scroll bar is displayed, all fill-mode columns are shown with their minimum widths, and user column-resizing is disabled. For more information about column fill mode, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). - - When the property is set to any other value except , the column will manage its width so that its cell values are fully displayed without clipping. In content-based sizing modes, size adjustments occur whenever cell contents change or, if is enabled, whenever row heights change. Some content-based sizing modes let you limit the size adjustment to the currently displayed rows in order to increase performance. - - Only columns with a property value of `true` are resized, and changing the visibility of a column does not cause resizing to occur. Additionally, when columns are set to automatically resize, the user cannot adjust the column widths with the mouse. - - To adjust column widths programmatically, use the control's or methods or set the column property. - - For more information about content-based automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). - - - -## Examples - The following code example forces a column to automatically resize its width to fit its contents. This code example is part of a larger example provided for the class. - + property, which is the same as the value of the property for all values except , which indicates that the value is inherited from the property instead. + + When the property value is , the column is resized along with other columns in that mode. All fill-mode columns in the control divide the available space in proportions determined by their property values. The width available for fill mode is determined by subtracting the widths of all other columns from the width of the client area of the control. If this width is smaller than the combined values of all fill-mode columns, the horizontal scroll bar is displayed, all fill-mode columns are shown with their minimum widths, and user column-resizing is disabled. For more information about column fill mode, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). + + When the property is set to any other value except , the column will manage its width so that its cell values are fully displayed without clipping. In content-based sizing modes, size adjustments occur whenever cell contents change or, if is enabled, whenever row heights change. Some content-based sizing modes let you limit the size adjustment to the currently displayed rows in order to increase performance. + + Only columns with a property value of `true` are resized, and changing the visibility of a column does not cause resizing to occur. Additionally, when columns are set to automatically resize, the user cannot adjust the column widths with the mouse. + + To adjust column widths programmatically, use the control's or methods or set the column property. + + For more information about content-based automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + + + +## Examples + The following code example forces a column to automatically resize its width to fit its contents. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet109"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet109"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet109"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet109"::: + ]]> The specified value when setting this property is a that is not valid. - The specified value when setting this property results in an value of for a visible column when column headers are hidden. - - -or- - + The specified value when setting this property results in an value of for a visible column when column headers are hidden. + + -or- + The specified value when setting this property results in an value of for a visible column that is frozen. - Sizing Options in the Windows Forms DataGridView Control - Resizing Columns and Rows in the Windows Forms DataGridView Control + Sizing Options in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control @@ -306,23 +306,23 @@ Gets or sets the template used to create new cells. A that all other cells in the column are modeled after. The default is . - class initialize this property. The parameterless constructor sets the property to `null`; the other constructor copies the cell template from its parameter. - + class initialize this property. The parameterless constructor sets the property to `null`; the other constructor copies the cell template from its parameter. + > [!NOTE] -> Changing the properties of the cell template will not immediately affect the user interface (UI) of the column's existing cells. These changes are only apparent after the column is regenerated (for example, by sorting the column or through a call to the method). - - - -## Examples - The following code example demonstrates how to use a as a template for a . Style changes made to any cell in the column affect all of the column's cells. This code example is part of a larger example provided for the class. - +> Changing the properties of the cell template will not immediately affect the user interface (UI) of the column's existing cells. These changes are only apparent after the column is regenerated (for example, by sorting the column or through a call to the method). + + + +## Examples + The following code example demonstrates how to use a as a template for a . Style changes made to any cell in the column affect all of the column's cells. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet120"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet120"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet120"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet120"::: + ]]> @@ -368,11 +368,11 @@ Gets the run-time type of the cell template. The of the used as a template for this column. The default is . - is . Use this property to determine the actual derived type. - + is . Use this property to determine the actual derived type. + ]]> @@ -444,20 +444,20 @@ Gets or sets the shortcut menu for the column. The associated with the current . The default is . - property to add functionality for changing a cell's background color. - + property to add functionality for changing a cell's background color. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet130"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet130"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet130"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet130"::: + ]]> @@ -527,22 +527,22 @@ Gets or sets the name of the data source property or database column to which the is bound. The case-insensitive name of the property or database column associated with the . - property is set to `true`, each column automatically sets its property to the name of a property or database column in the data source specified by the property. This binding can also be performed manually, which is useful when you want to display only a subset of the properties or database columns available in the data source. In such cases, set the property to `false`, and then manually add each , setting the value of each property to the properties or database columns in the data source that you want to display. - - - -## Examples - The following code example shows how to choose what property each column will represent. - + property is set to `true`, each column automatically sets its property to the name of a property or database column in the data source specified by the property. This binding can also be performed manually, which is useful when you want to display only a subset of the properties or database columns available in the data source. In such cases, set the property to `false`, and then manually add each , setting the value of each property to the properties or database columns in the data source that you want to display. + + + +## Examples + The following code example shows how to choose what property each column will represent. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewColumn/DataPropertyName/collectionbound.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._CollectionBound/VB/collectionbound.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._CollectionBound/VB/collectionbound.vb" id="Snippet20"::: + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewColumn/DataPropertyName/collectionbound.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._CollectionBound/VB/collectionbound.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._CollectionBound/VB/collectionbound.vb" id="Snippet10"::: + ]]> @@ -585,27 +585,27 @@ Gets or sets the column's default cell style. A that represents the default style of the cells in the column. - control displays its cells using the styles indicated by the cell property, which inherits styles from other properties of type . For cells in this column, the styles specified through the property override the styles specified through the property, but are overridden by the styles specified through the , , , and properties. - - For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). - - - -## Examples - The following code example uses the property to set the content alignment of various columns. - + control displays its cells using the styles indicated by the cell property, which inherits styles from other properties of type . For cells in this column, the styles specified through the property override the styles specified through the property, but are overridden by the styles specified through the , , , and properties. + + For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + + + +## Examples + The following code example uses the property to set the content alignment of various columns. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewButtonColumn/DefaultCellStyle/changecolumnalignment.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewContentAlignment/VB/changecolumnalignment.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewContentAlignment/VB/changecolumnalignment.vb" id="Snippet1"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control - Best Practices for Scaling the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -652,35 +652,35 @@ Gets or sets the display order of the column relative to the currently displayed columns. The zero-based position of the column as it is displayed in the associated , or -1 if the band is not contained within a control. - property, the property corresponds to the current position of the column as displayed by the user interface (UI). By default, each column's is set to numbers of increasing order, which reflects the order in which they were added. The property value does not affect the value. To determine the display position of a column based on its visibility or other state, use the , , or method of the class. - - Every column in the control has a unique value. The values start with 0 and proceed in numerical order without skipping any values. When you change the value for a column, the values for other columns are changed to reflect the new order. - - If the column has an associated control, setting this property will cause the control to redraw itself. - - - -## Examples - The following code example uses the property to swap the visual position of the first and last columns. Note that insertions occur before the . This code example is part of a larger example provided for the class. - + property, the property corresponds to the current position of the column as displayed by the user interface (UI). By default, each column's is set to numbers of increasing order, which reflects the order in which they were added. The property value does not affect the value. To determine the display position of a column based on its visibility or other state, use the , , or method of the class. + + Every column in the control has a unique value. The values start with 0 and proceed in numerical order without skipping any values. When you change the value for a column, the values for other columns are changed to reflect the new order. + + If the column has an associated control, setting this property will cause the control to redraw itself. + + + +## Examples + The following code example uses the property to swap the visual position of the first and last columns. Note that insertions occur before the . This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet170"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet170"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet170"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet170"::: + ]]> - is not and the specified value when setting this property is less than 0 or greater than or equal to the number of columns in the control. - - -or- - - is and the specified value when setting this property is less than -1. - - -or- - + is not and the specified value when setting this property is less than 0 or greater than or equal to the number of columns in the control. + + -or- + + is and the specified value when setting this property is less than -1. + + -or- + The specified value when setting this property is equal to Int32.MaxValue. @@ -762,21 +762,21 @@ Occurs when the is disposed. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `DataGridViewColumn1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `DataGridViewColumn1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet370"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet370"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet370"::: + ]]> @@ -814,20 +814,20 @@ Gets or sets the width, in pixels, of the column divider. The thickness, in pixels, of the divider (the column's right margin). - . The extra edge does not extend the area in which users can double-click to automatically resize a column. To resize a column, the user must double-click on the boundary between the divider and the adjacent column. - - - -## Examples - The following code example adds a vertical edge after the third column. This code example is part of a larger example provided for the class. - + . The extra edge does not extend the area in which users can double-click to automatically resize a column. To resize a column, the user must double-click on the boundary between the divider and the adjacent column. + + + +## Examples + The following code example adds a vertical edge after the third column. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet110"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet110"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet110"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet110"::: + ]]> @@ -870,29 +870,29 @@ Gets or sets a value that represents the width of the column when it is in fill mode relative to the widths of other fill-mode columns in the control. A representing the width of the column when it is in fill mode relative to the widths of other fill-mode columns. The default is 100. - property value is , the column is resized along with other columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. All fill-mode columns in the control divide the available space in proportions determined by their property values. For more information about column fill mode, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). - - The maximum sum of values for all columns in a control is 65535. - - - -## Examples - The following code example illustrates the use of this property. This example is part of a larger example available in [How to: Set the Sizing Modes of the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-set-the-sizing-modes-of-the-windows-forms-datagridview-control). - + property value is , the column is resized along with other columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. All fill-mode columns in the control divide the available space in proportions determined by their property values. For more information about column fill mode, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). + + The maximum sum of values for all columns in a control is 65535. + + + +## Examples + The following code example illustrates the use of this property. This example is part of a larger example available in [How to: Set the Sizing Modes of the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-set-the-sizing-modes-of-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewAutoSizeColumnMode/Overview/sizingscenarios.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewSizingScenarios/vb/sizingscenarios.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewSizingScenarios/vb/sizingscenarios.vb" id="Snippet30"::: + ]]> The specified value when setting this property is less than or equal to 0. - Column Fill Mode in the Windows Forms DataGridView Control - Resizing Columns and Rows in the Windows Forms DataGridView Control + Column Fill Mode in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control @@ -936,20 +936,20 @@ to freeze the column; otherwise, . - property to `true`, the user cannot drag a column from one group to the other. - - - -## Examples - The following code example demonstrates how to use the property, which is nearly identical to the property of the class. This code example is part of a larger example provided for the class. - + property to `true`, the user cannot drag a column from one group to the other. + + + +## Examples + The following code example demonstrates how to use the property, which is nearly identical to the property of the class. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewBandDemo.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewBandDemo.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewbanddemo.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewbanddemo.vb" id="Snippet7"::: + ]]> @@ -989,15 +989,15 @@ Calculates the ideal width of the column based on the specified criteria. The ideal width, in pixels, of the column. - control to determine the ideal width of a column. - - A `fixedHeight` parameter value of `false` calculates the column width based on calculated row heights that will achieve ideal cell height-to-width ratios. For cell contents to wrap onto multiple lines, the cell style in effect for the cell must have a property value of . - - For more information about automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). - + control to determine the ideal width of a column. + + A `fixedHeight` parameter value of `false` calculates the column width based on calculated row heights that will achieve ideal cell height-to-width ratios. For cell contents to wrap onto multiple lines, the cell style in effect for the cell must have a property value of . + + For more information about automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + ]]> @@ -1054,20 +1054,20 @@ Gets or sets the that represents the column header. A that represents the header cell for the column. - and properties, users can also click the column header to sort or select the column. - - - -## Examples - The following code example uses the property to change column header style and contents. - + and properties, users can also click the column header to sort or select the column. + + + +## Examples + The following code example uses the property to change column header style and contents. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet150"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet150"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet150"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet150"::: + ]]> @@ -1109,23 +1109,23 @@ Gets or sets the caption text on the column's header cell. A with the desired text. The default is an empty string (""). - property. - + property. + > [!NOTE] -> There is no corresponding header text property for rows. To display labels in row headers, you must handle the event and paint your own labels when is -1. - - - -## Examples - The following code example uses the property to change the text in the column header. This code example is part of a larger example provided for the class. - +> There is no corresponding header text property for rows. To display labels in row headers, you must handle the event and paint your own labels when is -1. + + + +## Examples + The following code example uses the property to change the text in the column header. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet160"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet160"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet160"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet160"::: + ]]> @@ -1176,29 +1176,29 @@ Gets the sizing mode in effect for the column. The value in effect for the column. - property, which is the same as the value of the property for all values except , which indicates that the value is inherited from the property instead. - - When the property value is , the column is resized along with other columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. All fill-mode columns in the control divide the available space in proportions determined by their property values. For more information about column fill mode, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). - - When the property is set to any other value except , the column will manage its width so that its cell values are fully displayed without clipping. In content-based sizing modes, size adjustments occur whenever cell contents change or, if is enabled, whenever row heights change. Some content-based sizing modes let you limit the size adjustment to the currently displayed rows in order to increase performance. - - Only columns with a property value of `true` are resized, and changing the visibility of a column does not cause resizing to occur. Additionally, when columns are set to automatically resize, the user cannot adjust the column widths with the mouse. - - To adjust column widths programmatically, use the control's or methods or set the column property. - - For more information about content-based automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). - + property, which is the same as the value of the property for all values except , which indicates that the value is inherited from the property instead. + + When the property value is , the column is resized along with other columns in that mode so that all visible columns in the control exactly fill the horizontal width of the available display area. All fill-mode columns in the control divide the available space in proportions determined by their property values. For more information about column fill mode, see [Column Fill Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/column-fill-mode-in-the-windows-forms-datagridview-control). + + When the property is set to any other value except , the column will manage its width so that its cell values are fully displayed without clipping. In content-based sizing modes, size adjustments occur whenever cell contents change or, if is enabled, whenever row heights change. Some content-based sizing modes let you limit the size adjustment to the currently displayed rows in order to increase performance. + + Only columns with a property value of `true` are resized, and changing the visibility of a column does not cause resizing to occur. Additionally, when columns are set to automatically resize, the user cannot adjust the column widths with the mouse. + + To adjust column widths programmatically, use the control's or methods or set the column property. + + For more information about content-based automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + ]]> - Sizing Options in the Windows Forms DataGridView Control - Resizing Columns and Rows in the Windows Forms DataGridView Control + Sizing Options in the Windows Forms DataGridView Control + Resizing Columns and Rows in the Windows Forms DataGridView Control @@ -1234,20 +1234,20 @@ Gets the cell style currently applied to the column. A that represents the cell style used to display the column. - property inherits its values from the and the property. - - For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). - + property inherits its values from the and the property. + + For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -1295,11 +1295,11 @@ if the column is connected to a data source; otherwise, . - . A column can become part of a data-bound if the column is automatically created when the property is set to `true`, or if the column's property is set when the column is manually added to the . - + . A column can become part of a data-bound if the column is automatically created when the property is set to `true`, or if the column's property is set when the column is manually added to the . + ]]> @@ -1349,20 +1349,20 @@ Gets or sets the minimum width, in pixels, of the column. The number of pixels, from 2 to Int32.MaxValue, that specifies the minimum width of the column. The default is 5. - property sets a limit on how narrow the column can be resized in the user interface (UI). The property can override the property. - - - -## Examples - The following code example sets the minimum width of a column. This code example is part of a larger example provided for the class. - + property sets a limit on how narrow the column can be resized in the user interface (UI). The property can override the property. + + + +## Examples + The following code example sets the minimum width of a column. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet107"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet107"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet107"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet107"::: + ]]> The value is less than 2 or greater than Int32.MaxValue. @@ -1406,19 +1406,19 @@ Gets or sets the name of the column. A that contains the name of the column. The default is an empty string (""). - and methods of the class use the property. The name is case-insensitive. The will treat `column1` and `COLUMN1` as the same column. - - - -## Examples - The following code example shows how to set the column name. - + and methods of the class use the property. The name is case-insensitive. The will treat `column1` and `COLUMN1` as the same column. + + + +## Examples + The following code example shows how to set the column name. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewColumn/DataPropertyName/collectionbound.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._CollectionBound/VB/collectionbound.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView._CollectionBound/VB/collectionbound.vb" id="Snippet10"::: + ]]> @@ -1454,20 +1454,20 @@ if the user cannot edit the column's cells; otherwise, . - property affects the property of each cell in the column. - - - -## Examples - The following code example demonstrates how to use the property, which is nearly identical to the property of the class. This code example is part of a larger example provided for the class overview. - + property affects the property of each cell in the column. + + + +## Examples + The following code example demonstrates how to use the property, which is nearly identical to the property of the class. This code example is part of a larger example provided for the class overview. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewBandDemo.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewBandDemo.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewbanddemo.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewbanddemo.vb" id="Snippet11"::: + ]]> This property is set to for a column that is bound to a read-only data source. @@ -1501,24 +1501,24 @@ Gets or sets a value indicating whether the column is resizable. One of the values. The default is . - property is , the user will not be able to manually adjust the column width. - - By default, the property value is based on the property value. If you explicitly set to or , however, the control value is ignored. Set to to restore the value-inheritance behavior. - - Because restores the value inheritance, the property will never return a value unless the column has not been added to a control. If you need to determine whether the property value of a column is inherited, check its property. If the property value includes the flag, the property value is not inherited. - - - -## Examples - The following code example uses this property to fix the size of the third column so that the user cannot change the column width. - + property is , the user will not be able to manually adjust the column width. + + By default, the property value is based on the property value. If you explicitly set to or , however, the control value is ignored. Set to to restore the value-inheritance behavior. + + Because restores the value inheritance, the property will never return a value unless the column has not been added to a control. If you need to determine whether the property value of a column is inherited, check its property. If the property value includes the flag, the property value is not inherited. + + + +## Examples + The following code example uses this property to fix the size of the third column so that the user cannot change the column width. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.MouseBasedResizing/CPP/mousesizing.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewBand/Resizable/mousesizing.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.MouseBasedResizing/VB/mousesizing.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.MouseBasedResizing/VB/mousesizing.vb" id="Snippet12"::: + ]]> @@ -1611,35 +1611,35 @@ Gets or sets the sort mode for the column. A that specifies the criteria used to order the rows based on the cell values in a column. - control is sorted using a column with a property value of , a sorting glyph is automatically displayed in the column header. - - Starting in the .NET Framework 4.6, the sorting glyph is resized according to the system DPI settings when the app.config file contains the following entry: - -``` - - - -``` - - When the control is sorted using a column with a property value of , you must display the sorting glyph yourself through the property. - - The default sort mode of a is . The default sort mode for other column types is . - - The value does not prevent you from sorting a column programmatically, although other restrictions may apply. For more information, see the method. - - A property value of will not prevent the event from occurring, but it will prevent the header from changing its appearance when it is clicked. - - - -## Examples - The following code example demonstrates how to use the property. - + control is sorted using a column with a property value of , a sorting glyph is automatically displayed in the column header. + + Starting in the .NET Framework 4.6, the sorting glyph is resized according to the system DPI settings when the app.config file contains the following entry: + +``` + + + +``` + + When the control is sorted using a column with a property value of , you must display the sorting glyph yourself through the property. + + The default sort mode of a is . The default sort mode for other column types is . + + The value does not prevent you from sorting a column programmatically, although other restrictions may apply. For more information, see the method. + + A property value of will not prevent the event from occurring, but it will prevent the header from changing its appearance when it is clicked. + + + +## Examples + The following code example demonstrates how to use the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellBeginEdit/datagridviewmisc.cs" id="Snippet066"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet066"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet066"::: + ]]> The value assigned to the property conflicts with . @@ -1689,20 +1689,20 @@ Gets or sets the text used for ToolTips. The text to display as a ToolTip for the column. - class. - + class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet145"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet145"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet145"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet145"::: + ]]> @@ -1735,11 +1735,11 @@ Gets a string that describes the column. A that describes the column. - method. The returned string contains the and properties of the . - + method. The returned string contains the and properties of the . + ]]> @@ -1792,19 +1792,19 @@ Gets or sets the data type of the values in the column's cells. A that describes the run-time class of the values stored in the column's cells. - property in the initialization of a that contains values. - + property in the initialization of a that contains values. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BeginEdit/misc2.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc2/vb/misc2.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc2/vb/misc2.vb" id="Snippet20"::: + ]]> @@ -1848,22 +1848,22 @@ if the column is visible; otherwise, . - . To completely remove a column, use the method. - - To hide a column that is automatically generated when binding to a data source, set this property in a event handler. - - - -## Examples - The following code example demonstrates how to use the property, which is nearly identical to the property of the class. This code example is part of a larger example provided for the class overview. - + . To completely remove a column, use the method. + + To hide a column that is automatically generated when binding to a data source, set this property in a event handler. + + + +## Examples + The following code example demonstrates how to use the property, which is nearly identical to the property of the class. This code example is part of a larger example provided for the class overview. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewBandDemo.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewBandDemo.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewbanddemo.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewbanddemo.vb" id="Snippet9"::: + ]]> @@ -1909,20 +1909,20 @@ Gets or sets the current width of the column. The width, in pixels, of the column. The default is 100. - property, the property value is used instead. - - - -## Examples - The following code example sets the width of a column. This code example is part of a larger example provided for the class. - + property, the property value is used instead. + + + +## Examples + The following code example sets the width of a column. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet108"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet108"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet108"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet108"::: + ]]> The specified value when setting this property is greater than 65536. diff --git a/xml/System.Windows.Forms/DataGridViewColumnCollection.xml b/xml/System.Windows.Forms/DataGridViewColumnCollection.xml index beea4a0298a..1f117b978d9 100644 --- a/xml/System.Windows.Forms/DataGridViewColumnCollection.xml +++ b/xml/System.Windows.Forms/DataGridViewColumnCollection.xml @@ -43,19 +43,19 @@ Represents a collection of objects in a control. - property of the control. The collection maintains a reference to the control through the property. - - - -## Examples - The following code example illustrates the use of this type. - + property of the control. The collection maintains a reference to the control through the property. + + + +## Examples + The following code example illustrates the use of this type. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/BeginEdit/misc2.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc2/vb/misc2.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc2/vb/misc2.vb" id="Snippet20"::: + ]]> @@ -132,72 +132,72 @@ Adds the given column to the collection. The index of the column. - is . - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - -- - - -or- - - already belongs to a control. - - -or- - - The property value is and the property value is or . Use the control and methods to temporarily set conflicting property values. - - -or- - - The property value is and the property value is . - - -or- - - has an property value of and a property value of . - - -or- - - has a property value that would cause the combined values of all columns in the control to exceed 65535. - - -or- - - has and property values that would display it among a set of adjacent columns with the opposite property value. - - -or- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + +- + + -or- + + already belongs to a control. + + -or- + + The property value is and the property value is or . Use the control and methods to temporarily set conflicting property values. + + -or- + + The property value is and the property value is . + + -or- + + has an property value of and a property value of . + + -or- + + has a property value that would cause the combined values of all columns in the control to exceed 65535. + + -or- + + has and property values that would display it among a set of adjacent columns with the opposite property value. + + -or- + The control contains at least one row and has a property value of . @@ -246,47 +246,47 @@ Adds a with the given column name and column header text to the collection. The index of the column. - and properties, respectively. - + and properties, respectively. + ]]> - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - -- - - -or- - - The property value is or , which conflicts with the default column property value of . - - -or- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + +- + + -or- + + The property value is or , which conflicts with the default column property value of . + + -or- + The default column property value of 100 would cause the combined values of all columns in the control to exceed 65535. @@ -328,80 +328,80 @@ An array of objects to add. Adds a range of columns to the collection. - is . - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - -- - - -or- - - At least one of the values in is . - - -or- - - At least one of the columns in already belongs to a control. - - -or- - - At least one of the columns in has a property value of and the control contains at least one row. - - -or- - - At least one of the columns in has a property value of and the property value is or . Use the control and methods to temporarily set conflicting property values. - - -or- - - At least one of the columns in has an property value of and the property value is . - - -or- - - At least one of the columns in has an property value of and a property value of . - - -or- - - The columns in have property values that would cause the combined values of all columns in the control to exceed 65535. - - -or- - - At least two of the values in are references to the same . - - -or- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + +- + + -or- + + At least one of the values in is . + + -or- + + At least one of the columns in already belongs to a control. + + -or- + + At least one of the columns in has a property value of and the control contains at least one row. + + -or- + + At least one of the columns in has a property value of and the property value is or . Use the control and methods to temporarily set conflicting property values. + + -or- + + At least one of the columns in has an property value of and the property value is . + + -or- + + At least one of the columns in has an property value of and a property value of . + + -or- + + The columns in have property values that would cause the combined values of all columns in the control to exceed 65535. + + -or- + + At least two of the values in are references to the same . + + -or- + At least one of the columns in has and property values that would display it among a set of adjacent columns with the opposite property value. @@ -433,42 +433,42 @@ Clears the collection. - - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + - @@ -506,23 +506,23 @@ Occurs when the collection changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `DataGridViewColumnCollection1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `DataGridViewColumnCollection1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet372"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet372"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet372"::: + ]]> @@ -569,11 +569,11 @@ if the column is contained in the collection; otherwise, . - property. - + property. + ]]> @@ -719,14 +719,14 @@ Returns the number of columns that meet the given filter requirements. The number of columns that meet the filter requirements. - @@ -766,14 +766,14 @@ Returns the width, in pixels, required to display all of the columns that meet the given filter requirements. The width, in pixels, that is necessary to display all of the columns that meet the filter requirements. - @@ -823,22 +823,22 @@ Returns the first column in display order that meets the given inclusion-filter requirements. The first column in display order that meets the given filter requirements, or if no column is found. - value, regardless of whether the column is actually visible on the screen. - - This method lets you determine the first column that fits the given criteria without having to compare index values directly. - - - -## Examples - The following code example uses the method to swap the first displayed column and the last displayed column. - + value, regardless of whether the column is actually visible on the screen. + + This method lets you determine the first column that fits the given criteria without having to compare index values directly. + + + +## Examples + The following code example uses the method to swap the first displayed column and the last displayed column. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet170"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet170"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet170"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet170"::: + ]]> @@ -882,13 +882,13 @@ Returns the first column in display order that meets the given inclusion-filter and exclusion-filter requirements. The first column in display order that meets the given filter requirements, or if no column is found. - value, regardless of whether the column is actually visible on the screen. - - This method lets you determine the first column that fits the given criteria without having to compare index values directly. - + value, regardless of whether the column is actually visible on the screen. + + This method lets you determine the first column that fits the given criteria without having to compare index values directly. + ]]> At least one of the filter values is not a valid bitwise combination of values. @@ -931,22 +931,22 @@ Returns the last column in display order that meets the given filter requirements. The last displayed column in display order that meets the given filter requirements, or if no column is found. - value, regardless of whether the column is actually visible on the screen. - - This method lets you determine the last column that fits the given criteria without having to compare index values directly. - - - -## Examples - The following code example uses the method to swap the last displayed column and the first displayed column. - + value, regardless of whether the column is actually visible on the screen. + + This method lets you determine the last column that fits the given criteria without having to compare index values directly. + + + +## Examples + The following code example uses the method to swap the last displayed column and the first displayed column. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet170"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet170"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet170"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet170"::: + ]]> At least one of the filter values is not a valid bitwise combination of values. @@ -991,13 +991,13 @@ Gets the first column after the given column in display order that meets the given filter requirements. The next column that meets the given filter requirements, or if no column is found. - value higher than the value of the specified column, regardless of whether the column is actually visible on the screen. - - This method lets you determine the next column after the current column that fits the given criteria without having to compare index values directly. - + value higher than the value of the specified column, regardless of whether the column is actually visible on the screen. + + This method lets you determine the next column after the current column that fits the given criteria without having to compare index values directly. + ]]> @@ -1044,13 +1044,13 @@ Gets the last column prior to the given column in display order that meets the given filter requirements. The previous column that meets the given filter requirements, or if no column is found. - value lower than the value of the specified column, regardless of whether the column is actually visible on the screen. - - This method lets you determine the first column before the current column that fits the given criteria without having to compare index values directly. - + value lower than the value of the specified column, regardless of whether the column is actually visible on the screen. + + This method lets you determine the first column before the current column that fits the given criteria without having to compare index values directly. + ]]> @@ -1127,68 +1127,68 @@ The to insert. Inserts a column at the given index in the collection. - is . - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - -- - - -or- - - already belongs to a control. - - -or- - - The property value is and the property value is or . Use the control and methods to temporarily set conflicting property values. - - -or- - - The property value is and the property value is . - - -or- - - has an property value of and a property value of . - - -or- - - has and property values that would display it among a set of adjacent columns with the opposite property value. - - -or- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + +- + + -or- + + already belongs to a control. + + -or- + + The property value is and the property value is or . Use the control and methods to temporarily set conflicting property values. + + -or- + + The property value is and the property value is . + + -or- + + has an property value of and a property value of . + + -or- + + has and property values that would display it among a set of adjacent columns with the opposite property value. + + -or- + The control contains at least one row and has a property value of . @@ -1346,13 +1346,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1401,53 +1401,53 @@ The name of the column to delete. Removes the column with the specified name from the collection. - property. - - To remove a column that is automatically generated when binding to a data source, call this method in a event handler. - - - -## Examples - The following code example illustrates the use of this method. For more information, see [How to: Remove Autogenerated Columns from a Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/remove-autogenerated-columns-from-a-wf-datagridview-control). - + property. + + To remove a column that is automatically generated when binding to a data source, call this method in a event handler. + + + +## Examples + The following code example illustrates the use of this method. For more information, see [How to: Remove Autogenerated Columns from a Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/remove-autogenerated-columns-from-a-wf-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellBeginEdit/datagridviewmisc.cs" id="Snippet110"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet110"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet110"::: + ]]> does not match the name of any column in the collection. is . - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + - @@ -1484,43 +1484,43 @@ The column to delete. Removes the specified column from the collection. - event handler. - + event handler. + ]]> is not in the collection. is . - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + - @@ -1556,41 +1556,41 @@ The index of the column to delete. Removes the column at the given index in the collection. - event handler. - + event handler. + ]]> is less than zero or greater than the number of columns in the control minus one. - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + - @@ -1631,11 +1631,11 @@ The zero-based index in at which copying begins. Copies the entire contents of the collection to a compatible one-dimensional , starting at the specified index of the target array. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1643,10 +1643,10 @@ is less than 0. - is multidimensional. - - -or- - + is multidimensional. + + -or- + The number of elements in the source collection is greater than the available space from to the end of . The type of the source element cannot be cast automatically to the type of . @@ -1684,11 +1684,11 @@ Gets the number of elements in the collection. The number of elements in the . - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1726,11 +1726,11 @@ in all cases. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1767,11 +1767,11 @@ Gets an object that can be used to synchronize access to the collection. An that can be used to synchronize access to the collection. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1809,11 +1809,11 @@ Returns an enumerator that iterates through the collection. An that can be used to iterate through the collection. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1856,71 +1856,71 @@ Adds an object to the end of the collection. The index at which has been added. - instance is cast to an interface. - + instance is cast to an interface. + ]]> is not a . is . - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - -- - - -or- - - The column indicated by already belongs to a control. - - -or- - - The property value of the column indicated by is and the property value is or . Use the control and methods to temporarily set conflicting property values. - - -or- - - The property value of the column indicated by is and the property value is . - - -or- - - The column indicated by has an property value of and a property value of . - - -or- - - The column indicated by has a property value that would cause the combined values of all columns in the control to exceed 65535. - - -or- - - The column indicated by has and property values that would display it among a set of adjacent columns with the opposite property value. - - -or- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + +- + + -or- + + The column indicated by already belongs to a control. + + -or- + + The property value of the column indicated by is and the property value is or . Use the control and methods to temporarily set conflicting property values. + + -or- + + The property value of the column indicated by is and the property value is . + + -or- + + The column indicated by has an property value of and a property value of . + + -or- + + The column indicated by has a property value that would cause the combined values of all columns in the control to exceed 65535. + + -or- + + The column indicated by has and property values that would display it among a set of adjacent columns with the opposite property value. + + -or- + The control contains at least one row and the column indicated by has a property value of . @@ -1962,39 +1962,39 @@ Removes all elements from the collection. - instance is cast to an interface. - + instance is cast to an interface. + ]]> - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + - @@ -2036,11 +2036,11 @@ if is found in the ; otherwise, . - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -2084,11 +2084,11 @@ Determines the index of a specific item in the collection. The zero-based index of the first occurrence of within the collection, if found; otherwise, -1. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -2131,71 +2131,71 @@ The to insert. The value can be . Inserts an element into the collection at the specified index. - instance is cast to an interface. - + instance is cast to an interface. + ]]> is not a . is . - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - -- - - -or- - - The column indicated by already belongs to a control. - - -or- - - The property value of the column indicated by is and the property value is or . Use the control and methods to temporarily set conflicting property values. - - -or- - - The property value of the column indicated by is and the property value is . - - -or- - - The column indicated by has an property value of and a property value of . - - -or- - - The column indicated by has a property value that would cause the combined values of all columns in the control to exceed 65535. - - -or- - - The column indicated by has and property values that would display it among a set of adjacent columns with the opposite property value. - - -or- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + +- + + -or- + + The column indicated by already belongs to a control. + + -or- + + The property value of the column indicated by is and the property value is or . Use the control and methods to temporarily set conflicting property values. + + -or- + + The property value of the column indicated by is and the property value is . + + -or- + + The column indicated by has an property value of and a property value of . + + -or- + + The column indicated by has a property value that would cause the combined values of all columns in the control to exceed 65535. + + -or- + + The column indicated by has and property values that would display it among a set of adjacent columns with the opposite property value. + + -or- + The control contains at least one row and the column indicated by has a property value of . @@ -2232,11 +2232,11 @@ in all cases. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -2274,11 +2274,11 @@ in all cases. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -2330,13 +2330,13 @@ Gets or sets the element at the specified index. The at the specified index. - instance is cast to an interface. - - This implementation does not support setting this property. - + instance is cast to an interface. + + This implementation does not support setting this property. + ]]> This property is being set. @@ -2379,11 +2379,11 @@ The to remove from the collection. The value can be . Removes the first occurrence of the specified object from the collection. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -2392,32 +2392,32 @@ is not in the collection. is . - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + - @@ -2462,41 +2462,41 @@ The location of the element to delete. Removes the element with the specified index from the collection. - instance is cast to an interface. - + instance is cast to an interface. + ]]> is less than zero or greater than the number of columns in the control minus one. - The associated control is performing one of the following actions that temporarily prevents new columns from being added: - -- Selecting all cells in the control. - -- Clearing the selection. - -- Updating column property values. - - -or- - - This method is being called from a handler for one of the following events: - -- - -- - -- - -- - -- - -- - -- - + The associated control is performing one of the following actions that temporarily prevents new columns from being added: + +- Selecting all cells in the control. + +- Clearing the selection. + +- Updating column property values. + + -or- + + This method is being called from a handler for one of the following events: + +- + +- + +- + +- + +- + +- + +- + - diff --git a/xml/System.Windows.Forms/DataGridViewColumnHeaderCell.xml b/xml/System.Windows.Forms/DataGridViewColumnHeaderCell.xml index a564f1b1acd..f6d66469005 100644 --- a/xml/System.Windows.Forms/DataGridViewColumnHeaderCell.xml +++ b/xml/System.Windows.Forms/DataGridViewColumnHeaderCell.xml @@ -57,11 +57,11 @@ Initializes a new instance of the class. - property to . - + property to . + ]]> @@ -125,14 +125,14 @@ Creates a new accessible object for the . A new for the . - method, it will be called when the property is referenced. - + method, it will be called when the property is referenced. + > [!NOTE] -> To get or set , you must add a reference to the `Accessibility` assembly installed with the .NET Framework. - +> To get or set , you must add a reference to the `Accessibility` assembly installed with the .NET Framework. + ]]> @@ -185,17 +185,17 @@ Retrieves the formatted value of the cell to copy to the . A that represents the value of the cell to copy to the . - property of the control, this method is called by the control's method to retrieve a clipboard-formatted value that represents the cell. - - The position-related parameters of this method indicate where this cell is located in the table of data representing the region defined by the selected cells in the control. Depending on the cell's position, formatting information may be returned by this method in addition to the cell value. For example, the HTML format for a cell in the first column of a row will include the tag that indicates the beginning of a row. - - The supported clipboard formats include , , , and . - - For more information, see the class. - + property of the control, this method is called by the control's method to retrieve a clipboard-formatted value that represents the cell. + + The position-related parameters of this method indicate where this cell is located in the table of data representing the region defined by the selected cells in the control. Depending on the cell's position, formatting information may be returned by this method in addition to the cell value. For example, the HTML format for a cell in the first column of a row will include the tag that indicates the beginning of a row. + + The supported clipboard formats include , , , and . + + For more information, see the class. + ]]> @@ -240,11 +240,11 @@ Returns the bounding rectangle that encloses the cell's content area, which is calculated using the specified object and cell style. The that bounds the cell's contents. - property is read. - + property is read. + ]]> @@ -253,7 +253,7 @@ - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -337,11 +337,11 @@ Gets the style applied to the cell. A that includes the style settings of the cell inherited from the cell's parent row, column, and . - that inherits its settings from the objects returned by the and properties of the . For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). - + that inherits its settings from the objects returned by the and properties of the . For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + ]]> @@ -352,7 +352,7 @@ - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -396,7 +396,7 @@ - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -590,26 +590,26 @@ Gets or sets a value indicating which sort glyph is displayed. A value representing the current glyph. The default is . - property set to . You must set this property yourself when sorting by columns with the property set to . - - - -## Examples - The following code demonstrates how to use the property in a programmatic sort. - + property set to . You must set this property yourself when sorting by columns with the property set to . + + + +## Examples + The following code demonstrates how to use the property in a programmatic sort. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/SelectedColumns/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewProgrammaticSort/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewProgrammaticSort/VB/form1.vb" id="Snippet10"::: + ]]> The specified value when setting this property is not a valid value. - When setting this property, the value of either the property or the property of the cell is . - - -or- - + When setting this property, the value of either the property or the property of the cell is . + + -or- + When changing the value of this property, the specified value is not and the value of the property of the owning column is . diff --git a/xml/System.Windows.Forms/DataGridViewColumnHeadersHeightSizeMode.xml b/xml/System.Windows.Forms/DataGridViewColumnHeadersHeightSizeMode.xml index 5aec9f0a9a6..0001e389dea 100644 --- a/xml/System.Windows.Forms/DataGridViewColumnHeadersHeightSizeMode.xml +++ b/xml/System.Windows.Forms/DataGridViewColumnHeadersHeightSizeMode.xml @@ -22,29 +22,29 @@ Defines values for specifying how the height of the column headers is adjusted. - control property and method. - - For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). - - - -## Examples - The following code example illustrates the use of this enumeration in a display-only, non-interactive control. - + control property and method. + + For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + + + +## Examples + The following code example illustrates the use of this enumeration in a display-only, non-interactive control. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AllowUserToAddRows/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: + ]]> - Sizing Options in the Windows Forms DataGridView Control + Sizing Options in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewColumnSortMode.xml b/xml/System.Windows.Forms/DataGridViewColumnSortMode.xml index ef9fdd483e3..11bd9c6a38b 100644 --- a/xml/System.Windows.Forms/DataGridViewColumnSortMode.xml +++ b/xml/System.Windows.Forms/DataGridViewColumnSortMode.xml @@ -22,19 +22,19 @@ Defines how a column can be sorted by the user. - property. - - - -## Examples - The following code example illustrates the use of this type. For more information, see [How to: Set the Sort Modes for Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/set-the-sort-modes-for-columns-wf-datagridview-control). - + property. + + + +## Examples + The following code example illustrates the use of this type. For more information, see [How to: Set the Sort Modes for Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/set-the-sort-modes-for-columns-wf-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellBeginEdit/datagridviewmisc.cs" id="Snippet066"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet066"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet066"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewComboBoxCell.xml b/xml/System.Windows.Forms/DataGridViewComboBoxCell.xml index f16328031fd..ea51265a745 100644 --- a/xml/System.Windows.Forms/DataGridViewComboBoxCell.xml +++ b/xml/System.Windows.Forms/DataGridViewComboBoxCell.xml @@ -64,7 +64,7 @@ - How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List + How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List @@ -1006,7 +1006,7 @@ For additional information, see [What's New in Accessibility in the .NET Framewo - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1045,14 +1045,14 @@ For additional information, see [What's New in Accessibility in the .NET Framewo ## Remarks When the property of the control is set to or , the control uses this method to determine whether a key other than F2 that is pressed by the user while this cell has focus will cause the cell to enter edit mode. - This method returns `true` if the e parameter indicates one of the following keys or key combinations: F4, ALT+UP ARROW, ALT+DOWN ARROW, or an ordinary data-entry key (such as a letter, number, punctuation mark, or the SPACE key) unmodified by ALT or CTRL, excluding SHIFT+SPACE, which is used by the control for selection purposes. For more information, see [Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/default-keyboard-and-mouse-handling-in-the-windows-forms-datagridview-control). + This method returns `true` if the e parameter indicates one of the following keys or key combinations: F4, ALT+UP ARROW, ALT+DOWN ARROW, or an ordinary data-entry key (such as a letter, number, punctuation mark, or the SPACE key) unmodified by ALT or CTRL, excluding SHIFT+SPACE, which is used by the control for selection purposes. For more information, see [Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/default-keyboard-and-mouse-handling-in-the-windows-forms-datagridview-control). ]]> - Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control + Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewComboBoxColumn.xml b/xml/System.Windows.Forms/DataGridViewComboBoxColumn.xml index 6dc09a921d6..0e10fff09df 100644 --- a/xml/System.Windows.Forms/DataGridViewComboBoxColumn.xml +++ b/xml/System.Windows.Forms/DataGridViewComboBoxColumn.xml @@ -94,7 +94,7 @@ - How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List + How to: Access Objects in a Windows Forms DataGridViewComboBoxCell Drop-Down List @@ -250,7 +250,7 @@ ## Examples - The following code example demonstrates the use of the property, which is similar to this property. This example is part of a larger example available in [How to: Manipulate Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-manipulate-columns-in-the-windows-forms-datagridview-control). + The following code example demonstrates the use of the property, which is similar to this property. This example is part of a larger example available in [How to: Manipulate Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-manipulate-columns-in-the-windows-forms-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet120"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet120"::: diff --git a/xml/System.Windows.Forms/DataGridViewContentAlignment.xml b/xml/System.Windows.Forms/DataGridViewContentAlignment.xml index ca1f6d22315..63607cc721c 100644 --- a/xml/System.Windows.Forms/DataGridViewContentAlignment.xml +++ b/xml/System.Windows.Forms/DataGridViewContentAlignment.xml @@ -22,19 +22,19 @@ Defines constants that indicate the alignment of content within a cell. - property. - - - -## Examples - The following code example illustrates the use of this type. For more information, see [How to: Format Data in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-format-data-in-the-windows-forms-datagridview-control). - + property. + + + +## Examples + The following code example illustrates the use of this type. For more information, see [How to: Format Data in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-format-data-in-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellBeginEdit/datagridviewmisc.cs" id="Snippet072"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet072"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet072"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewDataErrorContexts.xml b/xml/System.Windows.Forms/DataGridViewDataErrorContexts.xml index 2a9ecdd6896..f3104aa31d9 100644 --- a/xml/System.Windows.Forms/DataGridViewDataErrorContexts.xml +++ b/xml/System.Windows.Forms/DataGridViewDataErrorContexts.xml @@ -28,19 +28,19 @@ Represents the state of a data-bound control when a data error occurred. - when a data error occurred. For example, if a user enters an invalid cell value (such as entering a name in a cell that expects a date) and then selects a different cell, the will try to commit the invalid cell value. When the commit fails, the will raise a event whose property will have a value of Commit and CurrentCellChange. - - - -## Examples - The following code example illustrates the use of this type. This example is part of a larger example available in [How to: Handle Errors That Occur During Data Entry in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/handle-errors-that-occur-during-data-entry-in-the-datagrid). - + when a data error occurred. For example, if a user enters an invalid cell value (such as entering a name in a cell that expects a date) and then selects a different cell, the will try to commit the invalid cell value. When the commit fails, the will raise a event whose property will have a value of Commit and CurrentCellChange. + + + +## Examples + The following code example illustrates the use of this type. This example is part of a larger example available in [How to: Handle Errors That Occur During Data Entry in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/handle-errors-that-occur-during-data-entry-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewDataErrorContexts/Overview/errorhandling.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DataError/VB/errorhandling.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.DataError/VB/errorhandling.vb" id="Snippet20"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewEditMode.xml b/xml/System.Windows.Forms/DataGridViewEditMode.xml index fb56ad750fb..d5bf49c8060 100644 --- a/xml/System.Windows.Forms/DataGridViewEditMode.xml +++ b/xml/System.Windows.Forms/DataGridViewEditMode.xml @@ -22,21 +22,21 @@ Specifies how a user starts cell editing in the control. - property of the control. - - All values except for EditProgrammatically allow a user to double-click a cell to begin editing it. - - - -## Examples - The following code example illustrates the use of this type. For more information, see [How to: Specify the Edit Mode for the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-specify-the-edit-mode-for-the-windows-forms-datagridview-control). - + property of the control. + + All values except for EditProgrammatically allow a user to double-click a cell to begin editing it. + + + +## Examples + The following code example illustrates the use of this type. For more information, see [How to: Specify the Edit Mode for the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-specify-the-edit-mode-for-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellBeginEdit/datagridviewmisc.cs" id="Snippet067"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet067"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet067"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewElementStates.xml b/xml/System.Windows.Forms/DataGridViewElementStates.xml index 1a80df0a6b8..c23ca03a7da 100644 --- a/xml/System.Windows.Forms/DataGridViewElementStates.xml +++ b/xml/System.Windows.Forms/DataGridViewElementStates.xml @@ -32,19 +32,19 @@ Specifies the user interface (UI) state of a element within a control. - diff --git a/xml/System.Windows.Forms/DataGridViewHeaderBorderStyle.xml b/xml/System.Windows.Forms/DataGridViewHeaderBorderStyle.xml index cf8faae9e8b..86db7ee6631 100644 --- a/xml/System.Windows.Forms/DataGridViewHeaderBorderStyle.xml +++ b/xml/System.Windows.Forms/DataGridViewHeaderBorderStyle.xml @@ -22,14 +22,14 @@ Specifies the border style that can be applied to the and properties of a control. - diff --git a/xml/System.Windows.Forms/DataGridViewHeaderCell.xml b/xml/System.Windows.Forms/DataGridViewHeaderCell.xml index 0cf45e3477b..09ee88ac9c6 100644 --- a/xml/System.Windows.Forms/DataGridViewHeaderCell.xml +++ b/xml/System.Windows.Forms/DataGridViewHeaderCell.xml @@ -568,7 +568,7 @@ For more information about row sharing, see [Best Practices for Scaling the Wind - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -622,7 +622,7 @@ For more information about row sharing, see [Best Practices for Scaling the Wind - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -673,7 +673,7 @@ For more information about row sharing, see [Best Practices for Scaling the Wind - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -724,7 +724,7 @@ For more information about row sharing, see [Best Practices for Scaling the Wind - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewImageCell.xml b/xml/System.Windows.Forms/DataGridViewImageCell.xml index f5a388a3587..b3aabcf3b78 100644 --- a/xml/System.Windows.Forms/DataGridViewImageCell.xml +++ b/xml/System.Windows.Forms/DataGridViewImageCell.xml @@ -29,24 +29,24 @@ Displays a graphic in a control. - class is a specialized type of used to display an or an , depending on the value of the property. Typically, the property of a is set to `true` to indicate that the user cannot edit the cell contents. - - The is the column type specialized to hold cells of this type. By default, the is initialized to a new . To pattern the cells within a column after an existing , set the column's property to the cell to use as a pattern. - - The cell-related properties of the column are wrappers for the similarly-named properties of the template cell. Changing the property values of the template cell will affect only cells based on the template that are added after the change. Changing the cell-related property values of the column, however, will update the template cell and all other cells in the column, and refresh the column display if necessary. - - - -## Examples - The following code example demonstrates how to change the image in an image cell using . This code example is part of a larger example provided for the topic [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). - + class is a specialized type of used to display an or an , depending on the value of the property. Typically, the property of a is set to `true` to indicate that the user cannot edit the cell contents. + + The is the column type specialized to hold cells of this type. By default, the is initialized to a new . To pattern the cells within a column after an existing , set the column's property to the cell to use as a pattern. + + The cell-related properties of the column are wrappers for the similarly-named properties of the template cell. Changing the property values of the template cell will affect only cells based on the template that are added after the change. Changing the cell-related property values of the column, however, will update the template cell and all other cells in the column, and refresh the column display if necessary. + + + +## Examples + The following code example demonstrates how to change the image in an image cell using . This code example is part of a larger example provided for the topic [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet10"::: + ]]> @@ -99,11 +99,11 @@ Initializes a new instance of the class, configuring it for use with cell values other than objects. - with a `valueIsIcon` parameter value of `false`. - + with a `valueIsIcon` parameter value of `false`. + ]]> @@ -135,15 +135,15 @@ The cell will display an value. Initializes a new instance of the class, optionally configuring it for use with cell values. - property is set to the value of the `valueIsIcon` parameter. - - To ensure that the alpha channel of values is painted correctly, use this constructor with a `valueIsIcon` parameter value of `true`. - - If the `valueIsIcon` parameter is `true`, the and properties return a object representing the type. - + property is set to the value of the `valueIsIcon` parameter. + + To ensure that the alpha channel of values is painted correctly, use this constructor with a `valueIsIcon` parameter value of `true`. + + If the `valueIsIcon` parameter is `true`, the and properties return a object representing the type. + ]]> @@ -181,11 +181,11 @@ Creates an exact copy of this cell. An that represents the cloned . - method whenever you derive from and add new properties to the derived class. - + method whenever you derive from and add new properties to the derived class. + ]]> @@ -221,14 +221,14 @@ Creates a new accessible object for the . A new for the . - method, it will be called when the property is referenced. - + method, it will be called when the property is referenced. + > [!NOTE] -> To get or set , you must add a reference to the `Accessibility` assembly installed with the .NET Framework. - +> To get or set , you must add a reference to the `Accessibility` assembly installed with the .NET Framework. + ]]> @@ -269,13 +269,13 @@ Gets the default value that is used when creating a new row. An object containing a default image placeholder, or to display an empty cell. - or type , depending on the value of the property. - - Whenever a is displayed in which new rows can be added, the last row is an empty new row of cells loaded with default values. Override this property to provide a different default image for these cells or to return `null` to avoid displaying images. - + or type , depending on the value of the property. + + Whenever a is displayed in which new rows can be added, the last row is an empty new row of cells loaded with default values. Override this property to provide a different default image for these cells or to return `null` to avoid displaying images. + ]]> @@ -316,22 +316,22 @@ Gets or sets the text associated with the image. The text associated with the image displayed in the cell. - property of the owning column also sets the property of every cell in the column. To override the specified value for individual cells, set the cell values after you set the column value. - - - -## Examples - The following code example demonstrates the use of the property, which is similar to this property. This example is part of a larger example available in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). - + property of the owning column also sets the property of every cell in the column. To override the specified value for individual cells, set the cell values after you set the column value. + + + +## Examples + The following code example demonstrates the use of the property, which is similar to this property. This example is part of a larger example available in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet20"::: + ]]> @@ -375,11 +375,11 @@ Gets the type of the cell's hosted editing control. The of the underlying editing control. As implemented in this class, this property is always . - property is always `null` because there is no associated Windows Forms control for editing an image. - + property is always `null` because there is no associated Windows Forms control for editing an image. + ]]> @@ -411,19 +411,19 @@ Gets the type of the formatted value associated with the cell. A object representing display value type of the cell, which is the type if the property is set to or the type otherwise. - object representing either the type or the type because a can only handle graphic images. - - - -## Examples - The following code example demonstrates how to use the property to determine the type of the cell contents. In this example, the property is used to determine whether the cell contains a before attempting to convert the value. This example is part of a larger example available in the event. - + object representing either the type or the type because a can only handle graphic images. + + + +## Examples + The following code example demonstrates how to use the property to determine the type of the cell contents. In this example, the property is used to determine whether the cell contains a before attempting to convert the value. This example is part of a larger example available in the event. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellValidated/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewSelectionSum/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewSelectionSum/VB/form1.vb" id="Snippet10"::: + ]]> @@ -556,19 +556,19 @@ Returns a graphic as it would be displayed in the cell. An object that represents the formatted image. - control calls this method to convert a cell value into an equivalent display value of the type indicated by the property. The control passes the cell value to this method in the `value` parameter. - - If the `context` parameter value includes the value, this method returns the value of the property for copying to the Clipboard. Otherwise, the event occurs. - - A event handler can modify both `value` and `cellStyle`. If the handler does not set the property to `true`, however, this method formats `value` using the formatting properties of the `cellStyle` object. - - If formatting is unsuccessful, the event occurs. If there is no handler for this event or the handler sets the property to `true`, an exception is thrown. - - If formatting is successful and the type of the formatted value matches the value of the property, this method returns the formatted value. Otherwise, this method returns a standard error graphic in the type indicated by the property. - + control calls this method to convert a cell value into an equivalent display value of the type indicated by the property. The control passes the cell value to this method in the `value` parameter. + + If the `context` parameter value includes the value, this method returns the value of the property for copying to the Clipboard. Otherwise, the event occurs. + + A event handler can modify both `value` and `cellStyle`. If the handler does not set the property to `true`, however, this method formats `value` using the formatting properties of the `cellStyle` object. + + If formatting is unsuccessful, the event occurs. If there is no handler for this event or the handler sets the property to `true`, an exception is thrown. + + If formatting is successful and the type of the formatted value matches the value of the property, this method returns the formatted value. Otherwise, this method returns a standard error graphic in the type indicated by the property. + ]]> @@ -689,13 +689,13 @@ Gets or sets the graphics layout for the cell. A for this cell. The default is . - property of the owning column also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - + property of the owning column also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + ]]> The supplied value is invalid. @@ -841,17 +841,17 @@ if this cell displays an value; otherwise, . - values is painted correctly, set this property to `true`. When this property is `true`, the and properties return a object representing the type. - - Setting the property of the owning column also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - - When the value of this property changes for a cell in the row for new records, the image displayed in the cell is updated to the current value of the property. - - Unlike the column property, the cell property does not automatically update the property of the associated cell style when you change its value. When you change the cell property value to `true`, be sure to set the property of the object returned by the property to a valid . When you change the property value to `false`, be sure to set the property to a valid . - + values is painted correctly, set this property to `true`. When this property is `true`, the and properties return a object representing the type. + + Setting the property of the owning column also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + + When the value of this property changes for a cell in the row for new records, the image displayed in the cell is updated to the current value of the property. + + Unlike the column property, the cell property does not automatically update the property of the associated cell style when you change its value. When you change the cell property value to `true`, be sure to set the property of the object returned by the property to a valid . When you change the property value to `false`, be sure to set the property to a valid . + ]]> @@ -895,13 +895,13 @@ Gets or sets the data type of the values in the cell. The of the cell's value. - for the cell has not been set, then the for the owning column is used, if it exists. If no owning column exists, the default value type is used, which is the type if the property is set to `false` and the type otherwise. - - The is the actual data object contained in the cell, whereas the property is the formatted representation of this object. The and properties correspond to the data types of these values, respectively. - + for the cell has not been set, then the for the owning column is used, if it exists. If no owning column exists, the default value type is used, which is the type if the property is set to `false` and the type otherwise. + + The is the actual data object contained in the cell, whereas the property is the formatted representation of this object. The and properties correspond to the data types of these values, respectively. + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewImageCellLayout.xml b/xml/System.Windows.Forms/DataGridViewImageCellLayout.xml index ac13d558095..8bd5dc05b00 100644 --- a/xml/System.Windows.Forms/DataGridViewImageCellLayout.xml +++ b/xml/System.Windows.Forms/DataGridViewImageCellLayout.xml @@ -22,15 +22,15 @@ Specifies the layout for an image contained in a . - diff --git a/xml/System.Windows.Forms/DataGridViewImageColumn.xml b/xml/System.Windows.Forms/DataGridViewImageColumn.xml index 21587e20ba7..f6c7cb83c04 100644 --- a/xml/System.Windows.Forms/DataGridViewImageColumn.xml +++ b/xml/System.Windows.Forms/DataGridViewImageColumn.xml @@ -41,24 +41,24 @@ Hosts a collection of objects. - class is a specialized type of the class used to logically host cells that display images. A has an associated in every that intersects it. Each cell is capable of containing an or an , depending on the value of the property. Displaying icons is useful to accommodate images with transparency. - - By default, empty cells display a default error graphic. To prevent this graphic from appearing for cell values equal to `null` or , set the property of the cell style object returned by the property to `null` before adding rows to the control. This does not affect the row for new records, however. To prevent the error graphic from appearing in the row for new records when the control property value is `true`, you must also either explicitly set the cell value to `null` in a handler for the control event or set the column property to an instance of a -derived type with an overridden property that returns `null`. - - The default sort mode for this column type is . - - - -## Examples - The following code example demonstrates how to use images to create a TicTacToe game. - + class is a specialized type of the class used to logically host cells that display images. A has an associated in every that intersects it. Each cell is capable of containing an or an , depending on the value of the property. Displaying icons is useful to accommodate images with transparency. + + By default, empty cells display a default error graphic. To prevent this graphic from appearing for cell values equal to `null` or , set the property of the cell style object returned by the property to `null` before adding rows to the control. This does not affect the row for new records, however. To prevent the error graphic from appearing in the row for new records when the control property value is `true`, you must also either explicitly set the cell value to `null` in a handler for the control event or set the column property to an instance of a -derived type with an overridden property that returns `null`. + + The default sort mode for this column type is . + + + +## Examples + The following code example demonstrates how to use images to create a TicTacToe game. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet0"::: + ]]> @@ -111,11 +111,11 @@ Initializes a new instance of the class, configuring it for use with cell values of type . - with a `valuesAreIcons` parameter value of `false`. - + with a `valuesAreIcons` parameter value of `false`. + ]]> @@ -150,20 +150,20 @@ to indicate that the property of cells in this column will be set to values of type ; to indicate that they will be set to values of type . Initializes a new instance of the class, optionally configuring it for use with cell values. - |A new with its property initialized to the `valuesAreIcons` parameter value.| -||The value of the `valuesAreIcons` parameter.| -|The property of the object returned by the property.|| -|The property of the object returned by the property.|A standard error graphic of type if `valuesAreIcons` is `true` and type if `valuesAreIcons` is `false`.| - - To ensure that the alpha channel of cell values is painted correctly, use this constructor with a `valuesAreIcons` parameter value of `true`. - + |A new with its property initialized to the `valuesAreIcons` parameter value.| +||The value of the `valuesAreIcons` parameter.| +|The property of the object returned by the property.|| +|The property of the object returned by the property.|A standard error graphic of type if `valuesAreIcons` is `true` and type if `valuesAreIcons` is `false`.| + + To ensure that the alpha channel of cell values is painted correctly, use this constructor with a `valuesAreIcons` parameter value of `true`. + ]]> @@ -222,23 +222,23 @@ Gets or sets the template used to create new cells. A that all other cells in the column are modeled after. - class initialize this property to a newly created . - + class initialize this property to a newly created . + > [!CAUTION] -> Changing the properties of the cell template will not immediately affect the user interface (UI) of the column's existing cells. These changes are only apparent after the column is regenerated (for example, by sorting the column or through a call to the method). - - - -## Examples - The following code example demonstrates the use of the property, which is similar to this property. This example is part of a larger example available in [How to: Manipulate Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-manipulate-columns-in-the-windows-forms-datagridview-control). - +> Changing the properties of the cell template will not immediately affect the user interface (UI) of the column's existing cells. These changes are only apparent after the column is regenerated (for example, by sorting the column or through a call to the method). + + + +## Examples + The following code example demonstrates the use of the property, which is similar to this property. This example is part of a larger example available in [How to: Manipulate Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-manipulate-columns-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet120"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet120"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet120"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet120"::: + ]]> The set type is not compatible with type . @@ -276,11 +276,11 @@ Creates an exact copy of this column. An that represents the cloned . - @@ -321,36 +321,36 @@ Gets or sets the column's default cell style. The to be applied as the default style. - returned by this property has the following initial property values: - -|`DataGridViewCellStyle` property|Default value| -|--------------------------------------|-------------------| -||| -||A standard error graphic of type if the initial property value is `true`; otherwise, a standard error graphic of type .| - - These values override the value specified in the property of the control, but may be overridden by other cell style properties. For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). - - To prevent the standard error graphic from appearing for `null` or cell values, set the property for this cell style object to `null` or your own error graphic before adding rows to the control. This does not affect the row for new records, however. To prevent the error graphic from appearing in the row for new records when the control property value is `true`, you must also either explicitly set the cell value to `null` or your own error graphic in a handler for the control event or set the column property to an instance of a -derived type with an overridden property that returns `null` or your own error graphic. - - If the property of the object returned by the property has a value equal to the standard error graphic of type , changing the property value to `true` automatically sets to the standard error graphic of type . If has a value equal to the standard error graphic of type , changing the property value to `false` automatically sets to the standard error graphic of type . - - - -## Examples - The following code example demonstrates the use of this property. - + returned by this property has the following initial property values: + +|`DataGridViewCellStyle` property|Default value| +|--------------------------------------|-------------------| +||| +||A standard error graphic of type if the initial property value is `true`; otherwise, a standard error graphic of type .| + + These values override the value specified in the property of the control, but may be overridden by other cell style properties. For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + + To prevent the standard error graphic from appearing for `null` or cell values, set the property for this cell style object to `null` or your own error graphic before adding rows to the control. This does not affect the row for new records, however. To prevent the error graphic from appearing in the row for new records when the control property value is `true`, you must also either explicitly set the cell value to `null` or your own error graphic in a handler for the control event or set the column property to an instance of a -derived type with an overridden property that returns `null` or your own error graphic. + + If the property of the object returned by the property has a value equal to the standard error graphic of type , changing the property value to `true` automatically sets to the standard error graphic of type . If has a value equal to the standard error graphic of type , changing the property value to `false` automatically sets to the standard error graphic of type . + + + +## Examples + The following code example demonstrates the use of this property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewButtonColumn/DefaultCellStyle/changecolumnalignment.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewContentAlignment/VB/changecolumnalignment.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GridViewContentAlignment/VB/changecolumnalignment.vb" id="Snippet1"::: + ]]> - Cell Styles in the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -405,22 +405,22 @@ Gets or sets a string that describes the column's image. The textual description of the column image. The default is . - property to describe the image provided by the or property. This description provides an accessible alternative to the image. Additionally, the description text is used when the cell value is copied onto the Clipboard. - - Getting or setting this property gets or sets the property of the object returned by the property. Setting this property also sets the property of every cell in the column. To override the specified value for individual cells, set the cell values after you set the column value. - - - -## Examples - The following code example demonstrates how to use the property to reflect the image layout. This example is part of a larger example available in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). - + property to describe the image provided by the or property. This description provides an accessible alternative to the image. Additionally, the description text is used when the cell value is copied onto the Clipboard. + + Getting or setting this property gets or sets the property of the object returned by the property. Setting this property also sets the property of every cell in the column. To override the specified value for individual cells, set the cell values after you set the column value. + + + +## Examples + The following code example demonstrates how to use the property to reflect the image layout. This example is part of a larger example available in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet20"::: + ]]> The value of the property is . @@ -477,13 +477,13 @@ Gets or sets the icon displayed in the cells of this column when the cell's property is not set and the cell's property is set to . The to display. The default is . - property specifies an icons that is displayed in cells with no values when the column is not data-bound and the cell's property is set to `true`. For a data-bound column whose cells do not have an associated image, a standard error graphic is displayed. - - Using the property rather than the property ensures that an alpha channel in an icon is painted correctly. If you want to display an instead of an , set the property instead and set the property to `false`. You can also set the property of individual cells to indicate whether the cell displays the or the property value. - + property specifies an icons that is displayed in cells with no values when the column is not data-bound and the cell's property is set to `true`. For a data-bound column whose cells do not have an associated image, a standard error graphic is displayed. + + Using the property rather than the property ensures that an alpha channel in an icon is painted correctly. If you want to display an instead of an , set the property instead and set the property to `false`. You can also set the property of individual cells to indicate whether the cell displays the or the property value. + ]]> @@ -532,22 +532,22 @@ Gets or sets the image displayed in the cells of this column when the cell's property is not set and the cell's property is set to . The to display. The default is . - property specifies an image that is displayed in cells with no values when the column is not data-bound and the cell's property is set to `false`. For a data-bound column whose cells do not have an associated image, a standard error graphic is displayed. - - If you want to display an instead of an , set the property instead and set the property to `true`. This ensures that the alpha channel of the is painted correctly. You can also set the property of individual cells to indicate whether the cell displays the or the property value when there is no cell value. - - - -## Examples - The following code example demonstrates how to set the default image. This example is part of a larger example available in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). - + property specifies an image that is displayed in cells with no values when the column is not data-bound and the cell's property is set to `false`. For a data-bound column whose cells do not have an associated image, a standard error graphic is displayed. + + If you want to display an instead of an , set the property instead and set the property to `true`. This ensures that the alpha channel of the is painted correctly. You can also set the property of individual cells to indicate whether the cell displays the or the property value when there is no cell value. + + + +## Examples + The following code example demonstrates how to set the default image. This example is part of a larger example available in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet5"::: + ]]> @@ -602,20 +602,20 @@ Gets or sets the image layout in the cells for this column. A that specifies the cell layout. The default is . - property of the object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - - - -## Examples - The following code example demonstrates how to stretch and zoom images to fit cells. This example is part of a larger example available in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). - + property of the object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + + + +## Examples + The following code example demonstrates how to stretch and zoom images to fit cells. This example is part of a larger example available in [How to: Work with Image Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-work-with-image-columns-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/CPP/tictactoe.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellClick/tictactoe.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ImageColumn_TicTacToe/VB/tictactoe.vb" id="Snippet20"::: + ]]> The value of the property is . @@ -709,15 +709,15 @@ if cells display values of type ; if cells display values of type . The default is . - values is painted correctly, set this property to `true`. - - Getting or setting this property gets or sets the property of the object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. - - If the property of the object returned by the property has a value equal to the standard error graphic of type , changing the property value to `true` automatically sets to the standard error graphic of type . If has a value equal to the standard error graphic of type , changing the property value to `false` automatically sets to the standard error graphic of type . - + values is painted correctly, set this property to `true`. + + Getting or setting this property gets or sets the property of the object returned by the property. Setting this property also sets the property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value. + + If the property of the object returned by the property has a value equal to the standard error graphic of type , changing the property value to `true` automatically sets to the standard error graphic of type . If has a value equal to the standard error graphic of type , changing the property value to `false` automatically sets to the standard error graphic of type . + ]]> The value of the property is . diff --git a/xml/System.Windows.Forms/DataGridViewLinkCell.xml b/xml/System.Windows.Forms/DataGridViewLinkCell.xml index 248795df445..a8bb9927145 100644 --- a/xml/System.Windows.Forms/DataGridViewLinkCell.xml +++ b/xml/System.Windows.Forms/DataGridViewLinkCell.xml @@ -505,7 +505,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -690,7 +690,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -735,7 +735,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -780,7 +780,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -825,7 +825,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewPaintParts.xml b/xml/System.Windows.Forms/DataGridViewPaintParts.xml index 9de54c8aa4f..37cffc1bb16 100644 --- a/xml/System.Windows.Forms/DataGridViewPaintParts.xml +++ b/xml/System.Windows.Forms/DataGridViewPaintParts.xml @@ -28,19 +28,19 @@ Defines values for specifying the parts of a that are to be painted. - method and by handlers for the , , and events of the control. - - - -## Examples - The following code example illustrates the use of this type. This example is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + method and by handlers for the , , and events of the control. + + + +## Examples + The following code example illustrates the use of this type. This example is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet20"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewRow.xml b/xml/System.Windows.Forms/DataGridViewRow.xml index 11700fcbd56..fc041e1deee 100644 --- a/xml/System.Windows.Forms/DataGridViewRow.xml +++ b/xml/System.Windows.Forms/DataGridViewRow.xml @@ -40,14 +40,14 @@ Unlike a , a physically contains a collection of all of the cells in that row. You can access this collection through the property. - The class is used to access the individual cell elements, as well as to adjust the appearance and behavior of the row user interface (UI), such as height and cell style. Typically, you will want all rows or most rows in the control to share the same characteristics. To set cell styles for all rows in the control, set the properties of the object returned by the property. To set styles for alternating rows, use the property. For more information about cell styles, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). You can also use the property to define a row that will be used as a basis for all rows added to the control. + The class is used to access the individual cell elements, as well as to adjust the appearance and behavior of the row user interface (UI), such as height and cell style. Typically, you will want all rows or most rows in the control to share the same characteristics. To set cell styles for all rows in the control, set the properties of the object returned by the property. To set styles for alternating rows, use the property. For more information about cell styles, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). You can also use the property to define a row that will be used as a basis for all rows added to the control. The control will share objects across multiple data rows whenever possible to avoid performance penalties. Unless you are working with large amounts of data and experiencing performance issues, you can typically ignore row sharing. A shared row is indicated by an property value of -1. Some members of the class cannot be used with shared rows, but you can unshare a row by accessing it through the property. Rows can also become unshared in other ways. To access a row without unsharing it, use the method. When working with large amounts of data, you should be aware of how rows are shared and unshared to avoid performance penalties. For more information, see [Best Practices for Scaling the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control). ## Examples - The following code example illustrates the use of this type. This example is part of a larger example available in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). + The following code example illustrates the use of this type. This example is part of a larger example available in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewRowDemo.cpp" id="Snippet209"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewRowDemo.cs" id="Snippet209"::: @@ -61,8 +61,8 @@ - Best Practices for Scaling the Windows Forms DataGridView Control - Cell Styles in the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control @@ -271,7 +271,7 @@ ## Examples - The following code example uses the property to set the value of a cell in the row. This code example is part of a larger code example provided in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). + The following code example uses the property to set the value of a cell in the row. This code example is part of a larger code example provided in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewRowDemo.cpp" id="Snippet211"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewRowDemo.cs" id="Snippet211"::: @@ -403,7 +403,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -660,7 +660,7 @@ ## Examples - The following code example demonstrates how to use the property to access a business object bound to a row. This code example is part of a larger example provided in [How to: Access Objects Bound to Windows Forms DataGridView Rows](/dotnet/framework/winforms/controls/how-to-access-objects-bound-to-windows-forms-datagridview-rows). + The following code example demonstrates how to use the property to access a business object bound to a row. This code example is part of a larger example provided in [How to: Access Objects Bound to Windows Forms DataGridView Rows](/dotnet/desktop/winforms/controls/how-to-access-objects-bound-to-windows-forms-datagridview-rows). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewRow/DataBoundItem/datagridviewobjectbinding.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewObjectBinding/VB/datagridviewobjectbinding.vb" id="Snippet10"::: @@ -719,7 +719,7 @@ ## Remarks The control displays its cells using the styles indicated by the cell property, which inherits styles from other properties of type . For cells in this row, the styles specified through the property override the styles specified through the , , , and properties, but are overridden by the styles specified through the property. - For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). When getting this property, a with default values will be created if the property has not already been accessed. This can cause a performance impact when getting this property for many rows. Whenever possible, use a single to set this property for multiple rows. For more information, see [Best Practices for Scaling the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/best-practices-for-scaling-the-windows-forms-datagridview-control). @@ -736,8 +736,8 @@ When setting this property, the row is in a control and is a shared row. - Cell Styles in the Windows Forms DataGridView Control - Best Practices for Scaling the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -775,7 +775,7 @@ To be added. The row is in a control and is a shared row. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -832,7 +832,7 @@ When setting this property, the row is in a control and is a shared row. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -971,7 +971,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1025,7 +1025,7 @@ The row is in a control and is a shared row. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1071,7 +1071,7 @@ is less than zero or greater than or equal to the number of rows in the control minus one. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1114,7 +1114,7 @@ The row belongs to a control and is a shared row. The row belongs to a control and is less than zero or greater than the number of rows in the control minus one. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1161,12 +1161,12 @@ For cell contents to wrap onto multiple lines, the cell style in effect for the cell must have a property value of . - For more information about automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + For more information about automatic sizing, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). ## Examples - The following code example uses the method to determine the new padding for a row that has been resized. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + The following code example uses the method to determine the new padding for a row that has been resized. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet40"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet40"::: @@ -1180,9 +1180,9 @@ - How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control - Sizing Options in the Windows Forms DataGridView Control - Best Practices for Scaling the Windows Forms DataGridView Control + How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control + Sizing Options in the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1239,7 +1239,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1347,7 +1347,7 @@ ## Examples - The following code example uses the property to set the height of the first row. This code example is part of a larger code example provided in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). + The following code example uses the property to set the height of the first row. This code example is part of a larger code example provided in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewRowDemo.cpp" id="Snippet208"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewRowDemo.cs" id="Snippet208"::: @@ -1358,7 +1358,7 @@ When setting this property, the row is in a control and is a shared row. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1400,7 +1400,7 @@ - - For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). + For more information about cell style inheritance, see [Cell Styles in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/cell-styles-in-the-windows-forms-datagridview-control). ]]> @@ -1411,8 +1411,8 @@ - Cell Styles in the Windows Forms DataGridView Control - Best Practices for Scaling the Windows Forms DataGridView Control + Cell Styles in the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1475,7 +1475,7 @@ ]]> - Using the Row for New Records in the Windows Forms DataGridView Control + Using the Row for New Records in the Windows Forms DataGridView Control @@ -1526,7 +1526,7 @@ ## Examples - The following code example uses the property to set the minimum height of the second row. This code example is part of a larger code example provided in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). + The following code example uses the property to set the minimum height of the second row. This code example is part of a larger code example provided in [How to: Manipulate Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-manipulate-rows-in-the-windows-forms-datagridview-control). :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewRowDemo.cpp" id="Snippet207"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewRowDemo.cs" id="Snippet207"::: @@ -1538,7 +1538,7 @@ The specified value when setting this property is less than 2. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1604,7 +1604,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1803,7 +1803,7 @@ The row is in a control and is a shared row. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1863,7 +1863,7 @@ The row is in a control and is a shared row. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1910,7 +1910,7 @@ The row is in a control and is a shared row. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -1977,7 +1977,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -2017,7 +2017,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -2110,7 +2110,7 @@ The row is in a control and is a shared row. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewRowCancelEventArgs.xml b/xml/System.Windows.Forms/DataGridViewRowCancelEventArgs.xml index 8c7dd8fa251..60a91cc2154 100644 --- a/xml/System.Windows.Forms/DataGridViewRowCancelEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewRowCancelEventArgs.xml @@ -29,22 +29,22 @@ Provides data for the event of a . - event handler, set the property to `true`. - - For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example illustrates the use of this type. This example is part of a larger example available in [How to: Implement Virtual Mode in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-implement-virtual-mode-in-the-windows-forms-datagridview-control). - + event handler, set the property to `true`. + + For more information about how to handle events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example illustrates the use of this type. This example is part of a larger example available in [How to: Implement Virtual Mode in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-implement-virtual-mode-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.VirtualMode/CPP/virtualmode.cpp" id="Snippet180"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CancelRowEdit/virtualmode.cs" id="Snippet180"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.VirtualMode/VB/virtualmode.vb" id="Snippet180"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.VirtualMode/VB/virtualmode.vb" id="Snippet180"::: + ]]> @@ -86,11 +86,11 @@ The row the user is deleting. Initializes a new instance of the class. - property. - + property. + ]]> @@ -135,15 +135,15 @@ Gets the row that the user is deleting. The row that the user deleted. - diff --git a/xml/System.Windows.Forms/DataGridViewRowCollection.xml b/xml/System.Windows.Forms/DataGridViewRowCollection.xml index f14fdd9f392..911321e0df6 100644 --- a/xml/System.Windows.Forms/DataGridViewRowCollection.xml +++ b/xml/System.Windows.Forms/DataGridViewRowCollection.xml @@ -193,7 +193,7 @@ The row returned by the property has more cells than there are columns in the control. - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -491,7 +491,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -2223,7 +2223,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -2452,7 +2452,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventHandler.xml b/xml/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventHandler.xml index 05be5bedb51..14579288f06 100644 --- a/xml/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewRowContextMenuStripNeededEventHandler.xml @@ -74,6 +74,6 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewRowErrorTextNeededEventArgs.xml b/xml/System.Windows.Forms/DataGridViewRowErrorTextNeededEventArgs.xml index 537bcef1d74..e1869309e5c 100644 --- a/xml/System.Windows.Forms/DataGridViewRowErrorTextNeededEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewRowErrorTextNeededEventArgs.xml @@ -65,7 +65,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewRowErrorTextNeededEventHandler.xml b/xml/System.Windows.Forms/DataGridViewRowErrorTextNeededEventHandler.xml index 6f55edd6b6d..ce58f124a45 100644 --- a/xml/System.Windows.Forms/DataGridViewRowErrorTextNeededEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewRowErrorTextNeededEventHandler.xml @@ -66,6 +66,6 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewRowHeadersWidthSizeMode.xml b/xml/System.Windows.Forms/DataGridViewRowHeadersWidthSizeMode.xml index c945869a54e..9a9a907add6 100644 --- a/xml/System.Windows.Forms/DataGridViewRowHeadersWidthSizeMode.xml +++ b/xml/System.Windows.Forms/DataGridViewRowHeadersWidthSizeMode.xml @@ -22,31 +22,31 @@ Defines values for specifying how the row header width is adjusted. - control can adjust the width of its row headers to fit all their contents, only the contents of the first header, or only the contents of currently displayed headers. Calculating the new width using a subset of headers is useful to avoid a performance penalty when working with many rows of data. - - This enumeration is used by the control property and method. - - For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). - - - -## Examples - The following code example illustrates the use of this enumeration in a display-only, non-interactive control. - + control can adjust the width of its row headers to fit all their contents, only the contents of the first header, or only the contents of currently displayed headers. Calculating the new width using a subset of headers is useful to avoid a performance penalty when working with many rows of data. + + This enumeration is used by the control property and method. + + For more information about sizing modes, see [Sizing Options in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/sizing-options-in-the-windows-forms-datagridview-control). + + + +## Examples + The following code example illustrates the use of this enumeration in a display-only, non-interactive control. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AllowUserToAddRows/form1.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewStyleDemo/VB/form1.vb" id="Snippet20"::: + ]]> - Sizing Options in the Windows Forms DataGridView Control + Sizing Options in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewRowPostPaintEventArgs.xml b/xml/System.Windows.Forms/DataGridViewRowPostPaintEventArgs.xml index 3061a2b616c..b4425d60a76 100644 --- a/xml/System.Windows.Forms/DataGridViewRowPostPaintEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewRowPostPaintEventArgs.xml @@ -29,23 +29,23 @@ Provides data for the event. - event occurs after a row is painted on a control. allows you to manually adjust the appearance of the row after the cells in the row are painted. This is useful if you want to customize the row. - - - -## Examples - The following code example demonstrates how to handle the event to make the content of a cell span the entire row. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + event occurs after a row is painted on a control. allows you to manually adjust the appearance of the row after the cells in the row are painted. This is useful if you want to customize the row. + + + +## Examples + The following code example demonstrates how to handle the event to make the content of a cell span the entire row. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: + ]]> - How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control + How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control @@ -103,14 +103,14 @@ Initializes a new instance of the class. To be added. - is . - - -or- - - is . - - -or- - + is . + + -or- + + is . + + -or- + is . @@ -156,21 +156,21 @@ Gets or sets the area of the that needs to be repainted. A that represents the area of the that needs to be repainted. - property represents the area of the that needs to be repainted. For example, if a user covers the entire with another window and then uncovers it, then represents the entire . If a user covers a small area of the and then uncovers it, then represents the small area that was covered. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + property represents the area of the that needs to be repainted. For example, if a user covers the entire with another window and then uncovers it, then represents the entire . If a user covers a small area of the and then uncovers it, then represents the small area that was covered. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet355"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet355"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet355"::: + ]]> @@ -209,19 +209,19 @@ to use the property of the property to determine the color of the focus rectangle; to use the property of the property. Draws the focus rectangle around the specified bounds. - method when you draw the and its cells' contents yourself. - - - -## Examples - The following code example demonstrates how to use the method to draw a focus around the visible cells of the row. This example is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + method when you draw the and its cells' contents yourself. + + + +## Examples + The following code example demonstrates how to use the method to draw a focus around the visible cells of the row. This example is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: + ]]> @@ -269,21 +269,21 @@ Gets a string that represents an error message for the current . A string that represents an error message for the current . - property is the same as the current row's property. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + property is the same as the current row's property. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet355"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet355"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet355"::: + ]]> @@ -323,19 +323,19 @@ Gets the used to paint the current . The used to paint the current . - class provides properties and methods that are useful for custom drawing. - - - -## Examples - The following code example demonstrates how to use the property to paint a custom background. Although the code actually uses the property, this property is nearly identical to the property of . The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + class provides properties and methods that are useful for custom drawing. + + + +## Examples + The following code example demonstrates how to use the property to paint a custom background. Although the code actually uses the property, this property is nearly identical to the property of . The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet25"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet25"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet25"::: + ]]> @@ -375,21 +375,21 @@ Gets the cell style applied to the current . A that contains the cell style applied to the current . - property contains the same values as the current row's property. Directly accessing a in the can affect performance. Use in the event to avoid unsharing the row and maintain optimal performance. - - The property is read-only. Although you can set the properties of the retrieved through the property, the new settings will have no effect. - - - -## Examples - The following code example demonstrates how to use the to determine the color to use to draw the content. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + property contains the same values as the current row's property. Directly accessing a in the can affect performance. Use in the event to avoid unsharing the row and maintain optimal performance. + + The property is read-only. Although you can set the properties of the retrieved through the property, the new settings will have no effect. + + + +## Examples + The following code example demonstrates how to use the to determine the color to use to draw the content. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet34"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet34"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet34"::: + ]]> @@ -397,7 +397,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -433,16 +433,16 @@ if the row being painted is currently the first row displayed in the ; otherwise, . - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet355"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet355"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet355"::: + ]]> @@ -481,16 +481,16 @@ if the current row is the last row in the that has the property set to ; otherwise, . - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet355"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet355"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet355"::: + ]]> @@ -718,19 +718,19 @@ Get the bounds of the current . A that represents the bounds of the current . - property is the same as the width of the . To get the width of the columns in the , use the method. - - - -## Examples - The following code example demonstrates how to use the property to determine the bounds of the visible cells in a row. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + property is the same as the width of the . To get the width of the columns in the , use the method. + + + +## Examples + The following code example demonstrates how to use the property to determine the bounds of the visible cells in a row. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: + ]]> @@ -771,19 +771,19 @@ Gets the index of the current . The index of the current . - . - - - -## Examples - The following code example demonstrates how to use the property to access the current row. The code gets the value of the cell at the intersection of the selected row and the third column, and then paints this value over the entire row. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + . + + + +## Examples + The following code example demonstrates how to use the property to access the current row. The code gets the value of the cell at the intersection of the selected row and the third column, and then paints this value over the entire row. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet35"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet35"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet35"::: + ]]> @@ -822,19 +822,19 @@ Gets the state of the current . A bitwise combination of values that specifies the state of the row. - property to determine whether the current row is selected. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + property to determine whether the current row is selected. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet34"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet34"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet34"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewRowPostPaintEventHandler.xml b/xml/System.Windows.Forms/DataGridViewRowPostPaintEventHandler.xml index ccd14407b6e..69f1d8b19b4 100644 --- a/xml/System.Windows.Forms/DataGridViewRowPostPaintEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewRowPostPaintEventHandler.xml @@ -39,23 +39,23 @@ A that contains the event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example presents a delegate that paints textual content that spans the entire row below the normal cell values. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example presents a delegate that paints textual content that spans the entire row below the normal cell values. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: + ]]> - How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control + How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewRowPrePaintEventArgs.xml b/xml/System.Windows.Forms/DataGridViewRowPrePaintEventArgs.xml index 4afb1ab8383..e9d931e6e62 100644 --- a/xml/System.Windows.Forms/DataGridViewRowPrePaintEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewRowPrePaintEventArgs.xml @@ -29,19 +29,19 @@ Provides data for the event. - event occurs before a row is painted on a control. enables you to manually adjust the appearance of the row before any of the cells in the row are painted. This is useful if you want to customize the row, such as to produce a row where the content of one column spans multiple columns. Use the properties in to get the settings of the row without directly accessing the row in the . - - - -## Examples - The following code example demonstrates how to handle the event to draw a custom background for selected cells. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + event occurs before a row is painted on a control. enables you to manually adjust the appearance of the row before any of the cells in the row are painted. This is useful if you want to customize the row, such as to produce a row where the content of one column spans multiple columns. Use the properties in to get the settings of the row without directly accessing the row in the . + + + +## Examples + The following code example demonstrates how to handle the event to draw a custom background for selected cells. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet20"::: + ]]> @@ -103,14 +103,14 @@ Initializes a new instance of the class. To be added. - is . - - -or- - - is . - - -or- - + is . + + -or- + + is . + + -or- + is . @@ -156,21 +156,21 @@ Gets or sets the area of the that needs to be repainted. A that represents the area of the that needs to be repainted. - property represents the area of the that needs to be repainted. For example, if a user covers the entire with another window and then uncovers it, then represents the entire . If a user covers a small area of the and then uncovers it, then represents the small area that was covered. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + property represents the area of the that needs to be repainted. For example, if a user covers the entire with another window and then uncovers it, then represents the entire . If a user covers a small area of the and then uncovers it, then represents the small area that was covered. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet356"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet356"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet356"::: + ]]> @@ -209,19 +209,19 @@ to use the property of the property to determine the color of the focus rectangle; to use the property of the . Draws the focus rectangle around the specified bounds. - method when you draw the and its cells' contents yourself. If you manually paint the entire row and its cells' contents, set the property to `true`. When is `true`, the and events do not occur. - - - -## Examples - The following code example demonstrates how to use the method to draw a focus around the visible cells of the row. The code actually uses the method, which is nearly identical to the method of . This example is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + method when you draw the and its cells' contents yourself. If you manually paint the entire row and its cells' contents, set the property to `true`. When is `true`, the and events do not occur. + + + +## Examples + The following code example demonstrates how to use the method to draw a focus around the visible cells of the row. The code actually uses the method, which is nearly identical to the method of . This example is part of a larger example available in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet30"::: + ]]> @@ -270,21 +270,21 @@ Gets a string that represents an error message for the current . A string that represents an error message for the current . - property is the same as the current row's property. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + property is the same as the current row's property. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet356"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet356"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet356"::: + ]]> @@ -324,19 +324,19 @@ Gets the used to paint the current . The used to paint the current . - class provides properties and methods that are useful for custom drawing. - - - -## Examples - The following code example demonstrates how to use the property to paint the custom background. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + class provides properties and methods that are useful for custom drawing. + + + +## Examples + The following code example demonstrates how to use the property to paint the custom background. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet25"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet25"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet25"::: + ]]> @@ -376,21 +376,21 @@ Gets the cell style applied to the row. A that contains the cell style currently applied to the row. - property contains the same values as the row's property. Directly accessing a in the can affect performance. Use in the event to avoid unsharing the row and maintain optimal performance. - - The property is read-only. Although you can set the properties of the retrieved through the property, the new settings will have no effect. - - - -## Examples - The following code example demonstrates how to use the property to paint a custom background for the selected row. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + property contains the same values as the row's property. Directly accessing a in the can affect performance. Use in the event to avoid unsharing the row and maintain optimal performance. + + The property is read-only. Although you can set the properties of the retrieved through the property, the new settings will have no effect. + + + +## Examples + The following code example demonstrates how to use the property to paint a custom background for the selected row. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet25"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet25"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet25"::: + ]]> @@ -398,7 +398,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control @@ -434,16 +434,16 @@ if the row being painted is currently the first row displayed in the ; otherwise, . - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet356"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet356"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet356"::: + ]]> @@ -482,16 +482,16 @@ if the row being painted is currently the last row in the that has the property set to ; otherwise, . - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `DataGridView1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet356"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet356"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet356"::: + ]]> @@ -565,11 +565,11 @@ to paint the background of the specified bounds with the color of the property of the ; to paint the background of the specified bounds with the color of the property of the . Paints the cell backgrounds for the area in the specified bounds. - method when you draw the and its cells' contents yourself. If you manually paint the entire row and its cells' contents, set the property to `true`. When is `true`, the and events do not occur. - + method when you draw the and its cells' contents yourself. If you manually paint the entire row and its cells' contents, set the property to `true`. When is `true`, the and events do not occur. + ]]> @@ -654,11 +654,11 @@ to paint the row header with the color of the property of the ; to paint the row header with the of the property. Paints the entire row header of the current . - method when you draw the and its cells' contents yourself. If you manually paint the entire row and its cells' contents, set the property to `true`. When is `true`, the and events do not occur. - + method when you draw the and its cells' contents yourself. If you manually paint the entire row and its cells' contents, set the property to `true`. When is `true`, the and events do not occur. + ]]> @@ -735,14 +735,14 @@ The cell parts that are to be painted. A bitwise combination of values specifying the parts to be painted. - The specified value when setting this property is not a valid bitwise combination of values. @@ -781,19 +781,19 @@ Get the bounds of the current . A that represents the bounds of the current . - property is the same as the width of the . To get the width of the columns in the , use the method. - - - -## Examples - The following code example demonstrates how to use the property to calculate the bounds of the row to paint a custom background. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + property is the same as the width of the . To get the width of the columns in the , use the method. + + + +## Examples + The following code example demonstrates how to use the property to calculate the bounds of the row to paint a custom background. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet25"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet25"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet25"::: + ]]> @@ -834,19 +834,19 @@ Gets the index of the current . The index of the current . - . - - - -## Examples - The following code example demonstrates how to use the property to access the current row. Although the code actually uses the property, this property is nearly identical to the property of . The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + . + + + +## Examples + The following code example demonstrates how to use the property to access the current row. Although the code actually uses the property, this property is nearly identical to the property of . The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet35"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet35"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet35"::: + ]]> @@ -885,19 +885,19 @@ Gets the state of the current . A bitwise combination of the values that specifies the state of the row. - property to determine whether a row is selected. If the row is selected, the code paints a custom background. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + property to determine whether a row is selected. If the row is selected, the code paints a custom background. The variable, `e`, is of type . This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet25"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet25"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet25"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewRowPrePaintEventHandler.xml b/xml/System.Windows.Forms/DataGridViewRowPrePaintEventHandler.xml index 46b48c87ac7..528e9ce535e 100644 --- a/xml/System.Windows.Forms/DataGridViewRowPrePaintEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewRowPrePaintEventHandler.xml @@ -39,23 +39,23 @@ A that contains the event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example presents a delegate that paints a gradient row background if the row is selected. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). - + delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example presents a delegate that paints a gradient row background if the row is selected. This code example is part of a larger example provided in [How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/customize-the-appearance-of-rows-in-the-datagrid). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/ColumnWidthChanged/datagridviewrowpainting.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewRowPainting/VB/datagridviewrowpainting.vb" id="Snippet20"::: + ]]> - How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control + How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewSelectedColumnCollection.xml b/xml/System.Windows.Forms/DataGridViewSelectedColumnCollection.xml index 46cb9420368..fe1e8e65b94 100644 --- a/xml/System.Windows.Forms/DataGridViewSelectedColumnCollection.xml +++ b/xml/System.Windows.Forms/DataGridViewSelectedColumnCollection.xml @@ -56,7 +56,7 @@ - Best Practices for Scaling the Windows Forms DataGridView Control + Best Practices for Scaling the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewSelectionMode.xml b/xml/System.Windows.Forms/DataGridViewSelectionMode.xml index a8d657ea52d..6652e662baa 100644 --- a/xml/System.Windows.Forms/DataGridViewSelectionMode.xml +++ b/xml/System.Windows.Forms/DataGridViewSelectionMode.xml @@ -22,19 +22,19 @@ Describes how cells of a DataGridView control can be selected. - property of a control. - - - -## Examples - The following code example illustrates the use of this type. For more information, see [How to: Set the Selection Mode of the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-set-the-selection-mode-of-the-windows-forms-datagridview-control). - + property of a control. + + + +## Examples + The following code example illustrates the use of this type. For more information, see [How to: Set the Selection Mode of the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-set-the-selection-mode-of-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellBeginEdit/datagridviewmisc.cs" id="Snippet065"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet065"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet065"::: + ]]> diff --git a/xml/System.Windows.Forms/DataGridViewSortCompareEventArgs.xml b/xml/System.Windows.Forms/DataGridViewSortCompareEventArgs.xml index 257e26f0bd7..bf0ddd90d33 100644 --- a/xml/System.Windows.Forms/DataGridViewSortCompareEventArgs.xml +++ b/xml/System.Windows.Forms/DataGridViewSortCompareEventArgs.xml @@ -29,21 +29,21 @@ Provides data for the event. - event to provide custom sorting. This event occurs only when the property is not set and the property is set to `false`. This event occurs once for each pair of cells in the column being sorted. It occurs only when the user clicks the header of a column with a property value of , or when you call the overload. When this event occurs for a column with a property value of , you must display the sorting glyph yourself through the property. - - You can use this event to sort rows using the cell values in one column or in multiple columns. Use the and properties to compare cell values in the column specified in the property. Use the and properties to access values in other columns through the collection. - - - -## Examples - The following code example demonstrates the use of in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). - + event to provide custom sorting. This event occurs only when the property is not set and the property is set to `false`. This event occurs once for each pair of cells in the column being sorted. It occurs only when the user clicks the header of a column with a property value of , or when you call the overload. When this event occurs for a column with a property value of , you must display the sorting glyph yourself through the property. + + You can use this event to sort rows using the cell values in one column or in multiple columns. Use the and properties to compare cell values in the column specified in the property. Use the and properties to access values in other columns through the collection. + + + +## Examples + The following code example demonstrates the use of in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/SortCompare/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: + ]]> @@ -58,7 +58,7 @@ - How to: Customize Sorting in the Windows Forms DataGridView Control + How to: Customize Sorting in the Windows Forms DataGridView Control @@ -113,7 +113,7 @@ - How to: Customize Sorting in the Windows Forms DataGridView Control + How to: Customize Sorting in the Windows Forms DataGridView Control @@ -149,19 +149,19 @@ Gets the value of the first cell to compare. The value of the first cell. - property. - - - -## Examples - The following code example demonstrates the use of in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). - + property. + + + +## Examples + The following code example demonstrates the use of in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/SortCompare/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: + ]]> @@ -170,7 +170,7 @@ - How to: Customize Sorting in the Windows Forms DataGridView Control + How to: Customize Sorting in the Windows Forms DataGridView Control @@ -206,19 +206,19 @@ Gets the value of the second cell to compare. The value of the second cell. - property. - - - -## Examples - The following code example demonstrates the use of in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). - + property. + + + +## Examples + The following code example demonstrates the use of in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/SortCompare/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: + ]]> @@ -227,7 +227,7 @@ - How to: Customize Sorting in the Windows Forms DataGridView Control + How to: Customize Sorting in the Windows Forms DataGridView Control @@ -266,25 +266,25 @@ Gets the column being sorted. The to sort. - in a multiple column sort. In this example the ID column is used to determine the final order if there are identical values in the sorted column, so no additional sorting will be done if there are duplicate values in the ID column. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). - + in a multiple column sort. In this example the ID column is used to determine the final order if there are identical values in the sorted column, so no additional sorting will be done if there are duplicate values in the ID column. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/SortCompare/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: + ]]> - How to: Customize Sorting in the Windows Forms DataGridView Control + How to: Customize Sorting in the Windows Forms DataGridView Control @@ -319,26 +319,26 @@ Gets the index of the row containing the first cell to compare. The index of the row containing the second cell. - in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). - + in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/SortCompare/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: + ]]> - How to: Customize Sorting in the Windows Forms DataGridView Control + How to: Customize Sorting in the Windows Forms DataGridView Control @@ -373,26 +373,26 @@ Gets the index of the row containing the second cell to compare. The index of the row containing the second cell. - in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). - + in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/SortCompare/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: + ]]> - How to: Customize Sorting in the Windows Forms DataGridView Control + How to: Customize Sorting in the Windows Forms DataGridView Control @@ -431,25 +431,25 @@ Gets or sets a value indicating the order in which the compared cells will be sorted. Less than zero if the first cell will be sorted before the second cell; zero if the first cell and second cell have equivalent values; greater than zero if the second cell will be sorted before the first cell. - event. You will typically set this value to the return value of a comparison method such as . - - - -## Examples - The following code example demonstrates the use of in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). - + event. You will typically set this value to the return value of a comparison method such as . + + + +## Examples + The following code example demonstrates the use of in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/SortCompare/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: + ]]> - How to: Customize Sorting in the Windows Forms DataGridView Control + How to: Customize Sorting in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewSortCompareEventHandler.xml b/xml/System.Windows.Forms/DataGridViewSortCompareEventHandler.xml index ee902ce3b9b..2ffcdce151f 100644 --- a/xml/System.Windows.Forms/DataGridViewSortCompareEventHandler.xml +++ b/xml/System.Windows.Forms/DataGridViewSortCompareEventHandler.xml @@ -39,24 +39,24 @@ A that contains the event data. Represents the method that will handle the event of a control. - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates the use of in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). - + delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates the use of in a multiple column sort. This example is part of a larger example provided in [How to: Customize Sorting in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-customize-sorting-in-the-windows-forms-datagridview-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/SortCompare/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.SortCompare/VB/form1.vb" id="Snippet10"::: + ]]> - How to: Customize Sorting in the Windows Forms DataGridView Control + How to: Customize Sorting in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewTextBoxCell.xml b/xml/System.Windows.Forms/DataGridViewTextBoxCell.xml index 57293940b84..1c5301396b2 100644 --- a/xml/System.Windows.Forms/DataGridViewTextBoxCell.xml +++ b/xml/System.Windows.Forms/DataGridViewTextBoxCell.xml @@ -481,14 +481,14 @@ For additional information, see [What's New in Accessibility in the .NET Framewo ## Remarks When the property of the control is set to or , the control uses this method to determine whether a key other than F2 that is pressed by the user while this cell has focus will cause the cell to enter edit mode. - This method returns `true` if the e parameter indicates an ordinary data-entry key (such as a letter, number, punctuation mark, or the SPACE key) unmodified by ALT or CTRL, excluding SHIFT+SPACE, which is used by the control for selection purposes. For more information, see [Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/default-keyboard-and-mouse-handling-in-the-windows-forms-datagridview-control). + This method returns `true` if the e parameter indicates an ordinary data-entry key (such as a letter, number, punctuation mark, or the SPACE key) unmodified by ALT or CTRL, excluding SHIFT+SPACE, which is used by the control for selection purposes. For more information, see [Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/default-keyboard-and-mouse-handling-in-the-windows-forms-datagridview-control). ]]> - Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control + Default Keyboard and Mouse Handling in the Windows Forms DataGridView Control diff --git a/xml/System.Windows.Forms/DataGridViewTextBoxColumn.xml b/xml/System.Windows.Forms/DataGridViewTextBoxColumn.xml index 517c2d3dcc0..467944c11c8 100644 --- a/xml/System.Windows.Forms/DataGridViewTextBoxColumn.xml +++ b/xml/System.Windows.Forms/DataGridViewTextBoxColumn.xml @@ -37,21 +37,21 @@ Hosts a collection of cells. - class is a specialized type of class used to logically host cells that enable displaying and editing of text strings. A has an associated object in every that intersects it. When a becomes activated, it supplies a control to handle user input. - - The sort mode for this column type defaults to . - - - -## Examples - The following code example illustrates the use of this type. - + class is a specialized type of class used to logically host cells that enable displaying and editing of text strings. A has an associated object in every that intersects it. When a becomes activated, it supplies a control to handle user input. + + The sort mode for this column type defaults to . + + + +## Examples + The following code example illustrates the use of this type. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridViewAutoSizeColumnMode/Overview/sizingscenarios.cs" id="Snippet20"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewSizingScenarios/vb/sizingscenarios.vb" id="Snippet20"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewSizingScenarios/vb/sizingscenarios.vb" id="Snippet20"::: + ]]> @@ -87,16 +87,16 @@ Initializes a new instance of the class to the default state. - |A newly created .| -||| - + |A newly created .| +||| + ]]> @@ -146,23 +146,23 @@ Gets or sets the template used to model cell appearance. A that all other cells in the column are modeled after. - class initializes this property to a newly created . - + class initializes this property to a newly created . + > [!CAUTION] -> Changing the properties of the cell template will not immediately affect the user interface (UI) of the column's existing cells. These changes are only apparent after the column is regenerated (for example, by sorting the column or through a call to the method). - - - -## Examples - The following code example demonstrates the use of the property, which is similar to this property. This example is part of a larger example available in [How to: Manipulate Columns in the Windows Forms DataGridView Control](/dotnet/framework/winforms/controls/how-to-manipulate-columns-in-the-windows-forms-datagridview-control). - +> Changing the properties of the cell template will not immediately affect the user interface (UI) of the column's existing cells. These changes are only apparent after the column is regenerated (for example, by sorting the column or through a call to the method). + + + +## Examples + The following code example demonstrates the use of the property, which is similar to this property. This example is part of a larger example available in [How to: Manipulate Columns in the Windows Forms DataGridView Control](/dotnet/desktop/winforms/controls/how-to-manipulate-columns-in-the-windows-forms-datagridview-control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/CPP/DataGridViewColumnDemo.cpp" id="Snippet120"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/AutoResizeColumn/DataGridViewColumnDemo.cs" id="Snippet120"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet120"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridView.ButtonDemos/VB/datagridviewcolumndemo.vb" id="Snippet120"::: + ]]> The set type is not compatible with type . @@ -217,13 +217,13 @@ Gets or sets the maximum number of characters that can be entered into the text box. The maximum number of characters that can be entered into the text box; the default value is 32767. - property does not affect the length of text entered programmatically through the cell's value or through cell formatting. It affects only what the user can input and edit. - - Getting or setting this property gets or sets the property of the object returned by the property. Setting this property also sets the property of every cell in the column. To override the specified value for individual cells, set the cell values after you set the column value. - + property does not affect the length of text entered programmatically through the cell's value or through cell formatting. It affects only what the user can input and edit. + + Getting or setting this property gets or sets the property of the object returned by the property. Setting this property also sets the property of every cell in the column. To override the specified value for individual cells, set the cell values after you set the column value. + ]]> The value of the property is . @@ -265,27 +265,27 @@ Gets or sets the sort mode for the column. A that specifies the criteria used to order the rows based on the cell values in a column. - control is sorted using a column with a property value of , a sorting glyph is automatically displayed in the column header. - - When the control is sorted using a column with a property value of , you must display the sorting glyph yourself through the property. - - The default sort mode of a is . The default sort mode for other column types is . - - The value does not prevent you from sorting a column programmatically, although other restrictions may apply. For more information, see the method. - - A property value of will not prevent the event from occurring, but it will prevent the header from changing its appearance when it is clicked. - - - -## Examples - The following code example illustrates the use of this property. - + control is sorted using a column with a property value of , a sorting glyph is automatically displayed in the column header. + + When the control is sorted using a column with a property value of , you must display the sorting glyph yourself through the property. + + The default sort mode of a is . The default sort mode for other column types is . + + The value does not prevent you from sorting a column programmatically, although other restrictions may apply. For more information, see the method. + + A property value of will not prevent the event from occurring, but it will prevent the header from changing its appearance when it is clicked. + + + +## Examples + The following code example illustrates the use of this property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/CellBeginEdit/datagridviewmisc.cs" id="Snippet066"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet066"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewMisc/VB/datagridviewmisc.vb" id="Snippet066"::: + ]]> diff --git a/xml/System.Windows.Forms/DateTimePicker.xml b/xml/System.Windows.Forms/DateTimePicker.xml index f2b685455e9..52f6d3f0b5c 100644 --- a/xml/System.Windows.Forms/DateTimePicker.xml +++ b/xml/System.Windows.Forms/DateTimePicker.xml @@ -62,46 +62,46 @@ Represents a Windows control that allows the user to select a date and a time and to display the date and time with a specified format. - control is used to allow the user to select a date and time, and to display that date and time in the specified format. The control makes it easy to work with dates and times because it handles a lot of the data validation automatically. - + control is used to allow the user to select a date and time, and to display that date and time in the specified format. The control makes it easy to work with dates and times because it handles a lot of the data validation automatically. + > [!NOTE] -> The control only supports Gregorian calendars. - - When used to represent a date, the control appears in two parts: a drop-down list with a date represented in text, and a calendar that appears when you click the down-arrow next to the list. The calendar looks like the control, which can be used for selecting multiple dates. For more information about the control, see [MonthCalendar Control Overview](/dotnet/framework/winforms/controls/monthcalendar-control-overview-windows-forms). - - You can change the look of the calendar portion of the control by setting the , , , , , and properties. - - To use a spin button control (also known as an up-down control) to adjust the date/time value, set the property to `true`. The calendar will not drop down when the control is selected. The date and time can be adjusted by selecting each element individually and using the up and down buttons to change the value. - - The property contains the current date and time the control is set to. You can use the property or the appropriate member of to get the date and time value. For more information, see [How to: Set and Return Dates with the Windows Forms DateTimePicker Control](/dotnet/framework/winforms/controls/how-to-set-and-return-dates-with-the-windows-forms-datetimepicker-control). You can limit the dates and times that can be selected by setting the and properties. - - The values can be displayed in four formats, which are set by the property: , , , or . The default date is . - - If you want the to appear as a control for picking or editing times instead of dates, set the property to `true` and the property to . For more information, see [How to: Display Time with the DateTimePicker Control](/dotnet/framework/winforms/controls/how-to-display-time-with-the-datetimepicker-control). - - If the property is set to , you can create your own format style by setting the property and building a custom format string. The custom format string can be a combination of custom field characters and other literal characters. For example, you can display the date as "June 01, 2012 - Friday" by setting the property to "MMMM dd, yyyy - dddd". For more information, see [How to: Display a Date in a Custom Format with the Windows Forms DateTimePicker Control](/dotnet/framework/winforms/controls/display-a-date-in-a-custom-format-with-wf-datetimepicker-control) and [Custom Date and Time Format Strings](/dotnet/standard/base-types/custom-date-and-time-format-strings). - +> The control only supports Gregorian calendars. + + When used to represent a date, the control appears in two parts: a drop-down list with a date represented in text, and a calendar that appears when you click the down-arrow next to the list. The calendar looks like the control, which can be used for selecting multiple dates. For more information about the control, see [MonthCalendar Control Overview](/dotnet/desktop/winforms/controls/monthcalendar-control-overview-windows-forms). + + You can change the look of the calendar portion of the control by setting the , , , , , and properties. + + To use a spin button control (also known as an up-down control) to adjust the date/time value, set the property to `true`. The calendar will not drop down when the control is selected. The date and time can be adjusted by selecting each element individually and using the up and down buttons to change the value. + + The property contains the current date and time the control is set to. You can use the property or the appropriate member of to get the date and time value. For more information, see [How to: Set and Return Dates with the Windows Forms DateTimePicker Control](/dotnet/desktop/winforms/controls/how-to-set-and-return-dates-with-the-windows-forms-datetimepicker-control). You can limit the dates and times that can be selected by setting the and properties. + + The values can be displayed in four formats, which are set by the property: , , , or . The default date is . + + If you want the to appear as a control for picking or editing times instead of dates, set the property to `true` and the property to . For more information, see [How to: Display Time with the DateTimePicker Control](/dotnet/desktop/winforms/controls/how-to-display-time-with-the-datetimepicker-control). + + If the property is set to , you can create your own format style by setting the property and building a custom format string. The custom format string can be a combination of custom field characters and other literal characters. For example, you can display the date as "June 01, 2012 - Friday" by setting the property to "MMMM dd, yyyy - dddd". For more information, see [How to: Display a Date in a Custom Format with the Windows Forms DateTimePicker Control](/dotnet/desktop/winforms/controls/display-a-date-in-a-custom-format-with-wf-datetimepicker-control) and [Custom Date and Time Format Strings](/dotnet/standard/base-types/custom-date-and-time-format-strings). + > [!CAUTION] -> When a is data-bound and the backing value is changed to `null`, the value of the will not be updated and the previous value will be retained. In situations where this behavior is not desirable (for example, when using a set of data-bound controls to page through a recordset) use the event of the class to set the to a value recognizable as a `null`. - - - -## Examples - The following code example creates an new instance of a control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control. To run this example, paste the following code into a form and call the `CreateMyDateTimePicker` method in the example form's constructor or event handling method. - +> When a is data-bound and the backing value is changed to `null`, the value of the will not be updated and the previous value will be retained. In situations where this behavior is not desirable (for example, when using a set of data-bound controls to page through a recordset) use the event of the class to set the to a value recognizable as a `null`. + + + +## Examples + The following code example creates an new instance of a control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control. To run this example, paste the following code into a form and call the `CreateMyDateTimePicker` method in the example form's constructor or event handling method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DateTimePicker Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: + ]]> - How to: Set and Return Dates with the Windows Forms DateTimePicker Control - How to: Display Time with the DateTimePicker Control - How to: Display a Date in a Custom Format with the Windows Forms DateTimePicker Control + How to: Set and Return Dates with the Windows Forms DateTimePicker Control + How to: Display Time with the DateTimePicker Control + How to: Display a Date in a Custom Format with the Windows Forms DateTimePicker Control Custom Date and Time Format Strings @@ -128,15 +128,15 @@ Initializes a new instance of the class. - control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control (also known as an up-down control). - + control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control (also known as an up-down control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DateTimePicker Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -178,11 +178,11 @@ Gets or sets a value indicating the background color of the control. The background of the . - has no effect on the appearance of the . To set the background color for the drop-down calendar of the , see the property. - + has no effect on the appearance of the . To set the background color for the drop-down calendar of the , see the property. + ]]> @@ -267,11 +267,11 @@ Gets or sets the background image for the control. The background image for the control. - @@ -351,11 +351,11 @@ Gets or sets the layout of the background image of the control. One of the values. - property has no effect on the appearance of the control. - + property has no effect on the appearance of the control. + ]]> @@ -439,20 +439,20 @@ Gets or sets the font style applied to the calendar. A that represents the font style applied to the calendar. - property. This example creates a new control, adds it to the collection of a , and then initializes the property to a dynamically defined . - + property. This example creates a new control, adds it to the collection of a , and then initializes the property to a dynamically defined . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DateTimePicker.CalendarFont/CPP/calendarfont.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/CalendarFont/calendarfont.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DateTimePicker.CalendarFont/VB/calendarfont.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DateTimePicker.CalendarFont/VB/calendarfont.vb" id="Snippet1"::: + ]]> @@ -490,22 +490,22 @@ Gets or sets the foreground color of the calendar. A that represents the foreground color of the calendar. - is created, this property is initially set equal to the property value. - - Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the **Enable XP visual styles** check box. To disable visual styles in C#, open Program.cs and comment out `Application.EnableVisualStyles();`. - - - -## Examples - The following code example demonstrates how to initialize the property. This example creates a new , adds it to the collection, and then initializes its property to the constant. - + is created, this property is initially set equal to the property value. + + Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the **Enable XP visual styles** check box. To disable visual styles in C#, open Program.cs and comment out `Application.EnableVisualStyles();`. + + + +## Examples + The following code example demonstrates how to initialize the property. This example creates a new , adds it to the collection, and then initializes its property to the constant. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DateTimePicker.CalendarForeColor/CPP/calendarforecolor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/CalendarForeColor/calendarforecolor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DateTimePicker.CalendarForeColor/VB/calendarforecolor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DateTimePicker.CalendarForeColor/VB/calendarforecolor.vb" id="Snippet1"::: + ]]> The value assigned is . @@ -545,22 +545,22 @@ Gets or sets the background color of the calendar month. A that represents the background color of the calendar month. - is created, this property is initially set equal to the field value. - - Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the **Enable XP visual styles** check box. To disable visual styles in C#, open Program.cs and comment out `Application.EnableVisualStyles();`. - - - -## Examples - The following code example demonstrates how to initialize the property. After creating a and adding it to a , the example initializes the property to a constant. - + is created, this property is initially set equal to the field value. + + Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the **Enable XP visual styles** check box. To disable visual styles in C#, open Program.cs and comment out `Application.EnableVisualStyles();`. + + + +## Examples + The following code example demonstrates how to initialize the property. After creating a and adding it to a , the example initializes the property to a constant. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DateTimePicker.CalendarMonthBackground/CPP/calendarmonthbackground.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/CalendarMonthBackground/calendarmonthbackground.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DateTimePicker.CalendarMonthBackground/VB/calendarmonthbackground.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DateTimePicker.CalendarMonthBackground/VB/calendarmonthbackground.vb" id="Snippet1"::: + ]]> The value assigned is . @@ -600,13 +600,13 @@ Gets or sets the background color of the calendar title. A that represents the background color of the calendar title. - is created, this property is initially set equal to the field value. - - Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the **Enable XP visual styles** check box. To disable visual styles in C#, open Program.cs and comment out `Application.EnableVisualStyles();`. - + is created, this property is initially set equal to the field value. + + Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the **Enable XP visual styles** check box. To disable visual styles in C#, open Program.cs and comment out `Application.EnableVisualStyles();`. + ]]> The value assigned is . @@ -646,13 +646,13 @@ Gets or sets the foreground color of the calendar title. A that represents the foreground color of the calendar title. - is created, this property is initially set equal to the field value. - - Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the **Enable XP visual styles** check box. To disable visual styles in C#, open Program.cs and comment out `Application.EnableVisualStyles();`. - + is created, this property is initially set equal to the field value. + + Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the **Enable XP visual styles** check box. To disable visual styles in C#, open Program.cs and comment out `Application.EnableVisualStyles();`. + ]]> The value assigned is . @@ -692,15 +692,15 @@ Gets or sets the foreground color of the calendar trailing dates. A that represents the foreground color of the calendar trailing dates. - is created, this property is initially set equal to the field value. - - The trailing dates are the ending dates from the previous month or the beginning dates from the next month used to fill the calendar. - - Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the **Enable XP visual styles** check box. To disable visual styles in C#, open Program.cs and comment out `Application.EnableVisualStyles();`. - + is created, this property is initially set equal to the field value. + + The trailing dates are the ending dates from the previous month or the beginning dates from the next month used to fill the calendar. + + Starting with Windows Vista and depending on the theme, setting this property might not change the appearance of the calendar. For example, if Windows is set to use the Aero theme, setting this property has no effect. This is because an updated version of the calendar is rendered with an appearance that is derived at run time from the current operating system theme. If you want to use this property and enable the earlier version of the calendar, you can disable visual styles for your application. Disabling visual styles might affect the appearance and behavior of other controls in your application. To disable visual styles in Visual Basic, open the Project Designer and uncheck the **Enable XP visual styles** check box. To disable visual styles in C#, open Program.cs and comment out `Application.EnableVisualStyles();`. + ]]> The value assigned is . @@ -745,11 +745,11 @@ if the property has been set with a valid value and the displayed value is able to be updated; otherwise, . The default is . - property value is `true`. If the property value is `true`, the control displays the properly formatted property value; otherwise, the control displays the last valid date/time value assigned to the property or the current date and time () if no value has ever been assigned. - + property value is `true`. If the property value is `true`, the control displays the properly formatted property value; otherwise, the control displays the last valid date/time value assigned to the property or the current date and time () if no value has ever been assigned. + ]]> @@ -792,11 +792,11 @@ Occurs when the control is clicked. - @@ -828,21 +828,21 @@ Occurs when the drop-down calendar is dismissed and disappears. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `DateTimePicker1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `DateTimePicker1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet376"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet376"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet376"::: + ]]> @@ -876,14 +876,14 @@ Creates a new accessibility object for the control. A new for the control. - method, it will be called when the property is referenced. - + method, it will be called when the property is referenced. + > [!NOTE] -> To get or set the property, you must add a reference to the `Accessibility` assembly installed with the .NET Framework. - +> To get or set the property, you must add a reference to the `Accessibility` assembly installed with the .NET Framework. + ]]> @@ -1007,51 +1007,51 @@ Gets or sets the custom date/time format string. A string that represents the custom date/time format. The default is . - property to "MMMM dd 'at' t:mm tt". If the "at" substring is not enclosed by escape characters, the result is "June 15 aP 12:00PM" because the "t" character is read as the one-letter A.M./P.M. format string (see the format string table below). - - The format strings can be combined to format the date and time. For example, to display the date and time as 06/15/2001 12:00 PM, this property should be set to "MM'/'dd'/'yyyy hh':'mm tt". For more information, see [Custom Date and Time Format Strings](/dotnet/standard/base-types/custom-date-and-time-format-strings). - + property to "MMMM dd 'at' t:mm tt". If the "at" substring is not enclosed by escape characters, the result is "June 15 aP 12:00PM" because the "t" character is read as the one-letter A.M./P.M. format string (see the format string table below). + + The format strings can be combined to format the date and time. For example, to display the date and time as 06/15/2001 12:00 PM, this property should be set to "MM'/'dd'/'yyyy hh':'mm tt". For more information, see [Custom Date and Time Format Strings](/dotnet/standard/base-types/custom-date-and-time-format-strings). + > [!NOTE] -> The property must be set to for this property to affect the formatting of the displayed date and time. - - The following table lists all the valid format strings and their descriptions. - -|Format string|Description| -|-------------------|-----------------| -|d|The one- or two-digit day.| -|dd|The two-digit day. Single-digit day values are preceded by a 0.| -|ddd|The three-character day-of-week abbreviation.| -|dddd|The full day-of-week name.| -|h|The one- or two-digit hour in 12-hour format.| -|hh|The two-digit hour in 12-hour format. Single digit values are preceded by a 0.| -|H|The one- or two-digit hour in 24-hour format.| -|HH|The two-digit hour in 24-hour format. Single digit values are preceded by a 0.| -|m|The one- or two-digit minute.| -|mm|The two-digit minute. Single digit values are preceded by a 0.| -|M|The one- or two-digit month number.| -|MM|The two-digit month number. Single digit values are preceded by a 0.| -|MMM|The three-character month abbreviation.| -|MMMM|The full month name.| -|s|The one- or two-digit seconds.| -|ss|The two-digit seconds. Single digit values are preceded by a 0.| -|t|The one-letter A.M./P.M. abbreviation (A.M. is displayed as "A").| -|tt|The two-letter A.M./P.M. abbreviation (A.M. is displayed as "AM").| -|y|The one-digit year (2001 is displayed as "1").| -|yy|The last two digits of the year (2001 is displayed as "01").| -|yyyy|The full year (2001 is displayed as "2001").| - - - -## Examples - The following code example sets the property so that the will display the date as "June 01, 2001 - Friday". This code assumes that an instance of a control has been created on a . - +> The property must be set to for this property to affect the formatting of the displayed date and time. + + The following table lists all the valid format strings and their descriptions. + +|Format string|Description| +|-------------------|-----------------| +|d|The one- or two-digit day.| +|dd|The two-digit day. Single-digit day values are preceded by a 0.| +|ddd|The three-character day-of-week abbreviation.| +|dddd|The full day-of-week name.| +|h|The one- or two-digit hour in 12-hour format.| +|hh|The two-digit hour in 12-hour format. Single digit values are preceded by a 0.| +|H|The one- or two-digit hour in 24-hour format.| +|HH|The two-digit hour in 24-hour format. Single digit values are preceded by a 0.| +|m|The one- or two-digit minute.| +|mm|The two-digit minute. Single digit values are preceded by a 0.| +|M|The one- or two-digit month number.| +|MM|The two-digit month number. Single digit values are preceded by a 0.| +|MMM|The three-character month abbreviation.| +|MMMM|The full month name.| +|s|The one- or two-digit seconds.| +|ss|The two-digit seconds. Single digit values are preceded by a 0.| +|t|The one-letter A.M./P.M. abbreviation (A.M. is displayed as "A").| +|tt|The two-letter A.M./P.M. abbreviation (A.M. is displayed as "AM").| +|y|The one-digit year (2001 is displayed as "1").| +|yy|The last two digits of the year (2001 is displayed as "01").| +|yyyy|The full year (2001 is displayed as "2001").| + + + +## Examples + The following code example sets the property so that the will display the date as "June 01, 2001 - Friday". This code assumes that an instance of a control has been created on a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DateTimePicker.CustomFormat Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/CustomFormat/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker.CustomFormat Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker.CustomFormat Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1288,11 +1288,11 @@ if the control should redraw its surface using a secondary buffer; otherwise, . - property has no effect on the control. - + property has no effect on the control. + ]]> @@ -1333,11 +1333,11 @@ Occurs when the control is double-clicked. - @@ -1369,20 +1369,20 @@ Occurs when the drop-down calendar is shown. - event of a and using the and fields. To run this example paste the following code in a form that contains a named `DateTimePicker1`. - + event of a and using the and fields. To run this example paste the following code in a form that contains a named `DateTimePicker1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DateTimePicker/CPP/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/DropDown/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DateTimePicker/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DateTimePicker/VB/form1.vb" id="Snippet2"::: + ]]> @@ -1425,20 +1425,20 @@ Gets or sets the alignment of the drop-down calendar on the control. The alignment of the drop-down calendar on the control. The default is . - by setting the , , , and properties. To run this example, paste the following code into a form and call `InitializeDateTimePicker` from the form's constructor or event-handling method. - + by setting the , , , and properties. To run this example, paste the following code into a form and call `InitializeDateTimePicker` from the form's constructor or event-handling method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DateTimePicker/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/DropDown/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DateTimePicker/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DateTimePicker/VB/form1.vb" id="Snippet1"::: + ]]> The value assigned is not one of the values. @@ -1482,13 +1482,13 @@ Gets or sets the foreground color of the control. The foreground of the . - property has no effect on the appearance of the control. - - To set the foreground color for the drop-down calendar of the , see the property. - + property has no effect on the appearance of the control. + + To set the foreground color for the drop-down calendar of the , see the property. + ]]> @@ -1533,13 +1533,13 @@ Occurs when the value of the property changes. - property is changed either by a programmatic modification or through interaction. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - + property is changed either by a programmatic modification or through interaction. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + ]]> @@ -1585,25 +1585,25 @@ Gets or sets the format of the date and time displayed in the control. One of the values. The default is . - [!NOTE] -> The property must be set to for the property to affect the formatting of the displayed date and time. - - To display only time in a , set the to , and the property to `true`. - - - -## Examples - The following code example sets the property so that the will display the date as "June 01, 2001 - Friday". This code assumes that an instance of a control has been created on a . - +> The property must be set to for the property to affect the formatting of the displayed date and time. + + To display only time in a , set the to , and the property to `true`. + + + +## Examples + The following code example sets the property so that the will display the date as "June 01, 2001 - Friday". This code assumes that an instance of a control has been created on a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DateTimePicker.CustomFormat Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/CustomFormat/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker.CustomFormat Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker.CustomFormat Example/VB/source.vb" id="Snippet1"::: + ]]> The value assigned is not one of the values. @@ -1637,21 +1637,21 @@ Occurs when the property value has changed. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `DateTimePicker1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `DateTimePicker1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet374"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet374"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet374"::: + ]]> @@ -1689,11 +1689,11 @@ if the specified key is a regular input key; otherwise, . - @@ -1726,15 +1726,15 @@ Gets or sets the maximum date and time that can be selected in the control. The maximum date and time that can be selected in the control. The default is the earlier of `December 31st 9998 12 am` and the property of the current culture's `Calendar`. - control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control (also known as an up-down control). - + control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control (also known as an up-down control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DateTimePicker Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1784,19 +1784,19 @@ The value assigned is greater than the control. This field is read-only. - event of a and using the and fields. To run this example, paste the following code into a form that contains a named `DateTimePicker1`. - +## Examples + The following code example demonstrates handling the event of a and using the and fields. To run this example, paste the following code into a form that contains a named `DateTimePicker1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.DateTimePicker/CPP/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/DropDown/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DateTimePicker/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DateTimePicker/VB/form1.vb" id="Snippet2"::: + ]]> @@ -1830,12 +1830,12 @@ The maximum date is set to 12/31/9998 23:59:59. Gets the maximum date value allowed for the control. The maximum date value for the control. - @@ -1867,22 +1867,22 @@ The maximum date is set to December 31, 9998. Gets or sets the minimum date and time that can be selected in the control. The minimum date and time that can be selected in the control. The default is `1/1/1753 00:00:00`. - control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control (also known as an up-down control). - + control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control (also known as an up-down control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DateTimePicker Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: + ]]> The value assigned is greater than the value. -or- - + The value assigned is less than the value. @@ -1925,11 +1925,11 @@ The value assigned is less than the control. - @@ -1960,11 +1960,11 @@ The value assigned is less than the control. The minimum date value for the control. - @@ -2005,11 +2005,11 @@ The value assigned is less than the @@ -2050,11 +2050,11 @@ The value assigned is less than the @@ -2089,15 +2089,15 @@ The value assigned is less than the An that contains the event data. Raises the event. - event occurs when the drop-down calendar is dismissed and disappears. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event occurs when the drop-down calendar is dismissed and disappears. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2136,15 +2136,15 @@ The value assigned is less than the An that contains the event data. Raises the event. - event occurs when the drop-down calendar is shown. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event occurs when the drop-down calendar is shown. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2211,13 +2211,13 @@ The value assigned is less than the An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2255,15 +2255,15 @@ The value assigned is less than the An that contains the event data. Raises the event. - event occurs when the property value has changed. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event occurs when the property value has changed. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2329,13 +2329,13 @@ The value assigned is less than the An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2372,13 +2372,13 @@ The value assigned is less than the An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2421,13 +2421,13 @@ The value assigned is less than the An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2497,15 +2497,15 @@ The value assigned is less than the An that contains the event data. Raises the event. - event occurs when the value for the control changes. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event occurs when the value for the control changes. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2559,11 +2559,11 @@ The value assigned is less than the in all cases. - property has no effect on the control. - + property has no effect on the control. + ]]> @@ -2604,11 +2604,11 @@ The value assigned is less than the property changes. - @@ -2693,11 +2693,11 @@ The value assigned is less than the control. The preferred height, in pixels, of the control. - applied. - + applied. + ]]> @@ -2743,11 +2743,11 @@ The value assigned is less than the if the layout of the contents is from right to left; otherwise, . The default is . - property is used for international applications where the language is written from right to left, such as Hebrew or Arabic. - + property is used for international applications where the language is written from right to left, such as Hebrew or Arabic. + ]]> @@ -2778,21 +2778,21 @@ The value assigned is less than the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `DateTimePicker1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `DateTimePicker1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet377"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet377"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet377"::: + ]]> @@ -2867,20 +2867,20 @@ The value assigned is less than the if a check box is displayed to the left of the selected date; otherwise, . The default is . - property is set to `true`, a check box is displayed to the left of the date in the control. When the check box is selected, the date/time value can be updated. When the check box is cleared, the date/time value is unable to be changed. - - - -## Examples - The following code example creates an new instance of a control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control (also known as an up-down control). - + property is set to `true`, a check box is displayed to the left of the date in the control. When the check box is selected, the date/time value can be updated. When the check box is cleared, the date/time value is unable to be changed. + + + +## Examples + The following code example creates an new instance of a control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control (also known as an up-down control). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DateTimePicker Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2919,22 +2919,22 @@ The value assigned is less than the if a spin button control is used to adjust the date/time value; otherwise, . The default is . - property is set to `true`, a spin button control (also known as an up-down control), rather than a drop-down calendar, is used to adjust time values. The date and time can be adjusted by selecting each element individually and using the up and down buttons to change the value. - - To display only time in a , set the property to , and the property to `true`. - - - -## Examples - The following code example creates an new instance of a control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control. - + property is set to `true`, a spin button control (also known as an up-down control), rather than a drop-down calendar, is used to adjust time values. The date and time can be adjusted by selecting each element individually and using the up and down buttons to change the value. + + To display only time in a , set the property to , and the property to `true`. + + + +## Examples + The following code example creates an new instance of a control and initializes it. The control's property is set. Also, the property is set so that the control displays a , and the property is set so that the control is displayed as a spin button control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic DateTimePicker Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic DateTimePicker Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2989,13 +2989,13 @@ The value assigned is less than the property with the appropriate formatting or custom formatting applied. For example, if the property is set to 06/01/2001 12:00:00 AM while the property is set to "dddd, MMMM dd, yyyy", the property value is "Friday, June 01, 2001". - - When setting this property, the string must be convertible to an instance of the class. It is possible to define a custom format that results in a string that cannot be converted to a valid value. Because of this, the string returned from the property might cause an error if it is passed back to the property. If the string cannot be converted to a date/time value, the class throws a . - + property with the appropriate formatting or custom formatting applied. For example, if the property is set to 06/01/2001 12:00:00 AM while the property is set to "dddd, MMMM dd, yyyy", the property value is "Friday, June 01, 2001". + + When setting this property, the string must be convertible to an instance of the class. It is possible to define a custom format that results in a string that cannot be converted to a valid value. Because of this, the string returned from the property might cause an error if it is passed back to the property. If the string cannot be converted to a date/time value, the class throws a . + ]]> @@ -3112,20 +3112,20 @@ The value assigned is less than the value assign to the control. - property has not been changed in code or by the user, it is set to the current date and time (). - - - -## Examples - The following code example demonstrates how use the property to retrieve the current date value. First, the example displays the property. The example then increments the property by one day and displays the property value again. - + property has not been changed in code or by the user, it is set to the current date and time (). + + + +## Examples + The following code example demonstrates how use the property to retrieve the current date value. First, the example displays the property. The example then increments the property by one day and displays the property value again. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DateTimePicker.Value/CPP/value.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DateTimePicker/Value/value.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DateTimePicker.Value/VB/value.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DateTimePicker.Value/VB/value.vb" id="Snippet1"::: + ]]> The set value is less than or more than . @@ -3159,23 +3159,23 @@ The value assigned is less than the property changes. - or later than . - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `DateTimePicker1`. Then ensure that the event handler is associated with the event. - + or later than . + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `DateTimePicker1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet378"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet378"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet378"::: + ]]> diff --git a/xml/System.Windows.Forms/DragDropEffects.xml b/xml/System.Windows.Forms/DragDropEffects.xml index af730de7de0..a67cdb7c330 100644 --- a/xml/System.Windows.Forms/DragDropEffects.xml +++ b/xml/System.Windows.Forms/DragDropEffects.xml @@ -29,33 +29,33 @@ Specifies the possible effects of a drag-and-drop operation. - , , and classes. - - You can use `DragDropEffects` to display different mouse pointers for drag-and-drop operations. For example, you can display a plus symbol for a `Copy` drag-and-drop operation, an arrow symbol for a `Move` drag-and-drop operation, or a red circle with a line through it symbol for a `None` drag-and-drop operation. - - If you want to drop data at a position in the target that is not currently visible, you could scroll the target while dragging. If a target does not support scrolling, you must make sure that the drop position is visible in the target before you begin the drag-and-drop operation. The following are some scenarios when you might want to scroll a target: - -- You're dragging text into a document, and you want to drop the text at a position not visible in the document window. + , , and classes. + + You can use `DragDropEffects` to display different mouse pointers for drag-and-drop operations. For example, you can display a plus symbol for a `Copy` drag-and-drop operation, an arrow symbol for a `Move` drag-and-drop operation, or a red circle with a line through it symbol for a `None` drag-and-drop operation. + + If you want to drop data at a position in the target that is not currently visible, you could scroll the target while dragging. If a target does not support scrolling, you must make sure that the drop position is visible in the target before you begin the drag-and-drop operation. The following are some scenarios when you might want to scroll a target: + +- You're dragging text into a document, and you want to drop the text at a position not visible in the document window. + +- You're dragging a file into a file tree, and you want to drop the file on a node not visible in the file tree. + + + +## Examples The following example demonstrates using the `DragDropEffects` enumeration when the user moves the mouse over the drop target during a drag-and-drop operation. This example is part of a larger example provided for the method. - + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Control.DoDragDrop/CPP/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Control/DoDragDrop/form11.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Control.DoDragDrop/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Control.DoDragDrop/VB/form1.vb" id="Snippet4"::: + ]]> - Drag-and-Drop Operations and Clipboard Support + Drag-and-Drop Operations and Clipboard Support diff --git a/xml/System.Windows.Forms/FileDialog.xml b/xml/System.Windows.Forms/FileDialog.xml index 4ff88e1edc6..6efdaedd798 100644 --- a/xml/System.Windows.Forms/FileDialog.xml +++ b/xml/System.Windows.Forms/FileDialog.xml @@ -38,45 +38,45 @@ Displays a dialog box from which the user can select a file. - is an abstract class that contains common behavior for the and classes. It is not intended to be used directly but contains common behavior for those two classes. You cannot create an instance of . Although the class is declared public, you cannot inherit from it, as it contains internal abstract methods. To create a dialog box to select or save a file, use or . - - is a modal dialog box; therefore, when shown, it blocks the rest of the application until the user has chosen a file. When a dialog box is displayed modally, no input (keyboard or mouse click) can occur except to objects on the dialog box. The program must hide or close the dialog box (usually in response to some user action) before input to the calling program can occur. - + is an abstract class that contains common behavior for the and classes. It is not intended to be used directly but contains common behavior for those two classes. You cannot create an instance of . Although the class is declared public, you cannot inherit from it, as it contains internal abstract methods. To create a dialog box to select or save a file, use or . + + is a modal dialog box; therefore, when shown, it blocks the rest of the application until the user has chosen a file. When a dialog box is displayed modally, no input (keyboard or mouse click) can occur except to objects on the dialog box. The program must hide or close the dialog box (usually in response to some user action) before input to the calling program can occur. + > [!CAUTION] -> When you use classes derived from , such as and , avoid using string literals containing absolute paths. Instead, dynamically obtain the path using one or more of the techniques described in the following table. - - If you want to enable users to select a folder instead of a file, use the . - - Depending upon the type of application, how data associated with the application is stored, and the reason for accessing the file system, there are many possible ways in which you can create a directory path. The following table shows the techniques for creating paths dynamically. - -|Path or program category|Class and members to use| -|------------------------------|------------------------------| -|Standard Windows paths, such as Program Files, MyDocuments, the Desktop and so on|The class is the most complete source for these, either through its static methods, such as , or through the method, using one of the enumerated values.| -|Paths related to the current application|The class has static members to obtain certain paths, such as , , , and .

The method of the returns the path of the temporary folder.

The method of the class returns the application's current executing directory.

The property of the class represents the specified drive's root directory.| -|Paths stored as application settings|Access the corresponding applications settings property of the wrapper class derived from . For more information, see [Application Settings for Windows Forms](/dotnet/framework/winforms/advanced/application-settings-for-windows-forms).| -|Registry storage|Some applications store directory information in the registry. The class has the and properties that resolve to a value.| -|ClickOnce applications|For ClickOnce applications, use class members such as , which will return a pointer to the ClickOnce data directory. For more information, see [Accessing Local and Remote Data in ClickOnce Applications](/visualstudio/deployment/accessing-local-and-remote-data-in-clickonce-applications).| -|International applications|For international applications, retrieve the relative path portion from a string resource in your application by using the class. For more information about globalization and localization, see the topic [Globalization and Localization](/dotnet/standard/globalization-localization/).| - - Notice that a full path may be built up using one or more of the described techniques. For example, the method might be used to obtain the path to the MyDocuments folder, then an application setting may be used to add a relative subdirectory portion. - - The class contains static members to assist in manipulating absolute and relative path strings, whereas the and classes have static members that actually manipulate files and directories, respectively. - +> When you use classes derived from , such as and , avoid using string literals containing absolute paths. Instead, dynamically obtain the path using one or more of the techniques described in the following table. + + If you want to enable users to select a folder instead of a file, use the . + + Depending upon the type of application, how data associated with the application is stored, and the reason for accessing the file system, there are many possible ways in which you can create a directory path. The following table shows the techniques for creating paths dynamically. + +|Path or program category|Class and members to use| +|------------------------------|------------------------------| +|Standard Windows paths, such as Program Files, MyDocuments, the Desktop and so on|The class is the most complete source for these, either through its static methods, such as , or through the method, using one of the enumerated values.| +|Paths related to the current application|The class has static members to obtain certain paths, such as , , , and .

The method of the returns the path of the temporary folder.

The method of the class returns the application's current executing directory.

The property of the class represents the specified drive's root directory.| +|Paths stored as application settings|Access the corresponding applications settings property of the wrapper class derived from . For more information, see [Application Settings for Windows Forms](/dotnet/desktop/winforms/advanced/application-settings-for-windows-forms).| +|Registry storage|Some applications store directory information in the registry. The class has the and properties that resolve to a value.| +|ClickOnce applications|For ClickOnce applications, use class members such as , which will return a pointer to the ClickOnce data directory. For more information, see [Accessing Local and Remote Data in ClickOnce Applications](/visualstudio/deployment/accessing-local-and-remote-data-in-clickonce-applications).| +|International applications|For international applications, retrieve the relative path portion from a string resource in your application by using the class. For more information about globalization and localization, see the topic [Globalization and Localization](/dotnet/standard/globalization-localization/).| + + Notice that a full path may be built up using one or more of the described techniques. For example, the method might be used to obtain the path to the MyDocuments folder, then an application setting may be used to add a relative subdirectory portion. + + The class contains static members to assist in manipulating absolute and relative path strings, whereas the and classes have static members that actually manipulate files and directories, respectively. + > [!IMPORTANT] -> If the user of your application changes the folder in the , then the current working directory for your application is set to the location specified in the . To prevent this, set the property to `true`. - - - -## Examples - The following code example uses the implementation of and illustrates creating, setting of properties, and showing the dialog box. The example uses the method to display the dialog box and return the . The example requires a form with a placed on it and the namespace added to it. - +> If the user of your application changes the folder in the , then the current working directory for your application is set to the location specified in the . To prevent this, set the property to `true`. + + + +## Examples + The following code example uses the implementation of and illustrates creating, setting of properties, and showing the dialog box. The example uses the method to display the dialog box and return the . The example requires a form with a placed on it and the namespace added to it. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic OpenFileDialog Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic OpenFileDialog Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic OpenFileDialog Example/VB/source.vb" id="Snippet1"::: + ]]>
@@ -130,15 +130,15 @@ if the dialog box adds an extension to a file name if the user omits the extension; otherwise, . The default value is . - property. - - If the property is `true`, the dialog box adds the first extension from the current file filter that matches an existing file. If no files match the current file filter, the dialog box adds the extension specified in the property. - - If the property is `false`, the dialog box adds the first valid file name extension from the current file filter. If the current file filter contains no valid file name extensions, the dialog box adds the extension specified in the property. - + property. + + If the property is `true`, the dialog box adds the first extension from the current file filter that matches an existing file. If no files match the current file filter, the dialog box adds the extension specified in the property. + + If the property is `false`, the dialog box adds the first valid file name extension from the current file filter. If the current file filter contains no valid file name extensions, the dialog box adds the extension specified in the property. + ]]> @@ -216,13 +216,13 @@ if this instance should automatically upgrade appearance and behavior when running on Windows Vista; otherwise, . The default is . - class will have a Windows XP-style appearance and behavior on Windows Vista. - - On Windows XP, this property does not have any effect. - + class will have a Windows XP-style appearance and behavior on Windows Vista. + + On Windows XP, this property does not have any effect. + ]]>
@@ -265,11 +265,11 @@ if the dialog box displays a warning if the user specifies a file name that does not exist; otherwise, . The default value is . - and `false` for an inheriting . - + and `false` for an inheriting . + ]]> @@ -409,19 +409,19 @@ Gets the custom places collection for this instance. The custom places collection for this instance. - collection. To run this example, paste the following code into a Windows Form and call `InitializeDialogAndButton` from the form's constructor or event-handling method. - + collection. To run this example, paste the following code into a Windows Form and call `InitializeDialogAndButton` from the form's constructor or event-handling method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/CustomPlaces/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialogCommonPlaces/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialogCommonPlaces/VB/Form1.vb" id="Snippet1"::: + ]]> @@ -459,22 +459,22 @@ Gets or sets the default file name extension. The default file name extension. The returned string does not include the period. The default value is an empty string (""). - appends an extension to the file name. The extension that is used is determined by the and properties. If a filter is selected in the and the filter specifies an extension, then that extension is used. If the filter selected uses a wildcard in place of the extension, then the extension specified in the property is used. - - - -## Examples - The following code example demonstrates using the and methods with streams. It also demonstrates using the , , , and members. - - This is a complete example that is ready to run when you copy it to your project. - + appends an extension to the file name. The extension that is used is determined by the and properties. If a filter is selected in the and the filter specifies an extension, then that extension is used. If the filter selected uses a wildcard in place of the extension, then the extension specified in the property is used. + + + +## Examples + The following code example demonstrates using the and methods with streams. It also demonstrates using the , , , and members. + + This is a complete example that is ready to run when you copy it to your project. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.RichTextBoxSaveFile/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/DefaultExt/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RichTextBoxSaveFile/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RichTextBoxSaveFile/VB/form1.vb" id="Snippet1"::: + ]]> @@ -576,26 +576,26 @@ Gets or sets a string containing the file name selected in the file dialog box. The file name selected in the file dialog box. The default value is an empty string (""). - class, this property represents the file being saved; when used from the class, it represents the file being opened. - - This property can only be the name of one selected file. If you want to return an array containing the names of all selected files in a multiple-selection dialog box, use . - - - -## Examples - The following code example demonstrates using the and methods with streams. It also demonstrates using the , , , and members. - - This is a complete example that is ready to run when you copy it to your project. - + class, this property represents the file being saved; when used from the class, it represents the file being opened. + + This property can only be the name of one selected file. If you want to return an array containing the names of all selected files in a multiple-selection dialog box, use . + + + +## Examples + The following code example demonstrates using the and methods with streams. It also demonstrates using the , , , and members. + + This is a complete example that is ready to run when you copy it to your project. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.RichTextBoxSaveFile/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/DefaultExt/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RichTextBoxSaveFile/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RichTextBoxSaveFile/VB/form1.vb" id="Snippet1"::: + ]]> @@ -644,19 +644,19 @@ Gets the file names of all selected files in the dialog box. An array of type , containing the file names of all selected files in the dialog box. - controls on a Form. It demonstrates initializing an , setting the and properties, and allowing the user to select multiple files by setting the property to true. This code example assumes that your form already has an control named `openFileDialog1`, a named `SelectFileButton`, and a named `flowLayoutPanel1`. - + controls on a Form. It demonstrates initializing an , setting the and properties, and allowing the user to select multiple files by setting the property to true. This code example assumes that your form already has an control named `openFileDialog1`, a named `SelectFileButton`, and a named `flowLayoutPanel1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/FileNames/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.OpenFileDialog.MultiSelect/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.OpenFileDialog.MultiSelect/VB/Form1.vb" id="Snippet1"::: + ]]> @@ -688,20 +688,20 @@ Occurs when the user clicks on the **Open** or **Save** button on a file dialog box. - property, handling the event and using the method. When the example runs, a user can select graphics files from an object. The selected files are displayed in the form. The method forces a repaint of the form for each graphics file opened. To run this example paste the following code in a form containing a named `PictureBox1`, an named `OpenFileDialog1`, and a named `fileButton`. Call the `InitializePictureBox` and `InitializeOpenFileDialog` methods from the form's constructor or `Load` method. When the example is running, display the dialog box by clicking the button. - + property, handling the event and using the method. When the example runs, a user can select graphics files from an object. The selected files are displayed in the form. The method forces a repaint of the form for each graphics file opened. To run this example paste the following code in a form containing a named `PictureBox1`, an named `OpenFileDialog1`, and a named `fileButton`. Call the `InitializePictureBox` and `InitializeOpenFileDialog` methods from the form's constructor or `Load` method. When the example is running, display the dialog box by clicking the button. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FileDialog/CPP/filedialogform.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Application/DoEvents/filedialogform.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialog/VB/filedialogform.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialog/VB/filedialogform.vb" id="Snippet1"::: + ]]> @@ -744,30 +744,30 @@ Gets or sets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box. The file filtering options available in the dialog box. - property to set which filtering option is shown first to the user. - - - -## Examples - The following code example uses the implementation of and illustrates creating, setting of properties, and showing the dialog box. The example uses the and properties to provide a list of filters for the user. The example requires a form with a placed on it and the namespace added to it. - + property to set which filtering option is shown first to the user. + + + +## Examples + The following code example uses the implementation of and illustrates creating, setting of properties, and showing the dialog box. The example uses the and properties to provide a list of filters for the user. The example requires a form with a placed on it and the namespace added to it. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic OpenFileDialog Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic OpenFileDialog Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic OpenFileDialog Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -817,23 +817,23 @@ Gets or sets the index of the filter currently selected in the file dialog box. A value containing the index of the filter currently selected in the file dialog box. The default value is 1. - property to set which filtering option is shown first to the user. You can also use the value of after showing the file dialog to perform special file operations depending upon the filter chosen. - + property to set which filtering option is shown first to the user. You can also use the value of after showing the file dialog to perform special file operations depending upon the filter chosen. + > [!NOTE] -> The index value of the first filter entry is 1. - - - -## Examples - The following code example uses the implementation of and illustrates creating, setting of properties, and showing the dialog box. The example uses the and properties to provide a list of filters for the user. The example requires a form with a placed on it and the namespace added to it. - +> The index value of the first filter entry is 1. + + + +## Examples + The following code example uses the implementation of and illustrates creating, setting of properties, and showing the dialog box. The example uses the and properties to provide a list of filters for the user. The example requires a form with a placed on it and the namespace added to it. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic OpenFileDialog Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic OpenFileDialog Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic OpenFileDialog Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -877,13 +877,13 @@ Defines the common dialog box hook procedure that is overridden to add specific functionality to the file dialog box. Returns zero if the default dialog box procedure processes the message; returns a nonzero value if the default dialog box procedure ignores the message. - @@ -928,32 +928,32 @@ Gets or sets the initial directory displayed by the file dialog box. The initial directory displayed by the file dialog box. The default is an empty string (""). - property is typically set using one of the following sources: - -- A path that was previously used in the program, perhaps retained from the last directory or file operation. - -- A path read from a persistent source, such as an application setting, a or a string resource in the application. - -- Standard Windows system and user paths, such as Program Files, MyDocuments, MyMusic, and so on (which you can obtain using the method) - -- A path related to the current application, such as its startup directory (which you can obtain using properties on the object). - - For more information about creating dynamic paths, see the class overview. - - On Windows Vista, if is set to a full file name instead of just a directory path, the initial directory will default either to the application path, or to the directory from which the user last selected a file. - - - -## Examples - The following code example uses the implementation of and illustrates creating, setting of properties, and showing the dialog box. The example uses the property to set what the initial directory is when the dialog box is displayed to the user. The example requires a form with a placed on it and the namespace added to it. - + property is typically set using one of the following sources: + +- A path that was previously used in the program, perhaps retained from the last directory or file operation. + +- A path read from a persistent source, such as an application setting, a or a string resource in the application. + +- Standard Windows system and user paths, such as Program Files, MyDocuments, MyMusic, and so on (which you can obtain using the method) + +- A path related to the current application, such as its startup directory (which you can obtain using properties on the object). + + For more information about creating dynamic paths, see the class overview. + + On Windows Vista, if is set to a full file name instead of just a directory path, the initial directory will default either to the application path, or to the directory from which the user last selected a file. + + + +## Examples + The following code example uses the implementation of and illustrates creating, setting of properties, and showing the dialog box. The example uses the property to set what the initial directory is when the dialog box is displayed to the user. The example requires a form with a placed on it and the namespace added to it. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic OpenFileDialog Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic OpenFileDialog Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic OpenFileDialog Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1082,11 +1082,11 @@ Gets values to initialize the . A bitwise combination of internal values that initializes the . - property corresponds to the flags used to initialize a file dialog box using Win32. Use the properties of the class to get and set the options. - + property corresponds to the flags used to initialize a file dialog box using Win32. Use the properties of the class to get and set the options. + ]]> @@ -1161,15 +1161,15 @@ if the dialog box restores the current directory to the previously selected directory if the user changed the directory while searching for files; otherwise, . The default value is . - implementation of and illustrates creating, setting of properties, and showing the dialog box. The example uses the property to ensure that the previously selected directory is restored when the dialog box is closed. The example requires a form with a placed on it and the namespace added to it. - + implementation of and illustrates creating, setting of properties, and showing the dialog box. The example uses the property to ensure that the previously selected directory is restored when the dialog box is closed. The example requires a form with a placed on it and the namespace added to it. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic OpenFileDialog Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic OpenFileDialog Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic OpenFileDialog Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1207,13 +1207,13 @@ if the file could be opened; otherwise, . - , and is invoked when the user of a file dialog invokes . - - In the derived classes and an invalid file name can be raised. - + , and is invoked when the user of a file dialog invokes . + + In the derived classes and an invalid file name can be raised. + ]]> @@ -1260,11 +1260,11 @@ if the dialog box includes a help button; otherwise, . The default value is . - event is raised when the user clicks the **Help** button. - + event is raised when the user clicks the **Help** button. + ]]> @@ -1370,21 +1370,21 @@ if the dialog box supports multiple file name extensions; otherwise, . The default is . - property to a multi-dotted extension. - - If is `false`, and you assign a multi-dotted extension to , derived controls such as will only use the last extension in the string. For example, ".manifest" will be used instead of ".exe.manifest". - - - -## Examples - The following code example saves files with the extension ".data.txt". This code example requires that your application host a named `saveFileDialog1` and a named `button1`. - + property to a multi-dotted extension. + + If is `false`, and you assign a multi-dotted extension to , derived controls such as will only use the last extension in the string. For example, ".manifest" will be used instead of ".exe.manifest". + + + +## Examples + The following code example saves files with the extension ".data.txt". This code example requires that your application host a named `saveFileDialog1` and a named `button1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/SupportMultiDottedExtensions/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SupportMultiDottedExtensions/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SupportMultiDottedExtensions/VB/Form1.vb" id="Snippet1"::: + ]]> @@ -1427,20 +1427,20 @@ Gets or sets the file dialog box title. The file dialog box title. The default value is an empty string (""). - , setting the and properties, and allowing the user to select multiple files by setting the property to true. To run this example, paste the following code in a form containing an named `OpenFileDialog1` and a named `fileButton`. Call the `InitializeOpenFileDialog` method in the form's constructor or `Load` method. The example also requires that the `Click` event of the `Button` control is connected to the event handler defined in the example. - + , setting the and properties, and allowing the user to select multiple files by setting the property to true. To run this example, paste the following code in a form containing an named `OpenFileDialog1` and a named `fileButton`. Call the `InitializeOpenFileDialog` method in the form's constructor or `Load` method. The example also requires that the `Click` event of the `Button` control is connected to the event handler defined in the example. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FileDialog/CPP/filedialogform.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Application/DoEvents/filedialogform.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialog/VB/filedialogform.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialog/VB/filedialogform.vb" id="Snippet6"::: + ]]> @@ -1509,11 +1509,11 @@ if the dialog box accepts only valid Win32 file names; otherwise, . The default value is . - diff --git a/xml/System.Windows.Forms/FileDialogCustomPlace.xml b/xml/System.Windows.Forms/FileDialogCustomPlace.xml index 4f2c0c966c4..9f24373fb7f 100644 --- a/xml/System.Windows.Forms/FileDialogCustomPlace.xml +++ b/xml/System.Windows.Forms/FileDialogCustomPlace.xml @@ -50,8 +50,8 @@ ]]> - How To: Add a Custom Place to a File Dialog Box - Known Folder GUIDs for File Dialog Custom Places + How To: Add a Custom Place to a File Dialog Box + Known Folder GUIDs for File Dialog Custom Places @@ -96,7 +96,7 @@ Gets or sets the Windows Vista Known Folder GUID for the custom place. - A that indicates the Windows Vista Known Folder for the custom place. If the custom place was specified with a folder path, then an empty GUID is returned. For a list of the available Windows Vista Known Folders, see Known Folder GUIDs for File Dialog Custom Places or the KnownFolders.h file in the Windows SDK. + A that indicates the Windows Vista Known Folder for the custom place. If the custom place was specified with a folder path, then an empty GUID is returned. For a list of the available Windows Vista Known Folders, see Known Folder GUIDs for File Dialog Custom Places or the KnownFolders.h file in the Windows SDK. To be added. diff --git a/xml/System.Windows.Forms/FileDialogCustomPlacesCollection.xml b/xml/System.Windows.Forms/FileDialogCustomPlacesCollection.xml index c389ed728b8..b8366b1d4fe 100644 --- a/xml/System.Windows.Forms/FileDialogCustomPlacesCollection.xml +++ b/xml/System.Windows.Forms/FileDialogCustomPlacesCollection.xml @@ -43,19 +43,19 @@ Represents a collection of Windows Vista custom places for the class. - . To run this example, paste the following code into a Windows Form and call `InitializeDialogAndButton` from the form's constructor or event-handling method. - + . To run this example, paste the following code into a Windows Form and call `InitializeDialogAndButton` from the form's constructor or event-handling method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/CustomPlaces/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialogCommonPlaces/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialogCommonPlaces/VB/Form1.vb" id="Snippet1"::: + ]]> @@ -137,25 +137,25 @@ A that represents a Windows Vista Known Folder. Adds a custom place to the collection. - and is not a system or application wide change. - - The folders are positioned in the custom places in the order that they are added to the . The last one added will be at the top. If you add a custom place to the collection that does not exist on the computer running the application, the custom place will not be shown. GUIDs are case-insensitive. For a list of the available Windows Vista Known Folders, see [Known Folder GUIDs for File Dialog Custom Places](/dotnet/framework/winforms/controls/known-folder-guids-for-file-dialog-custom-places) or the KnownFolders.h file in the Windows SDK. - - - -## Examples - The following code example demonstrates how to use the method. To run this example, paste the following code into a Windows Form and call `InitializeDialogAndButton` from the form's constructor or event-handling method. - + and is not a system or application wide change. + + The folders are positioned in the custom places in the order that they are added to the . The last one added will be at the top. If you add a custom place to the collection that does not exist on the computer running the application, the custom place will not be shown. GUIDs are case-insensitive. For a list of the available Windows Vista Known Folders, see [Known Folder GUIDs for File Dialog Custom Places](/dotnet/desktop/winforms/controls/known-folder-guids-for-file-dialog-custom-places) or the KnownFolders.h file in the Windows SDK. + + + +## Examples + The following code example demonstrates how to use the method. To run this example, paste the following code into a Windows Form and call `InitializeDialogAndButton` from the form's constructor or event-handling method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/CustomPlaces/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialogCommonPlaces/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialogCommonPlaces/VB/Form1.vb" id="Snippet1"::: + ]]> - Known Folder Guids for File Dialog Custom Places + Known Folder Guids for File Dialog Custom Places
@@ -191,21 +191,21 @@ A folder path to the custom place. Adds a custom place to the collection. - and is not a system or application wide change. - - The folders are positioned in the custom places in the order that they are added to the . The last one added will be at the top. - - - -## Examples - The following code example demonstrates how to use the method. To run this example, paste the following code into a Windows Form and call `InitializeDialogAndButton` from the form's constructor or event-handling method. - + and is not a system or application wide change. + + The folders are positioned in the custom places in the order that they are added to the . The last one added will be at the top. + + + +## Examples + The following code example demonstrates how to use the method. To run this example, paste the following code into a Windows Form and call `InitializeDialogAndButton` from the form's constructor or event-handling method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FileDialog/CustomPlaces/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialogCommonPlaces/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FileDialogCommonPlaces/VB/Form1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/FlowLayoutPanel.xml b/xml/System.Windows.Forms/FlowLayoutPanel.xml index 0870c465147..5c78308c9a7 100644 --- a/xml/System.Windows.Forms/FlowLayoutPanel.xml +++ b/xml/System.Windows.Forms/FlowLayoutPanel.xml @@ -61,31 +61,31 @@ Represents a panel that dynamically lays out its contents horizontally or vertically. - control arranges its contents in a horizontal or vertical flow direction. Its contents can be wrapped from one row to the next, or from one column to the next. Alternatively, its contents can be clipped instead of wrapped. - - You can specify the flow direction by setting the value of the property. The control correctly reverses its flow direction in right-to-left (RTL) layouts. You can also specify whether the contents of the control are wrapped or clipped by setting the value of the property. - - Any Windows Forms control, including other instances of , can be a child of the control. With this capability, you can construct sophisticated layouts that adapt to your form's dimensions at run time. - - Docking and anchoring behaviors of child controls differ from the behaviors in other container controls. Both docking and anchoring are relative to the largest control in the flow direction. For more information, see [How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control](/dotnet/framework/winforms/controls/how-to-anchor-and-dock-child-controls-in-a-flowlayoutpanel-control). - - - -## Examples - The following example shows how to set the and properties on a control. Paste the code into the Form1 source file. If your project contains a file named Form1.Designer.cs or Form1.Designer.vb, remove that file from the project. You may need to click the **Show All Files** button in Solution Explorer to see the designer file. - + control arranges its contents in a horizontal or vertical flow direction. Its contents can be wrapped from one row to the next, or from one column to the next. Alternatively, its contents can be clipped instead of wrapped. + + You can specify the flow direction by setting the value of the property. The control correctly reverses its flow direction in right-to-left (RTL) layouts. You can also specify whether the contents of the control are wrapped or clipped by setting the value of the property. + + Any Windows Forms control, including other instances of , can be a child of the control. With this capability, you can construct sophisticated layouts that adapt to your form's dimensions at run time. + + Docking and anchoring behaviors of child controls differ from the behaviors in other container controls. Both docking and anchoring are relative to the largest control in the flow direction. For more information, see [How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control](/dotnet/desktop/winforms/controls/how-to-anchor-and-dock-child-controls-in-a-flowlayoutpanel-control). + + + +## Examples + The following example shows how to set the and properties on a control. Paste the code into the Form1 source file. If your project contains a file named Form1.Designer.cs or Form1.Designer.vb, remove that file from the project. You may need to click the **Show All Files** button in Solution Explorer to see the designer file. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel/cpp/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FlowDirection/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel/VB/form1.vb" id="Snippet1"::: + ]]> - How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control + How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control @@ -110,11 +110,11 @@ Initializes a new instance of the class. - and properties to their default values: and `true`, respectively. - + and properties to their default values: and `true`, respectively. + ]]> @@ -157,20 +157,20 @@ Gets or sets a value indicating the flow direction of the control. One of the values indicating the direction of consecutive placement of controls in the panel. The default is . - property is the default property for the class. - - - -## Examples - The following code example sets the value of depending on the selected . - + property is the default property for the class. + + + +## Examples + The following code example sets the value of depending on the selected . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FlowDirection/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel/VB/form1.vb" id="Snippet4"::: + ]]> @@ -326,11 +326,11 @@ if this object can provide extender properties to the specified object; otherwise, . - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -372,22 +372,22 @@ if the contents should be wrapped; otherwise, . The default is . - property depending on the value of a control. - + property depending on the value of a control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel/cpp/form1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/FlowDirection/Overview/form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel/VB/form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.FlowLayoutPanel/VB/form1.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Windows.Forms/Form.xml b/xml/System.Windows.Forms/Form.xml index d39dd61cae9..fc90f7087c9 100644 --- a/xml/System.Windows.Forms/Form.xml +++ b/xml/System.Windows.Forms/Form.xml @@ -100,7 +100,7 @@ ]]> - Multiple-Document Interface (MDI) Applications + Multiple-Document Interface (MDI) Applications @@ -722,7 +722,7 @@ ## Remarks > [!IMPORTANT] -> The is obsolete and has been retained for backward compatibility. The non-obsolete alternative is . For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/framework/winforms/automatic-scaling-in-windows-forms). +> The is obsolete and has been retained for backward compatibility. The non-obsolete alternative is . For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms). You can use this property to allow your form and its controls to automatically adjust based on changes in the font. This can be useful in applications where the font might increase or decrease based on the language specified for use by Windows. @@ -794,7 +794,7 @@ ## Remarks > [!IMPORTANT] -> This member has been retained for backward compatibility. For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/framework/winforms/automatic-scaling-in-windows-forms). +> This member has been retained for backward compatibility. For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms). The value of the property is used at form-display time to compute the scaling factor for the form. The autoscaling base size is used by the form as a baseline for comparison to the system's font size to determine how much to scale the form when autoscaling is used. If you want to determine the size a form will auto scale to based on a specific font, use the method. @@ -1330,7 +1330,7 @@ The size of the client area of the form is the size of the form excluding the borders and the title bar. The client area of a form is the area within a form where controls can be placed. You can use this property to get the proper dimensions when performing graphics operations or when sizing and positioning controls on the form. To get the size of the entire form, use the property or use the individual properties and . > [!NOTE] -> You cannot currently bind to this property using application settings. For more information on application settings, see [Application Settings Overview](/dotnet/framework/winforms/advanced/application-settings-overview). +> You cannot currently bind to this property using application settings. For more information on application settings, see [Application Settings Overview](/dotnet/desktop/winforms/advanced/application-settings-overview). @@ -2227,7 +2227,7 @@ - Note: Reading this property is only for tracking purposes. If the Form's border color is changed through other external means (Win32 calls), + Note: Reading this property is only for tracking purposes. If the Form's border color is changed through other external means (Win32 calls), reading this property will not reflect those changes, as the Win32 API does not provide a mechanism to retrieve the current title bar color. @@ -2362,11 +2362,11 @@ - Reading this property is only for tracking purposes. If the window's title bar color is changed through other external means (Win32 calls), + Reading this property is only for tracking purposes. If the window's title bar color is changed through other external means (Win32 calls), reading this property will not reflect those changes, as the Win32 API does not provide a mechanism to retrieve the current title bar color. - The property only reflects the value that was previously set using this property. The + The property only reflects the value that was previously set using this property. The event is raised accordingly when the value is changed, which allows the property to be participating in binding scenarios. @@ -2437,11 +2437,11 @@ - Reading this property is only for tracking purposes. If the Form's title bar's text color (window caption text) is changed through other external means (Win32 calls), + Reading this property is only for tracking purposes. If the Form's title bar's text color (window caption text) is changed through other external means (Win32 calls), reading this property will not reflect those changes, as the Win32 API does not provide a mechanism to retrieve the current title bar color. - The property only reflects the value that was previously set using this property. The + The property only reflects the value that was previously set using this property. The event is raised accordingly when the value is changed, which allows the property to be participating in binding scenarios. @@ -2635,7 +2635,7 @@ To be added. - Reading this property is only for tracking purposes. If the Form's corner preference is changed through other external means (Win32 calls), + Reading this property is only for tracking purposes. If the Form's corner preference is changed through other external means (Win32 calls), reading this property will not reflect those changes, as the Win32 API does not provide a mechanism to retrieve the current title bar color. @@ -2726,7 +2726,7 @@ ## Remarks > [!IMPORTANT] -> The method is obsolete starting with the .NET Framework 2.0. This member has been retained for backward compatibility. For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/framework/winforms/automatic-scaling-in-windows-forms). +> The method is obsolete starting with the .NET Framework 2.0. This member has been retained for backward compatibility. For more information about automatic scaling, see [Automatic Scaling in Windows Forms](/dotnet/desktop/winforms/automatic-scaling-in-windows-forms). You can use this method to determine the size a form would autoscale to for a specific font before applying the font to the form. If you want to determine the size a form is autoscaled to based on the font currently assigned to the form, use the property. @@ -6717,7 +6717,7 @@ This example assumes that the `CreateMyOpaqueForm` method is called from another ## Remarks The method overrides the base implementation to provide additional handling of main menu command keys and MDI accelerators. - For information about keyboard input, see [Keyboard Input in a Windows Forms Application](/dotnet/framework/winforms/keyboard-input-in-a-windows-forms-application). + For information about keyboard input, see [Keyboard Input in a Windows Forms Application](/dotnet/desktop/winforms/keyboard-input-in-a-windows-forms-application). ]]> @@ -7763,7 +7763,7 @@ This example assumes that the `CreateMyOpaqueForm` method is called from another If the owner window is provided, it ensures that the owner is topmost and sets the owner for the form. - This method also performs several checks to prevent invalid operations, such as trying to display a disabled form, attempting to display the form when + This method also performs several checks to prevent invalid operations, such as trying to display a disabled form, attempting to display the form when it is not a top-level window, or setting the form as its own owner. @@ -8197,7 +8197,7 @@ This example assumes that the `CreateMyOpaqueForm` method is called from another event is only raised the first time a form is displayed; subsequently minimizing, maximizing, restoring, hiding, showing, or invalidating and repainting will not raise this event. For more information about the order of events of a form, see [Order of Events in Windows Forms](/dotnet/framework/winforms/order-of-events-in-windows-forms). + The event is only raised the first time a form is displayed; subsequently minimizing, maximizing, restoring, hiding, showing, or invalidating and repainting will not raise this event. For more information about the order of events of a form, see [Order of Events in Windows Forms](/dotnet/desktop/winforms/order-of-events-in-windows-forms). For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). diff --git a/xml/System.Windows.Forms/GroupBoxRenderer.xml b/xml/System.Windows.Forms/GroupBoxRenderer.xml index d870d20344d..0d71e1249c9 100644 --- a/xml/System.Windows.Forms/GroupBoxRenderer.xml +++ b/xml/System.Windows.Forms/GroupBoxRenderer.xml @@ -33,24 +33,24 @@ Provides methods used to render a group box control with or without visual styles. This class cannot be inherited. - class provides a set of `static` methods that can be used to render a group box control. Rendering a control refers to drawing the user interface of a control. To draw a group box, use one of the methods. These methods provide a variety of text drawing options. - - If visual styles are enabled in the operating system and visual styles are applied to the current application, will draw the group box with the current visual style. Otherwise, will draw the group box with the classic Windows style. This is useful if you are drawing a custom control that should automatically match the current visual style setting of the operating system. - - This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - - - -## Examples - The following code example demonstrates how to create a custom control that uses the method to draw a group box with a double border if visual styles are enabled. - + class provides a set of `static` methods that can be used to render a group box control. Rendering a control refers to drawing the user interface of a control. To draw a group box, use one of the methods. These methods provide a variety of text drawing options. + + If visual styles are enabled in the operating system and visual styles are applied to the current application, will draw the group box with the current visual style. Otherwise, will draw the group box with the classic Windows style. This is useful if you are drawing a custom control that should automatically match the current visual style setting of the operating system. + + This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + + + +## Examples + The following code example demonstrates how to create a custom control that uses the method to draw a group box with a double border if visual styles are enabled. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/cpp/form1.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/GroupBoxRenderer/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/VB/form1.vb" id="Snippet0"::: + ]]> @@ -101,20 +101,20 @@ One of the values that specifies the visual state of the group box. Draws a group box control in the specified state and bounds. - method in a custom control's method to draw a group box with a double border. This code example is part of a larger example provided for the class. - + method in a custom control's method to draw a group box with a double border. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/GroupBoxRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/VB/form1.vb" id="Snippet2"::: + ]]> @@ -170,20 +170,20 @@ One of the values that specifies the visual state of the group box. Draws a group box control in the specified state and bounds, with the specified text and font. - method in a custom control's method to draw a group box with a double border. This code example is part of a larger example provided for the class. - + method in a custom control's method to draw a group box with a double border. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/GroupBoxRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/VB/form1.vb" id="Snippet2"::: + ]]> @@ -241,11 +241,11 @@ One of the values that specifies the visual state of the group box. Draws a group box control in the specified state and bounds, with the specified text, font, and color. - @@ -297,11 +297,11 @@ One of the values that specifies the visual state of the group box. Draws a group box control in the specified state and bounds, with the specified text, font, and text formatting. - @@ -355,11 +355,11 @@ One of the values that specifies the visual state of the group box. Draws a group box control in the specified state and bounds, with the specified text, font, color, and text formatting. - @@ -469,19 +469,19 @@ if the application state is used to determine rendering style; otherwise, . The default is . - is `true`, the uses the setting from to determine the rendering style. If is `false`, the renderer will always render using visual styles. - - - -## Examples - The following code example uses the property to change whether a group box is rendered using visual styles. This code example is part of a larger example provided for the class. - + is `true`, the uses the setting from to determine the rendering style. If is `false`, the renderer will always render using visual styles. + + + +## Examples + The following code example uses the property to change whether a group box is rendered using visual styles. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/GroupBoxRenderer/Overview/form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/VB/form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.GroupBoxRenderer/VB/form1.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Windows.Forms/HtmlDocument.xml b/xml/System.Windows.Forms/HtmlDocument.xml index c0583826bc0..8be6198f55d 100644 --- a/xml/System.Windows.Forms/HtmlDocument.xml +++ b/xml/System.Windows.Forms/HtmlDocument.xml @@ -29,50 +29,50 @@ Provides top-level programmatic access to an HTML document hosted by the control. - provides a managed wrapper around Internet Explorer's document object, also known as the HTML Document Object Model (DOM). You obtain an instance of through the property of the control. - - HTML tags inside of an HTML document can be nested inside one another. thus represents a document tree, whose children are instances of the class. The following code example shows a simple HTML file. - + provides a managed wrapper around Internet Explorer's document object, also known as the HTML Document Object Model (DOM). You obtain an instance of through the property of the control. + + HTML tags inside of an HTML document can be nested inside one another. thus represents a document tree, whose children are instances of the class. The following code example shows a simple HTML file. + ```html - - -
Simple HTML Form
-
- Enter Your Name: - - - - -``` - - In this example, represents the entire document inside the `HTML` tags. The `BODY`, `DIV`, `FORM` and `SPAN` tags are represented by individual objects. - - There are several ways you can access the elements in this tree. Use the property to access the `BODY` tag and all of its children. The property gives you the for the element on an HTML page that has user input focus. All elements within an HTML page can have a name; the collection provides access to each using its name as an index. will return an of all objects with a given HTML tag name, such as `DIV` or `TABLE`. will return the single corresponding to the unique ID that you supply. will return the that can be found on the screen at the supplied mouse pointer coordinates. - - You can also use the and collection to iterate through elements that represent user input forms and graphics, respectively. - - is based on the unmanaged interfaces implemented by Internet Explorer's DHTML DOM: `IHTMLDocument`, `IHTMLDocument2`, `IHTMLDocument3`, and `IHTMLDocument4`. Only the most frequently used properties and methods on these unmanaged interfaces are exposed by . You can access all other properties and methods directly using the property, which you can cast to the desired unmanaged interface pointer. - - An HTML document may contain frames, which are different windows inside of the control. Each frame displays its own HTML page. The collection is available through the property. You may also use the property to resize the displayed page, scroll the document, or display alerts and prompts to the user. - - exposes the most common events you would expect to handle when hosting HTML pages. For events not exposed directly by the interface, you can add a handler for the event using . - - HTML files may contain `SCRIPT` tags that encapsulate code written in one of the Active Scripting languages, such as JScript or VBScript. The method provides for execution of properties and methods defined in a `SCRIPT` tag. - + + +
Simple HTML Form
+
+ Enter Your Name: + + + + +``` + + In this example, represents the entire document inside the `HTML` tags. The `BODY`, `DIV`, `FORM` and `SPAN` tags are represented by individual objects. + + There are several ways you can access the elements in this tree. Use the property to access the `BODY` tag and all of its children. The property gives you the for the element on an HTML page that has user input focus. All elements within an HTML page can have a name; the collection provides access to each using its name as an index. will return an of all objects with a given HTML tag name, such as `DIV` or `TABLE`. will return the single corresponding to the unique ID that you supply. will return the that can be found on the screen at the supplied mouse pointer coordinates. + + You can also use the and collection to iterate through elements that represent user input forms and graphics, respectively. + + is based on the unmanaged interfaces implemented by Internet Explorer's DHTML DOM: `IHTMLDocument`, `IHTMLDocument2`, `IHTMLDocument3`, and `IHTMLDocument4`. Only the most frequently used properties and methods on these unmanaged interfaces are exposed by . You can access all other properties and methods directly using the property, which you can cast to the desired unmanaged interface pointer. + + An HTML document may contain frames, which are different windows inside of the control. Each frame displays its own HTML page. The collection is available through the property. You may also use the property to resize the displayed page, scroll the document, or display alerts and prompts to the user. + + exposes the most common events you would expect to handle when hosting HTML pages. For events not exposed directly by the interface, you can add a handler for the event using . + + HTML files may contain `SCRIPT` tags that encapsulate code written in one of the Active Scripting languages, such as JScript or VBScript. The method provides for execution of properties and methods defined in a `SCRIPT` tag. + > [!NOTE] -> While most of the properties, methods, and events on have kept the same names as they have on the unmanaged DOM, some have been changed for consistency with the .NET Framework. - - - -## Examples - The following code example uses data from the Northwind database to create an `HTML TABLE` dynamically using . The method is also used, first to add cells (`TD` elements) to rows (`TR` elements), then to add rows to the table, and finally to append the table to the end of the current document. The code example requires that your application has a control named `WebBrowser1`. The code should be called after a document has been loaded. - +> While most of the properties, methods, and events on have kept the same names as they have on the unmanaged DOM, some have been changed for consistency with the .NET Framework. + + + +## Examples + The following code example uses data from the Northwind database to create an `HTML TABLE` dynamically using . The method is also used, first to add cells (`TD` elements) to rows (`TR` elements), then to add rows to the table, and finally to append the table to the end of the current document. The code example requires that your application has a control named `WebBrowser1`. The code should be called after a document has been loaded. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet10"::: + ]]>
document - Web APIs @@ -112,15 +112,15 @@ Provides the which currently has user input focus. The which currently has user input focus. - returns the element corresponding to the `` tag. - - If the document does not have focus, returns `null`. - - If the current element with input focus is a cell (`TD`) in an HTML `TABLE` tag, will return the element that contains the `TABLE` element. - + returns the element corresponding to the `` tag. + + If the document does not have focus, returns `null`. + + If the current element with input focus is a cell (`TD`) in an HTML `TABLE` tag, will return the element that contains the `TABLE` element. + ]]> activeElement Property @@ -152,13 +152,13 @@ Gets or sets the of a hyperlink when clicked by a user. The for active links. - type in the .NET Framework supports an `Alpha` value, but the HTML DOM does not. Therefore, `Alpha` will have no effect when assigned to this property. - + type in the .NET Framework supports an `Alpha` value, but the HTML DOM does not. Therefore, `Alpha` will have no effect when assigned to this property. + ]]> alinkColor Property @@ -190,23 +190,23 @@ Gets an instance of , which stores all objects for the document. The of all elements in the document. - collection provides random access to any element in the HTML document, regardless of its position in the document tree. Use it to access any element in an HTML document by name, ID, or index. You may also iterate over all of the elements within a document. - - Some elements, such as `HEAD` and `TITLE`, will never have names associated with them. All other elements will have names only if the author of the HTML file assigned them. You can access elements without names by ID or index. - - You cannot add elements directly to the collection, because all elements in an HTML file outside of the `HTML` tag must have a parent element. Use the method or the property on to add new elements to the tree. - - - -## Examples - The following code example iterates through all of the elements in a document and sets `Enabled=True`, enabling any elements that may have been disabled by default to prevent user input while the document was loading. The code example requires that your application contains a control named `WebBrowser1`. - + collection provides random access to any element in the HTML document, regardless of its position in the document tree. Use it to access any element in an HTML document by name, ID, or index. You may also iterate over all of the elements within a document. + + Some elements, such as `HEAD` and `TITLE`, will never have names associated with them. All other elements will have names only if the author of the HTML file assigned them. You can access elements without names by ID or index. + + You cannot add elements directly to the collection, because all elements in an HTML file outside of the `HTML` tag must have a parent element. Use the method or the property on to add new elements to the tree. + + + +## Examples + The following code example iterates through all of the elements in a document and sets `Enabled=True`, enabling any elements that may have been disabled by default to prevent user input while the document was loading. The code example requires that your application contains a control named `WebBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet1"::: + ]]> all Property @@ -243,13 +243,13 @@ The managed code that handles the event. Adds an event handler for the named HTML DOM event. - event of the control. - - This method allows you to attach handlers to unmanaged DOM events not exposed by . For more information about available unmanaged DOM events, see [Accessing Unexposed Members on the Managed HTML Document Object Model](/dotnet/framework/winforms/controls/accessing-unexposed-members-on-the-managed-html-document-object-model) and the IHTMLDocument interfaces: [IHTMLDocument](https://go.microsoft.com/fwlink/?LinkId=104882), [IHTMLDocument2](https://go.microsoft.com/fwlink/?LinkId=104884), [IHTMLDocument3](https://go.microsoft.com/fwlink/?LinkId=104886), [IHTMLDocument4](https://go.microsoft.com/fwlink/?LinkId=104887), [IHTMLDocument5](https://go.microsoft.com/fwlink/?LinkId=104888). - + event of the control. + + This method allows you to attach handlers to unmanaged DOM events not exposed by . For more information about available unmanaged DOM events, see [Accessing Unexposed Members on the Managed HTML Document Object Model](/dotnet/desktop/winforms/controls/accessing-unexposed-members-on-the-managed-html-document-object-model) and the IHTMLDocument interfaces: [IHTMLDocument](https://go.microsoft.com/fwlink/?LinkId=104882), [IHTMLDocument2](https://go.microsoft.com/fwlink/?LinkId=104884), [IHTMLDocument3](https://go.microsoft.com/fwlink/?LinkId=104886), [IHTMLDocument4](https://go.microsoft.com/fwlink/?LinkId=104887), [IHTMLDocument5](https://go.microsoft.com/fwlink/?LinkId=104888). + ]]> attachEvent Method @@ -281,13 +281,13 @@ Gets or sets the background color of the HTML document. The of the document's background. - will display when no other element occupies that area of the screen. - - The type in the .NET Framework supports an `Alpha` value, but the HTML DOM does not. Therefore, `Alpha` will have no effect when assigned to this property. - + will display when no other element occupies that area of the screen. + + The type in the .NET Framework supports an `Alpha` value, but the HTML DOM does not. Therefore, `Alpha` will have no effect when assigned to this property. + ]]> @@ -329,25 +329,25 @@ Gets the for the BODY tag. The object for the BODY tag. - . To obtain the `HEAD` element, use . - - - -## Examples - The following code example creates a new `DIV` element and appends it to the bottom of the document using the method. - + . To obtain the `HEAD` element, use . + + + +## Examples + The following code example creates a new `DIV` element and appends it to the bottom of the document using the method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet13"::: + ]]> body Property @@ -385,19 +385,19 @@ Occurs when the user clicks anywhere on the document. - to align the element with the top of the Web page. - + to align the element with the top of the Web page. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet7"::: + ]]> onclick Event @@ -435,18 +435,18 @@ Occurs when the user requests to display the document's context menu. - event and uses it to display a . - - :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet15"::: - + event and uses it to display a . + + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet15"::: + ]]> oncontextmenu Event @@ -478,25 +478,25 @@ Gets or sets the HTTP cookies associated with this document. A containing a list of cookies, with each cookie separated by a semicolon. - property of exposes all cookies set for a Web page. - - A *cookie* is an arbitrary name/value pair associated with a given Web page. Web developers use cookies to track when users visit or return to a Web site. A cookie is composed of multiple parts, called cookie crumbs, that determine the following: - -- The document set to which the cookie applies; its domain and path. - -- The name and value of the cookie. - -- The expiration date of the cookie. - -- Whether the cookie can only be sent using a secure connection. - - The property may contain multiple cookies. - - You can only use the property to set one cookie at a time. - + property of exposes all cookies set for a Web page. + + A *cookie* is an arbitrary name/value pair associated with a given Web page. Web developers use cookies to track when users visit or return to a Web site. A cookie is composed of multiple parts, called cookie crumbs, that determine the following: + +- The document set to which the cookie applies; its domain and path. + +- The name and value of the cookie. + +- The expiration date of the cookie. + +- Whether the cookie can only be sent using a secure connection. + + The property may contain multiple cookies. + + You can only use the property to set one cookie at a time. + ]]> cookie Property @@ -533,25 +533,25 @@ Creates a new of the specified HTML tag type. A new element of the specified tag type. - returns an element unattached to the current document tree. To add the element to the document, use either the or methods. - - This method will not affect the state of an existing document's source code when you use the control's **View Source** context menu command or the and properties of the control. - - When you create new elements with , you will not be able to set certain properties, such as `Name`. In cases where you need to set the Name attribute, assign them as HTML to the property of another object in the document. - - - -## Examples - The following code example uses data from the Northwind database to create an HTML table using . The method is also used, first to add cells (`TD` elements) to rows (`TR` elements), then to add rows to the table, and finally to append the table to the end of the current document. The code example requires that your application has a control called `WebBrowser1`. - + returns an element unattached to the current document tree. To add the element to the document, use either the or methods. + + This method will not affect the state of an existing document's source code when you use the control's **View Source** context menu command or the and properties of the control. + + When you create new elements with , you will not be able to set certain properties, such as `Name`. In cases where you need to set the Name attribute, assign them as HTML to the property of another object in the document. + + + +## Examples + The following code example uses data from the Northwind database to create an HTML table using . The method is also used, first to add cells (`TD` elements) to rows (`TR` elements), then to add rows to the table, and finally to append the table to the end of the current document. The code example requires that your application has a control called `WebBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet10"::: + ]]> createElement Method @@ -583,11 +583,11 @@ Gets the encoding used by default for the current document. The representing the encoding that the browser uses when the page is first displayed. - defaultCharset Property @@ -653,15 +653,15 @@ Gets or sets the string describing the domain of this document for security purposes. A valid domain. - property. In the previous URL example, setting to microsoft.com would allow both pages to communicate with one another. - - Strings assigned to the property must be valid top-level domains. In the previous URL example, you can set to microsoft.com, but not to .com, which would enable any page on the Internet to script a page's contents. - - You cannot use the property to enable cross-frame scripting for pages accessed using two different protocols. If one frame in your page comes from a Web server (the http:// protocol) and another comes from the file system (the file://) protocol, they will not be able to communicate with one another regardless of the value of the property. - + property. In the previous URL example, setting to microsoft.com would allow both pages to communicate with one another. + + Strings assigned to the property must be valid top-level domains. In the previous URL example, you can set to microsoft.com, but not to .com, which would enable any page on the Internet to script a page's contents. + + You cannot use the property to enable cross-frame scripting for pages accessed using two different protocols. If one frame in your page comes from a Web server (the http:// protocol) and another comes from the file system (the file://) protocol, they will not be able to communicate with one another regardless of the value of the property. + ]]> The argument for the Domain property must be a valid domain name using Domain Name System (DNS) conventions. @@ -701,19 +701,19 @@ Gets the unmanaged interface pointer for this . An representing an IDispatch pointer to the unmanaged document. - is a wrapper for the Internet Explorer Document Object Model (DOM), which is written in COM. If you need to access unexposed properties or methods on the underlying COM interfaces, such as `IHTMLDocument2`, you can use this object to query for them. - - To use the unmanaged interfaces, import the MSHTML library (mshtml.dll) into your application. However, you can also execute unexposed properties and methods using the `IDispatch::Invoke` method. - -## Examples - The following code example casts the to an `IHTMLDocument2` pointer and displays the value of the `lastModified` property, which tells when the owner of the document last updated its contents. The code example requires that you have a on your form named `Button6`. - + is a wrapper for the Internet Explorer Document Object Model (DOM), which is written in COM. If you need to access unexposed properties or methods on the underlying COM interfaces, such as `IHTMLDocument2`, you can use this object to query for them. + + To use the unmanaged interfaces, import the MSHTML library (mshtml.dll) into your application. However, you can also execute unexposed properties and methods using the `IDispatch::Invoke` method. + +## Examples + The following code example casts the to an `IHTMLDocument2` pointer and displays the value of the `lastModified` property, which tells when the owner of the document last updated its contents. The code example requires that you have a on your form named `Button6`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet3"::: + ]]> IHTMLDocument2 Interface @@ -817,14 +817,14 @@ The value to assign using the command. Not applicable for all commands. Executes the specified command against the document. - exposes a large array of commands for which there are no methods exposed on . Using you can insert new HTML elements, select and format text, and clear any cached authentication credentials. For a full list of commands, see [Command Identifiers](https://go.microsoft.com/fwlink/?LinkId=198814). - + exposes a large array of commands for which there are no methods exposed on . Using you can insert new HTML elements, select and format text, and clear any cached authentication credentials. For a full list of commands, see [Command Identifiers](https://go.microsoft.com/fwlink/?LinkId=198814). + > [!NOTE] -> Certain commands, such as copy, have return values. In the current implementation of , you cannot obtain a return value from your call. To retrieve return values, use the corresponding unmanaged method on a reference instead. - +> Certain commands, such as copy, have return values. In the current implementation of , you cannot obtain a return value from your call. To retrieve return values, use the corresponding unmanaged method on a reference instead. + ]]> execCommand Method @@ -863,11 +863,11 @@ Sets user input focus on the current document. - will set focus on the control, if the control currently does not have focus. If the document is hosted inside of a `FRAME`, this method will put focus on that `FRAME` within the `FRAMESET`. - + will set focus on the control, if the control currently does not have focus. If the document is hosted inside of a `FRAME`, this method will put focus on that `FRAME` within the `FRAMESET`. + ]]> focus Method @@ -937,21 +937,21 @@ Occurs before focus is given to the document. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet424"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet424"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet424"::: + ]]> onfocusin Event @@ -983,11 +983,11 @@ Gets or sets the text color for the document. The color of the text in the document. - type in the .NET Framework supports an `Alpha` value, but the HTML DOM does not. Therefore, `Alpha` will have no effect when assigned to this property. - + type in the .NET Framework supports an `Alpha` value, but the HTML DOM does not. Therefore, `Alpha` will have no effect when assigned to this property. + ]]> @@ -1022,23 +1022,23 @@ Gets a collection of all of the <FORM> elements in the document. An of the <FORM> elements within the document. - and calling its `Submit` method using the method. - - To add a new `FORM` to a document, you can either create a new `FORM` tag as a string, and assign it to the property of an element previously added to the HTML DOM; or you can use the method, set its properties using , and add it as a child of an existing element using . - - - -## Examples - The following code example iterates through all of the `Form` elements on a Web page and clears all user input, setting the forms back to their default values. - + and calling its `Submit` method using the method. + + To add a new `FORM` to a document, you can either create a new `FORM` tag as a string, and assign it to the property of an element previously added to the HTML DOM; or you can use the method, set its properties using , and add it as a child of an existing element using . + + + +## Examples + The following code example iterates through all of the `Form` elements on a Web page and clears all user input, setting the forms back to their default values. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet4"::: + ]]> forms Property @@ -1076,19 +1076,19 @@ Retrieves a single using the element's ID attribute as a search key. Returns the first object with the same ID attribute as the specified value, or if the cannot be found. - will return the first one it finds. - - - -## Examples - The following code example retrieves a named `TABLE` from a document, counts up the number of rows, and displays the result in the Web page. The code example requires that you have a control in your project named `WebBrowser1`, and that you have loaded a Web page with a `TABLE` whose `ID` attribute is `Table1`. - + will return the first one it finds. + + + +## Examples + The following code example retrieves a named `TABLE` from a document, counts up the number of rows, and displays the result in the Web page. The code example requires that you have a control in your project named `WebBrowser1`, and that you have loaded a Web page with a `TABLE` whose `ID` attribute is `Table1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet5"::: + ]]> getElementById Method @@ -1125,19 +1125,19 @@ Retrieves the HTML element located at the specified client coordinates. The at the specified screen location in the document. - uses client coordinates, in which the upper-left corner of the document is assigned the value (0,0). Client coordinates for the current position of the cursor can be obtained using the property. - - - -## Examples - The following code example detects a click on the document, finds the element, and uses to align the element with the top of the Web page. - + uses client coordinates, in which the upper-left corner of the document is assigned the value (0,0). Client coordinates for the current position of the cursor can be obtained using the property. + + + +## Examples + The following code example detects a click on the document, finds the element, and uses to align the element with the top of the Web page. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet7"::: + ]]> elementFromPoint Method @@ -1173,14 +1173,14 @@ Retrieve a collection of elements with the specified HTML tag. The collection of elements who tag name is equal to the argument. - control named `WebBrowser1`. - + control named `WebBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet6"::: + ]]> getElementsByTagName Method @@ -1241,21 +1241,21 @@ Gets a collection of all image tags in the document. A collection of objects, one for each IMG tag in the document. Elements are returned from the collection in source order. - returns a collection of objects. To access attributes, such as `ALT` and `SRC`, that are not directly exposed by , use the method. - - To add a new image to a document, either create a new `IMG` tag as a string, and assign it to the property of an element previously added to the HTML DOM; or use the method, set its properties using , and add it as a child of an existing element using . - - - -## Examples - The following code example examines the `ALT` attribute of all of the images in the document, and sets a default `ALT` attribute if a value is not already set. - + returns a collection of objects. To access attributes, such as `ALT` and `SRC`, that are not directly exposed by , use the method. + + To add a new image to a document, either create a new `IMG` tag as a string, and assign it to the property of an element previously added to the HTML DOM; or use the method, set its properties using , and add it as a child of an existing element using . + + + +## Examples + The following code example examines the `ALT` attribute of all of the images in the document, and sets a default `ALT` attribute if a value is not already set. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet8"::: + ]]> images Property @@ -1269,28 +1269,28 @@ Executes an Active Scripting function defined in an HTML page. - - - - - - - -``` - + + + + + + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet9"::: + ]]> @@ -1332,56 +1332,56 @@ window.alert("Name is " + name + "; address is " + address); Executes an Active Scripting function defined in an HTML page. The object returned by the Active Scripting call. - will vary. If the called Active Scripting function returns scalar data, such as a string or an integer, it will be returned as a string. If it returns a script-based object, such as an object created using JScript or VBScript's `new` operator, it will be of type `Object`. (You can make calls on such objects by calling and using .) If it returns an HTML DOM element, such as a `DIV` or a `TABLE`, it will be of type `Object`; if you have added a project reference to MSHTML.DLL, however, it will be cast to its specific unmanaged DOM type. - - You may call any function written in any Active Scripting language installed on the user's computer, including JScript and VBScript. - - The will do nothing if the user has explicitly turned off script execution in Internet Explorer, or if the current security configuration for the Web page does not allow it. - -## Examples - The following code example executes the contents of a script in a Web page. The code example requires that you have a in your application called `WebBrowser1`, and that you have loaded the following Web page. - + will vary. If the called Active Scripting function returns scalar data, such as a string or an integer, it will be returned as a string. If it returns a script-based object, such as an object created using JScript or VBScript's `new` operator, it will be of type `Object`. (You can make calls on such objects by calling and using .) If it returns an HTML DOM element, such as a `DIV` or a `TABLE`, it will be of type `Object`; if you have added a project reference to MSHTML.DLL, however, it will be cast to its specific unmanaged DOM type. + + You may call any function written in any Active Scripting language installed on the user's computer, including JScript and VBScript. + + The will do nothing if the user has explicitly turned off script execution in Internet Explorer, or if the current security configuration for the Web page does not allow it. + +## Examples + The following code example executes the contents of a script in a Web page. The code example requires that you have a in your application called `WebBrowser1`, and that you have loaded the following Web page. + ```html - - - - Invoke Script Sample - - - - - - -
-
- - - - -``` - + + + + Invoke Script Sample + + + + + + +
+
+ + + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet12"::: + ]]>
@@ -1426,35 +1426,35 @@ window.alert("Name is " + name + "; address is " + address); Executes an Active Scripting function defined in an HTML page. The object returned by the Active Scripting call. - will vary. If the called Active Scripting function returns scalar data, such as a string or an integer, it will be returned as a string. If it returns a script-based object, such as an object created using JScript or VBScript's `new` operator, it will be of type `Object`. (You can make calls on such objects by calling and using .) If it returns an HTML DOM element, such as a `DIV` or a `TABLE`, it will be of type `Object`; if you have added a project reference to MSHTML.DLL, however, it will be cast to its specific unmanaged DOM type. - - You may call any function written in any Active Scripting language installed on the user's machine, including JScript and VBScript. - - This method will do nothing if the user has explicitly turned off script execution in Internet Explorer, or if the current security configuration for the Web page does not allow it. - -## Examples - The following code example executes the contents of a script in a Web page. The code example requires that you have a in your application called `WebBrowser1`, and that you have loaded the following Web page. - -``` - - - - - - - -``` - + will vary. If the called Active Scripting function returns scalar data, such as a string or an integer, it will be returned as a string. If it returns a script-based object, such as an object created using JScript or VBScript's `new` operator, it will be of type `Object`. (You can make calls on such objects by calling and using .) If it returns an HTML DOM element, such as a `DIV` or a `TABLE`, it will be of type `Object`; if you have added a project reference to MSHTML.DLL, however, it will be cast to its specific unmanaged DOM type. + + You may call any function written in any Active Scripting language installed on the user's machine, including JScript and VBScript. + + This method will do nothing if the user has explicitly turned off script execution in Internet Explorer, or if the current security configuration for the Web page does not allow it. + +## Examples + The following code example executes the contents of a script in a Web page. The code example requires that you have a in your application called `WebBrowser1`, and that you have loaded the following Web page. + +``` + + + + + + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet9"::: + ]]>
@@ -1485,11 +1485,11 @@ window.alert("Name is " + name + "; address is " + address); Gets or sets the color of hyperlinks. The color for hyperlinks in the current document. - type in the .NET Framework supports an `Alpha` value, but the HTML DOM does not. Therefore, `Alpha` will have no effect when assigned to this property. - + type in the .NET Framework supports an `Alpha` value, but the HTML DOM does not. Therefore, `Alpha` will have no effect when assigned to this property. + ]]> @@ -1524,13 +1524,13 @@ window.alert("Name is " + name + "; address is " + address); Gets a list of all the hyperlinks within this HTML document. An of objects. - objects contained within this collection encapsulate the unmanaged `IHTMLLinkElement` interface. To access the properties of the underlying interface safely, use the method. - + objects contained within this collection encapsulate the unmanaged `IHTMLLinkElement` interface. To access the properties of the underlying interface safely, use the method. + ]]> links Property @@ -1568,21 +1568,21 @@ window.alert("Name is " + name + "; address is " + address); Occurs while focus is leaving a control. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet425"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet425"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet425"::: + ]]> onfocusout Event @@ -1620,23 +1620,23 @@ window.alert("Name is " + name + "; address is " + address); Occurs when the user clicks the left mouse button. - event occurs before the event. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. - + event occurs before the event. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet426"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet426"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet426"::: + ]]> onmousedown Event @@ -1674,21 +1674,21 @@ window.alert("Name is " + name + "; address is " + address); Occurs when the mouse is no longer hovering over the document. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet427"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet427"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet427"::: + ]]> onmouseout Event @@ -1726,21 +1726,21 @@ window.alert("Name is " + name + "; address is " + address); Occurs when the mouse is moved over the document. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet428"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet428"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet428"::: + ]]> onmousemove Event @@ -1778,21 +1778,21 @@ window.alert("Name is " + name + "; address is " + address); Occurs when the mouse is moved over the document. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet429"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet429"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet429"::: + ]]> onmouseover Event @@ -1830,21 +1830,21 @@ window.alert("Name is " + name + "; address is " + address); Occurs when the user releases the left mouse button. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlDocument1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet430"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet430"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet430"::: + ]]> onmouseup Event @@ -1955,21 +1955,21 @@ window.alert("Name is " + name + "; address is " + address); Gets a new to use with the method. A new document for writing. - will clear the previous loaded document, including any associated state, such as variables. It will not cause navigation events in to be raised. - - always creates a new document in the current window. To open a document in a new window, use the method on the class. - - - -## Examples - The following code example prepares the DOM for writing and writes a new document using the method. - + will clear the previous loaded document, including any associated state, such as variables. It will not cause navigation events in to be raised. + + always creates a new document in the current window. To open a document in a new window, use the method on the class. + + + +## Examples + The following code example prepares the DOM for writing and writes a new document using the method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet11"::: + ]]> open Method @@ -2002,13 +2002,13 @@ window.alert("Name is " + name + "; address is " + address); if text renders from right to left; otherwise, . - will not have any value unless it has been set explicitly, either in code or in HTML. - - Unlike the property on Windows Forms controls, on the managed HTML DOM will not affect the direction of Latin text. - + will not have any value unless it has been set explicitly, either in code or in HTML. + + Unlike the property on Windows Forms controls, on the managed HTML DOM will not affect the direction of Latin text. + ]]> dir Property @@ -2046,20 +2046,20 @@ window.alert("Name is " + name + "; address is " + address); Occurs when navigation to another Web page is halted. - method of the control. Navigation failures caused by network outages or malfunctioning Web sites will not cause to occur. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example resets the status bar on a Windows Forms application when the `Stop` event has occurred. The code example requires that you have a control named `StatusBar1` in your application. - - :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet15"::: - + method of the control. Navigation failures caused by network outages or malfunctioning Web sites will not cause to occur. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example resets the status bar on a Windows Forms application when the `Stop` event has occurred. The code example requires that you have a control named `StatusBar1` in your application. + + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet15"::: + ]]> onstop Event @@ -2091,21 +2091,21 @@ window.alert("Name is " + name + "; address is " + address); Gets or sets the text value of the <TITLE> tag in the current HTML document. The title of the current document. - property to identify the document by way of a human-readable name. - - Changes to this property will also reflect in the property of the control. - - - -## Examples - The following code example creates an HTML hyperlink to the current document using the URL of the document as the link's location and the title of the document as the link text. The code example requires that your application has a control named `WebBrowser1`. - + property to identify the document by way of a human-readable name. + + Changes to this property will also reflect in the property of the control. + + + +## Examples + The following code example creates an HTML hyperlink to the current document using the URL of the document as the link's location and the title of the document as the link text. The code example requires that your application has a control named `WebBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet14"::: + ]]> @@ -2145,11 +2145,11 @@ window.alert("Name is " + name + "; address is " + address); Gets the URL describing the location of this document. A representing this document's URL. - property on the control. - + property on the control. + ]]> @@ -2180,11 +2180,11 @@ window.alert("Name is " + name + "; address is " + address); Gets or sets the Color of links to HTML pages that the user has already visited. The color of visited links. - @@ -2226,11 +2226,11 @@ window.alert("Name is " + name + "; address is " + address); Gets the associated with this document. The window for this document. - . - + . + ]]> parentWindow Property @@ -2265,21 +2265,21 @@ window.alert("Name is " + name + "; address is " + address); The HTML text to write into the document. Writes a new HTML page. - should be preceded by a call to , which will clear the current document and all of its variables. Your calls to will create a new HTML document in its place. To change only a specific portion of the document, obtain the appropriate and set its property. - - It is recommended that you write an entire valid HTML document using the method, including `HTML` and `BODY` tags. However, if you write just HTML elements, the Document Object Model (DOM) will supply these elements for you. - - - -## Examples - The following code example opens a new and writes in a new HTML file. - + should be preceded by a call to , which will clear the current document and all of its variables. Your calls to will create a new HTML document in its place. To change only a specific portion of the document, obtain the appropriate and set its property. + + It is recommended that you write an entire valid HTML document using the method, including `HTML` and `BODY` tags. However, if you write just HTML elements, the Document Object Model (DOM) will supply these elements for you. + + + +## Examples + The following code example opens a new and writes in a new HTML file. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet11"::: + ]]> diff --git a/xml/System.Windows.Forms/HtmlElement.xml b/xml/System.Windows.Forms/HtmlElement.xml index eb75e6b8998..297d155831a 100644 --- a/xml/System.Windows.Forms/HtmlElement.xml +++ b/xml/System.Windows.Forms/HtmlElement.xml @@ -29,27 +29,27 @@ Represents an HTML element inside of a Web page. - represents any possible type of element in an HTML document, such as `BODY`, `TABLE`, and `FORM`, among others. The class exposes the most common properties you can expect to find on all elements. - - Most elements can have *child elements*: other HTML elements that are placed underneath them. Use the property to test whether a given element has children, and the collection to iterate through them. The property returns the in which the current element is nested. - - You often need access to attributes, properties, and methods on the underlying element that are not directly exposed by , such as the `SRC` attribute on an `IMG` element or the `Submit` method on a `FORM`. The and methods enable you to retrieve and alter any attribute or property on a specific element, while provides access to any methods not exposed in the managed Document Object Model (DOM). If your application has unmanaged code permission, you can also access unexposed properties and methods with the attribute. - - Use the property to test whether an element is of a specific type. - - Any HTML document can be modified at run time. You can create new objects with the method of , and add them to another element using the or methods. You can also create the elements as HTML tags and assign them to an existing element's property. - - - -## Examples - The following code example shows how to examine an arbitrary HTML document and derive a string describing the HTML elements, with indentation and level numbers used to indicate how deeply nested the elements are in the document. This code example requires that your application hosts a control named `WebBrowser1`. - + represents any possible type of element in an HTML document, such as `BODY`, `TABLE`, and `FORM`, among others. The class exposes the most common properties you can expect to find on all elements. + + Most elements can have *child elements*: other HTML elements that are placed underneath them. Use the property to test whether a given element has children, and the collection to iterate through them. The property returns the in which the current element is nested. + + You often need access to attributes, properties, and methods on the underlying element that are not directly exposed by , such as the `SRC` attribute on an `IMG` element or the `Submit` method on a `FORM`. The and methods enable you to retrieve and alter any attribute or property on a specific element, while provides access to any methods not exposed in the managed Document Object Model (DOM). If your application has unmanaged code permission, you can also access unexposed properties and methods with the attribute. + + Use the property to test whether an element is of a specific type. + + Any HTML document can be modified at run time. You can create new objects with the method of , and add them to another element using the or methods. You can also create the elements as HTML tags and assign them to an existing element's property. + + + +## Examples + The following code example shows how to examine an arbitrary HTML document and derive a string describing the HTML elements, with indentation and level numbers used to indicate how deeply nested the elements are in the document. This code example requires that your application hosts a control named `WebBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet1"::: + ]]> IHTMLElement Interface @@ -90,13 +90,13 @@ Gets an of all elements underneath the current element. A collection of all elements that are direct or indirect children of the current element. If the current element is a TABLE, for example, will return every TH, TR, and TD element within the table, as well as any other elements, such as DIV and SPAN elements, contained within the cells. - collection instead. - - Elements in this collection will not necessarily be returned in source order. - + collection instead. + + Elements in this collection will not necessarily be returned in source order. + ]]> @@ -139,23 +139,23 @@ Adds an element to another element's subtree. The element after it has been added to the tree. - to add new elements to an existing document, or to move an element on the page. - - If an element has already been parented, appending an element to another element will automatically remove that element from its previous parent. - - Any additions made to a document at run-time using will not be persisted when you call the method on the control. - - - -## Examples - The following code example creates a new hyperlink using the method and adds it to end of a page using `AppendChild` on the `BODY` element. The example requires that your application contains a control named `WebBrowser1`. - + to add new elements to an existing document, or to move an element on the page. + + If an element has already been parented, appending an element to another element will automatically remove that element from its previous parent. + + Any additions made to a document at run-time using will not be persisted when you call the method on the control. + + + +## Examples + The following code example creates a new hyperlink using the method and adds it to end of a page using `AppendChild` on the `BODY` element. The example requires that your application contains a control named `WebBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet8"::: + ]]> @@ -193,15 +193,15 @@ The managed code that handles the event. Adds an event handler for a named event on the HTML Document Object Model (DOM). - to add an event handler to these unexposed events. - - You should not attach an event to the document or one of its objects until the document has completed loading. The earliest you should call this method is in the event of the control. - - For more information about the available unmanaged events, see [Accessing Unexposed Members on the Managed HTML Document Object Model](/dotnet/framework/winforms/controls/accessing-unexposed-members-on-the-managed-html-document-object-model) and the IHTMLElement interfaces: [IHTMLElement](https://go.microsoft.com/fwlink/?LinkId=104876), [IHTMLElement2](https://go.microsoft.com/fwlink/?LinkId=104877), [IHTMLElement3](https://go.microsoft.com/fwlink/?LinkId=104878), [IHTMLElement4](https://go.microsoft.com/fwlink/?LinkId=104879). - + to add an event handler to these unexposed events. + + You should not attach an event to the document or one of its objects until the document has completed loading. The earliest you should call this method is in the event of the control. + + For more information about the available unmanaged events, see [Accessing Unexposed Members on the Managed HTML Document Object Model](/dotnet/desktop/winforms/controls/accessing-unexposed-members-on-the-managed-html-document-object-model) and the IHTMLElement interfaces: [IHTMLElement](https://go.microsoft.com/fwlink/?LinkId=104876), [IHTMLElement2](https://go.microsoft.com/fwlink/?LinkId=104877), [IHTMLElement3](https://go.microsoft.com/fwlink/?LinkId=104878), [IHTMLElement4](https://go.microsoft.com/fwlink/?LinkId=104879). + ]]> EventTarget.addEventListener() @@ -234,19 +234,19 @@ if element can have child elements; otherwise, . - or on an arbitrary element. - - - -## Examples - The following code example handles the event on . If an element was not previous selected using a mouse click, the code assigns the element to a private class variable named `MoveElement`. If an element was selected, the code attempts to append it to the element that was just clicked. This code example requires that your application hosts a control named `WebBrowser1`, and that you have already added an event handler for the event on . - + or on an arbitrary element. + + + +## Examples + The following code example handles the event on . If an element was not previous selected using a mouse click, the code assigns the element to a private class variable named `MoveElement`. If an element was selected, the code attempts to append it to the element that was just clicked. This code example requires that your application hosts a control named `WebBrowser1`, and that you have already added an event handler for the event on . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet2"::: + ]]> @@ -283,25 +283,25 @@ Gets an of all children of the current element. A collection of all objects that have the current element as a parent. - collection provides a simple mechanism for exploring the tree structure of a document. - - only exposes elements whose direct parent is the current element. If you have an for a `TABLE` element, will give you all of the `TR` (row) elements inside of the `TABLE`. To retrieve the `TD` (cell) elements contained inside of the `TR` elements, you will need to use either the collection on each individual `TR` element, or use the collection on . - - Elements in this collection are not guaranteed to be in source order. - - If is `false`, `Children` will always be empty. - - - -## Examples - The following code example examines an arbitrary HTML document and derive a string describing the elements, with indentation and level numbers used to indicate how deeply nested the elements are in the document. It does this by searching the `Children` collection of all elements recursively, starting with the HTML element at the top of the document. This code example requires that your application has a control named `WebBrowser1`. - + collection provides a simple mechanism for exploring the tree structure of a document. + + only exposes elements whose direct parent is the current element. If you have an for a `TABLE` element, will give you all of the `TR` (row) elements inside of the `TABLE`. To retrieve the `TD` (cell) elements contained inside of the `TR` elements, you will need to use either the collection on each individual `TR` element, or use the collection on . + + Elements in this collection are not guaranteed to be in source order. + + If is `false`, `Children` will always be empty. + + + +## Examples + The following code example examines an arbitrary HTML document and derive a string describing the elements, with indentation and level numbers used to indicate how deeply nested the elements are in the document. It does this by searching the `Children` collection of all elements recursively, starting with the HTML element at the top of the document. This code example requires that your application has a control named `WebBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet1"::: + ]]> @@ -333,25 +333,25 @@ Occurs when the user clicks on the element with the left mouse button. - event on an element by setting the property of the class to `true`. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - If the user clicks on an element that does not currently have input focus, the event will occur after the event, but before the event for that element. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event on an element by setting the property of the class to `true`. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + If the user clicks on an element that does not currently have input focus, the event will occur after the event, but before the event for that element. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet432"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet432"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet432"::: + ]]> onclick Event @@ -383,35 +383,35 @@ Gets the bounds of the client area of the element in the HTML document. The client area occupied by the element, minus any area taken by borders and scroll bars. To obtain the position and dimensions of the element inclusive of its adornments, use instead. - will return position data only for elements that have been assigned an explicit height and width, or elements that use absolute positioning. A document is absolutely positioned if its position style is set to `absolute`, after which it can be positioned at any coordinate on the HTML page. - - - -## Examples - Assume you have loaded the following HTML page into a hosted instance of the control. - -``` - - - - -
- Edit this text. -
- - - - -``` - - The following code example demonstrates retrieving this element and expanding its dimensions if the client area is less than 400 pixels wide by 50 pixels high, and also sets the `DIV` to the `contentEditable` state so that the user can input text. - + will return position data only for elements that have been assigned an explicit height and width, or elements that use absolute positioning. A document is absolutely positioned if its position style is set to `absolute`, after which it can be positioned at any coordinate on the HTML page. + + + +## Examples + Assume you have loaded the following HTML page into a hosted instance of the control. + +``` + + + + +
+ Edit this text. +
+ + + + +``` + + The following code example demonstrates retrieving this element and expanding its dimensions if the client area is less than 400 pixels wide by 50 pixels high, and also sets the `DIV` to the `contentEditable` state so that the user can input text. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet3"::: + ]]>
@@ -482,11 +482,11 @@ Gets the to which this element belongs. The parent document of this element. - . This property is most useful when you have received a reference to an element in an event handler from the , and need to perform some action on the document in which the element resides. - + . This property is most useful when you have received a reference to an element in an event handler from the , and need to perform some action on the document in which the element resides. + ]]> @@ -528,19 +528,19 @@ Gets an unmanaged interface pointer for this element. The COM IUnknown pointer for the element, which you can cast to one of the HTML element interfaces, such as IHTMLElement. - is a wrapper for the Internet Explorer Document Object Model (DOM), which is written using the Component Object Model (COM). If you need to access unexposed properties or methods on the underlying COM interfaces, such as `IHTMLElement`, you can use this object to query for them. - - In order to use the unmanaged interfaces, you will need to import the MSHTML library (mshtml.dll) into your application. However, you can also execute unexposed properties and methods using the `Invoke` method. - -## Examples - The following code example uses unmanaged interfaces to take the currently selected text and convert it into a hyperlink, with the URL chosen by the user. This code was written under the assumption that your form has a control named `WebBrowser1`, and that you have added the unmanaged MSHTML library as a reference to your project. - + is a wrapper for the Internet Explorer Document Object Model (DOM), which is written using the Component Object Model (COM). If you need to access unexposed properties or methods on the underlying COM interfaces, such as `IHTMLElement`, you can use this object to query for them. + + In order to use the unmanaged interfaces, you will need to import the MSHTML library (mshtml.dll) into your application. However, you can also execute unexposed properties and methods using the `Invoke` method. + +## Examples + The following code example uses unmanaged interfaces to take the currently selected text and convert it into a hyperlink, with the URL chosen by the user. This code was written under the assumption that your form has a control named `WebBrowser1`, and that you have added the unmanaged MSHTML library as a reference to your project. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet4"::: + ]]> @@ -573,25 +573,25 @@ Occurs when the user clicks the left mouse button over an element twice, in rapid succession. - event on an element by setting the property of the class to `true`. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event on an element by setting the property of the class to `true`. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet433"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet433"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet433"::: + ]]> ondblclick Event @@ -623,27 +623,27 @@ Occurs when the user drags text to various locations. - control or Internet Explorer. - To another application. - To the Windows desktop. - - You can cancel the default action for a event on an element by setting the property of the class to `true`. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + + You can cancel the default action for a event on an element by setting the property of the class to `true`. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet434"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet434"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet434"::: + ]]> ondrag Event @@ -675,23 +675,23 @@ Occurs when a user finishes a drag operation. - event on an element by setting the property of the class to `true`. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event on an element by setting the property of the class to `true`. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet435"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet435"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet435"::: + ]]> ondragend Event @@ -723,16 +723,16 @@ Occurs when the user is no longer dragging an item over this element. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet436"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet436"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet436"::: + ]]> @@ -763,23 +763,23 @@ Occurs when the user drags text over the element. - event on an element by setting the property of the class to `true`. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event on an element by setting the property of the class to `true`. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet437"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet437"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet437"::: + ]]> ondragover Event @@ -812,11 +812,11 @@ if the element allows user input; otherwise, . - to `false` will prevent the user from using these form fields. For other elements, such as `DIV` or `SPAN`, setting to `false` will cause all text within the element to appear shaded; however, the text will still be selectable. To cancel selection, add an event handler for the unexposed `onselectstart` event using the method. - + to `false` will prevent the user from using these form fields. For other elements, such as `DIV` or `SPAN`, setting to `false` will cause all text within the element to appear shaded; however, the text will still be selectable. To cancel selection, add an event handler for the unexposed `onselectstart` event using the method. + ]]> disabled Property @@ -883,11 +883,11 @@ Gets the next element below this element in the document tree. An representing the first element contained underneath the current element, in source order. - in conjunction with to walk the document tree for an HTML document. - + in conjunction with to walk the document tree for an HTML document. + ]]> firstChild Property @@ -919,13 +919,13 @@ Puts user input focus on the current element. - property of . - - Any key strokes entered by a user after has been called will be sent to that element. - + property of . + + Any key strokes entered by a user after has been called will be sent to that element. + ]]> focus Method @@ -957,25 +957,25 @@ Occurs when the element first receives user input focus. - and events again when the user switches back to your application. - - You cannot cancel the default behavior of this event. To remove focus from an element, call on a different element from within the event. - - A event on an element will also occur on that element's parents and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + and events again when the user switches back to your application. + + You cannot cancel the default behavior of this event. To remove focus from an element, call on a different element from within the event. + + A event on an element will also occur on that element's parents and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet438"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet438"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet438"::: + ]]> onfocusin Event @@ -1011,21 +1011,21 @@ Retrieves the value of the named attribute on the element. The value of this attribute on the element, as a value. If the specified attribute does not exist on this element, returns an empty string. - exposes only those attributes that are common to all elements, leaving out those that only apply to certain types of elements; `SRC` is a predefined attribute for the `IMG` tag, for example, but not for the `DIV` tag. Use and to manipulate attributes not exposed on the managed Document Object Model (DOM). - - and are case-insensitive. - - - -## Examples - The following code example retrieves all of the `META` tags within an HTML document, using to find the `META` tag with the name `Description`. The example requires that your application has a control named `WebBrowser1`. - + exposes only those attributes that are common to all elements, leaving out those that only apply to certain types of elements; `SRC` is a predefined attribute for the `IMG` tag, for example, but not for the `DIV` tag. Use and to manipulate attributes not exposed on the managed Document Object Model (DOM). + + and are case-insensitive. + + + +## Examples + The following code example retrieves all of the `META` tags within an HTML document, using to find the `META` tag with the name `Description`. The example requires that your application has a control named `WebBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlDocument/Overview/Form1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlDocument/VB/Form1.vb" id="Snippet6"::: + ]]> getAttribute Method @@ -1120,33 +1120,33 @@ Occurs when the element has received user input focus. - on a different element from within the event. - - - -## Examples - Save the following HTML code into a file, and load the file into a control in a Windows Forms project. - -``` - - -
- - - - - - -``` - - The following code example prevents the next `INPUT` element in the tab order from receiving user input focus if the previous element contains less than five characters. The example requires that the previously mentioned HTML file is loaded into an instance of the control named `WebBrowser1`. - + on a different element from within the event. + + + +## Examples + Save the following HTML code into a file, and load the file into a control in a Windows Forms project. + +``` + + +
+ + + + + + +``` + + The following code example prevents the next `INPUT` element in the tab order from receiving user input focus if the previous element contains less than five characters. The example requires that the previously mentioned HTML file is loaded into an instance of the control named `WebBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet15"::: + ]]>
onfocus Event @@ -1184,11 +1184,11 @@ Gets or sets a label by which to identify the element. The unique identifier for the element. - must be unique; you cannot have two elements with the same inside of the same document. Use the property to give the same identifier to a group of logically related elements. - + must be unique; you cannot have two elements with the same inside of the same document. Use the property to give the same identifier to a group of logically related elements. + ]]> @@ -1228,21 +1228,21 @@ Gets or sets the HTML markup underneath this element. The HTML markup that defines the child elements of the current element. - and methods. Using is often the fastest way to add new content when you have to set many attributes or styles on your new elements. - - differs from in that will not include the HTML that represents the object you are calling. See for more information about the difference between these two properties. - - Setting destroys any children previously appended to the element. If you retrieve an element from the DOM and then assign new HTML to its parents' property, your reference to that element will be useless, and its behavior when it calls its properties and methods is undefined. - - For some elements, setting is not a valid operation. Some HTML tags have no closing tag, such as the `IMG` tag, and therefore cannot contain nested elements. Some tags, such as the `SCRIPT` tag, can only contain text content; setting will result in an error. For both types of tags, the property will return `false`. However, you also cannot set on `TABLE` and `TR` elements, as assigning malformed HTML to these elements could corrupt the rendering of the document. Use or the `insertRow` and `insertCell` methods on the unmanaged `IHTMLTable` interface to add rows and cells to a `TABLE`. - - If you need only to assign text to an element and not HTML markup, use the property instead. - - Assigning a value to will destroy any text values previously assigned using . - + and methods. Using is often the fastest way to add new content when you have to set many attributes or styles on your new elements. + + differs from in that will not include the HTML that represents the object you are calling. See for more information about the difference between these two properties. + + Setting destroys any children previously appended to the element. If you retrieve an element from the DOM and then assign new HTML to its parents' property, your reference to that element will be useless, and its behavior when it calls its properties and methods is undefined. + + For some elements, setting is not a valid operation. Some HTML tags have no closing tag, such as the `IMG` tag, and therefore cannot contain nested elements. Some tags, such as the `SCRIPT` tag, can only contain text content; setting will result in an error. For both types of tags, the property will return `false`. However, you also cannot set on `TABLE` and `TR` elements, as assigning malformed HTML to these elements could corrupt the rendering of the document. Use or the `insertRow` and `insertCell` methods on the unmanaged `IHTMLTable` interface to add rows and cells to a `TABLE`. + + If you need only to assign text to an element and not HTML markup, use the property instead. + + Assigning a value to will destroy any text values previously assigned using . + ]]> Creating child elements on this element is not allowed. @@ -1285,21 +1285,21 @@ Gets or sets the text assigned to the element. The element's text, absent any HTML markup. If the element contains child elements, only the text in those child elements will be preserved. - , the HTML code will display as literals in the document, just as if you were viewing HTML within a text file. If you assign HTML to an element using the property, will return all of the text in that HTML with the markup removed. - - Assigning a value to will destroy any child elements that belong to the element. - - - -## Examples - The following code creates a new hyperlink using , and assigns text to the link using the property. - + , the HTML code will display as literals in the document, just as if you were viewing HTML within a text file. If you assign HTML to an element using the property, will return all of the text in that HTML with the markup removed. + + Assigning a value to will destroy any child elements that belong to the element. + + + +## Examples + The following code creates a new hyperlink using , and assigns text to the link using the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet8"::: + ]]> The specified element cannot contain text (for example, an IMG element). @@ -1347,21 +1347,21 @@ Insert a new element into the Document Object Model (DOM). The that was just inserted. If insertion failed, this will return . - event on the control has occurred. Calling this method before then can result in an exception, as the document will not have finished loading. - - Whether a value of is valid will depend on the type of the element. For example, is valid if the element is a `DIV`, but not if it is a `SCRIPT` or `IMG` element, neither of which can contain child elements. - - - -## Examples - The following code example inserts a `DIV` element into the top of every page that users view outside of the ADatum.com server. The example requires that your form contains a control named `WebBrowser1`. Your sample must also import the namespace . - + event on the control has occurred. Calling this method before then can result in an exception, as the document will not have finished loading. + + Whether a value of is valid will depend on the type of the element. For example, is valid if the element is a `DIV`, but not if it is a `SCRIPT` or `IMG` element, neither of which can contain child elements. + + + +## Examples + The following code example inserts a `DIV` element into the top of every page that users view outside of the ADatum.com server. The example requires that your form contains a control named `WebBrowser1`. Your sample must also import the namespace . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet9"::: + ]]> insertAdjacentElement Method @@ -1413,11 +1413,11 @@ Executes an unexposed method on the underlying DOM element of this element. The element returned by this method, represented as an . If this is another HTML element, and you have a reference to the unmanaged MSHTML library added to your project, you can cast it to its appropriate unmanaged interface. - to execute unexposed methods that take no arguments. For an example, see . - + to execute unexposed methods that take no arguments. For an example, see . + ]]>
@@ -1466,19 +1466,19 @@ Executes a function defined in the current HTML page by a scripting language. The element returned by the function, represented as an . If this is another HTML element, and you have a reference to the unmanaged MSHTML library added to your project, you can cast it to its appropriate unmanaged interface. - will be converted to Win32 `VARIANT` data types before they are passed to the named scripting function. - - - -## Examples - The following code example gets a `TABLE` called `dataTable` and uses the unexposed `moveRow` method to move a row from the end of the table to the beginning. - + will be converted to Win32 `VARIANT` data types before they are passed to the named scripting function. + + + +## Examples + The following code example gets a `TABLE` called `dataTable` and uses the unexposed `moveRow` method to move a row from the end of the table to the beginning. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet11"::: + ]]>
@@ -1509,25 +1509,25 @@ Occurs when the user presses a key on the keyboard. - occurs before , which in turns occurs before . - - You can cancel the default action for a event on an element by setting the property of the class to `true`. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + occurs before , which in turns occurs before . + + You can cancel the default action for a event on an element by setting the property of the class to `true`. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet442"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet442"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet442"::: + ]]> onkeydown Event @@ -1559,25 +1559,25 @@ Occurs when the user presses and releases a key on the keyboard. - occurs after and before . - - You can cancel the default action for a event on an element by setting the property of the class to `true`. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + occurs after and before . + + You can cancel the default action for a event on an element by setting the property of the class to `true`. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet443"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet443"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet443"::: + ]]> onkeypress Event @@ -1609,25 +1609,25 @@ Occurs when the user releases a key on the keyboard. - occurs after , which occurs after . - - You cannot cancel this event. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + occurs after , which occurs after . + + You cannot cancel this event. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet444"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet444"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet444"::: + ]]> onkeyup Event @@ -1659,16 +1659,16 @@ Occurs when the element is losing user input focus. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet440"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet440"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet440"::: + ]]> @@ -1699,25 +1699,25 @@ Occurs when the element has lost user input focus. - occurs until it is given focus again, either by the user selecting it on the page or by the application calling the method on that element. - - You cannot cancel this event. - - An event on an element will also occur on that element's parents and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + occurs until it is given focus again, either by the user selecting it on the page or by the application calling the method on that element. + + You cannot cancel this event. + + An event on an element will also occur on that element's parents and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet441"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet441"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet441"::: + ]]> onfocusout Event @@ -1749,23 +1749,23 @@ Occurs when the user presses a mouse button. - event on an element by setting the property of the class to `true`. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event on an element by setting the property of the class to `true`. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet446"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet446"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet446"::: + ]]> onmousedown Event @@ -1797,16 +1797,16 @@ Occurs when the user first moves the mouse cursor over the current element. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet449"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet449"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet449"::: + ]]> @@ -1837,16 +1837,16 @@ Occurs when the user moves the mouse cursor off of the current element. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet450"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet450"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet450"::: + ]]> @@ -1877,23 +1877,23 @@ Occurs when the user moves the mouse cursor across the element. - event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet445"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet445"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet445"::: + ]]> onmousemove Event @@ -1925,23 +1925,23 @@ Occurs when the mouse cursor enters the bounds of the element. - event on an element by setting the property of the class to `true`. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event on an element by setting the property of the class to `true`. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet447"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet447"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet447"::: + ]]> onmouseover Event @@ -1973,23 +1973,23 @@ Occurs when the user releases a mouse button. - event on an element by setting the property of the class to `true`. - - A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. - + event on an element by setting the property of the class to `true`. + + A event on an element will also occur on that element's parent elements and on the class itself, unless you set the property of the class to `true`. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `HtmlElement1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet448"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet448"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet448"::: + ]]> onmouseup Event @@ -2035,13 +2035,13 @@ Gets or sets the name of the element. A representing the element's name. - property to retrieve elements from a document using the method on the property of . - - When applied to `INPUT` elements, defines the variable name for that element's data when its form is submitted to the server. - + property to retrieve elements from a document using the method on the property of . + + When applied to `INPUT` elements, defines the variable name for that element's data when its form is submitted to the server. + ]]> name Property @@ -2074,11 +2074,11 @@ Gets the next element at the same level as this element in the document tree. An representing the element to the right of the current element. - in conjunction with to walk the document tree for an HTML element. - + in conjunction with to walk the document tree for an HTML element. + ]]> nextSibling Property @@ -2109,49 +2109,49 @@ Gets the element from which is calculated. - The element from which the offsets are calculated. - + The element from which the offsets are calculated. + If an element's parent or another element in the element's hierarchy uses relative or absolute positioning, will be the first relatively or absolutely positioned element in which the current element is nested. If none of the elements above the current element are absolutely or relatively positioned, will be the BODY tag of the document. - and differ for `span1`, `span2` and `span3`: - -``` - - - -
- Placeholder text 1. -
- -
- Placeholder text 2. -
- -
-
- Placeholder text 3. -
-
- - - -``` - + and differ for `span1`, `span2` and `span3`: + +``` + + + +
+ Placeholder text 1. +
+ +
+ Placeholder text 2. +
+ +
+
+ Placeholder text 3. +
+
+ + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet6"::: + ]]>
offsetParent Property @@ -2181,53 +2181,53 @@ Gets the location of an element relative to its parent. - The x- and y-coordinate positions of the element, and its width and its height, in relation to its parent. - + The x- and y-coordinate positions of the element, and its width and its height, in relation to its parent. + If an element's parent is relatively or absolutely positioned, will return the offset of the parent element. If the element itself is relatively positioned with respect to its parent, will return the offset from its parent. - and differ for `span1`, `span2` and `span3`: - -``` - - - -
- Placeholder text 1. -
- -
- Placeholder text 2. -
- -
-
- Placeholder text 3. -
-
- - - -``` - + and differ for `span1`, `span2` and `span3`: + +``` + + + +
+ Placeholder text 1. +
+ +
+ Placeholder text 2. +
+ +
+
+ Placeholder text 3. +
+
+ + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet6"::: + ]]>
@@ -2271,11 +2271,11 @@ if both parameters are , or if both elements have the same underlying COM interface; otherwise, . - classes. - + classes. + The equivalent method for this operator is ]]>
@@ -2350,63 +2350,63 @@ Gets or sets the current element's HTML code. The HTML code for the current element and its children. - will return all HTML contained in the current element excluding the current element's surrounding tags, includes the current element's tag as well as the HTML that tag contains, for example: - - `` - - `` - - `
` - - `Hello` - - `
` - - `World` - - `
` - - `How are you?` - - `
` - - `
` - - `
` - - `` - - `` - - In this example, calling on `div2` will return: - - `
` - - `World` - - `
` - - `How are you?` - - `
` - - `
` - - Calling will return: - - `World` - - `
` - - `How are you?` - - `
` - - If you assign a new value to , the current element reference will become invalid; it will not reflect the name, properties and child content of the HTML you have just assigned. - + will return all HTML contained in the current element excluding the current element's surrounding tags, includes the current element's tag as well as the HTML that tag contains, for example: + + `` + + `` + + `
` + + `Hello` + + `
` + + `World` + + `
` + + `How are you?` + + `
` + + `
` + + `
` + + `` + + `` + + In this example, calling on `div2` will return: + + `
` + + `World` + + `
` + + `How are you?` + + `
` + + `
` + + Calling will return: + + `World` + + `
` + + `How are you?` + + `
` + + If you assign a new value to , the current element reference will become invalid; it will not reflect the name, properties and child content of the HTML you have just assigned. + ]]>
@@ -2445,13 +2445,13 @@ Gets or sets the current element's text. The text inside the current element, and in the element's children. - , the HTML code will display as literals in the document, just as if you were viewing HTML within a text file. If you assign HTML to an element using the property, will return all of the text in that HTML with the markup removed. - - Assigning a value to will destroy any child elements that belong to the element. - + , the HTML code will display as literals in the document, just as if you were viewing HTML within a text file. If you assign HTML to an element using the property, will return all of the text in that HTML with the markup removed. + + Assigning a value to will destroy any child elements that belong to the element. + ]]> You cannot set text outside of this element. @@ -2486,21 +2486,21 @@ Gets the current element's parent element. The element above the current element in the HTML document's hierarchy. - property enables discovery of an element's context. It is most useful inside of event handlers such as , which can fire for any element anywhere in the document's object hierarchy. - - The property of the HTML element (the top of an HTML document) points back to itself. If you call inside a loop, verify that the loop's break condition compares the type of the current element and the type of the `Parent` property, or else your code may execute an infinite loop. - - - -## Examples - The following code example finds all of the `IMG` tags in a document, and uses the property to test whether the `IMG` is hyperlinked to another page; if it is, the code assigns the URL to the `ALT` attribute of the `IMG` tag, so that users can mouse over the image to see where it will take them. - + property enables discovery of an element's context. It is most useful inside of event handlers such as , which can fire for any element anywhere in the document's object hierarchy. + + The property of the HTML element (the top of an HTML document) points back to itself. If you call inside a loop, verify that the loop's break condition compares the type of the current element and the type of the `Parent` property, or else your code may execute an infinite loop. + + + +## Examples + The following code example finds all of the `IMG` tags in a document, and uses the property to test whether the `IMG` is hyperlinked to another page; if it is, the code assigns the URL to the `ALT` attribute of the `IMG` tag, so that users can mouse over the image to see where it will take them. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet7"::: + ]]> parentElement Property @@ -2535,11 +2535,11 @@ The name of the event to raise. Causes the named event to call all registered event handlers. - class, see [Accessing Unexposed Members on the Managed HTML Document Object Model](/dotnet/framework/winforms/controls/accessing-unexposed-members-on-the-managed-html-document-object-model). - + class, see [Accessing Unexposed Members on the Managed HTML Document Object Model](/dotnet/desktop/winforms/controls/accessing-unexposed-members-on-the-managed-html-document-object-model). + ]]>
@@ -2570,13 +2570,13 @@ Removes focus from the current element, if that element has focus. - event for the element. - - When focus is cleared from an element using this method, it is given to the document containing the element, not to the next element in the tab order. - + event for the element. + + When focus is cleared from an element using this method, it is given to the document containing the element, not to the next element in the tab order. + ]]> blur Method @@ -2611,14 +2611,14 @@ If , the top of the object will be displayed at the top of the window. If , the bottom of the object will be displayed at the bottom of the window. Scrolls through the document containing this element until the top or bottom edge of this element is aligned with the document's window. - scrollIntoView Method @@ -2650,11 +2650,11 @@ Gets or sets the distance between the edge of the element and the left edge of its content. The distance, in pixels, between the left edge of the element and the left edge of its content. - ; `ScrollLeft` and are exposed independently because these are the only two properties of the scroll area that developers can set. - + ; `ScrollLeft` and are exposed independently because these are the only two properties of the scroll area that developers can set. + ]]> scrollLeft Property @@ -2686,13 +2686,13 @@ Gets the dimensions of an element's scrollable region. The size and coordinate location of the scrollable area of an element. - and properties to achieve this. - + and properties to achieve this. + ]]> scrollLeft Property @@ -2727,11 +2727,11 @@ Gets or sets the distance between the edge of the element and the top edge of its content. The distance, in pixels, between the top edge of the element and the top edge of its content. - ; and `ScrollTop` are exposed independently because these are the only two properties of the scroll area that developers can set. - + ; and `ScrollTop` are exposed independently because these are the only two properties of the scroll area that developers can set. + ]]> scrollTop Property @@ -2768,25 +2768,25 @@ The new value of this attribute. Sets the value of the named attribute on the element. - exposes only those attributes that are common to all elements, leaving out those that only apply to certain types of elements; `SRC` is a predefined attribute for the `IMG` tag, for example, but not for the `DIV` tag. Use and to manipulate attributes not exposed on the managed Document Object Model (DOM). - - If `attributeName` is not a defined attribute on an element, will define it on the element as a new attribute. - - and are case-insensitive. - - To set the `class` attribute on an , you must refer to the attribute as `className` when specifying the first argument to - - - -## Examples - The following code example adds a new `IMG` element to the current document, using to set the `SRC` attribute for the image. - + exposes only those attributes that are common to all elements, leaving out those that only apply to certain types of elements; `SRC` is a predefined attribute for the `IMG` tag, for example, but not for the `DIV` tag. Use and to manipulate attributes not exposed on the managed Document Object Model (DOM). + + If `attributeName` is not a defined attribute on an element, will define it on the element as a new attribute. + + and are case-insensitive. + + To set the `class` attribute on an , you must refer to the attribute as `className` when specifying the first argument to + + + +## Examples + The following code example adds a new `IMG` element to the current document, using to set the `SRC` attribute for the image. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet13"::: + ]]> setAttribute Method @@ -2824,19 +2824,19 @@ Gets or sets a semicolon-delimited list of styles for the current element. A string consisting of all of the element's styles. - property take the form of colon-delimited name-value pairs, with each pair separated by a semicolon, as follows: - - `style-name1:value1;...;[style-nameN:valueN;]` - - To set the font for a `DIV` element to 14-point Times New Roman bold, for example, you would assign the following string: - - `font-face:Times New Roman;font-size:14px;font-weight:bold;` - - For a full list of all available styles in the HTML DOM, see [STYLE Attribute](https://developer.mozilla.org/en-us/docs/web/html/global_attributes/style). - + property take the form of colon-delimited name-value pairs, with each pair separated by a semicolon, as follows: + + `style-name1:value1;...;[style-nameN:valueN;]` + + To set the font for a `DIV` element to 14-point Times New Roman bold, for example, you would assign the following string: + + `font-face:Times New Roman;font-size:14px;font-weight:bold;` + + For a full list of all available styles in the HTML DOM, see [STYLE Attribute](https://developer.mozilla.org/en-us/docs/web/html/global_attributes/style). + ]]> @@ -2867,13 +2867,13 @@ Gets or sets the location of this element in the tab order. The numeric index of the element in the tab order. - determines which element in an HTML document will next receive focus when the user presses the TAB key. By default, the only elements included in the tab order are `INPUT` elements, the `SELECT` control, and any element whose `contentEditable` property is set to `true`. You can include any HTML element in the tab order, such as a `DIV`, by assigning it an explicit . - - Valid values for range from -32767 to 32767. - + determines which element in an HTML document will next receive focus when the user presses the TAB key. By default, the only elements included in the tab order are `INPUT` elements, the `SELECT` control, and any element whose `contentEditable` property is set to `true`. You can include any HTML element in the tab order, such as a `DIV`, by assigning it an explicit . + + Valid values for range from -32767 to 32767. + ]]> tabIndex Property @@ -2911,19 +2911,19 @@ Gets the name of the HTML tag. The name used to create this element using HTML markup. - when you have an element of a potentially arbitrary type, and need to perform a type-specific operation. - - - -## Examples - The following code example finds all of the `IMG` tags in a document, and uses the `TagName` property to test whether the `IMG` is hyperlinked to another page; if it is, the code assigns the URL to the `ALT` attribute of the `IMG` tag, so that users can mouse over the image to see where it will take them. - + when you have an element of a potentially arbitrary type, and need to perform a type-specific operation. + + + +## Examples + The following code example finds all of the `IMG` tags in a document, and uses the `TagName` property to test whether the `IMG` is hyperlinked to another page; if it is, the code assigns the URL to the `ALT` attribute of the `IMG` tag, so that users can mouse over the image to see where it will take them. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/HtmlElement/Overview/Form1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.HtmlElement/VB/Form1.vb" id="Snippet7"::: + ]]> diff --git a/xml/System.Windows.Forms/HtmlWindow.xml b/xml/System.Windows.Forms/HtmlWindow.xml index 50bbc82cca8..28eb2c76a4f 100644 --- a/xml/System.Windows.Forms/HtmlWindow.xml +++ b/xml/System.Windows.Forms/HtmlWindow.xml @@ -1506,7 +1506,7 @@ The following example displays a
- Windows Forms Coordinates + Windows Forms Coordinates screenLeft Property screenTop Property diff --git a/xml/System.Windows.Forms/IDataGridViewEditingCell.xml b/xml/System.Windows.Forms/IDataGridViewEditingCell.xml index 2ca87015c06..2af622603a3 100644 --- a/xml/System.Windows.Forms/IDataGridViewEditingCell.xml +++ b/xml/System.Windows.Forms/IDataGridViewEditingCell.xml @@ -21,15 +21,15 @@ Defines common functionality for a cell that allows the manipulation of its value. - that derive from and provide a user interface (UI) for specifying values without hosting an editing control. The UI in this case is displayed regardless of whether the cell is in edit mode. - - Other cell types, such as , provide a UI but do not store user-specified values. In this case, the cell type does not implement or host an editing control. - - Cell types that display an editing control when the cell is in edit mode, such as , do not implement but instead provide a companion class that implements . For example, provides a that derives from the control and implements . In this case, the cell property is set to a object representing the editing control type. For information about implementing , see [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/framework/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). - + that derive from and provide a user interface (UI) for specifying values without hosting an editing control. The UI in this case is displayed regardless of whether the cell is in edit mode. + + Other cell types, such as , provide a UI but do not store user-specified values. In this case, the cell type does not implement or host an editing control. + + Cell types that display an editing control when the cell is in edit mode, such as , do not implement but instead provide a companion class that implements . For example, provides a that derives from the control and implements . In this case, the cell property is set to a object representing the editing control type. For information about implementing , see [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/desktop/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). + ]]> @@ -65,13 +65,13 @@ Gets or sets the formatted value of the cell. An that contains the cell's value. - method and passing in the value. - + method and passing in the value. + ]]> @@ -106,11 +106,11 @@ if the value of the cell has changed; otherwise, . - @@ -149,13 +149,13 @@ Retrieves the formatted value of the cell. An that represents the formatted version of the cell contents. - property. - + property. + ]]> @@ -195,11 +195,11 @@ to select the cell contents; otherwise, . Prepares the currently selected cell for editing. - diff --git a/xml/System.Windows.Forms/IDataGridViewEditingControl.xml b/xml/System.Windows.Forms/IDataGridViewEditingControl.xml index b76e8277935..f4bb9921b7f 100644 --- a/xml/System.Windows.Forms/IDataGridViewEditingControl.xml +++ b/xml/System.Windows.Forms/IDataGridViewEditingControl.xml @@ -21,35 +21,35 @@ Defines common functionality for controls that are hosted within cells of a . - and , that are hosted by corresponding cells, such as and , when they are in edit mode. - - Cell types that can host editing controls set their property to a representing the editing control type. When the cell enters edit mode, the following steps are performed: - -1. The control creates an instance of the editing control type. - -2. The control calls the cell method. You can override this method to transfer the cell value to the editing control. - -3. The control calls the editing control method and passes in the cell's current style. You can implement this method to initialize the appearance of the editing control so that it matches the appearance of the cell. - -4. The control calls the editing control method. You can implement this method to make final adjustments to the editing control, such as selecting the control value. - - For more information about implementing , see [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/framework/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). - - Cell types such as that provide a user interface (UI) for specifying values without hosting an editing control implement the interface. The UI in this case is displayed regardless of whether the cell is in edit mode. - - Other cell types, such as , provide a UI but do not store user-specified values. In this case, the cell type does not implement or host an editing control. - - - -## Examples - The following code example provides an implementation of this interface that derives from . This example is part of a larger example available in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/framework/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). - + and , that are hosted by corresponding cells, such as and , when they are in edit mode. + + Cell types that can host editing controls set their property to a representing the editing control type. When the cell enters edit mode, the following steps are performed: + +1. The control creates an instance of the editing control type. + +2. The control calls the cell method. You can override this method to transfer the cell value to the editing control. + +3. The control calls the editing control method and passes in the cell's current style. You can implement this method to initialize the appearance of the editing control so that it matches the appearance of the cell. + +4. The control calls the editing control method. You can implement this method to make final adjustments to the editing control, such as selecting the control value. + + For more information about implementing , see [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/desktop/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). + + Cell types such as that provide a user interface (UI) for specifying values without hosting an editing control implement the interface. The UI in this case is displayed regardless of whether the cell is in edit mode. + + Other cell types, such as , provide a UI but do not store user-specified values. In this case, the cell type does not implement or host an editing control. + + + +## Examples + The following code example provides an implementation of this interface that derives from . This example is part of a larger example available in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/desktop/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/EditingControl/datagridviewcalendarcolumn.cs" id="Snippet300"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCalendarColumn/VB/datagridviewcalendarcolumn.vb" id="Snippet300"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCalendarColumn/VB/datagridviewcalendarcolumn.vb" id="Snippet300"::: + ]]> @@ -60,7 +60,7 @@ - How to: Host Controls in Windows Forms DataGridView Cells + How to: Host Controls in Windows Forms DataGridView Cells @@ -92,19 +92,19 @@ The to use as the model for the UI. Changes the control's user interface (UI) to be consistent with the specified cell style. - @@ -173,19 +173,19 @@ Gets or sets the formatted value of the cell being modified by the editor. An that represents the formatted value of the cell. - @@ -219,11 +219,11 @@ Gets or sets the index of the hosting cell's parent row. The index of the row that contains the cell, or -1 if there is no parent row. - interface does not define a corresponding `ColumnIndex` property. You can use the property to retrieve the parent control and use the property to determine the row and column indexes of the active cell. - + interface does not define a corresponding `ColumnIndex` property. You can use the property to retrieve the parent control and use the property to determine the row and column indexes of the active cell. + ]]> @@ -258,11 +258,11 @@ if the value of the control differs from the cell value; otherwise, . - property is set to `true` to indicate that the hosting cell's state has changed and its user interface (UI) needs to be updated to reflect this change in value. The owning cell or table will reset this property to `false` after an update. - + property is set to `true` to indicate that the hosting cell's state has changed and its user interface (UI) needs to be updated to reflect this change in value. The owning cell or table will reset this property to `false` after an update. + ]]> @@ -307,21 +307,21 @@ if the specified key is a regular input key that should be handled by the editing control; otherwise, . - . - - The method is called by the . The will pass in `true` for `dataGridViewWantsInputKey` when it can process the `keyData`. If the editing control can let the handle the `keyData`, should return `false` when `dataGridViewWantsInputKey` is `true`. Other implementations of may ignore a `dataGridViewWantsInputKey` value of `true` and handle the `keyData` in the editing control. - - - -## Examples - The following code example provides an implementation of this member. This example is part of a larger example available in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/framework/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). - + . + + The method is called by the . The will pass in `true` for `dataGridViewWantsInputKey` when it can process the `keyData`. If the editing control can let the handle the `keyData`, should return `false` when `dataGridViewWantsInputKey` is `true`. Other implementations of may ignore a `dataGridViewWantsInputKey` value of `true` and handle the `keyData` in the editing control. + + + +## Examples + The following code example provides an implementation of this member. This example is part of a larger example available in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/desktop/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/EditingControl/datagridviewcalendarcolumn.cs" id="Snippet305"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCalendarColumn/VB/datagridviewcalendarcolumn.vb" id="Snippet305"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCalendarColumn/VB/datagridviewcalendarcolumn.vb" id="Snippet305"::: + ]]> @@ -353,19 +353,19 @@ Gets the cursor used when the mouse pointer is over the but not over the editing control. A that represents the mouse pointer used for the editing panel. - that hosts the editing control when the control is in edit mode. The actual editing control may not cover the entire area of the editing panel. In this case, the implementation should return the cursor to use when the mouse pointer is over the panel but not over the control. Typically, you will want to return the same cursor that the control uses. If you want to change the cursor that appears when the pointer is over the control, you must set the property. You can set this in the constructor of the implementation, or you can set it in the implementation. - - - -## Examples - The following code example provides an implementation of this member. This example is part of a larger example available in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/framework/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). - + that hosts the editing control when the control is in edit mode. The actual editing control may not cover the entire area of the editing panel. In this case, the implementation should return the cursor to use when the mouse pointer is over the panel but not over the control. Typically, you will want to return the same cursor that the control uses. If you want to change the cursor that appears when the pointer is over the control, you must set the property. You can set this in the constructor of the implementation, or you can set it in the implementation. + + + +## Examples + The following code example provides an implementation of this member. This example is part of a larger example available in [How to: Host Controls in Windows Forms DataGridView Cells](/dotnet/desktop/winforms/controls/how-to-host-controls-in-windows-forms-datagridview-cells). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DataGridView/EditingControl/datagridviewcalendarcolumn.cs" id="Snippet311"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCalendarColumn/VB/datagridviewcalendarcolumn.vb" id="Snippet311"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.DataGridViewCalendarColumn/VB/datagridviewcalendarcolumn.vb" id="Snippet311"::: + ]]> @@ -404,13 +404,13 @@ Retrieves the formatted value of the cell. An that represents the formatted version of the cell contents. - property. - + property. + ]]> @@ -451,11 +451,11 @@ to select all of the cell's content; otherwise, . Prepares the currently selected cell for editing. - @@ -488,11 +488,11 @@ if the contents need to be repositioned; otherwise, . - diff --git a/xml/System.Windows.Forms/LayoutSettings.xml b/xml/System.Windows.Forms/LayoutSettings.xml index 538e128561c..10870b9efe4 100644 --- a/xml/System.Windows.Forms/LayoutSettings.xml +++ b/xml/System.Windows.Forms/LayoutSettings.xml @@ -29,19 +29,19 @@ Provides a base class for collecting layout scheme characteristics. - class is the base class for types that collect the various characteristics common to a specific user interface (UI) layout scheme, such as and . - - - -## Examples - The following example shows how to initialize a object for a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/framework/winforms/controls/how-to-implement-a-custom-toolstriprenderer). - + class is the base class for types that collect the various characteristics common to a specific user interface (UI) layout scheme, such as and . + + + +## Examples + The following example shows how to initialize a object for a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/desktop/winforms/controls/how-to-implement-a-custom-toolstriprenderer). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: + ]]> @@ -107,11 +107,11 @@ Gets the current table layout engine. The currently being used. - property is typically used in two contexts: the container that uses a layout scheme, and the child control of the container to which the layout scheme is applied. - + property is typically used in two contexts: the container that uses a layout scheme, and the child control of the container to which the layout scheme is applied. + ]]> diff --git a/xml/System.Windows.Forms/ListView.xml b/xml/System.Windows.Forms/ListView.xml index 5430b03c8b3..9e9150d10db 100644 --- a/xml/System.Windows.Forms/ListView.xml +++ b/xml/System.Windows.Forms/ListView.xml @@ -3315,7 +3315,7 @@ When this property is set to `false`, selected items in the insertion mark feature lets you visually indicate the expected drop location in a drag-and-drop operation when an item is dragged to a new position. This feature works only when the property is set to `true` and when the control does not sort the items automatically. To prevent automatic sorting, the property must be set to and the property must be set to , , or . Additionally, the insertion mark feature may not be visible with the grouping feature because the grouping feature orders the items by group membership. - The class is typically used in a handler for the or event to update the position of the insertion mark as an item is dragged. It is also used in a handler for the or event to insert a dragged item at the correct location. For more information, see and [How to: Display an Insertion Mark in a Windows Forms ListView Control](/dotnet/framework/winforms/controls/how-to-display-an-insertion-mark-in-a-windows-forms-listview-control). + The class is typically used in a handler for the or event to update the position of the insertion mark as an item is dragged. It is also used in a handler for the or event to insert a dragged item at the correct location. For more information, see and [How to: Display an Insertion Mark in a Windows Forms ListView Control](/dotnet/desktop/winforms/controls/how-to-display-an-insertion-mark-in-a-windows-forms-listview-control). > [!NOTE] > The insertion mark feature is available only on Windows XP and Windows Server 2003 when your application calls the method. On earlier operating systems, any code relating to the insertion mark has no effect and the insertion mark will not appear. As a result, any code that depends on the insertion mark feature might not work correctly. You might want to include code that determines whether this feature is available, and provide alternate functionality when it is unavailable. For example, you might want to bypass all code that implements drag-and-drop item repositioning when running on operating systems that do not support insertion marks. diff --git a/xml/System.Windows.Forms/ListViewItem.xml b/xml/System.Windows.Forms/ListViewItem.xml index e8708ecb2aa..678f3f297af 100644 --- a/xml/System.Windows.Forms/ListViewItem.xml +++ b/xml/System.Windows.Forms/ListViewItem.xml @@ -61,47 +61,47 @@ Represents an item in a control. - control is similar to a in that it displays a list of items. The main difference is that the control provides a number of different ways items can be viewed by the user. The class defines the appearance, behavior, and data associated with an item that is displayed in the control. objects can be displayed in the control in one of four different views. Items can be displayed as large or small icons or as small icons in a vertical list. Items can also have subitems that contain information that is related to the parent item. The fourth view style, details view, allows you to display the item and its subitems in a grid with column headers that can be used to identify the information being displayed in a subitem. - - Most of the properties of the class provide ways to change the display of the item in the control it is associated with. The , , and properties allow you to change how the text of the item is displayed in the control. The property allows you to specify the image to load from the that is assigned to the control (by setting the or properties of the ). Items can display check boxes in order to obtain item choices from the user in a way similar to a control. You can use the property to determine if an item is checked, or to select or clear the check box at run time. Items can display any number of subitems when the property of the associated control is set to and columns are defined in the of the control. You can add subitems to an item by calling the method of the class. The property allows you to gain access to the class and its members. - - Some of the properties and methods of the class are item-specific versions of properties and methods in the control. For example, the method is similar to the version of the method, but the version affects only the current item. - - The class also provides methods that are not versions of methods. The method places the item's text into edit mode so the user can change the item's text (when the property of the control is set to `true`). The method allows you to create copies of existing objects to reuse in other controls. - - - -## Examples - The following code example creates a control with three objects specified and three objects specified for each item. The example also creates objects to display the subitems in details view. Two objects are also created in the code example to provide images for the objects. These objects are added to the and properties. The example uses the following properties in creating the control: - -- - -- - -- - -- - -- - -- - -- - - You need to add the code to a and call the method created in the example from the constructor or another method on the form. The example requires that images named `MySmallImage1`, `MySmallImage2`, `MyLargeImage1`, and `MyLargeImage2` are located in the root directory of drive C. - + control is similar to a in that it displays a list of items. The main difference is that the control provides a number of different ways items can be viewed by the user. The class defines the appearance, behavior, and data associated with an item that is displayed in the control. objects can be displayed in the control in one of four different views. Items can be displayed as large or small icons or as small icons in a vertical list. Items can also have subitems that contain information that is related to the parent item. The fourth view style, details view, allows you to display the item and its subitems in a grid with column headers that can be used to identify the information being displayed in a subitem. + + Most of the properties of the class provide ways to change the display of the item in the control it is associated with. The , , and properties allow you to change how the text of the item is displayed in the control. The property allows you to specify the image to load from the that is assigned to the control (by setting the or properties of the ). Items can display check boxes in order to obtain item choices from the user in a way similar to a control. You can use the property to determine if an item is checked, or to select or clear the check box at run time. Items can display any number of subitems when the property of the associated control is set to and columns are defined in the of the control. You can add subitems to an item by calling the method of the class. The property allows you to gain access to the class and its members. + + Some of the properties and methods of the class are item-specific versions of properties and methods in the control. For example, the method is similar to the version of the method, but the version affects only the current item. + + The class also provides methods that are not versions of methods. The method places the item's text into edit mode so the user can change the item's text (when the property of the control is set to `true`). The method allows you to create copies of existing objects to reuse in other controls. + + + +## Examples + The following code example creates a control with three objects specified and three objects specified for each item. The example also creates objects to display the subitems in details view. Two objects are also created in the code example to provide images for the objects. These objects are added to the and properties. The example uses the following properties in creating the control: + +- + +- + +- + +- + +- + +- + +- + + You need to add the code to a and call the method created in the example from the constructor or another method on the form. The example requires that images named `MySmallImage1`, `MySmallImage2`, `MyLargeImage1`, and `MyLargeImage2` are located in the root directory of drive C. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ListViewExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView+ColumnHeaderCollection/Add/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ListViewExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ListViewExample/VB/form1.vb" id="Snippet1"::: + ]]> - ListView Control (Windows Forms) + ListView Control (Windows Forms) @@ -136,31 +136,31 @@ Initializes a new instance of the class with default values. - control with three objects specified and three objects specified for each item. The example also creates objects to display the subitems in details view. Two objects are also created in the code example to provide images for the objects. These objects are added to the and properties. The example uses the following properties in creating the control: - -- - -- - -- - -- - -- - -- - -- - - You need to add the code to a and call the method created in the example from the constructor or another method on the form. The example requires that images named `MySmallImage1`, `MySmallImage2`, `MyLargeImage1`, and `MyLargeImage2` are located in the root directory of drive C. - + control with three objects specified and three objects specified for each item. The example also creates objects to display the subitems in details view. Two objects are also created in the code example to provide images for the objects. These objects are added to the and properties. The example uses the following properties in creating the control: + +- + +- + +- + +- + +- + +- + +- + + You need to add the code to a and call the method created in the example from the constructor or another method on the form. The example requires that images named `MySmallImage1`, `MySmallImage2`, `MyLargeImage1`, and `MyLargeImage2` are located in the root directory of drive C. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ListViewExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView+ColumnHeaderCollection/Add/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ListViewExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ListViewExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -199,11 +199,11 @@ The text to display for the item. This should not exceed 259 characters. Initializes a new instance of the class with the specified item text. - should not exceed 259 characters or unexpected behavior could occur. - + should not exceed 259 characters or unexpected behavior could occur. + ]]> @@ -278,14 +278,14 @@ The to assign the item to. Initializes a new instance of the class and assigns it to the specified group. - [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + ]]> @@ -352,11 +352,11 @@ The zero-based index of the image within the associated with the that contains the item. Initializes a new instance of the class with the specified item text and the image index position of the item's icon. - should not exceed 259 characters or unexpected behavior could occur. - + should not exceed 259 characters or unexpected behavior could occur. + ]]> @@ -392,13 +392,13 @@ The name of the image within the of the owning to display in the . Initializes a new instance of the class with the specified text and image. - associated with the owning control, which can be accessed with the property. - - The text of the should not exceed 259 characters or unexpected behavior could occur. - + associated with the owning control, which can be accessed with the property. + + The text of the should not exceed 259 characters or unexpected behavior could occur. + ]]> @@ -432,16 +432,16 @@ The to assign the item to. Initializes a new instance of the class with the specified item text and assigns it to the specified group. - [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - - The text of the should not exceed 259 characters or unexpected behavior could occur. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + + The text of the should not exceed 259 characters or unexpected behavior could occur. + ]]> @@ -525,11 +525,11 @@ The name of the image within the of the owning to display in the . Initializes a new instance of the class with the specified item and subitem text and image. - associated with the owning control, which can be accessed with the property. - + associated with the owning control, which can be accessed with the property. + ]]> @@ -570,14 +570,14 @@ The to assign the item to. Initializes a new instance of the class with an array of strings representing subitems, and assigns the item to the specified group. - [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + ]]> @@ -613,11 +613,11 @@ The zero-based index of the image within the associated with the that contains the item. Initializes a new instance of the class with the image index position of the item's icon and an array of objects. - objects before adding them to a (for example, to indicate special formatting or to use the subitems in multiple items). - + objects before adding them to a (for example, to indicate special formatting or to use the subitems in multiple items). + ]]> @@ -661,11 +661,11 @@ The name of the image within the of the owning to display in the . Initializes a new instance of the class with the specified subitems and image. - associated with the owning control, which can be accessed with the property. - + associated with the owning control, which can be accessed with the property. + ]]> @@ -701,16 +701,16 @@ The to assign the item to. Initializes a new instance of the class with the specified item text and the image index position of the item's icon, and assigns the item to the specified group. - [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - - The text of the should not exceed 259 characters or unexpected behavior could occur. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + + The text of the should not exceed 259 characters or unexpected behavior could occur. + ]]> @@ -749,18 +749,18 @@ The to assign the item to. Initializes a new instance of the class with the specified text, image, and group. - associated with the owning control, which can be accessed with the property. - + associated with the owning control, which can be accessed with the property. + > [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - - The text of the should not exceed 259 characters or unexpected behavior could occur. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + + The text of the should not exceed 259 characters or unexpected behavior could occur. + ]]> @@ -803,14 +803,14 @@ The to assign the item to. Initializes a new instance of the class with the image index position of the item's icon and an array of strings representing subitems, and assigns the item to the specified group. - [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + ]]> @@ -856,16 +856,16 @@ The to assign the item to. Initializes a new instance of the class with subitems containing the specified text, image, and group. - associated with the owning control, which can be accessed with the property. - + associated with the owning control, which can be accessed with the property. + > [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + ]]> @@ -908,14 +908,14 @@ The to assign the item to. Initializes a new instance of the class with the image index position of the item's icon and an array of objects, and assigns the item to the specified group. - objects before adding them to a object (for example, to indicate special formatting or to use the subitems in multiple items). It also allows you to specify the group to which an item belongs. - + objects before adding them to a object (for example, to indicate special formatting or to use the subitems in multiple items). It also allows you to specify the group to which an item belongs. + > [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + ]]> @@ -962,16 +962,16 @@ The to assign the item to. Initializes a new instance of the class with the specified subitems, image, and group. - objects before adding them to a (for example, to indicate special formatting or to use the subitems in multiple items). It also allows you to specify the group to which an item belongs. - - The `imageKey` parameter specifies an image in the associated with the owning control, which can be accessed with the property. - + objects before adding them to a (for example, to indicate special formatting or to use the subitems in multiple items). It also allows you to specify the group to which an item belongs. + + The `imageKey` parameter specifies an image in the associated with the owning control, which can be accessed with the property. + > [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + ]]> @@ -1019,15 +1019,15 @@ A that represents the font to display the item's text in. Initializes a new instance of the class with the image index position of the item's icon; the foreground color, background color, and font of the item; and an array of strings representing subitems. - control that manually sorts items when a column in the control is clicked. The example defines a class called `ListViewItemComparer` that implements the interface that performs the comparison. The example creates an instance of `ListViewItemComparer` and uses it to set the property of the control. The method call in the event handler uses the methods defined in `ListViewItemComparer` to perform the sort of items, based on the column that is clicked. - + control that manually sorts items when a column in the control is clicked. The example defines a class called `ListViewItemComparer` that implements the interface that performs the comparison. The example creates an instance of `ListViewItemComparer` and uses it to set the property of the control. The method call in the event handler uses the methods defined in `ListViewItemComparer` to perform the sort of items, based on the column that is clicked. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ListView.ColumnClick/CPP/listviewsort1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView+ColumnHeaderCollection/Overview/listviewsort1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ListView.ColumnClick/VB/listviewsort1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ListView.ColumnClick/VB/listviewsort1.vb" id="Snippet1"::: + ]]> @@ -1078,11 +1078,11 @@ A to apply to the item text. Initializes a new instance of the class with the subitems containing the specified text, image, colors, and font. - associated with the owning control, which can be accessed with the property. - + associated with the owning control, which can be accessed with the property. + ]]> @@ -1131,14 +1131,14 @@ The to assign the item to. Initializes a new instance of the class with the image index position of the item's icon; the foreground color, background color, and font of the item; and an array of strings representing subitems. Assigns the item to the specified group. - [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + ]]> @@ -1192,16 +1192,16 @@ The to assign the item to. Initializes a new instance of the class with the subitems containing the specified text, image, colors, font, and group. - associated with the owning control, which can be accessed with the property. - + associated with the owning control, which can be accessed with the property. + > [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + ]]> @@ -1243,13 +1243,13 @@ Gets or sets the background color of the item's text. A that represents the background color of the item's text. - property to change the color displayed behind the item text. This property can be used if you want to use different background and foreground color combinations (using the property to set the foreground color) to differentiate one item from another. For example, you could set the property to to identify items that have failed validation or are missing subitem information. - - If you want to use the same background color for all subitems of an item, set the property to `true`. This will cause the colors and fonts specified for the item to be used for all subitem text. - + property to change the color displayed behind the item text. This property can be used if you want to use different background and foreground color combinations (using the property to set the foreground color) to differentiate one item from another. For example, you could set the property to to identify items that have failed validation or are missing subitem information. + + If you want to use the same background color for all subitems of an item, set the property to `true`. This will cause the colors and fonts specified for the item to be used for all subitem text. + ]]> @@ -1283,11 +1283,11 @@ Places the item text into edit mode. - property of the control that contains the item is set to `true`. You can use this method at run time to force the item's text to display in edit mode. For example, if you are validating the item text edited by the user, and an item fails validation, you could select the item in the control and call the method to force the user to change the text that failed validation. - + property of the control that contains the item is set to `true`. You can use this method at run time to force the item's text to display in edit mode. For example, if you are validating the item text edited by the user, and an item fails validation, you could select the item in the control and call the method to force the user to change the text that failed validation. + ]]> The property of the associated is not set to . @@ -1326,15 +1326,15 @@ Gets the bounding rectangle of the item, including subitems. A that represents the bounding rectangle of the item. - method. The class provides a method that allows you to get the bounding rectangle of any item located within the control. - - The returned bounding rectangle uses client control coordinates that are relative to the top-left corner of the currently visible area of the containing . If the is scrollable and positioned so that the is not visible, the coordinates returned may be negative. - - When the property has a value of , the width of the bounding rectangle is the width of the column containing the item, not the width of the text in the item. If the collection does not contain any columns, the default column width of 60 pixels is used. - + method. The class provides a method that allows you to get the bounding rectangle of any item located within the control. + + The returned bounding rectangle uses client control coordinates that are relative to the top-left corner of the currently visible area of the containing . If the is scrollable and positioned so that the is not visible, the coordinates returned may be negative. + + When the property has a value of , the width of the bounding rectangle is the width of the column containing the item, not the width of the text in the item. If the collection does not contain any columns, the default column width of 60 pixels is used. + ]]> @@ -1383,36 +1383,36 @@ if the item is checked; otherwise, . The default is . - property of the control the item is contained in is set to `true`. You can use this property to determine if the item has been checked by the user or through code at run time. To determine all the items that are checked in a control, you can use the property. To take action when an item has been checked, you can create an event handler for the property of the control. - - - -## Examples - The following code example creates a control with three objects specified and three objects specified for each item. The example also creates objects to display the subitems in details view. Two objects are also created in the code example to provide images for the objects. These objects are added to the and properties. The example uses the following properties in creating the control: - -- - -- - -- - -- - -- - -- - -- - - You need to add the code to a and call the method created in the example from the constructor or another method on the form. The example requires that images named `MySmallImage1`, `MySmallImage2`, `MyLargeImage1`, and `MyLargeImage2` are located in the root directory of drive C. - + property of the control the item is contained in is set to `true`. You can use this property to determine if the item has been checked by the user or through code at run time. To determine all the items that are checked in a control, you can use the property. To take action when an item has been checked, you can create an event handler for the property of the control. + + + +## Examples + The following code example creates a control with three objects specified and three objects specified for each item. The example also creates objects to display the subitems in details view. Two objects are also created in the code example to provide images for the objects. These objects are added to the and properties. The example uses the following properties in creating the control: + +- + +- + +- + +- + +- + +- + +- + + You need to add the code to a and call the method created in the example from the constructor or another method on the form. The example requires that images named `MySmallImage1`, `MySmallImage2`, `MyLargeImage1`, and `MyLargeImage2` are located in the root directory of drive C. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ListViewExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView+ColumnHeaderCollection/Add/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ListViewExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ListViewExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1451,11 +1451,11 @@ Creates an identical copy of the item. An object that represents an item that has the same text, image, and subitems associated with it as the cloned item. - class based on an existing item. Even the subitems of the item being cloned are specified for the new version. This feature is useful if you want to reuse a in more than one control. - + class based on an existing item. Even the subitems of the item being cloned are specified for the new version. This feature is useful if you want to reuse a in more than one control. + ]]> @@ -1527,13 +1527,13 @@ Ensures that the item is visible within the control, scrolling the contents of the control, if necessary. - control. This method can be used when performing validation on the item. You can call the method to ensure that the item is displayed in the control if it failed validation, to allow the user to perform changes on the item. - - This method is similar to the method of the control. - + control. This method can be used when performing validation on the item. You can call the method to ensure that the item is displayed in the control if it failed validation, to allow the user to perform changes on the item. + + This method is similar to the method of the control. + ]]> @@ -1570,21 +1570,21 @@ Finds the next item from the , searching in the specified direction. The that is closest to the given coordinates, searching in the specified direction. - method returns `null` if no item is found in the given direction. - - Identifying the nearest item can vary depending on the operating system the application is running on and will affect the results of . - - - -## Examples - The following code example demonstrates how to use the method. To run this example, paste the following code into a Windows Form that contains a named `findListView`. Ensure that the property is set to an icon view and that the is populated with items. Associate the event of `findListView` with the `findListView_MouseDown` method in this example. - + method returns `null` if no item is found in the given direction. + + Identifying the nearest item can vary depending on the operating system the application is running on and will affect the results of . + + + +## Examples + The following code example demonstrates how to use the method. To run this example, paste the following code into a Windows Form that contains a named `findListView`. Ensure that the property is set to an icon view and that the is populated with items. Associate the event of `findListView` with the `findListView_MouseDown` method in this example. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView/ShowItemToolTips/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemWhidbeyMembers/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemWhidbeyMembers/VB/form1.vb" id="Snippet1"::: + ]]> The property of the containing is set to a value other than or . @@ -1632,13 +1632,13 @@ if the item has focus; otherwise, . - control does not have directly editable areas - only items contained in the can be edited - the text of an item in the will display the focus reticle when the has focus. Typically, the last selected item in the control is the item with focus. Although an item may display the focus reticle, it might not actually be a selected item in the . You can use the property to determine if the item is currently the focused item in the control that contains it. If the is not associated with a control, this property will return `false`. - - The control provides the property to allow you to determine which in the has the focus. - + control does not have directly editable areas - only items contained in the can be edited - the text of an item in the will display the focus reticle when the has focus. Typically, the last selected item in the control is the item with focus. Although an item may display the focus reticle, it might not actually be a selected item in the . You can use the property to determine if the item is currently the focused item in the control that contains it. If the is not associated with a control, this property will return `false`. + + The control provides the property to allow you to determine which in the has the focus. + ]]> @@ -1685,26 +1685,26 @@ Gets or sets the font of the text displayed by the item. The to apply to the text displayed by the control. The default is the value of the property if the is not associated with a control; otherwise, the font specified in the property for the control is used. - is immutable (you cannot adjust any of its properties), you can only assign the property a new . However, you can base the new font on the existing font. - - - -## Examples - The following code example shows how to adjust the existing font to make it bold. - -```csharp -listViewItem1.Font = new Font(listViewItem1.Font, - listViewItem1.Font.Style | FontStyle.Bold); -``` - -```vb -ListViewItem1.Font = New Font(ListViewItem1.Font, _ - ListViewItem1.Font.Style Or FontStyle.Bold) -``` - + is immutable (you cannot adjust any of its properties), you can only assign the property a new . However, you can base the new font on the existing font. + + + +## Examples + The following code example shows how to adjust the existing font to make it bold. + +```csharp +listViewItem1.Font = new Font(listViewItem1.Font, + listViewItem1.Font.Style | FontStyle.Bold); +``` + +```vb +ListViewItem1.Font = New Font(ListViewItem1.Font, _ + ListViewItem1.Font.Style Or FontStyle.Bold) +``` + ]]> @@ -1746,13 +1746,13 @@ ListViewItem1.Font = New Font(ListViewItem1.Font, _ Gets or sets the foreground color of the item's text. A that represents the foreground color of the item's text. - property to change the color of the item text. This property can be used if you want to use different background and foreground color combinations (using the property to set the background color) to differentiate one item from another. For example, you could set the property to to identify items that have a negative number associated with them or have failed item validation. - - If you want to use the same foreground color for all subitems of an item, set the property to `true`. This will cause the colors and fonts specified for the item to be used for all subitem text. - + property to change the color of the item text. This property can be used if you want to use different background and foreground color combinations (using the property to set the background color) to differentiate one item from another. For example, you could set the property to to identify items that have a negative number associated with them or have failed item validation. + + If you want to use the same foreground color for all subitems of an item, set the property to `true`. This will cause the colors and fonts specified for the item to be used for all subitem text. + ]]> @@ -1790,11 +1790,11 @@ ListViewItem1.Font = New Font(ListViewItem1.Font, _ Retrieves the specified portion of the bounding rectangle for the item. A that represents the bounding rectangle for the specified portion of the item. - method represents only the section of the item specified in the `portion` parameter. You can also call the methods of the class to obtain the bounding rectangle of any item in a control. - + method represents only the section of the item specified in the `portion` parameter. You can also call the methods of the class to obtain the bounding rectangle of any item in a control. + ]]> @@ -1833,19 +1833,19 @@ ListViewItem1.Font = New Font(ListViewItem1.Font, _ Returns the subitem of the at the specified coordinates. The at the specified x- and y-coordinates. - method will return `null` if the is not in view, or there is not a located at the specified point. - - - -## Examples - The following code example demonstrates how to use the method. To run this code, paste it into a Windows Form and call `InitializeListView1` from the form's constructor or event-handling method. - + method will return `null` if the is not in view, or there is not a located at the specified point. + + + +## Examples + The following code example demonstrates how to use the method. To run this code, paste it into a Windows Form and call `InitializeListView1` from the form's constructor or event-handling method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView/ShowItemToolTips/form1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemWhidbeyMembers/VB/form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemWhidbeyMembers/VB/form1.vb" id="Snippet5"::: + ]]> @@ -1895,25 +1895,25 @@ ListViewItem1.Font = New Font(ListViewItem1.Font, _ Gets or sets the group to which the item is assigned. The to which the item is assigned. - constructor, or you can use this property to modify the group membership at run time. If you set this property to `null` and there are groups in the collection, the item will appear in the default group, which has the header label "DefaultGroupSystem.Windows.Forms". The default group is not contained in the collection, and cannot be altered. It is primarily useful in debugging to ensure that all items have been properly added to groups. - + constructor, or you can use this property to modify the group membership at run time. If you set this property to `null` and there are groups in the collection, the item will appear in the default group, which has the header label "DefaultGroupSystem.Windows.Forms". The default group is not contained in the collection, and cannot be altered. It is primarily useful in debugging to ensure that all items have been properly added to groups. + > [!NOTE] -> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. - - - -## Examples - The following code example demonstrates how the property can be used in an application that organizes items by subitem value in the details view. This form of grouping is similar to the grouping used in Windows Explorer. In the example, the groups are created dynamically. For each subitem column, one group is created for each unique subitem value. For the parent item column, one group is created for each unique initial letter. The groups created for each column are stored in a hash table along with the subitem text or initial letter. When a column header is clicked, the hash table corresponding to that column is retrieved. Next, the subitem text values for that column are used as hash table keys to retrieve the correct group for each item. The item is then assigned to the group using the property. - - This code example is part of a larger example provided for the property. - +> groups are only available on Windows XP and the Windows Server 2003 family (Windows XP Home Edition, Windows XP Professional, Windows Server 2003). For more information, see the overview topic. + + + +## Examples + The following code example demonstrates how the property can be used in an application that organizes items by subitem value in the details view. This form of grouping is similar to the grouping used in Windows Explorer. In the example, the groups are created dynamically. For each subitem column, one group is created for each unique subitem value. For the parent item column, one group is created for each unique initial letter. The groups created for each column are stored in a hash table along with the subitem text or initial letter. When a column header is clicked, the hash table corresponding to that column is retrieved. Next, the subitem text values for that column are used as hash table keys to retrieve the correct group for each item. The item is then assigned to the group using the property. + + This code example is part of a larger example provided for the property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ListView.Groups/CPP/listviewgroupsexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView/Groups/listviewgroupsexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListView.Groups/VB/listviewgroupsexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListView.Groups/VB/listviewgroupsexample.vb" id="Snippet2"::: + ]]> @@ -1992,17 +1992,17 @@ ListViewItem1.Font = New Font(ListViewItem1.Font, _ Gets or sets the index of the image that is displayed for the item. The zero-based index of the image in the that is displayed for the item. The default is -1. - property. Depending on the current value of the property of the control associated with the item, the used by the item could be one specified in the property or the property of the control. If the property is set to , the specified in the property is used; otherwise, the specified in the property is used. The images defined in the specified in the property should have the same index positions as the images in the specified in the property. If the index positions are the same for both controls, you can set a single index value for the property and the appropriate image will be displayed regardless of the value of the property of the control. - + and are mutually exclusive, meaning if one is set, the other is set to an invalid value and ignored. -If you set the property, the property is automatically set to -1. Alternatively, if you set the property, the is automatically set to an empty string (""). - +If you set the property, the property is automatically set to -1. Alternatively, if you set the property, the is automatically set to an empty string (""). + If the property value is changed to `null`, the property returns its default value, -1. However, the assigned value is retained internally and used when another object is assigned to the property. If the new assigned to the property has an property value that is less than or equal to the value assigned to the property minus one (to account for the collection being a zero-based index), the property value is adjusted to one less than the property value. -For example, consider a button control whose has three images and whose property is set to 2. If a new that has only two images is assigned to the button, the value changes to 1. - +For example, consider a button control whose has three images and whose property is set to 2. If a new that has only two images is assigned to the button, the value changes to 1. + ]]> @@ -2076,15 +2076,15 @@ For example, consider a button control whose Gets or sets the key for the image that is displayed for the item. The key for the image that is displayed for the . - and are mutually exclusive, meaning if one is set, the other is set to an invalid value and ignored. -If you set the property, the property is automatically set to -1. Alternatively, if you set the property, the is automatically set to an empty string (""). - +If you set the property, the property is automatically set to -1. Alternatively, if you set the property, the is automatically set to an empty string (""). + > [!NOTE] -> If you are using multiple image lists, for small and large icon view, with a control, you should place small and large versions of the image at the same index location in their respective image lists. When switching between views, the index location of the image in one list is used to locate the image in the other list, regardless of the key value specified. - +> If you are using multiple image lists, for small and large icon view, with a control, you should place small and large versions of the image at the same index location in their respective image lists. When switching between views, the index location of the image in one list is used to locate the image in the other list, regardless of the key value specified. + ]]> @@ -2127,11 +2127,11 @@ If you set the property, th Gets the that contains the image displayed with the item. The used by the control that contains the image displayed with the item. - property of the control associated with the item, the used by the item could be one specified in the property or the property of the control. If the property is set to , the specified in the property is used; otherwise, the specified in the property is used. You can use this property to determine which control is providing the image for the item. To determine the index position in the that contains the image to display for the item, use the property. - + property of the control associated with the item, the used by the item could be one specified in the property or the property of the control. If the property is set to , the specified in the property is used; otherwise, the specified in the property is used. You can use this property to determine which control is providing the image for the item. To determine the index position in the that contains the image to display for the item, use the property. + ]]> @@ -2173,19 +2173,19 @@ If you set the property, th Gets or sets the number of small image widths by which to indent the . The number of small image widths by which to indent the . - property can be used only when the property of the containing is set to , and the property of the is set. - - - -## Examples - The following code example demonstrates how to set the property. To run this example, paste the following code into a Windows Form and call the `InitializeIndentedListViewItems` method from the form's constructor or event-handling method. - + property can be used only when the property of the containing is set to , and the property of the is set. + + + +## Examples + The following code example demonstrates how to set the property. To run this example, paste the following code into a Windows Form and call the `InitializeIndentedListViewItems` method from the form's constructor or event-handling method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView/ShowItemToolTips/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemWhidbeyMembers/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemWhidbeyMembers/VB/form1.vb" id="Snippet2"::: + ]]> When setting , the number specified is less than 0. @@ -2224,11 +2224,11 @@ If you set the property, th Gets the zero-based index of the item within the control. The zero-based index of the item within the of the control, or -1 if the item is not associated with a control. - control as well as to determine its position within the of the . - + control as well as to determine its position within the of the . + ]]> @@ -2275,11 +2275,11 @@ If you set the property, th Gets the control that contains the item. A that contains the . - control that owns the . - + control that owns the . + ]]> @@ -2329,11 +2329,11 @@ If you set the property, th Gets or sets the name associated with this . The name of the . The default is an empty string (""). - property is also the key for the when the item is accessed in a collection. - + property is also the key for the when the item is accessed in a collection. + ]]> @@ -2378,19 +2378,19 @@ If you set the property, th Gets or sets the position of the upper-left corner of the . The at the upper-left corner of the . - property should be set after the and containing are constructed. Changing the property when the containing is in or view will have no effect on the position of the items. Also, the property will automatically change when the property of the containing is changed from , , or view to or . When the is in , , or view, setting the property for an item will cause the other items contained in the to be rearranged. - - - -## Examples - The following code example demonstrates how to use the property of a . To run this example, paste the following code into a Windows Form and call the `InitializePositionedListViewItems` from the form's event-handling method. Click the button to see the items repositioned. - + property should be set after the and containing are constructed. Changing the property when the containing is in or view will have no effect on the position of the items. Also, the property will automatically change when the property of the containing is changed from , , or view to or . When the is in , , or view, setting the property for an item will cause the other items contained in the to be rearranged. + + + +## Examples + The following code example demonstrates how to use the property of a . To run this example, paste the following code into a Windows Form and call the `InitializePositionedListViewItems` from the form's event-handling method. Click the button to see the items repositioned. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView/ShowItemToolTips/form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemWhidbeyMembers/VB/form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemWhidbeyMembers/VB/form1.vb" id="Snippet3"::: + ]]> The is set when the containing is in virtual mode. @@ -2426,11 +2426,11 @@ If you set the property, th Removes the item from its associated control. - method of the in the control that contains the item. You can use the method to remove an item from its control. This feature can be useful if you want to move the item to a different control or need to remove the item based on a request from the user to remove the item from within your application. - + method of the in the control that contains the item. You can use the method to remove an item from its control. This feature can be useful if you want to move the item to a different control or need to remove the item based on a request from the user to remove the item from within your application. + ]]> @@ -2479,23 +2479,23 @@ If you set the property, th if the item is selected; otherwise, . - property of the control the item is contained in is set to `true`, setting the value of this property adds or removes the item from the set of selected items. If the property is set to `false`, setting the value of this property to select an item automatically cancels the selection for any other items in the control. You can use this property to determine if an item is selected or to select an item at run time. You can access all items that are selected in a control by using the property. - + property of the control the item is contained in is set to `true`, setting the value of this property adds or removes the item from the set of selected items. If the property is set to `false`, setting the value of this property to select an item automatically cancels the selection for any other items in the control. You can use this property to determine if an item is selected or to select an item at run time. You can access all items that are selected in a control by using the property. + > [!NOTE] -> Items appear selected only when the control has focus. To select items in response to a user action such as a button click, be sure to call the method in addition to setting this property. - - - -## Examples - The following code example demonstrates how to use the and members. To run the example, place the following code in a form containing a named `ListView1` and a , located toward the bottom of the form, named `Button1`. Call the `InitializeListView` method from the form's constructor or event-handling method. - +> Items appear selected only when the control has focus. To select items in response to a user action such as a button click, be sure to call the method in addition to setting this property. + + + +## Examples + The following code example demonstrates how to use the and members. To run the example, place the following code in a form containing a named `ListView1` and a , located toward the bottom of the form, named `Button1`. Call the `InitializeListView` method from the form's constructor or event-handling method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ListView4/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView/Clear/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListView4/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListView4/VB/form1.vb" id="Snippet1"::: + ]]> @@ -2611,20 +2611,20 @@ If you set the property, th Gets or sets the index of the state image (an image such as a selected or cleared check box that indicates the state of the item) that is displayed for the item. The zero-based index of the state image in the that is displayed for the item. - assigned to the property of the associated control, where the state images to display to the left of the item are stored. Typically, the state image is a selected or cleared check box or an image that is intended to represent selected or cleared states for the item. If no value is specified for the property, the control displays a default selected or cleared check box when the property of the control is set to `true`. - + assigned to the property of the associated control, where the state images to display to the left of the item are stored. Typically, the state image is a selected or cleared check box or an image that is intended to represent selected or cleared states for the item. If no value is specified for the property, the control displays a default selected or cleared check box when the property of the control is set to `true`. + > [!NOTE] -> Although the specified in the property can contain any number of images, and the property can be set to any value equal to or lower than 14, only the images at index positions 0 and 1 are displayed as state images. - +> Although the specified in the property can contain any number of images, and the property can be set to any value equal to or lower than 14, only the images at index positions 0 and 1 are displayed as state images. + ]]> - The value specified for this property is less than -1. - - -or- - + The value specified for this property is less than -1. + + -or- + The value specified for this property is greater than 14. @@ -2674,39 +2674,39 @@ If you set the property, th Gets a collection containing all subitems of the item. A that contains the subitems. - , you can add subitems, remove subitems, and obtain a count of subitems. For more information on the tasks that can be performed with the subitems in the collection, see the class reference topics. - + , you can add subitems, remove subitems, and obtain a count of subitems. For more information on the tasks that can be performed with the subitems in the collection, see the class reference topics. + > [!NOTE] -> The first subitem in the is always the item that owns the subitems. When performing operations on subitems in the collection, be sure to reference index position 1 instead of 0 to make changes to the first subitem. - - - -## Examples - The following code example creates a control with three objects specified and three objects specified for each item. The example also creates objects to display the subitems in details view. Two objects are also created in the code example to provide images for the objects. These objects are added to the and properties. The example uses the following properties in creating the control: - -- - -- - -- - -- - -- - -- - -- - - You need to add the code to a and call the method created in the example from the constructor or another method on the form. The example requires that images named `MySmallImage1`, `MySmallImage2`, `MyLargeImage1`, and `MyLargeImage2` are located in the root directory of drive C. - +> The first subitem in the is always the item that owns the subitems. When performing operations on subitems in the collection, be sure to reference index position 1 instead of 0 to make changes to the first subitem. + + + +## Examples + The following code example creates a control with three objects specified and three objects specified for each item. The example also creates objects to display the subitems in details view. Two objects are also created in the code example to provide images for the objects. These objects are added to the and properties. The example uses the following properties in creating the control: + +- + +- + +- + +- + +- + +- + +- + + You need to add the code to a and call the method created in the example from the constructor or another method on the form. The example requires that images named `MySmallImage1`, `MySmallImage2`, `MyLargeImage1`, and `MyLargeImage2` are located in the root directory of drive C. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ListViewExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView+ColumnHeaderCollection/Add/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ListViewExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ListViewExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -2813,20 +2813,20 @@ If you set the property, th Gets or sets an object that contains data to associate with the item. An object that contains information that is associated with the item. - property can be used to store any object that you want to associate with an item. Although you can store any item, the property is typically used to store string information about the item, such as a unique identifier or the index position of the item's data in a database. - - - -## Examples - The following code example demonstrates how to initialize a and set the and properties. To run this example, place the following code in a form that contains a named `ListView1`, and call `InitializeListViewItems` from the form's constructor or event-handling method. - + property can be used to store any object that you want to associate with an item. Although you can store any item, the property is typically used to store string information about the item, such as a unique identifier or the index position of the item's data in a database. + + + +## Examples + The following code example demonstrates how to initialize a and set the and properties. To run this example, place the following code in a form that contains a named `ListView1`, and call `InitializeListViewItems` from the form's constructor or event-handling method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListViewItem/Tag/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -2872,22 +2872,22 @@ If you set the property, th Gets or sets the text of the item. The text to display for the item. This should not exceed 259 characters. - property allows you to change the text displayed for the item. The text of the should not exceed 259 characters or unexpected behavior could occur. - - You can use the , , and properties to specify how the text is displayed. The class provides the property that determines whether text wraps to the next line or is displayed on a single line. - - - -## Examples - The following code example demonstrates how to initialize a and set the and properties. To run this example, place the following code in a form containing a named `ListView1`, and call `InitializeListViewItems` from the form's constructor or event-handling method. - + property allows you to change the text displayed for the item. The text of the should not exceed 259 characters or unexpected behavior could occur. + + You can use the , , and properties to specify how the text is displayed. The class provides the property that determines whether text wraps to the next line or is displayed on a single line. + + + +## Examples + The following code example demonstrates how to initialize a and set the and properties. To run this example, place the following code in a form containing a named `ListView1`, and call `InitializeListViewItems` from the form's constructor or event-handling method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListViewItem/Tag/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -2932,19 +2932,19 @@ If you set the property, th Gets or sets the text shown when the mouse pointer rests on the . The text shown when the mouse pointer rests on the . - and its containing have ToolTips set, only the ToolTip for the will be shown. - - - -## Examples - The following code example demonstrates how to use the and properties. To run this example, paste the code into a Windows Form and call `InitializeItemsWithToolTips` from the form's constructor or event-handling method. - + and its containing have ToolTips set, only the ToolTip for the will be shown. + + + +## Examples + The following code example demonstrates how to use the and properties. To run this example, paste the code into a Windows Form and call `InitializeItemsWithToolTips` from the form's constructor or event-handling method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView/ShowItemToolTips/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemWhidbeyMembers/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemWhidbeyMembers/VB/form1.vb" id="Snippet4"::: + ]]> @@ -3014,20 +3014,20 @@ If you set the property, th if all subitems use the font, foreground color, and background color settings of the item; otherwise, . The default is . - control, you can set this property to `false`. When this property is set to `true`, any changes made to the subitem's , , and properties are ignored, and the values of the item are used instead. You can use this property if you need to specify a different text color, background color, or font to be used for a subitem to highlight the item when subitems are displayed in the control. - - - -## Examples - The following code example demonstrates how to set the property to `false` to define a custom style for objects. The example also demonstrates how to set the and properties. To run the example, paste the following code into a form and call the `InitializeListView` method in form's constructor or event-handling method. - + control, you can set this property to `false`. When this property is set to `true`, any changes made to the subitem's , , and properties are ignored, and the values of the item are used instead. You can use this property if you need to specify a different text color, background color, or font to be used for a subitem to highlight the item when subitems are displayed in the control. + + + +## Examples + The following code example demonstrates how to set the property to `false` to define a custom style for objects. The example also demonstrates how to set the and properties. To run the example, paste the following code into a form and call the `InitializeListView` method in form's constructor or event-handling method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemStyle/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ListView/TopItem/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemStyle/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ListViewItemStyle/VB/form1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/MainMenu.xml b/xml/System.Windows.Forms/MainMenu.xml index 9897e11b845..653ff952bed 100644 --- a/xml/System.Windows.Forms/MainMenu.xml +++ b/xml/System.Windows.Forms/MainMenu.xml @@ -36,31 +36,31 @@ Represents the menu structure of a form. - + This class is not available in .NET Core 3.1 and later versions. Use instead, which replaces and extends the control. - instead. - The control represents the container for the menu structure of a form. A menu is composed of objects that represent the individual menu commands in the menu structure. Each can be a command for your application or a parent menu for other submenu items. To bind the to the that will display it, assign the to the property of the . - - For applications that will have support for multiple languages, you can use the property to display the text of the menu from right to left to support languages such as Arabic. - - You can create different objects to represent different menu structures for your form. If you want to reuse the menu structure contained in a specific , you can use its method to create a copy. Once you have a copy of the menu structure, you can make the appropriate modifications for your new menu structure. - + The control represents the container for the menu structure of a form. A menu is composed of objects that represent the individual menu commands in the menu structure. Each can be a command for your application or a parent menu for other submenu items. To bind the to the that will display it, assign the to the property of the . + + For applications that will have support for multiple languages, you can use the property to display the text of the menu from right to left to support languages such as Arabic. + + You can create different objects to represent different menu structures for your form. If you want to reuse the menu structure contained in a specific , you can use its method to create a copy. Once you have a copy of the menu structure, you can make the appropriate modifications for your new menu structure. + > [!NOTE] > Cutting and pasting menu items from one form to another in the designer might not work as expected if the form you are pasting into has no menu items defined. - -## Examples - The following code example creates a , assigns two objects to the and binds it to a form. This example requires that you have a created that is named `Form1`. - + +## Examples + The following code example creates a , assigns two objects to the and binds it to a form. This example requires that you have a created that is named `Form1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic MainMenu.MainMenu Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Menu/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.MainMenu Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.MainMenu Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -69,7 +69,7 @@ This class is not available in .NET Core 3.1 and later versions. Use - MenuStrip Control (Windows Forms) + MenuStrip Control (Windows Forms) @@ -99,20 +99,20 @@ This class is not available in .NET Core 3.1 and later versions. Use Initializes a new instance of the class without any specified menu items. - without any specified objects. To add menu items to the control use the other version of this constructor that accepts an array of objects as its parameter or use the method of the property. - - - -## Examples - The following code example creates a , assigns two objects to the and binds it to a form. This example requires that you have a created that is named `Form1`. - + without any specified objects. To add menu items to the control use the other version of this constructor that accepts an array of objects as its parameter or use the method of the property. + + + +## Examples + The following code example creates a , assigns two objects to the and binds it to a form. This example requires that you have a created that is named `Form1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic MainMenu.MainMenu Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Form/Menu/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.MainMenu Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.MainMenu Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -166,20 +166,20 @@ This class is not available in .NET Core 3.1 and later versions. Use An array of objects that will be added to the . Initializes a new instance of the with a specified set of objects. - objects to the at the time of its creation. After the has been created you can add additional objects to the using the method of the property. - - - -## Examples - The following code example creates a , and assigns two objects to the using this version of the constructor. The example then binds the to a . This example requires that you have a created that is named `Form1`. - + objects to the at the time of its creation. After the has been created you can add additional objects to the using the method of the property. + + + +## Examples + The following code example creates a , and assigns two objects to the using this version of the constructor. The example then binds the to a . This example requires that you have a created that is named `Form1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic MainMenu.MainMenu1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MainMenu/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.MainMenu1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.MainMenu1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -208,20 +208,20 @@ This class is not available in .NET Core 3.1 and later versions. Use Creates a new that is a duplicate of the current . A that represents the cloned menu. - . You can use this method to reuse the menu structure stored in a as the foundation for a new . For example, if you want to create a menu structure that has the same menu items as an existing but will also have additional objects added to it, you can use the method to create a copy of the original and then add the new objects to the cloned . - - - -## Examples - The following code example uses the method to determine if a is currently parented to the form. If the call in the example code to does not return `null`, the code then clones the menu structure of the using the method. The code then sets the property to true on the new copy of the to create a that can be used for languages that support right to left text. This example requires that you have a created that is named `mainMenu1`. - + . You can use this method to reuse the menu structure stored in a as the foundation for a new . For example, if you want to create a menu structure that has the same menu items as an existing but will also have additional objects added to it, you can use the method to create a copy of the original and then add the new objects to the cloned . + + + +## Examples + The following code example uses the method to determine if a is currently parented to the form. If the call in the example code to does not return `null`, the code then clones the menu structure of the using the method. The code then sets the property to true on the new copy of the to create a that can be used for languages that support right to left text. This example requires that you have a created that is named `mainMenu1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic MainMenu.GetForm Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MainMenu/CloneMenu/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.GetForm Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.GetForm Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -246,21 +246,21 @@ This class is not available in .NET Core 3.1 and later versions. Use Occurs when the main menu collapses. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `MainMenu1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `MainMenu1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet483"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet483"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet483"::: + ]]> @@ -315,14 +315,14 @@ This class is not available in .NET Core 3.1 and later versions. Use to release both managed and unmanaged resources; to release only unmanaged resources. Disposes of the resources, other than memory, used by the . - when you are finished using the . The method leaves the in an unusable state. After calling , you must release all references to the so the memory it was occupying can be reclaimed by garbage collection. - + when you are finished using the . The method leaves the in an unusable state. After calling , you must release all references to the so the memory it was occupying can be reclaimed by garbage collection. + > [!NOTE] -> Always call before you release your last reference to the . Otherwise, the resources the is using will not be freed until garbage collection calls the object's destructor. - +> Always call before you release your last reference to the . Otherwise, the resources the is using will not be freed until garbage collection calls the object's destructor. + ]]> @@ -350,20 +350,20 @@ This class is not available in .NET Core 3.1 and later versions. Use Gets the that contains this control. A that is the container for this control. Returns if the is not currently hosted on a form. - is parented to a form. The property is typically used when multiple objects are being used on a form and you need to determine which one is currently being used by a form. - - - -## Examples - The following code example uses the method to determine if a is currently parented to the form. If the call in the example code to does not return `null`, the code then clones the menu structure of the using the method. The code then sets the property to true on the new copy of the to create a that can be used for languages that support right to left text. This example requires that you have a created that is named `mainMenu1`. - + is parented to a form. The property is typically used when multiple objects are being used on a form and you need to determine which one is currently being used by a form. + + + +## Examples + The following code example uses the method to determine if a is currently parented to the form. If the call in the example code to does not return `null`, the code then clones the menu structure of the using the method. The code then sets the property to true on the new copy of the to create a that can be used for languages that support right to left text. This example requires that you have a created that is named `mainMenu1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic MainMenu.GetForm Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MainMenu/CloneMenu/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.GetForm Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.GetForm Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -393,13 +393,13 @@ This class is not available in .NET Core 3.1 and later versions. Use An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -439,23 +439,23 @@ This class is not available in .NET Core 3.1 and later versions. Use Gets or sets whether the text displayed by the control is displayed from right to left. One of the values. - [!NOTE] -> For more information about how enabling right-to-left alignment affects Windows Forms controls, see the property. - - - -## Examples - The following code example uses the method to determine if a is currently parented to the form. If the call in the example code to does not return `null`, the code then clones the menu structure of the using the method. The example code then sets the property to `RightToLeft.Yes` on the new copy of the to create a that can be used for languages that support right to left text. This example requires that you have a created that is named `mainMenu1`. - +> For more information about how enabling right-to-left alignment affects Windows Forms controls, see the property. + + + +## Examples + The following code example uses the method to determine if a is currently parented to the form. If the call in the example code to does not return `null`, the code then clones the menu structure of the using the method. The example code then sets the property to `RightToLeft.Yes` on the new copy of the to create a that can be used for languages that support right to left text. This example requires that you have a created that is named `mainMenu1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic MainMenu.RightToLeft Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MainMenu/RightToLeft/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.RightToLeft Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic MainMenu.RightToLeft Example/VB/source.vb" id="Snippet1"::: + ]]> The value assigned to the property is not a valid member of the enumeration. @@ -484,11 +484,11 @@ This class is not available in .NET Core 3.1 and later versions. Use Returns a string that represents the . A string that represents the current . - method if the is assigned to a form. - + method if the is assigned to a form. + ]]> diff --git a/xml/System.Windows.Forms/MaskedTextBox.xml b/xml/System.Windows.Forms/MaskedTextBox.xml index 519c07204ee..b776e8eddce 100644 --- a/xml/System.Windows.Forms/MaskedTextBox.xml +++ b/xml/System.Windows.Forms/MaskedTextBox.xml @@ -57,73 +57,73 @@ Uses a mask to distinguish between proper and improper user input. - class is an enhanced control that supports a declarative syntax for accepting or rejecting user input. Using the property, you can specify the following input without writing any custom validation logic in your application: - -- Required input characters. - -- Optional input characters. - -- The type of input expected at a given position in the mask; for example, a digit, or an alphabetic or alphanumeric character. - -- Mask literals, or characters that should appear directly in the ; for example, the hyphens (-) in a phone number, or the currency symbol in a price. - -- Special processing for input characters; for example, to convert alphabetic characters to uppercase. - - When a control is displayed at run time, it represents the mask as a series of prompt characters and optional literal characters. Each editable mask position, representing a required or optional input, is shown with a single prompt character. For example, the number sign (#) is often used as a placeholder for a numeric character input. You can use the property to specify a custom prompt character. The property determines if the user sees the prompt characters when the control loses input focus. - - As the user types input into the masked text box, valid input characters replace their respective prompt characters in a sequential fashion. If the user types an invalid input character, no replacement occurs, but instead a beep is issued if the property is set to `true`, and the event is raised. You can provide your own custom error logic by handing this event. - - When the current insertion point is at a literal character, the user has a number of options: - -- If a character other than the prompt character is typed, the literal will automatically be skipped and the input character will be applied to the next editable position, represented by the next prompt character. - -- If the prompt character is typed and the property is true, the input will overtype the prompt character and insertion point will be moved to the next position in the mask. - -- As is always the case, the arrow keys can be used to navigate to a previous or subsequent position. - - You can use the property to verify whether or not the user has entered all of the required input. The property will always retrieve the user's input formatted according to the mask and the property. - - The control actually defers all mask processing to the class specified by the property. This standard provider supports all Unicode characters except for surrogates and vertically combined characters; however, the property can be used to restrict input to the characters sets a-z, A-Z, and 0-9. - - Masks do not necessarily guarantee that a user's input will represent a valid value for a given type; for example, -9 could be entered for an age in years. You can verify that a user's input represents a valid value by assigning an instance of that value's type to the property. You can detect whether the user removes focus from when it contains an invalid value by monitoring for the event. If type validation succeeds, the object representing the value will be available through the property of the parameter. - - As with the control, several common keyboard shortcuts do not work with . In particular, CTRL-R (right justify text), CTRL-L (left justify text), and CTRL-L (center text) have no effect. - -## Compatibility with Visual Basic 6.0 - was designed to retain most of the functionality of the Masked Edit control in Visual Basic 6.0. The following table lists common properties on the Masked Edit control and gives their equivalents on . - -|Masked Edit control (Visual Basic 6.0) property|Equivalent MaskedTextBox (.NET Framework) property| -|-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------| -|`AllowPrompt` property|| -|`AutoTab` property|None| -|`ClipMode` property|| -|`ClipText` property| (when is set to )| -|`Format` property|None| -|`FormattedText` property| (when is set to )| -|`Mask` property|| -|`PromptChar` property|| -|`PromptInclude` property|| -|`ValidationError` event|| - + class is an enhanced control that supports a declarative syntax for accepting or rejecting user input. Using the property, you can specify the following input without writing any custom validation logic in your application: + +- Required input characters. + +- Optional input characters. + +- The type of input expected at a given position in the mask; for example, a digit, or an alphabetic or alphanumeric character. + +- Mask literals, or characters that should appear directly in the ; for example, the hyphens (-) in a phone number, or the currency symbol in a price. + +- Special processing for input characters; for example, to convert alphabetic characters to uppercase. + + When a control is displayed at run time, it represents the mask as a series of prompt characters and optional literal characters. Each editable mask position, representing a required or optional input, is shown with a single prompt character. For example, the number sign (#) is often used as a placeholder for a numeric character input. You can use the property to specify a custom prompt character. The property determines if the user sees the prompt characters when the control loses input focus. + + As the user types input into the masked text box, valid input characters replace their respective prompt characters in a sequential fashion. If the user types an invalid input character, no replacement occurs, but instead a beep is issued if the property is set to `true`, and the event is raised. You can provide your own custom error logic by handing this event. + + When the current insertion point is at a literal character, the user has a number of options: + +- If a character other than the prompt character is typed, the literal will automatically be skipped and the input character will be applied to the next editable position, represented by the next prompt character. + +- If the prompt character is typed and the property is true, the input will overtype the prompt character and insertion point will be moved to the next position in the mask. + +- As is always the case, the arrow keys can be used to navigate to a previous or subsequent position. + + You can use the property to verify whether or not the user has entered all of the required input. The property will always retrieve the user's input formatted according to the mask and the property. + + The control actually defers all mask processing to the class specified by the property. This standard provider supports all Unicode characters except for surrogates and vertically combined characters; however, the property can be used to restrict input to the characters sets a-z, A-Z, and 0-9. + + Masks do not necessarily guarantee that a user's input will represent a valid value for a given type; for example, -9 could be entered for an age in years. You can verify that a user's input represents a valid value by assigning an instance of that value's type to the property. You can detect whether the user removes focus from when it contains an invalid value by monitoring for the event. If type validation succeeds, the object representing the value will be available through the property of the parameter. + + As with the control, several common keyboard shortcuts do not work with . In particular, CTRL-R (right justify text), CTRL-L (left justify text), and CTRL-L (center text) have no effect. + +## Compatibility with Visual Basic 6.0 + was designed to retain most of the functionality of the Masked Edit control in Visual Basic 6.0. The following table lists common properties on the Masked Edit control and gives their equivalents on . + +|Masked Edit control (Visual Basic 6.0) property|Equivalent MaskedTextBox (.NET Framework) property| +|-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------| +|`AllowPrompt` property|| +|`AutoTab` property|None| +|`ClipMode` property|| +|`ClipText` property| (when is set to )| +|`Format` property|None| +|`FormattedText` property| (when is set to )| +|`Mask` property|| +|`PromptChar` property|| +|`PromptInclude` property|| +|`ValidationError` event|| + > [!CAUTION] -> The control does not support multiline configuration or undo functionality. However, while the members associated with these features have been retained for compatibility with the base class, their implementations perform no actions. - - - -## Examples - The following code example initializes the to accept a date, and uses both the and events to alert the user to invalid input. - +> The control does not support multiline configuration or undo functionality. However, while the members associated with these features have been retained for compatibility with the base class, their implementations perform no actions. + + + +## Examples + The following code example initializes the to accept a date, and uses both the and events to alert the user to invalid input. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MaskedTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MaskInputRejectedSample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MaskInputRejectedSample/VB/form1.vb" id="Snippet1"::: + ]]> - MaskedTextBox Control (Windows Forms) + MaskedTextBox Control (Windows Forms) @@ -157,11 +157,11 @@ Initializes a new instance of the class using defaults. - constructor sets the property to a null mask, represented by the string "<>". A null mask will accept any combination of characters as input. - + constructor sets the property to a null mask, represented by the string "<>". A null mask will accept any combination of characters as input. + ]]> @@ -194,13 +194,13 @@ A custom mask language provider, derived from the class. Initializes a new instance of the class using the specified custom mask language provider. - . It is responsible for parsing the mask and determining whether user input conforms to the current mask position. You can derive a new class from to define your own custom masking language, and use the constructor to replace the standard . - - If you want to use the default masking language and supply your own input mask, you do not need to use this constructor. Instead, you can either use the constructor, or use the parameterless constructor then set the property. - + . It is responsible for parsing the mask and determining whether user input conforms to the current mask position. You can derive a new class from to define your own custom masking language, and use the constructor to replace the standard . + + If you want to use the default masking language and supply your own input mask, you do not need to use this constructor. Instead, you can either use the constructor, or use the parameterless constructor then set the property. + ]]> @@ -236,13 +236,13 @@ A representing the input mask. The initial value of the property. Initializes a new instance of the class using the specified input mask. - constructor uses the standard with the input `mask` to parse user input into the . - - If you assign a new mask to the property, it will override the value set by this constructor. - + constructor uses the standard with the input `mask` to parse user input into the . + + If you assign a new mask to the property, it will override the value set by this constructor. + ]]> @@ -296,11 +296,11 @@ in all cases. - property is inherited from the base class. However, because the control does not support multiline configuration, this property is not supported. - + property is inherited from the base class. However, because the control does not support multiline configuration, this property is not supported. + ]]> @@ -356,11 +356,11 @@ Occurs when the value of the property has changed. This event is not raised by . - event is inherited from the base class. However, because the control does not support multiline configuration, this event is not supported. - + event is inherited from the base class. However, because the control does not support multiline configuration, this event is not supported. + ]]> @@ -401,13 +401,13 @@ if the user can enter the prompt character into the control; otherwise, . The default is . - is `true`, the prompt character must be valid for the current location in the mask in order to be accepted. For example, if is "*", and the current location in the mask demands the user enter a digit, entering an asterisk (\*) will fail and cause the event to occur. - - The property takes precedence over . - + is `true`, the prompt character must be valid for the current location in the mask in order to be accepted. For example, if is "*", and the current location in the mask demands the user enter a digit, entering an asterisk (\*) will fail and cause the event to occur. + + The property takes precedence over . + ]]> @@ -456,11 +456,11 @@ if only ASCII is accepted; if the control can accept any arbitrary Unicode character. The default is . - restricts user input to the characters a-z and A-Z. ASCII control characters are not allowed. - + restricts user input to the characters a-z and A-Z. ASCII control characters are not allowed. + ]]> @@ -500,11 +500,11 @@ if the control should beep on invalid input; otherwise, . The default is . - event will still occur if the property is set to `true`. - + event will still occur if the property is set to `true`. + ]]> @@ -556,11 +556,11 @@ in all cases. - property is inherited from the base class. However, because does not support undo functionality, this property always has a value of `false`. - + property is inherited from the base class. However, because does not support undo functionality, this property always has a value of `false`. + ]]> @@ -599,11 +599,11 @@ Clears information about the most recent operation from the undo buffer of the text box. This method is not supported by . - method is inherited from the base class. However, does not support undo functionality. - + method is inherited from the base class. However, does not support undo functionality. + ]]> @@ -778,14 +778,14 @@ Gets or sets a value that determines whether literals and prompt characters are copied to the clipboard. One of the values. The default is . - property determines how text, selected within the control, is interpreted when it is copied to the clipboard or retrieved through the property. Specifically, it determines whether literal characters, prompt characters, or both are included when selected text is accessed. When prompt characters are excluded, they are transformed into spaces in the copied string. - + property determines how text, selected within the control, is interpreted when it is copied to the clipboard or retrieved through the property. Specifically, it determines whether literal characters, prompt characters, or both are included when selected text is accessed. When prompt characters are excluded, they are transformed into spaces in the copied string. + > [!NOTE] -> The property serves a similar purpose with respect to how the property is interpreted. - +> The property serves a similar purpose with respect to how the property is interpreted. + ]]> Property set with a value that is not valid. @@ -849,11 +849,11 @@ Gets or sets the to use when performing type validation. An object that implements the interface. - determines which symbols are used for the currency, date, and other culture-specific mask placeholders when type validation occurs and the control has a non-null property. - + determines which symbols are used for the currency, date, and other culture-specific mask placeholders when type validation occurs and the control has a non-null property. + ]]> @@ -962,11 +962,11 @@ Retrieves the index of the first character of a given line. This method is not supported by . This method will always return 0. - method is inherited from the base class. However, because the control does not support multiline configuration, this method is not supported. - + method is inherited from the base class. However, because the control does not support multiline configuration, this method is not supported. + ]]> @@ -1007,11 +1007,11 @@ Retrieves the index of the first character of the current line. This method is not supported by . This method will always return 0. - method is inherited from the base class. However, because the control does not support multiline configuration, this method is not supported. - + method is inherited from the base class. However, because the control does not support multiline configuration, this method is not supported. + ]]> @@ -1055,11 +1055,11 @@ Retrieves the line number from the specified character position within the text of the control. This method is not supported by . This method will always return 0. - method is inherited from the base class. However, because the control does not support multiline configuration, this method is not supported. - + method is inherited from the base class. However, because the control does not support multiline configuration, this method is not supported. + ]]> @@ -1183,15 +1183,15 @@ Gets or sets the text insertion mode of the masked text box control. An value that indicates the current insertion mode. The default is . - property controls the character insertion behavior of the control. The state of this property is defined by the enumeration, which can be always on, always off or set to respect the setting of the user's keyboard. This property supersedes the insertion mode of the keyboard. For example, if the keyboard is set to overwrite, but is set to `Insert`, the will operate in insert mode. The property will access the true insertion mode of the . - - If changing changes the value of , will raise the event. - - This property has no effect if no mask has been set. - + property controls the character insertion behavior of the control. The state of this property is defined by the enumeration, which can be always on, always off or set to respect the setting of the user's keyboard. This property supersedes the insertion mode of the keyboard. For example, if the keyboard is set to overwrite, but is set to `Insert`, the will operate in insert mode. The property will access the true insertion mode of the . + + If changing changes the value of , will raise the event. + + This property has no effect if no mask has been set. + ]]> An invalid value was supplied when setting this property. @@ -1265,13 +1265,13 @@ if will overwrite existing characters as the user enters new ones; if will shift existing characters forward. The default is . - takes into account both the value of the property and the state of the user's keyboard. If is set to either or , will return `false` or `true`, respectively. If is set to , it will return the state of the INSERT key. - - When is `false`, will reject as invalid any character entry that would result in a violation anywhere in the mask. In explanation, if inserting a character would cause a character to be shifted over into a mask position where it would not be valid, the character insertion will be rejected. - + takes into account both the value of the property and the state of the user's keyboard. If is set to either or , will return `false` or `true`, respectively. If is set to , it will return the state of the INSERT key. + + When is `false`, will reject as invalid any character entry that would result in a violation anywhere in the mask. In explanation, if inserting a character would cause a character to be shifted over into a mask position where it would not be valid, the character insertion will be rejected. + ]]> @@ -1310,23 +1310,23 @@ Occurs after the insert mode has changed. - event is raised after value of the property is changed. - - This event is required to properly bind data to a control. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `MaskedTextBox1`. Then ensure that the event handler is associated with the event. - + event is raised after value of the property is changed. + + This event is required to properly bind data to a control. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `MaskedTextBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet484"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet484"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet484"::: + ]]> @@ -1377,11 +1377,11 @@ Gets or sets the lines of text in multiline configurations. This property is not supported by . An array of type that contains a single line. - property is inherited from the base class. However, because the control does not support multiline configuration, this property is not supported. - + property is inherited from the base class. However, because the control does not support multiline configuration, this property is not supported. + ]]> @@ -1445,53 +1445,53 @@ Gets or sets the input mask to use at run time. A representing the current mask. The default value is the empty string which allows any input. - is the default property for the class. - - must be a string composed of one or more of the masking elements, as shown in the following table. The masking language used by is defined by its associated . The standard provider specifies a masking language based upon the one used by the Masked Edit control in Visual Basic 6.0, and should be very familiar to users migrating from that platform. - -|Masking element|Description| -|---------------------|-----------------| -|0|Digit, required. This element will accept any single digit between 0 and 9.| -|9|Digit or space, optional.| -|#|Digit or space, optional. If this position is blank in the mask, it will be rendered as a space in the property. Plus (+) and minus (-) signs are allowed.| -|L|Letter, required. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-zA-Z] in regular expressions.| -|?|Letter, optional. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-zA-Z]? in regular expressions.| -|&|Character, required. If the property is set to true, this element behaves like the "L" element.| -|C|Character, optional. Any non-control character. If the property is set to `true`, this element behaves like the "?" element.| -|A|Alphanumeric, required. If the property is set to `true`, the only characters it will accept are the ASCII letters a-z and A-Z. This mask element behaves like the "a" element.| -|a|Alphanumeric, optional. If the property is set to `true`, the only characters it will accept are the ASCII letters a-z and A-Z. This mask element behaves like the "A" element.| -|.|Decimal placeholder. The actual display character used will be the decimal symbol appropriate to the format provider, as determined by the control's property.| -|,|Thousands placeholder. The actual display character used will be the thousands placeholder appropriate to the format provider, as determined by the control's property.| -|:|Time separator. The actual display character used will be the time symbol appropriate to the format provider, as determined by the control's property.| -|/|Date separator. The actual display character used will be the date symbol appropriate to the format provider, as determined by the control's property.| -|$|Currency symbol. The actual character displayed will be the currency symbol appropriate to the format provider, as determined by the control's property.| -|\<|Shift down. Converts all characters that follow to lowercase.| -|>|Shift up. Converts all characters that follow to uppercase.| -|||Disable a previous shift up or shift down.| -|\|Escape. Escapes a mask character, turning it into a literal. "\\\\" is the escape sequence for a backslash.| -|All other characters|Literals. All non-mask elements will appear as themselves within . Literals always occupy a static position in the mask at run time, and cannot be moved or deleted by the user.| - - If you change a mask when already contains user input filtered by a previous mask, will attempt to migrate that input into the new mask definition. If it fails, it will clear the existing input. Assigning a zero-length string as the mask will preserve any existing data in the control. When used with a zero-length mask, behaves like a single-line control. - - The decimal (.), thousandths (,), time (:), date (/), and currency ($) symbols default to displaying those symbols as defined by the application's culture. You can force them to display symbols for another culture by using the property. - - Character insertion into the mask at run time is controlled by the property. Users can navigate through the mask by using the left and right arrow keys or the mouse cursor, and can skip optional positions in the mask by entering a space. - + is the default property for the class. + + must be a string composed of one or more of the masking elements, as shown in the following table. The masking language used by is defined by its associated . The standard provider specifies a masking language based upon the one used by the Masked Edit control in Visual Basic 6.0, and should be very familiar to users migrating from that platform. + +|Masking element|Description| +|---------------------|-----------------| +|0|Digit, required. This element will accept any single digit between 0 and 9.| +|9|Digit or space, optional.| +|#|Digit or space, optional. If this position is blank in the mask, it will be rendered as a space in the property. Plus (+) and minus (-) signs are allowed.| +|L|Letter, required. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-zA-Z] in regular expressions.| +|?|Letter, optional. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-zA-Z]? in regular expressions.| +|&|Character, required. If the property is set to true, this element behaves like the "L" element.| +|C|Character, optional. Any non-control character. If the property is set to `true`, this element behaves like the "?" element.| +|A|Alphanumeric, required. If the property is set to `true`, the only characters it will accept are the ASCII letters a-z and A-Z. This mask element behaves like the "a" element.| +|a|Alphanumeric, optional. If the property is set to `true`, the only characters it will accept are the ASCII letters a-z and A-Z. This mask element behaves like the "A" element.| +|.|Decimal placeholder. The actual display character used will be the decimal symbol appropriate to the format provider, as determined by the control's property.| +|,|Thousands placeholder. The actual display character used will be the thousands placeholder appropriate to the format provider, as determined by the control's property.| +|:|Time separator. The actual display character used will be the time symbol appropriate to the format provider, as determined by the control's property.| +|/|Date separator. The actual display character used will be the date symbol appropriate to the format provider, as determined by the control's property.| +|$|Currency symbol. The actual character displayed will be the currency symbol appropriate to the format provider, as determined by the control's property.| +|\<|Shift down. Converts all characters that follow to lowercase.| +|>|Shift up. Converts all characters that follow to uppercase.| +|||Disable a previous shift up or shift down.| +|\|Escape. Escapes a mask character, turning it into a literal. "\\\\" is the escape sequence for a backslash.| +|All other characters|Literals. All non-mask elements will appear as themselves within . Literals always occupy a static position in the mask at run time, and cannot be moved or deleted by the user.| + + If you change a mask when already contains user input filtered by a previous mask, will attempt to migrate that input into the new mask definition. If it fails, it will clear the existing input. Assigning a zero-length string as the mask will preserve any existing data in the control. When used with a zero-length mask, behaves like a single-line control. + + The decimal (.), thousandths (,), time (:), date (/), and currency ($) symbols default to displaying those symbols as defined by the application's culture. You can force them to display symbols for another culture by using the property. + + Character insertion into the mask at run time is controlled by the property. Users can navigate through the mask by using the left and right arrow keys or the mouse cursor, and can skip optional positions in the mask by entering a space. + > [!IMPORTANT] -> supports all Unicode characters except for surrogates and vertically combined characters. - - The following table shows example masks. - -|Mask|Behavior| -|----------|--------------| -|`00/00/0000`|A date (day, numeric month, year) in international date format. The "/" character is a logical date separator, and will appear to the user as the date separator appropriate to the application's current culture.| -|`00->L supports all Unicode characters except for surrogates and vertically combined characters. + + The following table shows example masks. + +|Mask|Behavior| +|----------|--------------| +|`00/00/0000`|A date (day, numeric month, year) in international date format. The "/" character is a logical date separator, and will appear to the user as the date separator appropriate to the application's current culture.| +|`00->L The string supplied to the property is not a valid mask. Invalid masks include masks containing non-printable characters. @@ -1534,21 +1534,21 @@ Occurs after the input mask is changed. - event is raised after the value of the property is changed. This event is also raised if the is indirectly altered by a member such as , , , and . - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `MaskedTextBox1`. Then ensure that the event handler is associated with the event. - + event is raised after the value of the property is changed. This event is also raised if the is indirectly altered by a member such as , , , and . + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `MaskedTextBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet485"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet485"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet485"::: + ]]> @@ -1589,11 +1589,11 @@ if all required input has been entered into the mask; otherwise, . - checks only required input elements. To determine whether all required and optional input elements have been filled in, use the property instead. - + checks only required input elements. To determine whether all required and optional input elements have been filled in, use the property instead. + ]]> @@ -1647,13 +1647,13 @@ Gets a clone of the mask provider associated with this instance of the masked text box control. A masking language provider of type . - property defines the mask-parsing engine and the masking language used by the control. The default provider is the class; however, a custom provider can be specified using the constructor. - - cannot be set directly. However, setting some of the properties of - such as , , , and - may internally cause the creation of a new . - + property defines the mask-parsing engine and the masking language used by the control. The default provider is the class; however, a custom provider can be specified using the constructor. + + cannot be set directly. However, setting some of the properties of - such as , , , and - may internally cause the creation of a new . + ]]> @@ -1693,19 +1693,19 @@ if all required and optional inputs have been entered; otherwise, . - property within the event handler to determine if the user's input was rejected because there are no remaining inputs in the mask. To determine whether only required input elements have been entered, use the property. - - - -## Examples - The following code example handles the event, and uses a to alert the user if an attempt is made to enter data after all positions in the mask have been used. - + property within the event handler to determine if the user's input was rejected because there are no remaining inputs in the mask. To determine whether only required input elements have been entered, use the property. + + + +## Examples + The following code example handles the event, and uses a to alert the user if an attempt is made to enter data after all positions in the mask have been used. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MaskedTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MaskInputRejectedSample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MaskInputRejectedSample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1747,37 +1747,37 @@ Occurs when the user's input or assigned character does not match the corresponding format element of the input mask. - is the default event for the class. - - The event occurs when a character is rejected by the input mask. The input mask, represented by the property, is interpreted by the masked text provider associated with the control through the property. is raised in the following situations: - -- An input character does not match the corresponding format element. For example, the user enters an alphabetic character when a digit is required. This is probably the most common reason why this event is raised. - -- The user is trying to input extraneous characters beyond the end of the mask either because the mask has already been filled or the current caret position has been moved to the very end of the displayed input mask string. - -- A paste operation either inserts a character that does not match its associated format element, or if the property is `false`, it shifts existing characters into new positions where they do not match their format elements. - -- A cut operation shifts existing characters to the left, and one or more characters do not match their newly associated format elements. - -- An assignment was made to the property and the assigned string caused one or more mask violations. - - If a string was assigned to the control that causes to occur, no part of the string will appear in . - - The default handling for will play a beep sound if the property is set to `true`. This event is often handled to implement custom error handling, for example, to move to the next user input control if the mask is full, or to display a custom error dialog box or ToolTip if the input character is invalid. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `MaskedTextBox1`. Then ensure that the event handler is associated with the event. - + is the default event for the class. + + The event occurs when a character is rejected by the input mask. The input mask, represented by the property, is interpreted by the masked text provider associated with the control through the property. is raised in the following situations: + +- An input character does not match the corresponding format element. For example, the user enters an alphabetic character when a digit is required. This is probably the most common reason why this event is raised. + +- The user is trying to input extraneous characters beyond the end of the mask either because the mask has already been filled or the current caret position has been moved to the very end of the displayed input mask string. + +- A paste operation either inserts a character that does not match its associated format element, or if the property is `false`, it shifts existing characters into new positions where they do not match their format elements. + +- A cut operation shifts existing characters to the left, and one or more characters do not match their newly associated format elements. + +- An assignment was made to the property and the assigned string caused one or more mask violations. + + If a string was assigned to the control that causes to occur, no part of the string will appear in . + + The default handling for will play a beep sound if the property is set to `true`. This event is often handled to implement custom error handling, for example, to move to the next user input control if the mask is full, or to display a custom error dialog box or ToolTip if the input character is invalid. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `MaskedTextBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet486"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet486"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet486"::: + ]]> @@ -1832,11 +1832,11 @@ Gets or sets the maximum number of characters the user can type or paste into the text box control. This property is not supported by . This property always returns 0. - property and the property in the class for information about how to determine the maximum length of a string in a . - + property and the property in the class for information about how to determine the maximum length of a string in a . + ]]> @@ -1887,11 +1887,11 @@ Gets or sets a value indicating whether this is a multiline text box control. This property is not fully supported by . This property always returns . - property is inherited from the base class. However, because the control does not support multiline configuration, this property is not fully supported; it cannot be set and it always resolves to `false`. - + property is inherited from the base class. However, because the control does not support multiline configuration, this property is not fully supported; it cannot be set and it always resolves to `false`. + ]]> @@ -1947,11 +1947,11 @@ Typically occurs when the value of the property has changed; however, this event is not raised by . - event is inherited from the base class. However, because the control does not support multiline configuration, this event is not implemented in . - + event is inherited from the base class. However, because the control does not support multiline configuration, this event is not implemented in . + ]]> @@ -2081,13 +2081,13 @@ An that contains event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2228,13 +2228,13 @@ An that contains event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2305,11 +2305,11 @@ An that contains event data. Typically raises the event, but disabled for . - method is inherited from the base class. However, because the control does not support multiline configuration, this method is overridden to perform no actions. - + method is inherited from the base class. However, because the control does not support multiline configuration, this method is overridden to perform no actions. + ]]> @@ -2345,13 +2345,13 @@ An that contains event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2390,13 +2390,13 @@ An that contains event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2441,18 +2441,18 @@ A that contains event data. Raises the event. - method causes the input string to be validated against the property, if a has been specified for this property. It will then also raise the event. - + method causes the input string to be validated against the property, if a has been specified for this property. It will then also raise the event. + > [!NOTE] -> To ensure consistency with text-based controls, validation will occur even if the is read-only (its property is set to `true`). - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - +> To ensure consistency with text-based controls, validation will occur even if the is read-only (its property is set to `true`). + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> A critical exception occurred during the parsing of the input string. @@ -2504,16 +2504,16 @@ Gets or sets the character to be displayed in substitute for user input. The value used as the password character. - property is set to a non-null character, will display this character for all input into the control. Setting this property to `null` will disable this functionality. - - If you want to use the operating system supplied password character, which is defined in COMCTL32.dll, use the property instead. If both the and properties are activated, the latter takes precedence. - + property is set to a non-null character, will display this character for all input into the control. Setting this property to `null` will disable this functionality. + + If you want to use the operating system supplied password character, which is defined in COMCTL32.dll, use the property instead. If both the and properties are activated, the latter takes precedence. + > [!IMPORTANT] -> As a security consideration, the control disables cut and copy operations on password-protected strings. - +> As a security consideration, the control disables cut and copy operations on password-protected strings. + ]]> The character specified when setting this property is not a valid password character, as determined by the method of the class. @@ -2590,11 +2590,11 @@ if the message was processed by the control; otherwise, . - overrides its base control's implementation of to properly handle character events when the user is entering characters using an Input Method Editor (IME), such as is used for entering Japanese, Chinese, and other complex non-Latin scripts. detects any WM_CHAR messages that occur after it receives a WM_IME_CHAR message and suppresses them in order to prevent these characters from showing up in the control. If you derive from this control and override this message, you should duplicate this behavior if you wish your new control to work with IMEs. - + overrides its base control's implementation of to properly handle character events when the user is entering characters using an Input Method Editor (IME), such as is used for entering Japanese, Chinese, and other complex non-Latin scripts. detects any WM_CHAR messages that occur after it receives a WM_IME_CHAR message and suppresses them in order to prevent these characters from showing up in the control. If you derive from this control and override this message, you should duplicate this behavior if you wish your new control to work with IMEs. + ]]> @@ -2643,13 +2643,13 @@ Gets or sets the character used to represent the absence of user input in . The character used to prompt the user for input. The default is an underscore (_). - will be displayed in for any mask position that the user has not yet filled in. - - Use the property to specify whether the prompt is displayed when does not have focus. - + will be displayed in for any mask position that the user has not yet filled in. + + Use the property to specify whether the prompt is displayed when does not have focus. + ]]> The character specified when setting this property is not a valid prompt character, as determined by the method of the class. @@ -2723,21 +2723,21 @@ if processing of the input string should be terminated at the first parsing error; otherwise, if processing should ignore all errors. The default is . - in a single input operation, typically by copying and pasting a string. If the entire string only contains valid characters, according to their paste position in the input mask, then the entire operation will succeed. However, when a parsing error occurs, the behavior of depends on the value of , as follows: - -- If this property is `true`, then processing of the input string stops at the invalid character. All subsequent characters are ignored. A single event is raised. - -- If this property is `false`, then the invalid character is rejected, but parsing continues with the next character in the input string. A event is raised for every invalid character in the input string. - - The , and properties can also influence the interpretation of the user input. - - If the property is `false`, then any characters already in the input mask to the right of the insertion point will be displaced by the accepted number of characters. This shifting may cause additional parsing errors. - - A pasting operation can be mimicked programmatically by setting the property. - + in a single input operation, typically by copying and pasting a string. If the entire string only contains valid characters, according to their paste position in the input mask, then the entire operation will succeed. However, when a parsing error occurs, the behavior of depends on the value of , as follows: + +- If this property is `true`, then processing of the input string stops at the invalid character. All subsequent characters are ignored. A single event is raised. + +- If this property is `false`, then the invalid character is rejected, but parsing continues with the next character in the input string. A event is raised for every invalid character in the input string. + + The , and properties can also influence the interpretation of the user input. + + If the property is `false`, then any characters already in the input mask to the right of the insertion point will be displaced by the accepted number of characters. This shifting may cause additional parsing errors. + + A pasting operation can be mimicked programmatically by setting the property. + ]]> @@ -2781,20 +2781,20 @@ if the prompt character entered as input causes the current editable position in the mask to be reset; otherwise, to indicate that the prompt character is to be processed as a normal input character. The default is . - can treat two categories of characters - spaces and prompt characters - specially. Typically, each input character will be tested against the mask and either accepted or rejected. Assuming that the property is set to non-`null`, then setting the property to `true` will result in special processing for the prompt character. When the user enters the prompt character into the mask, it causes the current mask character position to be cleared and the current position to be advanced to the next editable character. - - takes precedence over the property, as shown in the following table. - -|ResetOnPrompt value|AllowPromptAsInput value|Resulting behavior| -|-------------------------|------------------------------|------------------------| -|`true`|`true`|The prompt character can be entered and it causes the current mask position to be reset. This is the default.| -|`true`|`false`|The prompt character can be entered and it causes the current mask position to be reset.| -|`false`|`true`|The prompt character is processed as a standard input character.| -|`false`|`false`|The prompt character is not valid and raises a event.| - + can treat two categories of characters - spaces and prompt characters - specially. Typically, each input character will be tested against the mask and either accepted or rejected. Assuming that the property is set to non-`null`, then setting the property to `true` will result in special processing for the prompt character. When the user enters the prompt character into the mask, it causes the current mask character position to be cleared and the current position to be advanced to the next editable character. + + takes precedence over the property, as shown in the following table. + +|ResetOnPrompt value|AllowPromptAsInput value|Resulting behavior| +|-------------------------|------------------------------|------------------------| +|`true`|`true`|The prompt character can be entered and it causes the current mask position to be reset. This is the default.| +|`true`|`false`|The prompt character can be entered and it causes the current mask position to be reset.| +|`false`|`true`|The prompt character is processed as a standard input character.| +|`false`|`false`|The prompt character is not valid and raises a event.| + ]]> @@ -2836,13 +2836,13 @@ if the space input character causes the current editable position in the mask to be reset; otherwise, to indicate that it is to be processed as a normal input character. The default is . - can treat two categories of characters - spaces and prompt characters - specially. Typically, each input character will be tested against the mask and either accepted or rejected. Setting the property to `true` will result in the current mask character position to be cleared and the current position to be advanced to the next editable character. - - The type of character input will determine whether the masking engine moves forward to the next character in the mask, or stays at the current position and waits for a matching character. If the input character is a space, and does not match the current non-editable character in the mask, the masking engine will skip ahead to the next character in the mask. If the input character is not a space, and does not match the current non-editable character in the mask, the masking engine will remain at the current mask position, and attempt to match the next input character against it. - + can treat two categories of characters - spaces and prompt characters - specially. Typically, each input character will be tested against the mask and either accepted or rejected. Setting the property to `true` will result in the current mask character position to be cleared and the current position to be advanced to the next editable character. + + The type of character input will determine whether the masking engine moves forward to the next character in the mask, or stays at the current position and waits for a matching character. If the input character is a space, and does not match the current non-editable character in the mask, the masking engine will skip ahead to the next character in the mask. If the input character is not a space, and does not match the current non-editable character in the mask, the masking engine will remain at the current mask position, and attempt to match the next input character against it. + ]]> @@ -2880,11 +2880,11 @@ Scrolls the contents of the control to the current caret position. This method is not supported by . - method is inherited from the base class. However, because the control does not support multiline configuration, this method is overridden to perform no actions. - + method is inherited from the base class. However, because the control does not support multiline configuration, this method is overridden to perform no actions. + ]]> @@ -2916,11 +2916,11 @@ Gets or sets the current selection in the control. The currently selected text as a . If no text is currently selected, this property resolves to an empty string. - , , and . Selections set using this property behave like a Paste operation: each character is matched against the mask, and the event is raised for invalid characters. If is `true`, literals and prompt characters are allowed when setting , and will be removed silently unless they violate the mask. - + , , and . Selections set using this property behave like a Paste operation: each character is matched against the mask, and the event is raised for invalid characters. If is `true`, literals and prompt characters are allowed when setting , and will be removed silently unless they violate the mask. + ]]> @@ -2963,23 +2963,23 @@ to allow literals to be reentered; otherwise, to prevent the user from overwriting literal characters. The default is . - at runtime, the current character position will sometimes fall on a literal. The property describes how user input for the next character is to be handled, as follows: - -- If this property is `true`, the user can either redundantly enter the same character as the literal at the current position, or can enter the next editable character, thereby jumping the current position to that position. - -- If this property is `false`, the user can only enter the next editable character. If the next position in the mask will not accept the literal character (for example, the user types "/" and the next position only accepts digits), the control will raise the event. - - As an example, in the "90/90/0000" date entry mask, the forward slash characters are literals. Assume that the user has entered two initial digits, "11", so the current position in the mask is at the first forward slash (/) literal. If is `true`, then the user has the following valid choices: - -- The user can enter a "/" character. This results in the position being moved to the next character, which in this example is the fourth position, a 9 masking element. - -- The user can enter the next editable character, which in this example is a digit. The digit would be validated and the current position would automatically be moved to the fifth position, which is a 0 masking element. - - If is `false`, then only a valid data input is allowed, which in this example would be a digit. - + at runtime, the current character position will sometimes fall on a literal. The property describes how user input for the next character is to be handled, as follows: + +- If this property is `true`, the user can either redundantly enter the same character as the literal at the current position, or can enter the next editable character, thereby jumping the current position to that position. + +- If this property is `false`, the user can only enter the next editable character. If the next position in the mask will not accept the literal character (for example, the user types "/" and the next position only accepts digits), the control will raise the event. + + As an example, in the "90/90/0000" date entry mask, the forward slash characters are literals. Assume that the user has entered two initial digits, "11", so the current position in the mask is at the first forward slash (/) literal. If is `true`, then the user has the following valid choices: + +- The user can enter a "/" character. This results in the position being moved to the next character, which in this example is the fourth position, a 9 masking element. + +- The user can enter the next editable character, which in this example is a digit. The digit would be validated and the current position would automatically be moved to the fifth position, which is a 0 masking element. + + If is `false`, then only a valid data input is allowed, which in this example would be a digit. + ]]> @@ -3041,26 +3041,26 @@ Gets or sets the text as it is currently displayed to the user. A containing the text currently displayed by the control. The default is an empty string. - is the default binding property for the class. - - Strings retrieved using this property are formatted according to the control's formatting properties, such as and . - - You can assign a string with or without literal characters to depending on the values of , , and . - - is the default binding property for . - - will raise the event whenever the formatted text value changes. Different properties may or may not cause this value to change. For example, changing the property will not raise the event, but changing the property will. - - - -## Examples - The following code example demonstrates the use of the property. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TestMaskedTextBox/VB/form1.vb" id="Snippet3"::: - + is the default binding property for the class. + + Strings retrieved using this property are formatted according to the control's formatting properties, such as and . + + You can assign a string with or without literal characters to depending on the values of , , and . + + is the default binding property for . + + will raise the event whenever the formatted text value changes. Different properties may or may not cause this value to change. For example, changing the property will not raise the event, but changing the property will. + + + +## Examples + The following code example demonstrates the use of the property. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TestMaskedTextBox/VB/form1.vb" id="Snippet3"::: + ]]> @@ -3112,11 +3112,11 @@ Gets or sets how text is aligned in a masked text box control. One of the enumeration values that specifies how text is aligned relative to the control. The default is . - property to align the displayed text within a to match the layout of visual elements on your form. For example, if your controls are all located on the right side of the form, you can set the property to , and the text will be aligned with the right side of the control instead of the default left alignment. - + property to align the displayed text within a to match the layout of visual elements on your form. For example, if your controls are all located on the right side of the form, you can set the property to , and the text will be aligned with the right side of the control instead of the default left alignment. + ]]> The value assigned to this property is not of type . @@ -3158,21 +3158,21 @@ Occurs when the text alignment is changed. - event is raised after the property is changed. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `MaskedTextBox1`. Then ensure that the event handler is associated with the event. - + event is raised after the property is changed. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `MaskedTextBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet487"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet487"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet487"::: + ]]> @@ -3253,14 +3253,14 @@ Gets or sets a value that determines whether literals and prompt characters are included in the formatted string. One of the values. The default is . - property determines how the literal and prompt characters in the mask are processed when the generating the formatted string. More specifically, it determines whether literal characters, prompt characters, or both are included in the property. When prompt characters are excluded, they are transformed into spaces in the formatted string. - + property determines how the literal and prompt characters in the mask are processed when the generating the formatted string. More specifically, it determines whether literal characters, prompt characters, or both are included in the property. When prompt characters are excluded, they are transformed into spaces in the formatted string. + > [!NOTE] -> The property serves a similar purpose with respect to how the property is interpreted. - +> The property serves a similar purpose with respect to how the property is interpreted. + ]]> Property set with a value that is not valid. @@ -3298,15 +3298,15 @@ Returns a string that represents the current masked text box. This method overrides . A that contains information about the current . The string includes the type, a simplified view of the input string, and the formatted input string. - method calls the base class implementation of this method, , then appends the input string after processing by the mask. This method honors properties that alter the appearance of the formatted string, with the following exceptions: - -- The returned string always includes prompt and literal characters, regardless of the values of the property. - -- Password characters are ignored, so that the actual user-typed characters are returned. In other words, the values of the and properties are ignored. - + method calls the base class implementation of this method, , then appends the input string after processing by the mask. This method honors properties that alter the appearance of the formatted string, with the following exceptions: + +- The returned string always includes prompt and literal characters, regardless of the values of the property. + +- Password characters are ignored, so that the actual user-typed characters are returned. In other words, the values of the and properties are ignored. + ]]> @@ -3347,37 +3347,37 @@ Occurs when has finished parsing the current value using the property. - control will optionally validate user input against the type defined by its property. When this property is not `null`, the following series of events occurs: - -1. The validation sequence begins when one of the following occurs: - - - control looses focus. - - - The property is retrieved. - - - The method is called. - -2. Any of these events result in a call to the `Parse` method of the type specified with the property. `Parse` is responsible for the conversion of the formatted input string to the target type. A successful conversion equates to a successful validation. - -3. After `Parse` returns, the event is raised. The event handler for this event is most commonly implemented to perform type or mask validation processing. It receives a parameter containing information about the conversion; for example, the member indicates whether the conversion was successful. - -4. After the event handler for the event returns, the standard validation event, , is raised. A handler can be implemented to perform standard validation, perhaps including canceling the event. - -5. If the event is not canceled in step 3, the standard control validation event is raised. - - If the property is set to `true` in the event handler, the event will be canceled and the control retains focus, unless the subsequent event sets its version of the property back to `false`. - - - -## Examples - The following code example attempts to parse the user's input as a valid object. If it fails, the event handler displays an error message to the user. If the value is a valid , the code verifies that the date supplied is not prior to today's date. This code example requires that your Windows Forms project contains a control named `MaskedTextBox1` and a control named `ToolTip1`. - + control will optionally validate user input against the type defined by its property. When this property is not `null`, the following series of events occurs: + +1. The validation sequence begins when one of the following occurs: + + - control looses focus. + + - The property is retrieved. + + - The method is called. + +2. Any of these events result in a call to the `Parse` method of the type specified with the property. `Parse` is responsible for the conversion of the formatted input string to the target type. A successful conversion equates to a successful validation. + +3. After `Parse` returns, the event is raised. The event handler for this event is most commonly implemented to perform type or mask validation processing. It receives a parameter containing information about the conversion; for example, the member indicates whether the conversion was successful. + +4. After the event handler for the event returns, the standard validation event, , is raised. A handler can be implemented to perform standard validation, perhaps including canceling the event. + +5. If the event is not canceled in step 3, the standard control validation event is raised. + + If the property is set to `true` in the event handler, the event will be canceled and the control retains focus, unless the subsequent event sets its version of the property back to `false`. + + + +## Examples + The following code example attempts to parse the user's input as a valid object. If it fails, the event handler displays an error message to the user. If the value is a valid , the code verifies that the date supplied is not prior to today's date. This code example requires that your Windows Forms project contains a control named `MaskedTextBox1` and a control named `ToolTip1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MaskedTextBox/TypeValidationCompleted/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidatingTypeSample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidatingTypeSample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -3418,11 +3418,11 @@ Undoes the last edit operation in the text box. This method is not supported by . - method is inherited from the base class. However, does not support undo functionality. - + method is inherited from the base class. However, does not support undo functionality. + ]]> @@ -3470,14 +3470,14 @@ if the system password should be used as the prompt character; otherwise, . The default is . - property determines whether user-supplied input should be displayed in the as multiple occurrences of a password character defined by the operating system. functions similarly to the property, but instead of using a programmer-supplied character for the prompt, uses a prompt defined by the operating system. This property has precedence over . - + property determines whether user-supplied input should be displayed in the as multiple occurrences of a password character defined by the operating system. functions similarly to the property, but instead of using a programmer-supplied character for the prompt, uses a prompt defined by the operating system. This property has precedence over . + > [!IMPORTANT] -> As a security consideration, the control disables cut and copy operations on password-protected strings. - +> As a security consideration, the control disables cut and copy operations on password-protected strings. + ]]> The password character specified is the same as the current prompt character, . The two are required to be different. @@ -3520,13 +3520,13 @@ Converts the user input string to an instance of the validating type. If successful, an of the type specified by the property; otherwise, to indicate conversion failure. - method attempts to convert the formatted string contained in the property to an instance of the type that is specified by the property. Prompt characters are ignored in the formatted string, but literals are handled in accordance with the current value of the property. - - raises the event after the conversion is attempted, regardless of its success. - + method attempts to convert the formatted string contained in the property to an instance of the type that is specified by the property. Prompt characters are ignored in the formatted string, but literals are handled in accordance with the current value of the property. + + raises the event after the conversion is attempted, regardless of its success. + ]]> A critical exception occurred during the parsing of the input string. @@ -3581,37 +3581,37 @@ Gets or sets the data type used to verify the data input by the user. A representing the data type used in validation. The default is . - to verify whether the data entered by the user falls within the correct range - in the previously mentioned case, by assigning it an instance of the type. The current text in the control will be validated either when the user leaves the control. You can determine whether or not the data fails validation by monitoring for the event. will only perform the check against if is `true`. - - If you want to use your own custom data types with , you must implement a static `Parse` method that takes a string as a parameter. This method must be implemented with one or both of the following signatures: - - `public static Object Parse(string)` - - `public static Object Parse(string, IFormatProvider)` - - - -## Examples - The following code example attempts to parse the user's input as a valid . If it fails, the event handler displays an error message to the user. If the value is a valid , the code performs an additional check to ensure that the date supplied is not prior to today's date. This code example requires that your Windows Forms project contains a control named `MaskedTextBox1` and a control named `ToolTip1`. - + to verify whether the data entered by the user falls within the correct range - in the previously mentioned case, by assigning it an instance of the type. The current text in the control will be validated either when the user leaves the control. You can determine whether or not the data fails validation by monitoring for the event. will only perform the check against if is `true`. + + If you want to use your own custom data types with , you must implement a static `Parse` method that takes a string as a parameter. This method must be implemented with one or both of the following signatures: + + `public static Object Parse(string)` + + `public static Object Parse(string, IFormatProvider)` + + + +## Examples + The following code example attempts to parse the user's input as a valid . If it fails, the event handler displays an error message to the user. If the value is a valid , the code performs an additional check to ensure that the date supplied is not prior to today's date. This code example requires that your Windows Forms project contains a control named `MaskedTextBox1` and a control named `ToolTip1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MaskedTextBox/TypeValidationCompleted/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidatingTypeSample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ValidatingTypeSample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -3695,11 +3695,11 @@ maskedTextBox1.Mask = "99/99/9999"; Gets or sets a value indicating whether a multiline text box control automatically wraps words to the beginning of the next line when necessary. This property is not supported by . The property always returns . - does not support multiple lines of input, the property is ignored. - + does not support multiple lines of input, the property is ignored. + ]]> diff --git a/xml/System.Windows.Forms/MdiClient.xml b/xml/System.Windows.Forms/MdiClient.xml index 092bd71a6fb..31daf29d9c5 100644 --- a/xml/System.Windows.Forms/MdiClient.xml +++ b/xml/System.Windows.Forms/MdiClient.xml @@ -46,15 +46,15 @@ Represents the container for multiple-document interface (MDI) child forms. This class cannot be inherited. - control. A form creates and uses the when you set the property to `true`. - + control. A form creates and uses the when you set the property to `true`. + ]]> - How To: Create an MDI Window List with MenuStrip (Windows Forms) - How to: Create an MDI Form with Menu Merging and ToolStrip Controls + How To: Create an MDI Window List with MenuStrip (Windows Forms) + How to: Create an MDI Form with Menu Merging and ToolStrip Controls @@ -120,11 +120,11 @@ Gets or sets the background image displayed in the control. The image to display in the background of the control. - property to get and set the background image of a form's MDI client area. - + property to get and set the background image of a form's MDI client area. + ]]> @@ -256,11 +256,11 @@ One of the enumeration values that defines the layout of MDI child forms. Arranges the multiple-document interface (MDI) child forms within the MDI parent form. - method to arrange MDI child forms on a parent form. - + method to arrange MDI child forms on a parent form. + ]]> @@ -293,11 +293,11 @@ Gets the child multiple-document interface (MDI) forms of the control. A array that contains the child MDI forms of the . - property to get the child MDI forms of the . - + property to get the child MDI forms of the . + ]]> diff --git a/xml/System.Windows.Forms/MenuStrip.xml b/xml/System.Windows.Forms/MenuStrip.xml index 29defbab9e0..ba90af89193 100644 --- a/xml/System.Windows.Forms/MenuStrip.xml +++ b/xml/System.Windows.Forms/MenuStrip.xml @@ -37,36 +37,36 @@ Provides a menu system for a form. - is the top-level container that supersedes . It also provides key handling and multiple document interface (MDI) features. Functionally, and work along with , although they are derived from . - - The following items are specifically designed to work seamlessly with both and in all orientations. They are available by default at design time for the control: - -- - -- - -- - - The control represents the container for the menu structure of a form. You can add objects to the that represent the individual menu commands in the menu structure. Each can be a command for your application or a parent menu for other submenu items. - + is the top-level container that supersedes . It also provides key handling and multiple document interface (MDI) features. Functionally, and work along with , although they are derived from . + + The following items are specifically designed to work seamlessly with both and in all orientations. They are available by default at design time for the control: + +- + +- + +- + + The control represents the container for the menu structure of a form. You can add objects to the that represent the individual menu commands in the menu structure. Each can be a command for your application or a parent menu for other submenu items. + The replaces and extends the control, which was removed in .NET Core 3.1. -## Examples - The following code example demonstrates a in a multiple-document interface (MDI) scenario. - +## Examples + The following code example demonstrates a in a multiple-document interface (MDI) scenario. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenuStrip/Overview/Program.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet10"::: + ]]> - MenuStrip Control (Windows Forms) - How to: Configure MenuStrip Check Margins and Image Margins - How to: Provide Standard Menu Items to a Form + MenuStrip Control (Windows Forms) + How to: Configure MenuStrip Check Margins and Image Margins + How to: Provide Standard Menu Items to a Form @@ -91,17 +91,17 @@ The replaces and extends the Initializes a new instance of the class. - to which you can add objects. -## Examples - The following code example demonstrates the constructor. This example is part of a larger example provided for the class. - +## Examples + The following code example demonstrates the constructor. This example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenuStrip/Overview/Program.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet12"::: + ]]> @@ -143,11 +143,11 @@ The replaces and extends the if the supports overflow functionality; otherwise, . The default is . - . When you set the property to `true`, you must also enable overflow for specific menu items by setting the property. By default, menu items are not displayed if they cannot fit within the available space. - + . When you set the property to `true`, you must also enable overflow for specific menu items by setting the property. By default, menu items are not displayed if they cannot fit within the available space. + ]]> @@ -179,16 +179,16 @@ The replaces and extends the Creates a new accessibility object for the control. A new for the control. - method, it will be called when the property is referenced. - + method, it will be called when the property is referenced. + > [!NOTE] -> To get or set the property, you must add a reference to the `Accessibility` assembly installed with the .NET Framework. - - For a code example of using , see . - +> To get or set the property, you must add a reference to the `Accessibility` assembly installed with the .NET Framework. + + For a code example of using , see . + ]]> @@ -228,11 +228,11 @@ The replaces and extends the Creates a with the specified text, image, and event handler on a new . A , or a if the parameter is a hyphen (-). - method to add a with commonly used characteristics to a . - + method to add a with commonly used characteristics to a . + ]]> @@ -292,11 +292,11 @@ The replaces and extends the Gets the spacing, in pixels, between the left, right, top, and bottom edges of the from the edges of the form. A that represents the spacing. The default is {Left=6, Top=2, Right=0, Bottom=2}. - property to set the interior space between controls. When a control is a container of items, padding represents the space from the edge of the container. - + property to set the interior space between controls. When a control is a container of items, padding represents the space from the edge of the container. + ]]> @@ -328,11 +328,11 @@ The replaces and extends the in all cases. - property always returns `false` because typically, ToolTips are not used for menus or menu items. - + property always returns `false` because typically, ToolTips are not used for menus or menu items. + ]]> @@ -448,19 +448,19 @@ The replaces and extends the Gets or sets the that is used to display a list of Multiple-document interface (MDI) child forms. A that represents the menu item displaying a list of MDI child forms that are open in the application. - property to designate or discover which displays MDI children. - + property to designate or discover which displays MDI children. + Use the and events on child menus to reflect changes to the value of . -## Examples - The following code example demonstrates the property. This example is part of a larger example provided for the class. - +## Examples + The following code example demonstrates the property. This example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenuStrip/Overview/Program.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet12"::: + ]]> @@ -491,21 +491,21 @@ The replaces and extends the Occurs when the user accesses the menu with the keyboard or mouse. - or typically neither take nor remove the focus from the control that currently has the focus. If there is a control hosted within the or a drop-down of the , the control gains focus when the user presses the TAB key. In general, the , , , and events of might not be raised when they are activated by the keyboard. In such cases, use the and events instead. - + or typically neither take nor remove the focus from the control that currently has the focus. If there is a control hosted within the or a drop-down of the , the control gains focus when the user presses the TAB key. In general, the , , , and events of might not be raised when they are activated by the keyboard. In such cases, use the and events instead. + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `MenuStrip1`. Then ensure that the event handler is associated with the event. - +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `MenuStrip1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet489"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet489"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet489"::: + ]]> @@ -536,21 +536,21 @@ The replaces and extends the Occurs when the is deactivated. - or typically neither take nor remove the focus from the control that currently has the focus. If there is a control hosted within the or a drop-down of the , the control gains focus when the user presses the TAB key. In general, the , , , and events of might not be raised when they are activated by the keyboard. In such cases, use the and events instead. - + or typically neither take nor remove the focus from the control that currently has the focus. If there is a control hosted within the or a drop-down of the , the control gains focus when the user presses the TAB key. In general, the , , , and events of might not be raised when they are activated by the keyboard. In such cases, use the and events instead. + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `MenuStrip1`. Then ensure that the event handler is associated with the event. - +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `MenuStrip1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet490"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet490"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet490"::: + ]]> @@ -584,13 +584,13 @@ The replaces and extends the An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -627,13 +627,13 @@ The replaces and extends the An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -709,11 +709,11 @@ The replaces and extends the if ToolTips are shown for the ; otherwise, . The default is . - property returns `false` by default because typically, ToolTips are not used for menus or menu items. - + property returns `false` by default because typically, ToolTips are not used for menus or menu items. + ]]> @@ -782,22 +782,22 @@ The replaces and extends the The Windows to process. Processes Windows messages. - method after getting filtered through the method. - + method after getting filtered through the method. + The method corresponds exactly to the Windows `WindowProc` function. For more information about processing Windows messages, see [WindowProc callback function](https://msdn.microsoft.com/library/windows/desktop/ms633573). - - - -## Examples - The following code example demonstrates overriding the method to handle operating system messages identified in the structure. The WM_ACTIVATEAPP operating system message is handled in this example to know when another application is becoming active. Refer to the Platform SDK documentation reference located at to understand the available , , and values. Actual constant values can be found in the windows.h header file included in the Platform SDK (Core SDK section) download, which is also available on Docs. - + + + +## Examples + The following code example demonstrates overriding the method to handle operating system messages identified in the structure. The WM_ACTIVATEAPP operating system message is handled in this example to know when another application is becoming active. Refer to the Platform SDK documentation reference located at to understand the available , , and values. Actual constant values can be found in the windows.h header file included in the Platform SDK (Core SDK section) download, which is also available on Docs. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.Control.WndProc/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/CheckedListBox/WndProc/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Control.WndProc/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Control.WndProc/VB/form1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/MessageBoxOptions.xml b/xml/System.Windows.Forms/MessageBoxOptions.xml index 62ffbf39eb0..8ef70707127 100644 --- a/xml/System.Windows.Forms/MessageBoxOptions.xml +++ b/xml/System.Windows.Forms/MessageBoxOptions.xml @@ -29,22 +29,22 @@ Specifies options on a . - class. +## Remarks -If you do not want to specify an argument when calling methods on , you can pass in 0 instead. +This enumeration is used by the class. + +If you do not want to specify an argument when calling methods on , you can pass in 0 instead. ## Examples -The following example demonstrates how to display a with the options supported by the overloads of that include an `options` parameter. After verifying that a string variable, `ServerName`, is empty, the example displays a with a question box icon, offering the user the option to cancel the operation. The example uses the `MessageBoxOptions.RightAlign` enumeration member to align the text to the right edge of the dialog box. If the method's return value evaluates to , the form that displayed the is closed. - +The following example demonstrates how to display a with the options supported by the overloads of that include an `options` parameter. After verifying that a string variable, `ServerName`, is empty, the example displays a with a question box icon, offering the user the option to cancel the operation. The example uses the `MessageBoxOptions.RightAlign` enumeration member to align the text to the right edge of the dialog box. If the method's return value evaluates to , the form that displayed the is closed. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/MessageBox.Show Variations/CPP/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DialogResult/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MessageBox.Show Variations/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MessageBox.Show Variations/VB/form1.vb" id="Snippet2"::: + ]]> @@ -74,7 +74,7 @@ The following example demonstrates how to display a 131072 - The message box is displayed on the active desktop. This constant is similar to `ServiceNotification`, except that the system displays the message box only on the default desktop of the interactive window station. The application that displayed the message box loses focus, and the message box is displayed without using visual styles. For more information, see Rendering Controls with Visual Styles. + The message box is displayed on the active desktop. This constant is similar to `ServiceNotification`, except that the system displays the message box only on the default desktop of the interactive window station. The application that displayed the message box loses focus, and the message box is displayed without using visual styles. For more information, see Rendering Controls with Visual Styles.
diff --git a/xml/System.Windows.Forms/MonthCalendar.xml b/xml/System.Windows.Forms/MonthCalendar.xml index 9aa9995c2ad..c21f139f61e 100644 --- a/xml/System.Windows.Forms/MonthCalendar.xml +++ b/xml/System.Windows.Forms/MonthCalendar.xml @@ -90,10 +90,10 @@ ]]> - How to: Change the Windows Forms MonthCalendar Control's Appearance - How to: Display More than One Month in the Windows Forms MonthCalendar Control - How to: Display Specific Days in Bold with the Windows Forms MonthCalendar Control - How to: Select a Range of Dates in the Windows Forms MonthCalendar Control + How to: Change the Windows Forms MonthCalendar Control's Appearance + How to: Display More than One Month in the Windows Forms MonthCalendar Control + How to: Display Specific Days in Bold with the Windows Forms MonthCalendar Control + How to: Select a Range of Dates in the Windows Forms MonthCalendar Control diff --git a/xml/System.Windows.Forms/MouseEventArgs.xml b/xml/System.Windows.Forms/MouseEventArgs.xml index c08a73b330a..259e271bd07 100644 --- a/xml/System.Windows.Forms/MouseEventArgs.xml +++ b/xml/System.Windows.Forms/MouseEventArgs.xml @@ -30,35 +30,35 @@ Provides data for the , , and events. - event occurs when the user presses the mouse button while the pointer is over a control. The event occurs when the user releases the mouse button while the pointer remains over the control. The event occurs when the user moves the mouse pointer over a control. A specifies which mouse button is pressed, how many times the mouse button was pressed and released, the coordinates of the mouse, and the amount the mouse wheel moved. - - It is possible to receive a event without a corresponding , if the user switches focus to another application before releasing the mouse button. - - These three events exist for the , , and classes. - - For information about the event model, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example handles the event on a control so that clicking the right mouse button selects all the text in the control. This example requires that you have a form that contains a control that is named `textBox1`. - + event occurs when the user presses the mouse button while the pointer is over a control. The event occurs when the user releases the mouse button while the pointer remains over the control. The event occurs when the user moves the mouse pointer over a control. A specifies which mouse button is pressed, how many times the mouse button was pressed and released, the coordinates of the mouse, and the amount the mouse wheel moved. + + It is possible to receive a event without a corresponding , if the user switches focus to another application before releasing the mouse button. + + These three events exist for the , , and classes. + + For information about the event model, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example handles the event on a control so that clicking the right mouse button selects all the text in the control. This example requires that you have a form that contains a control that is named `textBox1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MouseEventArgs/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet1"::: - - The following code example uses the `Location` property to track clicks of the left mouse button and to draw a series of straight line segments in response to user input. The example does not redraw the lines if you hide the form and then redisplay it; this code has been omitted for simplicity. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet1"::: + + The following code example uses the `Location` property to track clicks of the left mouse button and to draw a series of straight line segments in response to user input. The example does not redraw the lines if you hide the form and then redisplay it; this code has been omitted for simplicity. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MouseEventArgs/Overview/Form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet2"::: - - The following code example uses the and properties to display the current position of the mouse pointer in a window. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet2"::: + + The following code example uses the and properties to display the current position of the mouse pointer in a window. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MouseEventArgs/Overview/Form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet3"::: + ]]> @@ -150,14 +150,14 @@ Gets which mouse button was pressed. One of the values. - event on a control so that clicking the right mouse button selects all the text in the control. This example requires that you have a form that contains a control named `textBox1`. - + event on a control so that clicking the right mouse button selects all the text in the control. This example requires that you have a form that contains a control named `textBox1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MouseEventArgs/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet1"::: + ]]> @@ -199,21 +199,21 @@ Gets the number of times the mouse button was pressed and released. An that contains the number of times the mouse button was pressed and released. - event. This report helps you learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `Control1` and ensure that the event handler is associated with the event. - + event. This report helps you learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `Control1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet54"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet54"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet54"::: + ]]> @@ -253,23 +253,23 @@ Gets a signed count of the number of detents the mouse wheel has rotated, multiplied by the WHEEL_DELTA constant. A detent is one notch of the mouse wheel. A signed count of the number of detents the mouse wheel has rotated, multiplied by the WHEEL_DELTA constant. - event. This report helps you learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `Control1` and ensure that the event handler is associated with the event. - + event. This report helps you learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `Control1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet54"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet54"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet54"::: + ]]> @@ -302,21 +302,21 @@ Gets the location of the mouse during the generating mouse event. A that contains the x- and y- mouse coordinates, in pixels, relative to the upper-left corner of the control. - property to track left mouse clicks and draw a series of straight line segments in response to user input. The example does not persist the drawn lines if you hide the form and then redisplay it; this code was omitted for simplicity. - + property to track left mouse clicks and draw a series of straight line segments in response to user input. The example does not persist the drawn lines if you hide the form and then redisplay it; this code was omitted for simplicity. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MouseEventArgs/Overview/Form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet2"::: + ]]> - Windows Forms Coordinates - Mouse Events in Windows Forms + Windows Forms Coordinates + Mouse Events in Windows Forms @@ -352,19 +352,19 @@ Gets the x-coordinate of the mouse during the generating mouse event. The x-coordinate of the mouse, in pixels. - event is handled, the mouse coordinate values are relative to the coordinates of the control that raised the event. Some events related to drag-and-drop operations have associated mouse-coordinate values that are relative to the form origin or the screen origin. - - - -## Examples - The following code example uses the and properties to display the current position of the mouse pointer in a window. - + event is handled, the mouse coordinate values are relative to the coordinates of the control that raised the event. Some events related to drag-and-drop operations have associated mouse-coordinate values that are relative to the form origin or the screen origin. + + + +## Examples + The following code example uses the and properties to display the current position of the mouse pointer in a window. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MouseEventArgs/Overview/Form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet3"::: + ]]> @@ -405,19 +405,19 @@ Gets the y-coordinate of the mouse during the generating mouse event. The y-coordinate of the mouse, in pixels. - event is handled, the mouse coordinate values are relative to the coordinates of the control that raised the event. Some events related to drag-and-drop operations have associated mouse coordinate values that are relative to the form origin or the screen origin. - - - -## Examples - The following code example uses the and properties to display the current position of the mouse pointer in a window. To use this code, call `TrackCoordinates` from the form constructor. - + event is handled, the mouse coordinate values are relative to the coordinates of the control that raised the event. Some events related to drag-and-drop operations have associated mouse coordinate values that are relative to the form origin or the screen origin. + + + +## Examples + The following code example uses the and properties to display the current position of the mouse pointer in a window. To use this code, call `TrackCoordinates` from the form constructor. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/MouseEventArgs/Overview/Form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/MouseEventArgs/VB/Form1.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Windows.Forms/Padding.xml b/xml/System.Windows.Forms/Padding.xml index 1d76fb35859..131d6050421 100644 --- a/xml/System.Windows.Forms/Padding.xml +++ b/xml/System.Windows.Forms/Padding.xml @@ -56,37 +56,37 @@ Represents padding or margin information associated with a user interface (UI) element. - structure represents the padding or margin associated with a rectangular UI element such as a control. The padding is the internal space between the body of the UI element and its edge. In contrast, a margin is the distance separating the adjoining edges of two adjacent UI elements. Because of structural similarities, is used to represent both padding and margins. - - For a diagram that illustrates the and properties on a control, see [Margin and Padding in Windows Forms Controls](/dotnet/framework/winforms/controls/margin-and-padding-in-windows-forms-controls). - - Padding has a different effect on controls that are containers than on controls that are not. For example, in a control, the property defines the spacing between the border of the and its child controls. For a control, the property defines the spacing between the border of the control and its contained text. - - In addition to typical methods and properties, also defines the following type-level members: - -- The field, which represents a predefined with no padding. - -- A set of operators for performing common arithmetic operations for the class, such as adding two objects together. For languages that do not support operator overloading, you can invoke these members by using alternative method syntax. - -- The , , and properties, which provide combined values that are convenient for use in custom layout calculations. - - - -## Examples - The following code example demonstrates how to use the Padding property to create an outline around a control. - - For a full code listing, see [How to: Create a Border Around a Windows Forms Control Using Padding](/dotnet/framework/winforms/controls/how-to-create-a-border-around-a-windows-forms-control-using-padding). - + structure represents the padding or margin associated with a rectangular UI element such as a control. The padding is the internal space between the body of the UI element and its edge. In contrast, a margin is the distance separating the adjoining edges of two adjacent UI elements. Because of structural similarities, is used to represent both padding and margins. + + For a diagram that illustrates the and properties on a control, see [Margin and Padding in Windows Forms Controls](/dotnet/desktop/winforms/controls/margin-and-padding-in-windows-forms-controls). + + Padding has a different effect on controls that are containers than on controls that are not. For example, in a control, the property defines the spacing between the border of the and its child controls. For a control, the property defines the spacing between the border of the control and its contained text. + + In addition to typical methods and properties, also defines the following type-level members: + +- The field, which represents a predefined with no padding. + +- A set of operators for performing common arithmetic operations for the class, such as adding two objects together. For languages that do not support operator overloading, you can invoke these members by using alternative method syntax. + +- The , , and properties, which provide combined values that are convenient for use in custom layout calculations. + + + +## Examples + The following code example demonstrates how to use the Padding property to create an outline around a control. + + For a full code listing, see [How to: Create a Border Around a Windows Forms Control Using Padding](/dotnet/desktop/winforms/controls/how-to-create-a-border-around-a-windows-forms-control-using-padding). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Padding/Overview/Form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Padding/VB/Form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.Padding/VB/Form1.vb" id="Snippet2"::: + ]]> - Margin and Padding in Windows Forms Controls + Margin and Padding in Windows Forms Controls @@ -127,16 +127,16 @@ The number of pixels to be used for padding for all edges. Initializes a new instance of the class using the supplied padding size for all edges. - , , , and properties to the value of the `all` parameter. - + , , , and properties to the value of the `all` parameter. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -174,19 +174,19 @@ The padding size, in pixels, for the bottom edge. Initializes a new instance of the class using a separate padding size for each edge. - property will reflect this common value. - + property will reflect this common value. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -230,8 +230,8 @@ Computes the sum of the two specified values. A that contains the sum of the two specified values. To be added. - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -277,21 +277,21 @@ Gets or sets the padding value for all the edges. The padding, in pixels, for all edges if the same; otherwise, -1. - , , , and properties. - + , , , and properties. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -337,19 +337,19 @@ Gets or sets the padding value for the bottom edge. The padding, in pixels, for the bottom edge. - property. - + property. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -380,18 +380,18 @@ Provides a object with no padding. - , , and padding properties set to 0. - - This immutable field is useful for comparison operations and initializations. - + , , and padding properties set to 0. + + This immutable field is useful for comparison operations and initializations. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -436,17 +436,17 @@ if the objects are equivalent; otherwise, . - (or a derived type) can be equal to the current . In addition, the corresponding , , and properties for both objects must be the same. - + (or a derived type) can be equal to the current . In addition, the corresponding , , and properties for both objects must be the same. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -528,21 +528,21 @@ Generates a hash code for the current . A 32-bit signed integer hash code. - method uses the , , , and values to generate a 32-bit hash code that represents the current . - - A hash code is a number that corresponds to the value of an object (so two objects that have the same value should generate the same hash code). Hash codes are used to sort and store collections of objects. For example, a represents a collection of key-and-value pairs that are organized based on the hash code of the key. - - For more information on hash codes and hash functions, see the method. - + method uses the , , , and values to generate a 32-bit hash code that represents the current . + + A hash code is a number that corresponds to the value of an object (so two objects that have the same value should generate the same hash code). Hash codes are used to sort and store collections of objects. For example, a represents a collection of key-and-value pairs that are organized based on the hash code of the key. + + For more information on hash codes and hash functions, see the method. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -584,17 +584,17 @@ Gets the combined padding for the right and left edges. Gets the sum, in pixels, of the and padding values. - - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -640,19 +640,19 @@ Gets or sets the padding value for the left edge. The padding, in pixels, for the left edge. - property. - + property. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -690,18 +690,18 @@ Performs vector addition on the two specified objects, resulting in a new . A new that results from adding and . - property of the result is the sum of the properties of the two operands. - - This operation is transitive. - + property of the result is the sum of the properties of the two operands. + + This operation is transitive. + The equivalent method for this operator is ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -740,17 +740,17 @@ if the two objects are equal; otherwise, . - objects are equal if the padding values for each of the four edges - , , , and - are the same for both objects. - + objects are equal if the padding values for each of the four edges - , , , and - are the same for both objects. + The equivalent method for this operator is ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -789,16 +789,16 @@ if the two objects are different; otherwise, . - . - + . + The equivalent method for this operator is the negation of ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -836,16 +836,16 @@ Performs vector subtraction on the two specified objects, resulting in a new . The result of subtracting from . - property of the result is the difference between the properties of two operands. - + property of the result is the difference between the properties of two operands. + The equivalent method for this operator is ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -891,19 +891,19 @@ Gets or sets the padding value for the right edge. The padding, in pixels, for the right edge. - property. - + property. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -949,21 +949,21 @@ Gets the padding information in the form of a . A containing the padding information. - property performs a type conversion from to . The property corresponds to the property, and the property corresponds to the property. - - is convenient for use in many layout calculations. - + property performs a type conversion from to . The property corresponds to the property, and the property corresponds to the property. + + is convenient for use in many layout calculations. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -1007,8 +1007,8 @@ Subtracts one specified value from another. A that contains the result of the subtraction of one specified value from another. To be added. - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -1058,19 +1058,19 @@ Gets or sets the padding value for the top edge. The padding, in pixels, for the top edge. - property. - + property. + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -1110,18 +1110,18 @@ Returns a string that represents the current . A that represents the current . - . - + . + ]]> - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls @@ -1163,17 +1163,17 @@ Gets the combined padding for the top and bottom edges. Gets the sum, in pixels, of the and padding values. - - How to: Outline a Windows Forms Control Using Padding - Margin and Padding in Windows Forms Controls + How to: Outline a Windows Forms Control Using Padding + Margin and Padding in Windows Forms Controls diff --git a/xml/System.Windows.Forms/PictureBox.xml b/xml/System.Windows.Forms/PictureBox.xml index 0c0dc26e618..4d3920201c2 100644 --- a/xml/System.Windows.Forms/PictureBox.xml +++ b/xml/System.Windows.Forms/PictureBox.xml @@ -94,7 +94,7 @@ ]]> - Images, Bitmaps, and Metafiles + Images, Bitmaps, and Metafiles Working with Images, Bitmaps, Icons, and Metafiles diff --git a/xml/System.Windows.Forms/PrintDialog.xml b/xml/System.Windows.Forms/PrintDialog.xml index c9b7910caf9..b1c801aed8c 100644 --- a/xml/System.Windows.Forms/PrintDialog.xml +++ b/xml/System.Windows.Forms/PrintDialog.xml @@ -42,27 +42,27 @@ Lets users select a printer and choose which sections of the document to print from a Windows Forms application. - , the read/write properties are set to initial values. For a list of these values, see the constructor. To get printer settings that are modified by the user with the , use the property. - - For more information about printing with Windows Forms, see the namespace overview. If you want to print from a Windows Presentation Foundation application, see the namespace. - - - -## Examples - The following code example demonstrates how to use the control to set the , , and properties. To run this example, paste the following code into a form that contains a control named `PrintDialog1` and a button named `Button1`. This example requires that the button's event and the event of `docToPrint` have been connected to the event-handling methods defined in this example. - + , the read/write properties are set to initial values. For a list of these values, see the constructor. To get printer settings that are modified by the user with the , use the property. + + For more information about printing with Windows Forms, see the namespace overview. If you want to print from a Windows Presentation Foundation application, see the namespace. + + + +## Examples + The following code example demonstrates how to use the control to set the , , and properties. To run this example, paste the following code into a form that contains a control named `PrintDialog1` and a button named `Button1`. This example requires that the button's event and the event of `docToPrint` have been connected to the event-handling methods defined in this example. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/PrintDialog/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/VB/form1.vb" id="Snippet1"::: + ]]> - PrintDialog Component (Windows Forms) + PrintDialog Component (Windows Forms) @@ -88,24 +88,24 @@ Initializes a new instance of the class. - , the following read/write properties are set to initial values. - -|Property|Initial Value| -|--------------|-------------------| -||`false`| -||`true`| -||`false`| -||`null`| -||`null`| -||`false`| -||`false`| -||`true`| - - You can change the value for any one of these properties through a separate call to the property. - + , the following read/write properties are set to initial values. + +|Property|Initial Value| +|--------------|-------------------| +||`false`| +||`true`| +||`false`| +||`null`| +||`null`| +||`false`| +||`false`| +||`true`| + + You can change the value for any one of these properties through a separate call to the property. + ]]> @@ -154,11 +154,11 @@ if the **Current Page** option button is displayed; otherwise, . The default is . - property has no effect. - + property has no effect. + ]]> @@ -298,15 +298,15 @@ if the **Pages** option button is enabled; otherwise, . The default is . - control to set the , , and properties. To run this example, paste the following code into a form that contains a control named `PrintDialog1` and a button named `Button1`. This example requires that the button's event and the event of `docToPrint` have been connected to the event-handling methods defined in this example. - + control to set the , , and properties. To run this example, paste the following code into a form that contains a control named `PrintDialog1` and a button named `Button1`. This example requires that the button's event and the event of `docToPrint` have been connected to the event-handling methods defined in this example. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/PrintDialog/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -355,15 +355,15 @@ Gets or sets a value indicating the used to obtain . The used to obtain . The default is . - control to set the , , and properties. To run this example, paste the following code into a form that contains a control named `PrintDialog1` and a button named `Button1`. This example requires that the button's event and the event of `docToPrint` have been connected to the event-handling methods defined in this example. - + control to set the , , and properties. To run this example, paste the following code into a form that contains a control named `PrintDialog1` and a button named `Button1`. This example requires that the button's event and the event of `docToPrint` have been connected to the event-handling methods defined in this example. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/PrintDialog/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -414,11 +414,11 @@ Gets or sets the printer settings the dialog box modifies. The the dialog box modifies. - property must be set before you call or an exception will occur. - + property must be set before you call or an exception will occur. + ]]> @@ -572,20 +572,20 @@ if the **Help** button is displayed; otherwise, . The default is . - control setting the , , and properties. To run this example paste the following code in a form that contains a control named `PrintDialog1` and a button named `Button1`. This example requires that the button's event and the event of `docToPrint` have been connected to the event handling methods defined in this example. - + control setting the , , and properties. To run this example paste the following code in a form that contains a control named `PrintDialog1` and a button named `Button1`. This example requires that the button's event and the event of `docToPrint` have been connected to the event handling methods defined in this example. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/PrintDialog/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.PrintDialogExample/VB/form1.vb" id="Snippet1"::: + ]]> @@ -633,11 +633,11 @@ if the **Network** button is displayed; otherwise, . The default is . - @@ -684,11 +684,11 @@ to indicate the dialog should be shown with the Windows XP style, otherwise . The default is . - and will be ignored as these properties were made obsolete for Windows 2000 and later versions of Windows. - + and will be ignored as these properties were made obsolete for Windows 2000 and later versions of Windows. + ]]> diff --git a/xml/System.Windows.Forms/ProfessionalColorTable.xml b/xml/System.Windows.Forms/ProfessionalColorTable.xml index b177c78c161..56429063ecf 100644 --- a/xml/System.Windows.Forms/ProfessionalColorTable.xml +++ b/xml/System.Windows.Forms/ProfessionalColorTable.xml @@ -29,15 +29,15 @@ Provides colors used for Microsoft Office display elements. - . - + . + ]]> - How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms + How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms @@ -832,11 +832,11 @@ Gets the starting color of the gradient used in the image margin of a . A that is the starting color of the gradient used in the image margin of a . - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -867,11 +867,11 @@ Gets the end color of the gradient used in the image margin of a . A that is the end color of the gradient used in the image margin of a . - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -908,11 +908,11 @@ Gets the middle color of the gradient used in the image margin of a . A that is the middle color of the gradient used in the image margin of a . - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -949,11 +949,11 @@ Gets the starting color of the gradient used in the image margin of a when an item is revealed. A that is the starting color of the gradient used in the image margin of a when an item is revealed. - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -990,11 +990,11 @@ Gets the end color of the gradient used in the image margin of a when an item is revealed. A that is the end color of the gradient used in the image margin of a when an item is revealed. - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -1031,11 +1031,11 @@ Gets the middle color of the gradient used in the image margin of a when an item is revealed. A that is the middle color of the gradient used in the image margin of a when an item is revealed. - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -2050,11 +2050,11 @@ to use ; otherwise, . The default is . - uses the colors in . - + uses the colors in . + ]]> diff --git a/xml/System.Windows.Forms/ProfessionalColors.xml b/xml/System.Windows.Forms/ProfessionalColors.xml index fcd4e2f93f0..c8811dc6545 100644 --- a/xml/System.Windows.Forms/ProfessionalColors.xml +++ b/xml/System.Windows.Forms/ProfessionalColors.xml @@ -34,7 +34,7 @@ Provides structures that are colors of a Windows display element. This class cannot be inherited. To be added. - How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms + How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms @@ -679,11 +679,11 @@ Gets the starting color of the gradient used in the image margin of a . A that is the starting color of the gradient used in the image margin of a . - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -714,11 +714,11 @@ Gets the end color of the gradient used in the image margin of a . A that is the end color of the gradient used in the image margin of a . - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -749,11 +749,11 @@ Gets the middle color of the gradient used in the image margin of a . A that is the middle color of the gradient used in the image margin of a . - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -784,11 +784,11 @@ Gets the starting color of the gradient used in the image margin of a when an item is revealed. A that is the starting color of the gradient used in the image margin of a when an item is revealed. - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -819,11 +819,11 @@ Gets the end color of the gradient used in the image margin of a when an item is revealed. A that is the end color of the gradient used in the image margin of a when an item is revealed. - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> @@ -854,11 +854,11 @@ Gets the middle color of the gradient used in the image margin of a when an item is revealed. A that is the middle color of the gradient used in the image margin of a when an item is revealed. - must be set to `true` for this color to be displayed. - + must be set to `true` for this color to be displayed. + ]]> diff --git a/xml/System.Windows.Forms/ProgressBarRenderer.xml b/xml/System.Windows.Forms/ProgressBarRenderer.xml index 05d9f58416f..4347b2c3c61 100644 --- a/xml/System.Windows.Forms/ProgressBarRenderer.xml +++ b/xml/System.Windows.Forms/ProgressBarRenderer.xml @@ -33,24 +33,24 @@ Provides methods used to render a progress bar control with visual styles. This class cannot be inherited. - class provides a set of `static` methods that can be used to render a progress bar control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a progress bar, use the or methods to draw the empty bar, and then use the or methods to draw the elements that fill in the bar. - - If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, the methods of this class will draw the progress bar with the current visual style. Otherwise, the methods and properties of this class will throw an . To determine whether the members of this class can be used, you can check the value of the property. - - This class wraps the functionality of a that is set to one of the elements exposed by the , , , and classes. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - - - -## Examples - The following code example demonstrates how to create a custom control that uses the and methods to draw a vertical progress bar. The control uses a to redraw the progress bar with an added piece each second. The `SetupProgressBar` method uses the and properties to calculate the height of each progressively larger rectangle that is drawn. - + class provides a set of `static` methods that can be used to render a progress bar control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a progress bar, use the or methods to draw the empty bar, and then use the or methods to draw the elements that fill in the bar. + + If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, the methods of this class will draw the progress bar with the current visual style. Otherwise, the methods and properties of this class will throw an . To determine whether the members of this class can be used, you can check the value of the property. + + This class wraps the functionality of a that is set to one of the elements exposed by the , , , and classes. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + + + +## Examples + The following code example demonstrates how to create a custom control that uses the and methods to draw a vertical progress bar. The control uses a to redraw the progress bar with an added piece each second. The `SetupProgressBar` method uses the and properties to calculate the height of each progressively larger rectangle that is drawn. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/cpp/form1.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ProgressBarRenderer/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet0"::: + ]]> @@ -83,32 +83,32 @@ Gets the width, in pixels, of the space between each inner piece of the progress bar. The width, in pixels, of the space between each inner piece of the progress bar. - property returns `true`. - - - -## Examples - The following code example uses the property to determine the size of each rectangle that represents an increment of the progress bar drawn by the method. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the property to determine the size of each rectangle that represents an increment of the progress bar drawn by the method. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ProgressBarRenderer/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet4"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -138,32 +138,32 @@ Gets the width, in pixels, of a single inner piece of the progress bar. The width, in pixels, of a single inner piece of the progress bar. - property returns `true`. - - - -## Examples - The following code example uses the property to determine the size of each rectangle that represents an increment of the progress bar drawn by the method. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the property to determine the size of each rectangle that represents an increment of the progress bar drawn by the method. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ProgressBarRenderer/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet4"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -198,21 +198,21 @@ The that specifies the bounds of the progress bar. Draws an empty progress bar control that fills in horizontally. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -247,23 +247,23 @@ The that specifies the bounds to be filled by progress bar pieces. Draws a set of progress bar pieces that fill a horizontal progress bar. - and properties. - - Before using this method, you should verify that the property returns `true`. - + and properties. + + Before using this method, you should verify that the property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -298,30 +298,30 @@ The that specifies the bounds of the progress bar. Draws an empty progress bar control that fills in vertically. - property returns `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw an empty progress bar. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw an empty progress bar. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ProgressBarRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet2"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -356,32 +356,32 @@ The that specifies the bounds to be filled by progress bar pieces. Draws a set of progress bar pieces that fill a vertical progress bar. - and . - - Before using this method, you should verify that the property returns `true`. - - - -## Examples - The following code example uses the method in a event handler to draw each increment of a progress bar. This code example is part of a larger example provided for the class. - + and . + + Before using this method, you should verify that the property returns `true`. + + + +## Examples + The following code example uses the method in a event handler to draw each increment of a progress bar. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/cpp/form1.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ProgressBarRenderer/Overview/form1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet6"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -412,20 +412,20 @@ if the user has enabled visual styles in the operating system and visual styles are applied to the client area of application windows; otherwise, . - . - - - -## Examples - The following code example uses the property to determine whether to call the method. This code example is part of a larger example provided for the class. - + . + + + +## Examples + The following code example uses the property to determine whether to call the method. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ProgressBarRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ProgressBarRenderer/VB/form1.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Windows.Forms/RadioButtonRenderer.xml b/xml/System.Windows.Forms/RadioButtonRenderer.xml index c32b3617e79..fc72f97cc11 100644 --- a/xml/System.Windows.Forms/RadioButtonRenderer.xml +++ b/xml/System.Windows.Forms/RadioButtonRenderer.xml @@ -33,24 +33,24 @@ Provides methods used to render an option button control (also known as a radio button) with or without visual styles. This class cannot be inherited. - class provides a set of `static` methods that can be used to render an option button control. Rendering a control refers to drawing the user interface of a control. To draw an option button, use one of the methods. These methods provide a variety of options, such as drawing text or an image with the option button. - - If visual styles are enabled in the operating system and visual styles are applied to the current application, will draw the option button with the current visual style. Otherwise, will draw the option button with the classic Windows style. This is useful if you are drawing a custom control that should automatically match the current visual style setting of the operating system. - - This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - - - -## Examples - The following code example demonstrates how to write a custom control that uses the method to draw an option button that responds to mouse clicks. - + class provides a set of `static` methods that can be used to render an option button control. Rendering a control refers to drawing the user interface of a control. To draw an option button, use one of the methods. These methods provide a variety of options, such as drawing text or an image with the option button. + + If visual styles are enabled in the operating system and visual styles are applied to the current application, will draw the option button with the current visual style. Otherwise, will draw the option button with the classic Windows style. This is useful if you are drawing a custom control that should automatically match the current visual style setting of the operating system. + + This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + + + +## Examples + The following code example demonstrates how to write a custom control that uses the method to draw an option button that responds to mouse clicks. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/cpp/form1.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/RadioButtonRenderer/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/VB/form1.vb" id="Snippet0"::: + ]]> @@ -92,11 +92,11 @@ The control whose parent's background will be drawn. Draws the background of a control's parent in the specified area. - @@ -144,11 +144,11 @@ One of the values that specifies the visual state of the option button. Draws an option button control (also known as a radio button) in the specified state and location. - @@ -210,20 +210,20 @@ One of the values that specifies the visual state of the option button. Draws an option button control (also known as a radio button) in the specified state and location, with the specified text, and with an optional focus rectangle. - method in a custom control's method to draw an option button in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. - + method in a custom control's method to draw an option button in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/RadioButtonRenderer/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/VB/form1.vb" id="Snippet4"::: + ]]> @@ -281,11 +281,11 @@ One of the values that specifies the visual state of the option button. Draws an option button control (also known as a radio button) in the specified state and location, with the specified text and text formatting, and with an optional focus rectangle. - @@ -358,11 +358,11 @@ One of the values that specifies the visual state of the option button. Draws an option button control (also known as a radio button) in the specified state and location, with the specified text and image, and with an optional focus rectangle. - @@ -431,11 +431,11 @@ One of the values that specifies the visual state of the option button. Draws an option button control (also known as a radio button) in the specified state and location; with the specified text, text formatting, and image; and with an optional focus rectangle. - @@ -472,20 +472,20 @@ Returns the size, in pixels, of the option button (also known as a radio button) glyph. A that represents the size, in pixels, of the option button glyph. - method to determine the bounds of the option button text. This code example is part of a larger example provided for the class. - + method to determine the bounds of the option button text. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/RadioButtonRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/VB/form1.vb" id="Snippet2"::: + ]]> @@ -561,19 +561,19 @@ if the application state is used to determine rendering style; otherwise, . The default is . - property is `true`, the uses the setting from the property to determine the rendering style. If is `false`, the renderer will always render using visual styles. - - - -## Examples - The following code example uses the property to show the render style is changed depending on the application state. This code example is part of a larger example provided for the class. - + property is `true`, the uses the setting from the property to determine the rendering style. If is `false`, the renderer will always render using visual styles. + + + +## Examples + The following code example uses the property to show the render style is changed depending on the application state. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/RadioButtonRenderer/Overview/form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/VB/form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.RadioButtonRenderer/VB/form1.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Windows.Forms/ScrollBarRenderer.xml b/xml/System.Windows.Forms/ScrollBarRenderer.xml index e0325bc9115..018f95f8a89 100644 --- a/xml/System.Windows.Forms/ScrollBarRenderer.xml +++ b/xml/System.Windows.Forms/ScrollBarRenderer.xml @@ -33,24 +33,24 @@ Provides methods used to render a scroll bar control with visual styles. This class cannot be inherited. - class provides a set of `static` methods that can be used to render a scroll bar control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a scroll bar, use a combination of the methods in this class to render each part of the scroll bar. - - If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, the methods of this class will draw the scroll bar with the current visual style. Otherwise, the methods of this class will throw an . To determine whether the members of this class can be used, you can check the value of the property. - - This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - - - -## Examples - The following code example demonstrates how to create a custom control that uses the methods to draw a scroll bar that responds to mouse clicks. - + class provides a set of `static` methods that can be used to render a scroll bar control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a scroll bar, use a combination of the methods in this class to render each part of the scroll bar. + + If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, the methods of this class will draw the scroll bar with the current visual style. Otherwise, the methods of this class will throw an . To determine whether the members of this class can be used, you can check the value of the property. + + This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + + + +## Examples + The following code example demonstrates how to create a custom control that uses the methods to draw a scroll bar that responds to mouse clicks. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/cpp/form1.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ScrollBarRenderer/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet0"::: + ]]> @@ -90,30 +90,30 @@ One of the values that specifies the visual state of the scroll arrow. Draws a scroll arrow with visual styles. - property returns `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw a scroll arrow in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw a scroll arrow in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ScrollBarRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -150,30 +150,30 @@ One of the values that specifies the visual state of the scroll box. Draws a horizontal scroll box (also known as the thumb) with visual styles. - property returns `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw a scroll box in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw a scroll box in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ScrollBarRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -210,30 +210,30 @@ One of the values that specifies the visual state of the scroll box grip. Draws a grip on a horizontal scroll box (also known as the thumb) with visual styles. - property returns `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw a scroll box grip in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw a scroll box grip in the state determined by the location of the mouse pointer. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ScrollBarRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -270,30 +270,30 @@ One of the values that specifies the visual state of the scroll bar track. Draws a horizontal scroll bar track with visual styles. - property returns `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw the left side of a scroll bar track in the pressed state. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw the left side of a scroll bar track in the pressed state. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ScrollBarRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -330,21 +330,21 @@ One of the values that specifies the visual state of the scroll bar track. Draws a vertical scroll bar track with visual styles. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -381,30 +381,30 @@ One of the values that specifies the visual state of the scroll bar track. Draws a horizontal scroll bar track with visual styles. - property returns `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw the scroll bar track. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw the scroll bar track. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ScrollBarRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -441,21 +441,21 @@ One of the values that specifies the visual state of the sizing handle. Draws a scroll bar sizing handle with visual styles. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -492,21 +492,21 @@ One of the values that specifies the visual state of the scroll bar track. Draws a vertical scroll bar track with visual styles. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -543,21 +543,21 @@ One of the values that specifies the visual state of the scroll box. Draws a vertical scroll box (also known as the thumb) with visual styles. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -594,21 +594,21 @@ One of the values that specifies the visual state of the scroll box grip. Draws a grip on a vertical scroll box (also known as the thumb) with visual styles. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -644,23 +644,23 @@ Returns the size of the sizing handle. A that specifies the size of the sizing handle. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -696,23 +696,23 @@ Returns the size of the scroll box grip. A that specifies the size of the scroll box grip. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -743,20 +743,20 @@ if the user has enabled visual styles in the operating system and visual styles are applied to the client areas of application windows; otherwise, . - . - - - -## Examples - The following code example uses the property to determine whether to use the methods. This code example is part of a larger example provided for the class. - + . + + + +## Examples + The following code example uses the property to determine whether to use the methods. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ScrollBarRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ScrollBarRenderer/VB/form1.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Windows.Forms/SplitContainer.xml b/xml/System.Windows.Forms/SplitContainer.xml index 36b795d2b6b..321a181ba32 100644 --- a/xml/System.Windows.Forms/SplitContainer.xml +++ b/xml/System.Windows.Forms/SplitContainer.xml @@ -62,38 +62,38 @@ Represents a control consisting of a movable bar that divides a container's display area into two resizable panels. - controls to existing panels to create many resizable display areas. - - Use the control to divide the display area of a container (such as a ) and allow the user to resize controls that are added to the panels. When the user passes the mouse pointer over the splitter, the cursor changes to indicate that the controls inside the control can be resized. - + controls to existing panels to create many resizable display areas. + + Use the control to divide the display area of a container (such as a ) and allow the user to resize controls that are added to the panels. When the user passes the mouse pointer over the splitter, the cursor changes to indicate that the controls inside the control can be resized. + > [!NOTE] -> Previous versions of the .NET Framework only support the control. - - also eases control placement at design time. For example, to create a window similar to Windows Explorer, add a control to a and set its property to `DockStyle.Fill`. Add a control to the and set its property to `DockStyle.Fill`. To complete the layout, add a control and set its property to `DockStyle.Fill` to have the occupy the remaining space on the . At run time, the user can then resize the width of both controls using the splitter. Use the property to specify that a control should not be resized along with the or other container. - - Use to specify where the splitter starts on your form. Use to specify how many pixels the splitter moves at a time. The default for is one pixel. - - Use and to specify how close the splitter bar can be moved to the outside edge of a panel. The default minimum size of a panel is 25 pixels. - - Use the property to specify horizontal orientation. The default orientation of the is vertical. - - Use the property to specify the border style of the and coordinate its border style with the border style of controls that you add to the . - - - -## Examples - The following code example shows both a vertical and horizontal . The vertical splitter moves in 10-pixel increments. The left panel of the vertical contains a control, and its right panel contains a horizontal . Both panels of the horizontal are filled with controls, and the top panel is defined as a so that it does not resize when you resize the container. Moving the vertical splitter raises the event, signified in this example by a change to the cursor style. The event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default. - +> Previous versions of the .NET Framework only support the control. + + also eases control placement at design time. For example, to create a window similar to Windows Explorer, add a control to a and set its property to `DockStyle.Fill`. Add a control to the and set its property to `DockStyle.Fill`. To complete the layout, add a control and set its property to `DockStyle.Fill` to have the occupy the remaining space on the . At run time, the user can then resize the width of both controls using the splitter. Use the property to specify that a control should not be resized along with the or other container. + + Use to specify where the splitter starts on your form. Use to specify how many pixels the splitter moves at a time. The default for is one pixel. + + Use and to specify how close the splitter bar can be moved to the outside edge of a panel. The default minimum size of a panel is 25 pixels. + + Use the property to specify horizontal orientation. The default orientation of the is vertical. + + Use the property to specify the border style of the and coordinate its border style with the border style of controls that you add to the . + + + +## Examples + The following code example shows both a vertical and horizontal . The vertical splitter moves in 10-pixel increments. The left panel of the vertical contains a control, and its right panel contains a horizontal . Both panels of the horizontal are filled with controls, and the top panel is defined as a so that it does not resize when you resize the container. Moving the vertical splitter raises the event, signified in this example by a change to the cursor style. The event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/BasicSplitContainer/CPP/basicsplitcontainer.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/Overview/basicsplitcontainer.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet1"::: + ]]> - SplitContainer Control (Windows Forms) + SplitContainer Control (Windows Forms) @@ -165,11 +165,11 @@ if scroll bars to automatically appear when controls are placed outside the client area; otherwise, . The default is . - @@ -218,15 +218,15 @@ Gets or sets the size of the auto-scroll margin. This property is not relevant to this class. This property is not relevant to this class. A value that represents the height and width, in pixels, of the auto-scroll margin. - size is added to the size of any child controls contained in the scrollable control to determine if scroll bars are needed. The property is evaluated when the parent scrollable control is resized or the individual child controls are brought into view, and is used to determine if scroll bars must be displayed. Docked controls are excluded from the calculations that determine if scroll bars must be displayed. - - If the distance from the edge of a child control to the parent scrollable control is less than the value assigned to the property and the property is set to `true`, the appropriate scroll bar is displayed. - - This property is not relevant to this class. - + size is added to the size of any child controls contained in the scrollable control to determine if scroll bars are needed. The property is evaluated when the parent scrollable control is resized or the individual child controls are brought into view, and is used to determine if scroll bars must be displayed. Docked controls are excluded from the calculations that determine if scroll bars must be displayed. + + If the distance from the edge of a child control to the parent scrollable control is less than the value assigned to the property and the property is set to `true`, the appropriate scroll bar is displayed. + + This property is not relevant to this class. + ]]> @@ -276,13 +276,13 @@ Gets or sets the minimum size of the scroll bar. This property is not relevant to this class. A that represents the minimum height and width of the scroll bar, in pixels. - property to manage the screen size allocated to the automatic scroll bar. - - This property is not relevant to this class. - + property to manage the screen size allocated to the automatic scroll bar. + + This property is not relevant to this class. + ]]> @@ -328,11 +328,11 @@ This property is not relevant to this class. A value. - @@ -381,11 +381,11 @@ This property is not relevant to this class. A value. - @@ -435,11 +435,11 @@ if the is automatically resized; otherwise, . - property is set to `true`, the will resize automatically to encompass its contents, although it will never be resized to be smaller than its original . This operation will maintain the control's . This property is not relevant to this class. - + property is set to `true`, the will resize automatically to encompass its contents, although it will never be resized to be smaller than its original . This operation will maintain the control's . This property is not relevant to this class. + ]]> @@ -481,13 +481,13 @@ Occurs when the value of the property changes. This property is not relevant to this class. - @@ -529,17 +529,17 @@ Gets or sets the background image displayed in the control. An that represents the image to display in the background of the control. - property to place a graphic image onto a control. - + property to place a graphic image onto a control. + > [!NOTE] -> Images with translucent or transparent colors are not supported by Windows Forms controls as background images. -> -> This property is not supported on child controls whose property is `true`. - +> Images with translucent or transparent colors are not supported by Windows Forms controls as background images. +> +> This property is not supported on child controls whose property is `true`. + ]]> @@ -582,23 +582,23 @@ Occurs when the property changes. - property is changed by either a programmatic modification or user interaction. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `SplitContainer1`. Then ensure that the event handler is associated with the event. - + property is changed by either a programmatic modification or user interaction. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `SplitContainer1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet546"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet546"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet546"::: + ]]> @@ -641,11 +641,11 @@ This property is not relevant to this class. An value. - @@ -686,11 +686,11 @@ Occurs when the property changes. This event is not relevant to this class. - @@ -802,11 +802,11 @@ Gets or sets the style of border for the . One of the values. The default is . - property to coordinate the border of the splitter and the outer edges of the panels with the border of the control or controls that the contains. - + property to coordinate the border of the splitter and the outer edges of the panels with the border of the control or controls that the contains. + ]]> The value of the property is not one of the values. @@ -849,11 +849,11 @@ This event is not relevant to this class. - @@ -894,11 +894,11 @@ This event is not relevant to this class. - @@ -947,11 +947,11 @@ Gets a collection of child controls. This property is not relevant to this class. An object of type that contains the child controls. - @@ -1044,11 +1044,11 @@ Gets the default size of the . A that represents the size of the . - property in a derived class to specify a default size for . This is more efficient than setting the size in the constructor. - + property in a derived class to specify a default size for . This is more efficient than setting the size in the constructor. + ]]> @@ -1080,29 +1080,29 @@ Gets or sets which borders are attached to the edges of the container. One of the values. The default value is . - to any edge of its container, or you can dock a to all edges of the container so that the entirely fills the container. For example, set this property to to attach the left edge of the to the left edge of its container. Controls are docked in z-order. - + to any edge of its container, or you can dock a to all edges of the container so that the entirely fills the container. For example, set this property to to attach the left edge of the to the left edge of its container. Controls are docked in z-order. + > [!NOTE] -> The z-order corresponds to the depth dimension of the screen, and the x-order and y-order corresponds to the horizontal and vertical dimensions, respectively. Z-order defines which object appears in front of which, in cases where controls or windows can overlap or occupy the same space on the screen. A control or window at the top of the z-order appears on top of all other controls or windows and is referenced by an index of 0 in the property. A control or window at the bottom of the z-order appears underneath all other controls or windows and is referenced by an index of `(Controls.Count-1)` in the property. - - For more information about anchoring and docking controls, see [How to: Create a Multipane User Interface with Windows Forms](/dotnet/framework/winforms/controls/how-to-create-a-multipane-user-interface-with-windows-forms). - - - -## Examples - The following code example shows a vertical splitter whose property is set to `Fill`. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. - +> The z-order corresponds to the depth dimension of the screen, and the x-order and y-order corresponds to the horizontal and vertical dimensions, respectively. Z-order defines which object appears in front of which, in cases where controls or windows can overlap or occupy the same space on the screen. A control or window at the top of the z-order appears on top of all other controls or windows and is referenced by an index of 0 in the property. A control or window at the bottom of the z-order appears underneath all other controls or windows and is referenced by an index of `(Controls.Count-1)` in the property. + + For more information about anchoring and docking controls, see [How to: Create a Multipane User Interface with Windows Forms](/dotnet/desktop/winforms/controls/how-to-create-a-multipane-user-interface-with-windows-forms). + + + +## Examples + The following code example shows a vertical splitter whose property is set to `Fill`. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/BasicSplitContainer/CPP/basicsplitcontainer.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/Overview/basicsplitcontainer.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: + ]]> - How to: Create a Multipane User Interface with Windows Forms + How to: Create a Multipane User Interface with Windows Forms @@ -1171,20 +1171,20 @@ Gets or sets which panel remains the same size when the container is resized. One of the values of . The default value is . - panel stays the same size when a user resizes the container. - - - -## Examples - The following code example shows a horizontal splitter whose top panel is defined as a so that it does not resize along with the container. Other basic properties of a horizontal splitter are also shown. This example is part of a larger example provided for the class. - + panel stays the same size when a user resizes the container. + + + +## Examples + The following code example shows a horizontal splitter whose top panel is defined as a so that it does not resize along with the container. Other basic properties of a horizontal splitter are also shown. This example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/BasicSplitContainer/CPP/basicsplitcontainer.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/Overview/basicsplitcontainer.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet3"::: + ]]> The assigned value is not one of the values. @@ -1237,11 +1237,11 @@ if the splitter is fixed; otherwise, . The default is . - property to enable or disable splitter movement. For example, you might programmatically set to `true` when refreshing the display, when some other control has the focus, or when an event is occurring for which the display areas divided by the must remain constant, and set to `false` when those circumstances do not apply. - + property to enable or disable splitter movement. For example, you might programmatically set to `true` when refreshing the display, when some other control has the focus, or when an event is occurring for which the display areas divided by the must remain constant, and set to `false` when those circumstances do not apply. + ]]> @@ -1275,13 +1275,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1320,15 +1320,15 @@ A that contains the event data. Raises the event. - event handler allows the user to move the splitter down when the DOWN arrow key is pressed. The event handler also draws the to show the current position of the splitter while it is moving. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event handler allows the user to move the splitter down when the DOWN arrow key is pressed. The event handler also draws the to show the current position of the splitter while it is moving. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1367,15 +1367,15 @@ A that contains the event data. Raises the event. - event handler allows the user to move the splitter up when the UP arrow key is pressed. The event handler also draws the to show the current position of the splitter while it is moving. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event handler allows the user to move the splitter up when the UP arrow key is pressed. The event handler also draws the to show the current position of the splitter while it is moving. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1414,13 +1414,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1458,13 +1458,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1534,15 +1534,15 @@ A that contains the event data. Raises the event. - event handler allows the user to track the splitter position while it is moved down with the mouse. also draws the to show the current position of the splitter while it is moving. The keeps track of the initial in case the user cancels the move. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event handler allows the user to track the splitter position while it is moved down with the mouse. also draws the to show the current position of the splitter while it is moving. The keeps track of the initial in case the user cancels the move. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1582,13 +1582,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1632,15 +1632,15 @@ A that contains the event data. Raises the event. - event handler allows the user to track the splitter position while it is moved with the mouse. also draws the to show the current position of the splitter while it is moving. The keeps track of the initial in case the user cancels the move. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event handler allows the user to track the splitter position while it is moved with the mouse. also draws the to show the current position of the splitter while it is moving. The keeps track of the initial in case the user cancels the move. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1680,15 +1680,15 @@ A that contains the event data. Raises the event. - event handler allows the user to track the splitter position while it is moved up with the mouse. also draws the to show the current position of the splitter while it is moving. The keeps track of the initial in case the user cancels the move. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event handler allows the user to track the splitter position while it is moved up with the mouse. also draws the to show the current position of the splitter while it is moving. The keeps track of the initial in case the user cancels the move. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1728,13 +1728,13 @@ The data for the event. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1771,13 +1771,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1852,22 +1852,22 @@ A that contains the event data. Raises the event. - event is raised after the splitter has been moved. When the is in the process of moving, use the event and the event handler. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example raises the event, signified in this example by a change to the cursor style when you move the splitter. The event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default. - + event is raised after the splitter has been moved. When the is in the process of moving, use the event and the event handler. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example raises the event, signified in this example by a change to the cursor style when you move the splitter. The event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SplitContainerEvents/CPP/splitcontainerevents.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/OnSplitterMoved/splitcontainerevents.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SplitContainerEvents/VB/splitcontainerevents.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SplitContainerEvents/VB/splitcontainerevents.vb" id="Snippet1"::: + ]]> @@ -1905,22 +1905,22 @@ A that contains the event data. Raises the event. - event is raised while the splitter is in the process of moving. After the has moved, use the event and the event handler. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example raises the event, signified in this example by a change to the cursor style when you move the splitter. The event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default. - + event is raised while the splitter is in the process of moving. After the has moved, use the event and the event handler. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example raises the event, signified in this example by a change to the cursor style when you move the splitter. The event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SplitContainerEvents/CPP/splitcontainerevents.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/OnSplitterMoved/splitcontainerevents.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SplitContainerEvents/VB/splitcontainerevents.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SplitContainerEvents/VB/splitcontainerevents.vb" id="Snippet1"::: + ]]> @@ -1969,20 +1969,20 @@ Gets or sets a value indicating the horizontal or vertical orientation of the panels. One of the values. The default is . - property to change the from vertical to horizontal or from horizontal to vertical. - - - -## Examples - The following code example shows a horizontal splitter whose top and bottom panels contain controls. Other basic properties of a horizontal splitter are also shown. This example is part of a larger example provided for the class. - + property to change the from vertical to horizontal or from horizontal to vertical. + + + +## Examples + The following code example shows a horizontal splitter whose top and bottom panels contain controls. Other basic properties of a horizontal splitter are also shown. This example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/BasicSplitContainer/CPP/basicsplitcontainer.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/Overview/basicsplitcontainer.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet3"::: + ]]> The assigned value is not one of the values. @@ -2033,11 +2033,11 @@ Gets or sets the interior spacing, in pixels, between the edges of a and its contents. This property is not relevant to this class. An object of type representing the interior spacing. - @@ -2078,11 +2078,11 @@ This event is not relevant to this class. - @@ -2135,18 +2135,18 @@ Gets the left or top panel of the , depending on . If is , the left panel of the . If is , the top panel of the . - property to configure the left panel of a vertical or the top panel of a horizontal . For example, you can specify the minimum size of the panel by changing the value of the property, set the property to `Panel1` so that the panel remains the same size when the container is resized, or you can get or set the panel's and properties. - - You cannot remove from the . - + property to configure the left panel of a vertical or the top panel of a horizontal . For example, you can specify the minimum size of the panel by changing the value of the property, set the property to `Panel1` so that the panel remains the same size when the container is resized, or you can get or set the panel's and properties. + + You cannot remove from the . + > [!NOTE] -> If or contains no control that can receive the focus, the focus remains on the splitter when it is clicked. To change the focus to or , set the property of to 0 and the property of to 1. - - If or contains no control that can receive the focus, the focus remains on the splitter when it is clicked. To change the focus to or , set the property of to 0 and the property of to 1. - +> If or contains no control that can receive the focus, the focus remains on the splitter when it is clicked. To change the focus to or , set the property of to 0 and the property of to 1. + + If or contains no control that can receive the focus, the focus remains on the splitter when it is clicked. To change the focus to or , set the property of to 0 and the property of to 1. + ]]> @@ -2237,22 +2237,22 @@ Gets or sets the minimum distance in pixels of the splitter from the left or top edge of . An representing the minimum distance in pixels of the splitter from the left or top edge of . The default value is 25 pixels, regardless of . - property to prevent the splitter from moving too close to the left or top edge of the container. For example, you might want to prevent some of the display area of a from being covered. - - If the property is `Vertical` (the default), returns the minimum distance in pixels of the splitter from the left edge of . If the property is `Horizontal`, returns the minimum distance in pixels of the splitter from the top edge of . - - - -## Examples - The following code example shows a vertical splitter where the minimum size of (the left panel) is set to 30 pixels, which is now the minimum distance the splitter can be from the left edge of the container. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. - + property to prevent the splitter from moving too close to the left or top edge of the container. For example, you might want to prevent some of the display area of a from being covered. + + If the property is `Vertical` (the default), returns the minimum distance in pixels of the splitter from the left edge of . If the property is `Horizontal`, returns the minimum distance in pixels of the splitter from the top edge of . + + + +## Examples + The following code example shows a vertical splitter where the minimum size of (the left panel) is set to 30 pixels, which is now the minimum distance the splitter can be from the left edge of the container. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/BasicSplitContainer/CPP/basicsplitcontainer.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/Overview/basicsplitcontainer.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: + ]]> The specified value is incompatible with the orientation. @@ -2308,16 +2308,16 @@ Gets the right or bottom panel of the , depending on . If is , the right panel of the . If is , the bottom panel of the . - property to configure the right panel of a vertical or the bottom panel of a horizontal . For example, you can specify the minimum size of the panel by changing the value of the property, set the property to `Panel2` so that the panel remains the same size when the container is resized, or you can get or set the panel's and properties. - - You cannot remove from the . - + property to configure the right panel of a vertical or the bottom panel of a horizontal . For example, you can specify the minimum size of the panel by changing the value of the property, set the property to `Panel2` so that the panel remains the same size when the container is resized, or you can get or set the panel's and properties. + + You cannot remove from the . + > [!NOTE] -> If or contains no control that can receive the focus, the focus remains on the splitter when it is clicked. To change the focus to or , set the property of to 0 and the property of to 1. - +> If or contains no control that can receive the focus, the focus remains on the splitter when it is clicked. To change the focus to or , set the property of to 0 and the property of to 1. + ]]> @@ -2408,22 +2408,22 @@ Gets or sets the minimum distance in pixels of the splitter from the right or bottom edge of . An representing the minimum distance in pixels of the splitter from the right or bottom edge of . The default value is 25 pixels, regardless of . - property to prevent the splitter from moving too close to the right or bottom edge of the container. For example, you might want to prevent some of the display area of a from being covered. - - If the property is `Vertical` (the default), returns the minimum distance in pixels that the splitter can be from the right edge of . If the property is `Horizontal`, returns the minimum distance in pixels that the splitter can be from the bottom edge of . - - - -## Examples - The following code example shows a vertical splitter where the minimum size of (the right panel) is set to 20 pixels, which is now the minimum distance the splitter can be from the right edge of the container. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. - + property to prevent the splitter from moving too close to the right or bottom edge of the container. For example, you might want to prevent some of the display area of a from being covered. + + If the property is `Vertical` (the default), returns the minimum distance in pixels that the splitter can be from the right edge of . If the property is `Horizontal`, returns the minimum distance in pixels that the splitter can be from the bottom edge of . + + + +## Examples + The following code example shows a vertical splitter where the minimum size of (the right panel) is set to 20 pixels, which is now the minimum distance the splitter can be from the right edge of the container. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/BasicSplitContainer/CPP/basicsplitcontainer.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/Overview/basicsplitcontainer.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: + ]]> The specified value is incompatible with the orientation. @@ -2462,11 +2462,11 @@ if the key was processed by the control; otherwise, . - method indicates that the control is not processing the key. The simply sends the character to the parent's method, or returns `false` if the control has no parent. The class overrides this method to perform actual processing of dialog box keys. The run time calls this method only when the control is hosted in a Windows Forms application or as an ActiveX control. - + method indicates that the control is not processing the key. The simply sends the character to the parent's method, or returns `false` if the control has no parent. The class overrides this method to perform actual processing of dialog box keys. The run time calls this method only when the control is hosted in a Windows Forms application or as an ActiveX control. + ]]> @@ -2509,21 +2509,21 @@ if a control is selected; otherwise, . - controls the tab focus order in the following manner: - -- From the first control outside the to the first control on . - -- All controls on . - -- The splitter (so that the user can use the arrow keys to move the splitter). - -- All controls on . - -- The second control outside the that is next in the tab order. - + controls the tab focus order in the following manner: + +- From the first control outside the to the first control on . + +- All controls on . + +- The splitter (so that the user can use the arrow keys to move the splitter). + +- All controls on . + +- The second control outside the that is next in the tab order. + ]]> @@ -2686,20 +2686,20 @@ Gets or sets the location of the splitter, in pixels, from the left or top edge of the . An representing the location of the splitter, in pixels, from the left or top edge of the . The default value is 50 pixels. - property to determine or specify the distance in pixels of the splitter from the left or top edge of the container. You can both specify an initial distance and change the distance at design time or run time. If is `Horizontal`, is calculated in pixels from the top edge of the . If is `Vertical`, is calculated in pixels from the left edge of the . - - - -## Examples - The following code example specifies that the initial distance of the vertical splitter from the left edge of the container is 79 pixels. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. - + property to determine or specify the distance in pixels of the splitter from the left or top edge of the container. You can both specify an initial distance and change the distance at design time or run time. If is `Horizontal`, is calculated in pixels from the top edge of the . If is `Vertical`, is calculated in pixels from the left edge of the . + + + +## Examples + The following code example specifies that the initial distance of the vertical splitter from the left edge of the container is 79 pixels. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/BasicSplitContainer/CPP/basicsplitcontainer.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/Overview/basicsplitcontainer.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: + ]]> The value is less than zero. @@ -2747,20 +2747,20 @@ Gets or sets a value representing the increment of splitter movement in pixels. An representing the increment of splitter movement in pixels. The default value is one pixel. - property to create a snapping splitter that moves in larger increments than one pixel. - - - -## Examples - The following code example specifies that the vertical splitter moves in 10-pixel increments. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. - + property to create a snapping splitter that moves in larger increments than one pixel. + + + +## Examples + The following code example specifies that the vertical splitter moves in 10-pixel increments. Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/BasicSplitContainer/CPP/basicsplitcontainer.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/Overview/basicsplitcontainer.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: + ]]> The value is less than one. @@ -2792,20 +2792,20 @@ Occurs when the splitter control is moved. - event, signified in this example by a change to the cursor style when you move the splitter. The event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default. - + event, signified in this example by a change to the cursor style when you move the splitter. The event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SplitContainerEvents/CPP/splitcontainerevents.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/OnSplitterMoved/splitcontainerevents.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SplitContainerEvents/VB/splitcontainerevents.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SplitContainerEvents/VB/splitcontainerevents.vb" id="Snippet1"::: + ]]> @@ -2840,22 +2840,22 @@ Occurs when the splitter control is in the process of moving. - property value programmatically. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example raises the event, signified in this example by a change to the cursor style when you move the splitter. The event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default. - + property value programmatically. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example raises the event, signified in this example by a change to the cursor style when you move the splitter. The event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SplitContainerEvents/CPP/splitcontainerevents.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/OnSplitterMoved/splitcontainerevents.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SplitContainerEvents/VB/splitcontainerevents.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SplitContainerEvents/VB/splitcontainerevents.vb" id="Snippet1"::: + ]]> @@ -2896,20 +2896,20 @@ Gets the size and location of the splitter relative to the . A that specifies the size and location of the splitter relative to the . - to get the width and height of the splitter relative to the . The , , , , and event handlers draw the to show the current position of the splitter while it is moving. - - The meaning of the values vary depending on the . The output of is in the format `{X, Y, Width, Height}`. The following table shows the meaning of the values for vertical and horizontal splitters. - -|Dimension|Vertical Splitter|Horizontal Splitter| -|---------------|-----------------------|-------------------------| -|X|The distance in pixels of the splitter from the left edge of the .|This value is always 0 for a horizontal splitter, indicating that the splitter is flush with the left edge of the .| -|Y|This value is always 0 for a vertical splitter, indicating that the splitter is flush with the top edge of the .|The distance in pixels of the splitter from the top edge of the .| -|Width|The width of the splitter.|The height of the splitter, which is equivalent to the height of the control.| -|Height|The height of the splitter, which is equivalent to the height of the control.|The width of the splitter.| - + to get the width and height of the splitter relative to the . The , , , , and event handlers draw the to show the current position of the splitter while it is moving. + + The meaning of the values vary depending on the . The output of is in the format `{X, Y, Width, Height}`. The following table shows the meaning of the values for vertical and horizontal splitters. + +|Dimension|Vertical Splitter|Horizontal Splitter| +|---------------|-----------------------|-------------------------| +|X|The distance in pixels of the splitter from the left edge of the .|This value is always 0 for a horizontal splitter, indicating that the splitter is flush with the left edge of the .| +|Y|This value is always 0 for a vertical splitter, indicating that the splitter is flush with the top edge of the .|The distance in pixels of the splitter from the top edge of the .| +|Width|The width of the splitter.|The height of the splitter, which is equivalent to the height of the control.| +|Height|The height of the splitter, which is equivalent to the height of the control.|The width of the splitter.| + ]]> @@ -2955,20 +2955,20 @@ Gets or sets the width of the splitter in pixels. An representing the width of the splitter, in pixels. The default is four pixels. - property to change the width of the splitter itself, not the . - - - -## Examples - The following code example specifies that the initial width of the vertical splitter is 6 pixels (the default). Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. - + property to change the width of the splitter itself, not the . + + + +## Examples + The following code example specifies that the initial width of the vertical splitter is 6 pixels (the default). Other basic properties of a vertical splitter are also shown. This example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/BasicSplitContainer/CPP/basicsplitcontainer.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/Overview/basicsplitcontainer.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/BasicSplitContainer/VB/basicsplitcontainer.vb" id="Snippet2"::: + ]]> The value is less than one or is incompatible with the orientation. @@ -3015,16 +3015,16 @@ if the user can give the focus to the splitter using the TAB key; otherwise, . The default is . - to `true` to give input focus to a splitter so that it can be moved with the arrow keys as well as with the mouse. Starting in the .NET Framework 4, setting to `false` excludes the splitter and any of the controls that are contained in the from the collection of controls in the tab order. To enable controls to get focus by using the TAB key, create a control that inherits from . Create a new property named `TabStop` and override the method. The following example demonstrates how to accomplish this. - + to `true` to give input focus to a splitter so that it can be moved with the arrow keys as well as with the mouse. Starting in the .NET Framework 4, setting to `false` excludes the splitter and any of the controls that are contained in the from the collection of controls in the tab order. To enable controls to get focus by using the TAB key, create a control that inherits from . Create a new property named `TabStop` and override the method. The following example demonstrates how to accomplish this. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/SplitContainer/TabStop/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/splitcontainertabstop/vb/module1.vb" id="Snippet1"::: - - You can manipulate the tab order by setting the control's property value. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/splitcontainertabstop/vb/module1.vb" id="Snippet1"::: + + You can manipulate the tab order by setting the control's property value. + ]]> @@ -3074,11 +3074,11 @@ This property is not relevant to this class. A string. - @@ -3119,11 +3119,11 @@ This event is not relevant to this class. - @@ -3157,13 +3157,13 @@ The Windows to process. Processes Windows messages. - method after getting filtered through the method. - - The method corresponds exactly to the Windows `WindowProc` function. For more information about processing Windows messages, see the [WindowProc function](https://learn.microsoft.com/previous-versions/windows/desktop/legacy/ms633573(v=vs.85)). - + method after getting filtered through the method. + + The method corresponds exactly to the Windows `WindowProc` function. For more information about processing Windows messages, see the [WindowProc function](https://learn.microsoft.com/previous-versions/windows/desktop/legacy/ms633573(v=vs.85)). + ]]> diff --git a/xml/System.Windows.Forms/StatusStrip.xml b/xml/System.Windows.Forms/StatusStrip.xml index 96dec3e6a74..7f0cb1ed674 100644 --- a/xml/System.Windows.Forms/StatusStrip.xml +++ b/xml/System.Windows.Forms/StatusStrip.xml @@ -71,8 +71,8 @@ The following items are specifically designed to work seamlessly with both StatusStrip Items Collection Editor StatusStrip Tasks Dialog Box - StatusStrip Control - How to: Use the Spring Property Interactively in a StatusStrip + StatusStrip Control + How to: Use the Spring Property Interactively in a StatusStrip diff --git a/xml/System.Windows.Forms/TabControl.xml b/xml/System.Windows.Forms/TabControl.xml index b97bd4c7194..68f702fb28f 100644 --- a/xml/System.Windows.Forms/TabControl.xml +++ b/xml/System.Windows.Forms/TabControl.xml @@ -58,54 +58,54 @@ Manages a related set of tab pages. - contains tab pages, which are represented by objects that you add through the property. The order of tab pages in this collection reflects the order the tabs appear in the control. - - The user can change the current by clicking one of the tabs in the control. You can also programmatically change the current by using one of the following properties: - -- - -- - - In .NET Framework 2.0, you can also use one of the following methods: - -- - -- - - In .NET Framework 2.0, you can respond when the current tab changes by handling one of the following events: - -- - -- - -- - -- - - The tabs in a are part of the , but not parts of the individual controls. Members of the class, such as the property, affect only the client rectangle of the tab page, but not the tabs. Additionally, the method of the will not hide the tab. To hide the tab, you must remove the control from the collection. - - In .NET Framework 2.0, the tab is considered part of the tab page for determining when the and events of the occur. In earlier versions of the .NET Framework, the and events of the do not occur when focus enters or leaves a tab, but only when focus enters or leaves the client rectangle of the tab page. - - The following events are not raised for the class unless there is at least one in the collection: , , , , , , and . If there is at least one in the collection, and the user interacts with the tab control's header (where the names appear), the raises the appropriate event. However, if the user interaction is within the of the tab page, the raises the appropriate event. - - Controls contained in a are not created until the tab page is shown, and any data bindings in these controls are not activated until the tab page is shown. - - When visual styles are enabled, and the property is set to a value other than , the tab contents might not render correctly. To work around this issue, you can paint the tab contents yourself using owner drawing. For more information, see [How to: Display Side-Aligned Tabs with TabControl](/dotnet/framework/winforms/controls/how-to-display-side-aligned-tabs-with-tabcontrol). - - When the property is set to a value other than and the property is set to a value other than , the tab page contents might not render correctly. - - - -## Examples - The following code example uses the Visual Studio Windows Forms Designer to create a with three tab pages. Each tab page contains several controls. - + contains tab pages, which are represented by objects that you add through the property. The order of tab pages in this collection reflects the order the tabs appear in the control. + + The user can change the current by clicking one of the tabs in the control. You can also programmatically change the current by using one of the following properties: + +- + +- + + In .NET Framework 2.0, you can also use one of the following methods: + +- + +- + + In .NET Framework 2.0, you can respond when the current tab changes by handling one of the following events: + +- + +- + +- + +- + + The tabs in a are part of the , but not parts of the individual controls. Members of the class, such as the property, affect only the client rectangle of the tab page, but not the tabs. Additionally, the method of the will not hide the tab. To hide the tab, you must remove the control from the collection. + + In .NET Framework 2.0, the tab is considered part of the tab page for determining when the and events of the occur. In earlier versions of the .NET Framework, the and events of the do not occur when focus enters or leaves a tab, but only when focus enters or leaves the client rectangle of the tab page. + + The following events are not raised for the class unless there is at least one in the collection: , , , , , , and . If there is at least one in the collection, and the user interacts with the tab control's header (where the names appear), the raises the appropriate event. However, if the user interaction is within the of the tab page, the raises the appropriate event. + + Controls contained in a are not created until the tab page is shown, and any data bindings in these controls are not activated until the tab page is shown. + + When visual styles are enabled, and the property is set to a value other than , the tab contents might not render correctly. To work around this issue, you can paint the tab contents yourself using owner drawing. For more information, see [How to: Display Side-Aligned Tabs with TabControl](/dotnet/desktop/winforms/controls/how-to-display-side-aligned-tabs-with-tabcontrol). + + When the property is set to a value other than and the property is set to a value other than , the tab page contents might not render correctly. + + + +## Examples + The following code example uses the Visual Studio Windows Forms Designer to create a with three tab pages. Each tab page contains several controls. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic TabControl Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic TabControl Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic TabControl Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -133,15 +133,15 @@ Initializes a new instance of the class. - with one . The constructor creates an instance of `tabControl1`. - + with one . The constructor creates an instance of `tabControl1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TabControl_constructor/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/.ctor/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TabControl_constructor/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TabControl_constructor/VB/form1.vb" id="Snippet1"::: + ]]> @@ -195,27 +195,27 @@ Gets or sets the area of the control (for example, along the top) where the tabs are aligned. One of the values. The default is . - property is set to or , the property is automatically set to `true`. - - When you set the property to , it only appears as such when the property is set to . Otherwise, the property displays as if set to the value. - - When you set the property to , you must also set the property to so that the buttons display correctly. - + property is set to or , the property is automatically set to `true`. + + When you set the property to , it only appears as such when the property is set to . Otherwise, the property displays as if set to the value. + + When you set the property to , you must also set the property to so that the buttons display correctly. + > [!NOTE] -> When you set the property to `Buttons`, you must also set the property to `Top` so that the tab page contents display correctly. Additionally, when visual styles are enabled, and the property is set to a value other than , the tab contents may not render correctly. - - - -## Examples - The following code example creates a with three objects. The property is set to `Left`, which positions the tabs of `tabControl1` on the left side. - +> When you set the property to `Buttons`, you must also set the property to `Top` so that the tab page contents display correctly. Additionally, when visual styles are enabled, and the property is set to a value other than , the tab contents may not render correctly. + + + +## Examples + The following code example creates a with three objects. The property is set to `Left`, which positions the tabs of `tabControl1` on the left side. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TabAlignment/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/Alignment/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TabAlignment/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TabAlignment/VB/form1.vb" id="Snippet1"::: + ]]> The property value is not a valid value. @@ -261,23 +261,23 @@ Gets or sets the visual appearance of the control's tabs. One of the values. The default is . - property to `FlatButtons`, it only appears as such when the property is set to `Top`. Otherwise, the property appears as if set to the `Buttons` value. - + property to `FlatButtons`, it only appears as such when the property is set to `Top`. Otherwise, the property appears as if set to the `Buttons` value. + > [!NOTE] -> When you set the property to `Buttons`, you must also set the property to `Top` so that the tab page contents display correctly. - - - -## Examples - The following code example creates a with two objects. This example sets the property to `Buttons`, which displays the tabs of the tab pages as buttons. - +> When you set the property to `Buttons`, you must also set the property to `Top` so that the tab page contents display correctly. + + + +## Examples + The following code example creates a with two objects. This example sets the property to `Buttons`, which displays the tabs of the tab pages as buttons. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Appearance/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/Appearance/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Appearance/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Appearance/VB/form1.vb" id="Snippet1"::: + ]]> The property value is not a valid value. @@ -452,11 +452,11 @@ Occurs when the value of the property changes. - property is not meaningful for this control, although you can change its value and handle the event to detect the change. - + property is not meaningful for this control, although you can change its value and handle the event to detect the change. + ]]> @@ -539,11 +539,11 @@ Occurs when the value of the property changes. - property is not meaningful for this control, although you can change its value and handle the event to detect the change. - + property is not meaningful for this control, although you can change its value and handle the event to detect the change. + ]]> @@ -723,33 +723,33 @@ Occurs when a tab is deselected. - , the following events occur in the following order. - -- - -- - -- - -- - - These events let you perform tasks such as canceling a tab change if a is in an invalid state or updating the state of a newly displayed . - - The current tab changes when the user clicks a tab, when you call the or method, or when you change the value of the or property. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. - + , the following events occur in the following order. + +- + +- + +- + +- + + These events let you perform tasks such as canceling a tab change if a is in an invalid state or updating the state of a newly displayed . + + The current tab changes when the user clicks a tab, when you call the or method, or when you change the value of the or property. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet560"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet560"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet560"::: + ]]> @@ -794,33 +794,33 @@ Occurs before a tab is deselected, enabling a handler to cancel the tab change. - , the following events occur in the following order. - -- - -- - -- - -- - - These events let you perform tasks such as canceling a tab change if a is in an invalid state or updating the state of a newly displayed . - - The current tab changes when the user clicks a tab, when you call the or method, or when you change the value of the or property. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. - + , the following events occur in the following order. + +- + +- + +- + +- + + These events let you perform tasks such as canceling a tab change if a is in an invalid state or updating the state of a newly displayed . + + The current tab changes when the user clicks a tab, when you call the or method, or when you change the value of the or property. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet559"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet559"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet559"::: + ]]> @@ -879,11 +879,11 @@ The index in the collection of the tab to deselect. Makes the tab following the tab with the specified index the current tab. - . If there are at least two tabs in the control, the tab following the specified tab becomes the current tab. If the specified tab is the last tab in the control, the first tab becomes the current tab. - + . If there are at least two tabs in the control, the tab following the specified tab becomes the current tab. If the specified tab is the last tab in the control, the first tab becomes the current tab. + ]]> @@ -927,17 +927,17 @@ The of the tab to deselect. Makes the tab following the tab with the specified name the current tab. - . If there are at least two tabs in the control, the tab following the specified tab becomes the current tab. If the specified tab is the last tab in the control, the first tab becomes the current tab. - + . If there are at least two tabs in the control, the tab following the specified tab becomes the current tab. If the specified tab is the last tab in the control, the first tab becomes the current tab. + ]]> - The argument is . - - -or- - + The argument is . + + -or- + The argument does not match the property of any in the collection. @@ -978,18 +978,18 @@ The to deselect. Makes the tab following the specified the current tab. - . If there are at least two tabs in the control, the tab following the specified tab becomes the current tab. If the specified tab is the last tab in the control, the first tab becomes the current tab. - + . If there are at least two tabs in the control, the tab following the specified tab becomes the current tab. If the specified tab is the last tab in the control, the first tab becomes the current tab. + ]]> - is less than 0 or greater than the number of controls in the collection minus 1. - - -or- - + is less than 0 or greater than the number of controls in the collection minus 1. + + -or- + is not in the collection. The argument is . @@ -1029,15 +1029,15 @@ Gets the display area of the control's tab pages. A that represents the display area of the tab pages. - with one . This example uses the property to draw a representing the tab page display area of `tabControl1`. Notice that the example uses the method; otherwise, the drawing code overwrites the drawn in the `DrawOnTabPage` method. - + with one . This example uses the property to draw a representing the tab page display area of `tabControl1`. Notice that the example uses the method; otherwise, the drawing code overwrites the drawn in the `DrawOnTabPage` method. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DisplayRectangle1/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/DisplayRectangle/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DisplayRectangle1/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DisplayRectangle1/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1143,24 +1143,24 @@ Occurs when the needs to paint each of its tabs if the property is set to . - property to , the raises the event whenever it needs to paint one of its tabs. To customize the appearance of the tabs, provide your own painting code in a handler for the event. - - The does not support variable tab sizes with owner drawing. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example creates a with one . This example declares an event handler that is used to draw a string and `Rectangle` on the tab of `tabPage1`. The event handler is bound to the `DrawItem` event. - + property to , the raises the event whenever it needs to paint one of its tabs. To customize the appearance of the tabs, provide your own painting code in a handler for the event. + + The does not support variable tab sizes with owner drawing. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example creates a with one . This example declares an event handler that is used to draw a string and `Rectangle` on the tab of `tabPage1`. The event handler is bound to the `DrawItem` event. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DrawItem/CPP/drawitem.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/DrawItem/drawitem.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DrawItem/VB/drawitem.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DrawItem/VB/drawitem.vb" id="Snippet1"::: + ]]> @@ -1204,24 +1204,24 @@ Gets or sets the way that the control's tabs are drawn. One of the values. The default is . - property to , the raises the event whenever it needs to paint one of its tabs. To customize the appearance of the tabs, provide your own painting code in a handler for the event. - - The does not support variable tab sizes with owner drawing. - - - -## Examples - The following code example creates a with one . This example sets the property to `OwnerDrawFixed`, which specifies that the tabs are drawn by the parent object `Form1`. The value `OwnerDrawFixed` also enables access to the event, which, in this example, is used to draw `myTabRect` on the `tabPage1` tab. - - Use the and namespaces with this example. - + property to , the raises the event whenever it needs to paint one of its tabs. To customize the appearance of the tabs, provide your own painting code in a handler for the event. + + The does not support variable tab sizes with owner drawing. + + + +## Examples + The following code example creates a with one . This example sets the property to `OwnerDrawFixed`, which specifies that the tabs are drawn by the parent object `Form1`. The value `OwnerDrawFixed` also enables access to the event, which, in this example, is used to draw `myTabRect` on the `tabPage1` tab. + + Use the and namespaces with this example. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/DrawMode/CPP/drawmode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/DrawMode/drawmode.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DrawMode/VB/drawmode.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/DrawMode/VB/drawmode.vb" id="Snippet1"::: + ]]> The property value is not a valid value. @@ -1309,11 +1309,11 @@ Occurs when the value of the property changes. - property is not meaningful for this control, although you can change its value and handle the event to detect the change. - + property is not meaningful for this control, although you can change its value and handle the event to detect the change. + ]]> @@ -1463,23 +1463,23 @@ Returns the bounding rectangle for a specified tab in this tab control. A that represents the bounds of the specified tab. - with one . This example uses the method to get a `Rectangle` that represents the `tabPage1` tab area. The `myTabRect` `Rectangle` is drawn by the event. - - Use the and namespaces with this example. - + with one . This example uses the method to get a `Rectangle` that represents the `tabPage1` tab area. The `myTabRect` `Rectangle` is drawn by the event. + + Use the and namespaces with this example. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/GetTabRect/CPP/gettabrect.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/GetTabRect/gettabrect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/GetTabRect/VB/gettabrect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/GetTabRect/VB/gettabrect.vb" id="Snippet1"::: + ]]> - The index is less than zero. - - -or- - + The index is less than zero. + + -or- + The index is greater than or equal to . @@ -1552,20 +1552,20 @@ if the tabs change in appearance when the mouse passes over them; otherwise, . The default is . - with two objects. The property is set to `true`, which highlights the tab `myTabPage1` or `myTabPage2` when the mouse passes over the tabs. - + with two objects. The property is set to `true`, which highlights the tab `myTabPage1` or `myTabPage2` when the mouse passes over the tabs. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/HotTrack/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/HotTrack/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/HotTrack/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/HotTrack/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1620,20 +1620,20 @@ Gets or sets the images to display on the control's tabs. An that specifies the images to display on the tabs. - property of that . The acts as the index into the . - - - -## Examples - The following code example creates a with one . This example uses the property to display images, from the collection defined by the named `myImages`, on the tabs of `tabControl1`. - + property of that . The acts as the index into the . + + + +## Examples + The following code example creates a with one . This example uses the property to display images, from the collection defined by the named `myImages`, on the tabs of `tabControl1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TabControl.ImageList/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/ImageList/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TabControl.ImageList/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TabControl.ImageList/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1671,11 +1671,11 @@ if the specified key is a regular input key; otherwise, . - @@ -1713,20 +1713,20 @@ Gets or sets the size of the control's tabs. A that represents the size of the tabs. The default automatically sizes the tabs to fit the icons and labels on the tabs. - property of the property, the property must be set to `Fixed`. - - - -## Examples - The following code example creates a with two objects. To define the dimensions of the tabs, set the property equal to a structure. In this example, defines the tabs 90 pixels wide and 50 pixels high. You cannot change the width of the tabs unless the property is set to the value. - + property of the property, the property must be set to `Fixed`. + + + +## Examples + The following code example creates a with two objects. To define the dimensions of the tabs, set the property equal to a structure. In this example, defines the tabs 90 pixels wide and 50 pixels high. You cannot change the width of the tabs unless the property is set to the value. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ItemSize/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/ItemSize/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ItemSize/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ItemSize/VB/form1.vb" id="Snippet1"::: + ]]> The width or height of the is less than 0. @@ -1767,22 +1767,22 @@ if more than one row of tabs can be displayed; otherwise, . The default is . - is `false`, only one row of tabs is displayed, even if all the tabs do not fit in the available space. In that case, however, arrows are displayed that enable the user to navigate to the undisplayed tabs. - - If the property is changed to `false` while the property is set to `Left` or `Right`, the property is automatically reset to `Top`. - - - -## Examples - The following code example creates a with four objects. The property is set to `true`, which displays two rows of tabs instead of one. - + is `false`, only one row of tabs is displayed, even if all the tabs do not fit in the available space. In that case, however, arrows are displayed that enable the user to navigate to the undisplayed tabs. + + If the property is changed to `false` while the property is set to `Left` or `Right`, the property is automatically reset to `Top`. + + + +## Examples + The following code example creates a with four objects. The property is set to `true`, which displays two rows of tabs instead of one. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Multiline/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/Multiline/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Multiline/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Multiline/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1817,13 +1817,13 @@ A that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1861,13 +1861,13 @@ A that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1906,13 +1906,13 @@ A that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1953,15 +1953,15 @@ An that contains the event data. Raises the event of the . - event of the current . In .NET Framework 2.0, the tab is considered part of the tab page for determining when the and events of the occur. In earlier versions of the .NET Framework, the and events of the do not occur when focus enters or leaves a tab, but only when focus enters or leaves the client rectangle of the tab page. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event of the current . In .NET Framework 2.0, the tab is considered part of the tab page for determining when the and events of the occur. In earlier versions of the .NET Framework, the and events of the do not occur when focus enters or leaves a tab, but only when focus enters or leaves the client rectangle of the tab page. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2000,13 +2000,13 @@ An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2104,13 +2104,13 @@ An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2150,18 +2150,18 @@ A that contains the event data. Raises the event. - control enables the user to use the keyboard to switch between controls. The following table describes how the switches between the selected controls, depending on which keys are pressed. - -|Key|Description| -|---------|-----------------| -| + |Selects the next .| -| + + |Selects the previous .| -| + |Selects the next .| -| + |Selects the previous .| - + control enables the user to use the keyboard to switch between controls. The following table describes how the switches between the selected controls, depending on which keys are pressed. + +|Key|Description| +|---------|-----------------| +| + |Selects the next .| +| + + |Selects the previous .| +| + |Selects the next .| +| + |Selects the previous .| + ]]> @@ -2199,15 +2199,15 @@ An that contains the event data. Raises the event of the . - event of the current . In .NET Framework 2.0, the tab is considered part of the tab page for determining when the and events of the occur. In earlier versions of the .NET Framework, the and events of the do not occur when focus enters or leaves a tab, but only when focus enters or leaves the client rectangle of the tab page. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event of the current . In .NET Framework 2.0, the tab is considered part of the tab page for determining when the and events of the occur. In earlier versions of the .NET Framework, the and events of the do not occur when focus enters or leaves a tab, but only when focus enters or leaves the client rectangle of the tab page. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2311,13 +2311,13 @@ An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2355,13 +2355,13 @@ A that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2400,13 +2400,13 @@ An that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2443,13 +2443,13 @@ A that contains the event data. Raises the event. - method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also enables derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2527,15 +2527,15 @@ Gets or sets the amount of space around each item on the control's tab pages. A that specifies the amount of space around each item. The default is (6,3). - with two objects. The property is used to create a cushion of 22 pixels around the tab `myTabPage1` and `myTabPage2`. - + with two objects. The property is used to create a cushion of 22 pixels around the tab `myTabPage1` and `myTabPage2`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Padding/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/Padding/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Padding/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Padding/VB/form1.vb" id="Snippet1"::: + ]]> The width or height of the is less than 0. @@ -2646,11 +2646,11 @@ Removes all the tab pages and additional controls from this tab control. - @@ -2696,15 +2696,15 @@ if right-to-left mirror placement is turned on; for standard child control placement. The default is . - property is primarily useful for developing forms for worldwide audiences. Many containers are designed so that controls are laid out in the container in a left-to-right fashion. These containers are compatible with languages that follow this writing direction. However, when you display the same containers to users of right-to-left languages, it is often preferable to reverse the order of the controls on the form. If both the and properties are `true`, mirroring will be turned on for the container and control placement and text flow will be right-to-left. - - Changing the value of this property raises the event. - - For more information about globalization issues, see [Best Practices for Developing World-Ready Applications](/dotnet/standard/globalization-localization/best-practices-for-developing-world-ready-apps). - + property is primarily useful for developing forms for worldwide audiences. Many containers are designed so that controls are laid out in the container in a left-to-right fashion. These containers are compatible with languages that follow this writing direction. However, when you display the same containers to users of right-to-left languages, it is often preferable to reverse the order of the controls on the form. If both the and properties are `true`, mirroring will be turned on for the container and control placement and text flow will be right-to-left. + + Changing the value of this property raises the event. + + For more information about globalization issues, see [Best Practices for Developing World-Ready Applications](/dotnet/standard/globalization-localization/best-practices-for-developing-world-ready-apps). + ]]> @@ -2744,21 +2744,21 @@ Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet555"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet555"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet555"::: + ]]> @@ -2805,20 +2805,20 @@ Gets the number of rows that are currently being displayed in the control's tab strip. The number of rows that are currently being displayed in the tab strip. - property when the property is `true` and you want to know the number of rows that the tabs occupy. - - - -## Examples - The following code example creates a with five objects. This example uses the property to get the number of rows currently in the `tabControl1` tab strip. - + property when the property is `true` and you want to know the number of rows that the tabs occupy. + + + +## Examples + The following code example creates a with five objects. This example uses the property to get the number of rows currently in the `tabControl1` tab strip. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/RowCount/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/RowCount/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/RowCount/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/RowCount/VB/form1.vb" id="Snippet1"::: + ]]> @@ -2895,33 +2895,33 @@ Occurs when a tab is selected. - , the following events occur in the following order. - -- - -- - -- - -- - - These events let you perform tasks such as canceling a tab change if a is in an invalid state or updating the state of a newly displayed . - - The current tab changes when the user clicks a tab, when you call the or method, or when you change the value of the or property. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. - + , the following events occur in the following order. + +- + +- + +- + +- + + These events let you perform tasks such as canceling a tab change if a is in an invalid state or updating the state of a newly displayed . + + The current tab changes when the user clicks a tab, when you call the or method, or when you change the value of the or property. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet558"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet558"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet558"::: + ]]> @@ -2971,15 +2971,15 @@ Gets or sets the index of the currently selected tab page. The zero-based index of the currently selected tab page. The default is -1, which is also the value if no tab page is selected. - with two objects. The property sets `tabPage2` as the currently selected tab page using its index value. - + with two objects. The property sets `tabPage2` as the currently selected tab page using its index value. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SelectedIndex/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/SelectedIndex/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SelectedIndex/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SelectedIndex/VB/form1.vb" id="Snippet1"::: + ]]> The value is less than -1. @@ -3026,23 +3026,23 @@ Occurs when the property has changed. - property to determine its new value. Alternatively, you can handle the event and use the property to determine the index of the selected tab page. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. - + property to determine its new value. Alternatively, you can handle the event and use the property to determine the index of the selected tab page. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet556"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet556"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet556"::: + ]]> @@ -3101,20 +3101,20 @@ Gets or sets the currently selected tab page. A that represents the selected tab page. If no tab page is selected, the value is . - collection to make it the current tab page. - - - -## Examples - The following code example creates a with two objects. The property sets `tabPage2` as the currently selected tab page. - + collection to make it the current tab page. + + + +## Examples + The following code example creates a with two objects. The property sets `tabPage2` as the currently selected tab page. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SelectedTab/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/SelectedTab/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SelectedTab/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SelectedTab/VB/form1.vb" id="Snippet1"::: + ]]> @@ -3160,33 +3160,33 @@ Occurs before a tab is selected, enabling a handler to cancel the tab change. - , the following events occur in the following order. - -- - -- - -- - -- - - These events let you perform tasks such as canceling a tab change if a is in an invalid state or updating the state of a newly displayed . - - The current tab changes when the user clicks a tab, when you call the or method, or when you change the value of the or property. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. - + , the following events occur in the following order. + +- + +- + +- + +- + + These events let you perform tasks such as canceling a tab change if a is in an invalid state or updating the state of a newly displayed . + + The current tab changes when the user clicks a tab, when you call the or method, or when you change the value of the or property. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `TabControl1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet557"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet557"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet557"::: + ]]> @@ -3245,11 +3245,11 @@ The index in the collection of the tab to select. Makes the tab with the specified index the current tab. - . - + . + ]]> @@ -3293,17 +3293,17 @@ The of the tab to select. Makes the tab with the specified name the current tab. - . - + . + ]]> - The argument is . - - -or- - + The argument is . + + -or- + The argument does not match the property of any in the collection. @@ -3344,18 +3344,18 @@ The to select. Makes the specified the current tab. - . - + . + ]]> - is less than 0 or greater than the number of controls in the collection minus 1. - - -or- - + is less than 0 or greater than the number of controls in the collection minus 1. + + -or- + is not in the collection. The argument is . @@ -3406,20 +3406,20 @@ if ToolTips are shown for the tabs that have them; otherwise, . The default is . - property of the . - - - -## Examples - The following code example creates a with two objects. For tab page ToolTips to display, the property must equal to `true`, as in this example. The property is used to assign string values to the ToolTips. - + property of the . + + + +## Examples + The following code example creates a with two objects. For tab page ToolTips to display, the property must equal to `true`, as in this example. The property is used to assign string values to the ToolTips. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ToolTipText/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/ShowToolTips/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTipText/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTipText/VB/form1.vb" id="Snippet1"::: + ]]> @@ -3470,15 +3470,15 @@ Gets or sets the way that the control's tabs are sized. One of the values. The default is . - with five . This example sets the property to `FillToRight`, which sizes the tabs so that each row fills the entire width of `tabControl1`. - + with five . This example sets the property to `FillToRight`, which sizes the tabs so that each row fills the entire width of `tabControl1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/SizeMode/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/SizeMode/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SizeMode/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/SizeMode/VB/form1.vb" id="Snippet1"::: + ]]> The property value is not a valid value. @@ -3530,15 +3530,15 @@ Gets the number of tabs in the tab strip. The number of tabs in the tab strip. - with five objects. This example uses the property to get the number of tabs currently in the `tabControl1` tab strip. - + with five objects. This example uses the property to get the number of tabs currently in the `tabControl1` tab strip. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TabCount/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl/TabCount/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TabCount/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TabCount/VB/form1.vb" id="Snippet1"::: + ]]> @@ -3600,20 +3600,20 @@ Gets the collection of tab pages in this tab control. A that contains the objects in this . - with one . This example uses the method to add a single tab page to the `tabControl1` tab control. Notice the property is used to get the `tabControl1` controls collection to add the `tabPage1` to this collection. - + with one . This example uses the method to add a single tab page to the `tabControl1` tab control. Notice the property is used to get the `tabControl1` controls collection to add the `tabPage1` to this collection. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TabPageCollection.Add/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabControl+TabPageCollection/Add/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TabPageCollection.Add/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TabPageCollection.Add/VB/form1.vb" id="Snippet1"::: + ]]> @@ -3704,11 +3704,11 @@ Occurs when the value of the property changes. - property is not meaningful for this control, although you can change its value and handle the event to detect the change. - + property is not meaningful for this control, although you can change its value and handle the event to detect the change. + ]]> @@ -3741,11 +3741,11 @@ Returns a string that represents the control. A string that represents the current . - property of the control. If there is at least one control on the , this method returns a string that includes the string returned by the method for the first . - + property of the control. If there is at least one control on the , this method returns a string that includes the string returned by the method for the first . + ]]> @@ -3789,11 +3789,11 @@ to change focus to the next ; otherwise, . Sets the property to for the appropriate control in the collection. - is visible. If you want the tab control to set the property to `true` for the next in the tab order, call this method with `updateFocus` set to `true`. - + is visible. If you want the tab control to set the property to `true` for the next in the tab order, call this method with `updateFocus` set to `true`. + ]]> diff --git a/xml/System.Windows.Forms/TabRenderer.xml b/xml/System.Windows.Forms/TabRenderer.xml index 755dff0cb74..5123ec49404 100644 --- a/xml/System.Windows.Forms/TabRenderer.xml +++ b/xml/System.Windows.Forms/TabRenderer.xml @@ -33,24 +33,24 @@ Provides methods used to render a tab control with visual styles. This class cannot be inherited. - class provides a set of `static` methods that can be used to render a tab control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a tab control, use the method to draw the page, and use the method to draw each tab. - - If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, the methods of this class will draw the tab control with the current visual style. Otherwise, the methods and properties of this class will throw an . To determine whether the members of this class can be used, check the value of the property. - - This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - - - -## Examples - The following code example demonstrates how to create a custom control that uses the and methods to draw a basic tab control with two tabs. - + class provides a set of `static` methods that can be used to render a tab control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a tab control, use the method to draw the page, and use the method to draw each tab. + + If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, the methods of this class will draw the tab control with the current visual style. Otherwise, the methods and properties of this class will throw an . To determine whether the members of this class can be used, check the value of the property. + + This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + + + +## Examples + The following code example demonstrates how to create a custom control that uses the and methods to draw a basic tab control with two tabs. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/cpp/form1.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabRenderer/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/VB/form1.vb" id="Snippet0"::: + ]]> @@ -99,21 +99,21 @@ One of the values that specifies the visual state of the tab. Draws a tab in the specified state and bounds. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -153,21 +153,21 @@ One of the values that specifies the visual state of the tab. Draws a tab in the specified state and bounds, and with an optional focus rectangle. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows.
@@ -222,21 +222,21 @@ One of the values that specifies the visual state of the tab. Draws a tab in the specified state and bounds, and with the specified text. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -280,21 +280,21 @@ One of the values that specifies the visual state of the tab. Draws a tab in the specified state and bounds, with the specified image, and with an optional focus rectangle. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -352,30 +352,30 @@ One of the values that specifies the visual state of the tab. Draws a tab in the specified state and bounds, with the specified text, and with an optional focus rectangle. - property returns `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw a tab item. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw a tab item. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/VB/form1.vb" id="Snippet2"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -429,21 +429,21 @@ One of the values that specifies the visual state of the tab. Draws a tab in the specified state and bounds, with the specified text and text formatting, and with an optional focus rectangle. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -512,21 +512,21 @@ One of the values that specifies the visual state of the tab. Draws a tab in the specified state and bounds, with the specified text and image, and with an optional focus rectangle. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -591,21 +591,21 @@ One of the values that specifies the visual state of the tab. Draws a tab in the specified state and bounds; with the specified text, text formatting, and image; and with an optional focus rectangle. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -640,30 +640,30 @@ The that specifies the bounds of the tab page. Draws a tab page in the specified bounds. - property returns `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw a tab page. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw a tab page. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/VB/form1.vb" id="Snippet2"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -694,20 +694,20 @@ if the user has enabled visual styles in the operating system and visual styles are applied to the client area of application windows; otherwise, . - and methods will throw an . - - - -## Examples - The following code example uses the property to determine whether to use the and methods. This code example is part of a larger example provided for the class. - + and methods will throw an . + + + +## Examples + The following code example uses the property to determine whether to use the and methods. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TabRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TabRenderer/VB/form1.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Windows.Forms/TableLayoutPanel.xml b/xml/System.Windows.Forms/TableLayoutPanel.xml index 8557491c2f5..7a683c873c7 100644 --- a/xml/System.Windows.Forms/TableLayoutPanel.xml +++ b/xml/System.Windows.Forms/TableLayoutPanel.xml @@ -85,66 +85,66 @@ Represents a panel that dynamically lays out its contents in a grid composed of rows and columns. - control arranges its contents in a grid. Because the layout is performed both at design time and run time, it can change dynamically as the application environment changes. This gives the controls in the panel the ability to proportionally resize, so it can respond to changes such as the parent control resizing or text length changing due to localization. - - Any Windows Forms control can be a child of the control, including other instances of . This allows you to construct sophisticated layouts that adapt to changes at runtime. - - The control can expand to accommodate new controls when they are added, depending on the value of the , , and properties. Setting either the or property to a value of 0 specifies that the will be unbound in the corresponding direction. - - You can also control the direction of expansion (horizontal or vertical) after the control is full of child controls. By default, the control expands downward by adding rows. - - If you want rows and columns that behave differently from the default behavior, you can control the properties of rows and columns by using the and properties. You can set the properties of rows or columns individually. - - The control adds the following properties to its child controls: `Cell`, `Column`, `Row`, `ColumnSpan`, and `RowSpan`. - - You can merge cells in the control by setting the `ColumnSpan` or `RowSpan` properties on a child control. - + control arranges its contents in a grid. Because the layout is performed both at design time and run time, it can change dynamically as the application environment changes. This gives the controls in the panel the ability to proportionally resize, so it can respond to changes such as the parent control resizing or text length changing due to localization. + + Any Windows Forms control can be a child of the control, including other instances of . This allows you to construct sophisticated layouts that adapt to changes at runtime. + + The control can expand to accommodate new controls when they are added, depending on the value of the , , and properties. Setting either the or property to a value of 0 specifies that the will be unbound in the corresponding direction. + + You can also control the direction of expansion (horizontal or vertical) after the control is full of child controls. By default, the control expands downward by adding rows. + + If you want rows and columns that behave differently from the default behavior, you can control the properties of rows and columns by using the and properties. You can set the properties of rows or columns individually. + + The control adds the following properties to its child controls: `Cell`, `Column`, `Row`, `ColumnSpan`, and `RowSpan`. + + You can merge cells in the control by setting the `ColumnSpan` or `RowSpan` properties on a child control. + > [!NOTE] -> To set the `Cell`, `Column`, `Row`, `ColumnSpan`, and `RowSpan` properties at run time, use the , , , , and methods. -> -> To read the `Cell`, `Column`, `Row`, `ColumnSpan`, and `RowSpan` properties at run time, use the , , , , and methods. - - The docking behavior of child controls is the same as other container controls. - - The anchoring behavior of child controls in a differs from the behavior in other container controls. If the value of the child control's property is set to or , the control will be placed against the left or right border of the cell, at a distance that is the sum of the control's property and the panel's property. If both the and values are set, the control will be sized to the width of the cell, with the and values taken into account. The behavior for and anchoring is analogous. For more information, see [How to: Anchor and Dock Child Controls in a TableLayoutPanel Control](/dotnet/framework/winforms/controls/how-to-anchor-and-dock-child-controls-in-a-tablelayoutpanel-control). - - If you need a child control to mimic the default anchoring behavior in other container controls, you can adjust the and properties to maintain a constant distance between the control's border and the cell's border. - - Setting the values of both the `Column` and `Row` properties of a child control to -1 will cause the control to be moved to the first empty cell in the control. The empty cell will be chosen in a search that proceeds from left to right and from top to bottom. This order is dependent on the culture, so it will behave correctly in right-to-left (RTL) layouts. - +> To set the `Cell`, `Column`, `Row`, `ColumnSpan`, and `RowSpan` properties at run time, use the , , , , and methods. +> +> To read the `Cell`, `Column`, `Row`, `ColumnSpan`, and `RowSpan` properties at run time, use the , , , , and methods. + + The docking behavior of child controls is the same as other container controls. + + The anchoring behavior of child controls in a differs from the behavior in other container controls. If the value of the child control's property is set to or , the control will be placed against the left or right border of the cell, at a distance that is the sum of the control's property and the panel's property. If both the and values are set, the control will be sized to the width of the cell, with the and values taken into account. The behavior for and anchoring is analogous. For more information, see [How to: Anchor and Dock Child Controls in a TableLayoutPanel Control](/dotnet/desktop/winforms/controls/how-to-anchor-and-dock-child-controls-in-a-tablelayoutpanel-control). + + If you need a child control to mimic the default anchoring behavior in other container controls, you can adjust the and properties to maintain a constant distance between the control's border and the cell's border. + + Setting the values of both the `Column` and `Row` properties of a child control to -1 will cause the control to be moved to the first empty cell in the control. The empty cell will be chosen in a search that proceeds from left to right and from top to bottom. This order is dependent on the culture, so it will behave correctly in right-to-left (RTL) layouts. + > [!NOTE] -> Only controls that have the property set to `true` participate in the control's layout computations. - - Also see: - -- [How to: Align and Stretch a Control in a TableLayoutPanel Control](/dotnet/framework/winforms/controls/how-to-align-and-stretch-a-control-in-a-tablelayoutpanel-control) - -- [How to: Span Rows and Columns in a TableLayoutPanel Control](/dotnet/framework/winforms/controls/how-to-span-rows-and-columns-in-a-tablelayoutpanel-control) - -- [How to: Edit Columns and Rows in a TableLayoutPanel Control](/dotnet/framework/winforms/controls/how-to-edit-columns-and-rows-in-a-tablelayoutpanel-control) - -- [Walkthrough: Arranging Controls on Windows Forms Using a TableLayoutPanel](/dotnet/framework/winforms/controls/walkthrough-arranging-controls-on-windows-forms-using-a-tablelayoutpanel) - - - -## Examples - The following code example demonstrates how to override the method to create a custom appearance for a cell. - +> Only controls that have the property set to `true` participate in the control's layout computations. + + Also see: + +- [How to: Align and Stretch a Control in a TableLayoutPanel Control](/dotnet/desktop/winforms/controls/how-to-align-and-stretch-a-control-in-a-tablelayoutpanel-control) + +- [How to: Span Rows and Columns in a TableLayoutPanel Control](/dotnet/desktop/winforms/controls/how-to-span-rows-and-columns-in-a-tablelayoutpanel-control) + +- [How to: Edit Columns and Rows in a TableLayoutPanel Control](/dotnet/desktop/winforms/controls/how-to-edit-columns-and-rows-in-a-tablelayoutpanel-control) + +- [Walkthrough: Arranging Controls on Windows Forms Using a TableLayoutPanel](/dotnet/desktop/winforms/controls/walkthrough-arranging-controls-on-windows-forms-using-a-tablelayoutpanel) + + + +## Examples + The following code example demonstrates how to override the method to create a custom appearance for a cell. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet100"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet100"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet100"::: + ]]> - Best Practices for the TableLayoutPanel Control - AutoSize Behavior in the TableLayoutPanel Control - How to: Anchor and Dock Child Controls in a TableLayoutPanel Control - How to: Design a Windows Forms Layout that Responds Well to Localization - How to: Create a Resizable Windows Form for Data Entry + Best Practices for the TableLayoutPanel Control + AutoSize Behavior in the TableLayoutPanel Control + How to: Anchor and Dock Child Controls in a TableLayoutPanel Control + How to: Design a Windows Forms Layout that Responds Well to Localization + How to: Create a Resizable Windows Form for Data Entry @@ -169,11 +169,11 @@ Initializes a new instance of the class. - , , , and properties to their default values. - + , , , and properties to their default values. + ]]> @@ -256,18 +256,18 @@ Gets or sets the style of the cell borders. One of the values describing the style of all the cell borders in the table. The default is . - property depending on the selected . - +## Examples + The following code example sets the value of the property depending on the selected . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet6"::: + ]]> .NET 6 and later versions only: The property value is not valid for the enumeration type. @@ -308,21 +308,21 @@ Setting this value causes the panel to redraw itself and its contents. Occurs when the cell is redrawn. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of type named `TableLayoutPanel1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of type named `TableLayoutPanel1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet561"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet561"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet561"::: + ]]> @@ -363,17 +363,17 @@ Setting this value causes the panel to redraw itself and its contents. Gets or sets the maximum number of columns allowed in the table. The maximum number of columns in the control. The default is 0. - property does not create columns or allocate any backing memory. Memory allocation occurs when the columns are created, so you can set this property to . - - Setting this property causes the table to undergo another layout operation. - You can specify both the and the properties for layouts with a known and fixed number of cells. You can also specify one property or the other if you expect the number of cells in your layout to grow, assuming that the property allows for such growth. If the value of is 0, the panel will grow by adding rows, and if the value of is 0, the panel will grow by adding columns. Specifying panel growth with the property is preferred to setting or to 0, however. - - Controls can be added or deleted from the table using the property. - + Setting this property causes the table to undergo another layout operation. + + You can specify both the and the properties for layouts with a known and fixed number of cells. You can also specify one property or the other if you expect the number of cells in your layout to grow, assuming that the property allows for such growth. If the value of is 0, the panel will grow by adding rows, and if the value of is 0, the panel will grow by adding columns. Specifying panel growth with the property is preferred to setting or to 0, however. + + Controls can be added or deleted from the table using the property. + ]]> @@ -430,32 +430,32 @@ Setting this value causes the panel to redraw itself and its contents. Gets a collection of column styles for the . A containing a for each column in the control. - property to access the style properties of specific columns. You can use members of the class to set the characteristics of individual columns in the table. - - When the control arranges its columns, it assigns priorities to each in the following order: - -1. Columns with set to are considered first, and their fixed widths are allocated. - -2. Columns with set to are sized to their contents. - -3. Remaining space is divided among columns with set to . - - - -## Examples - The following code example sets the properties of each column when a is clicked. - + property to access the style properties of specific columns. You can use members of the class to set the characteristics of individual columns in the table. + + When the control arranges its columns, it assigns priorities to each in the following order: + +1. Columns with set to are considered first, and their fixed widths are allocated. + +2. Columns with set to are sized to their contents. + +3. Remaining space is divided among columns with set to . + + + +## Examples + The following code example sets the properties of each column when a is clicked. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet8"::: + ]]> - AutoSize Behavior in the TableLayoutPanel Control + AutoSize Behavior in the TableLayoutPanel Control @@ -498,19 +498,19 @@ Setting this value causes the panel to redraw itself and its contents. Gets the collection of controls contained within the . A containing the controls associated with the current . - property contains all of the controls associated with the table, including controls that may not be currently displayed because of , , or limitations. - - - -## Examples - The following code example enumerates all the child controls in the . - + property contains all of the controls associated with the table, including controls that may not be currently displayed because of , , or limitations. + + + +## Examples + The following code example enumerates all the child controls in the . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet2"::: + ]]> @@ -654,25 +654,25 @@ Setting this value causes the panel to redraw itself and its contents. Returns the column position of the specified child control. The column position of the specified child control, or -1 if the position of is determined by . - method will return the lowest column index. - - The column position value is zero based, so you can use it as an index for the array returned by . - - This method is called by the `Column` property, which the panel adds to its child controls at design time. - - To get the actual position of `control`, even when its position is determined by , call the method. - - - -## Examples - The following code example enumerates all the child controls in the and finds the column index for each control using the method. - + method will return the lowest column index. + + The column position value is zero based, so you can use it as an index for the array returned by . + + This method is called by the `Column` property, which the panel adds to its child controls at design time. + + To get the actual position of `control`, even when its position is determined by , call the method. + + + +## Examples + The following code example enumerates all the child controls in the and finds the column index for each control using the method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet3"::: + ]]> @@ -724,21 +724,21 @@ Setting this value causes the panel to redraw itself and its contents. Returns the number of columns spanned by the specified child control. The number of columns spanned by the child control. The default is 1. - and methods to set the width of a control in a . - + and methods to set the width of a control in a . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet11"::: + ]]> @@ -819,19 +819,19 @@ Setting this value causes the panel to redraw itself and its contents. Returns the child control occupying the specified position. The child control occupying the specified cell; otherwise, if no control exists at the specified column and row, or if the control has its property set to . - by looping through the columns and rows given by and , and then calling the method to retrieve the control at each cell. - + by looping through the columns and rows given by and , and then calling the method to retrieve the control at each cell. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet5"::: + ]]> Either or (or both) is less than 0. @@ -870,11 +870,11 @@ Setting this value causes the panel to redraw itself and its contents. Gets the that represents the row and the column of the cell that contains the control. A that represents the cell position. - method returns the actual current position of `control`, even if its position is determined by the . This method takes into account the entire control state, including column or row spanning and when the has placed a control with its `Column` and `Row` properties set to -1. This is equivalent to the situation in which and return -1. - + method returns the actual current position of `control`, even if its position is determined by the . This method takes into account the entire control state, including column or row spanning and when the has placed a control with its `Column` and `Row` properties set to -1. This is equivalent to the situation in which and return -1. + ]]> @@ -927,25 +927,25 @@ Setting this value causes the panel to redraw itself and its contents. Returns the row position of the specified child control. The row position of , or -1 if the position of is determined by . - method will return the lowest row index. - - The row position value is zero based, so you can use it as an index for the array returned by . - - This method is called by the `Row` property, which the panel adds to its child controls at design time. - - To get the actual position of `control`, even when its position is determined by , call the method. - - - -## Examples - The following code example enumerates all the child controls in the and finds the row index for each using the method. - + method will return the lowest row index. + + The row position value is zero based, so you can use it as an index for the array returned by . + + This method is called by the `Row` property, which the panel adds to its child controls at design time. + + To get the actual position of `control`, even when its position is determined by , call the method. + + + +## Examples + The following code example enumerates all the child controls in the and finds the row index for each using the method. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet4"::: + ]]> @@ -1036,21 +1036,21 @@ Setting this value causes the panel to redraw itself and its contents. Returns the number of rows spanned by the specified child control. The number of rows spanned by the child control. The default is 1. - and methods to set the width of a control in a . - + and methods to set the width of a control in a . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet11"::: + ]]> @@ -1091,22 +1091,22 @@ Setting this value causes the panel to redraw itself and its contents. Gets or sets a value indicating whether the control should expand to accommodate new cells when all existing cells are occupied. A indicating the growth scheme. The default is . - control expands downward by adding rows. - + control expands downward by adding rows. + > [!NOTE] -> If an attempt is made to add a control to a full control, and the value of is , then an is thrown. - - - -## Examples - The following code example sets the value of the property depending on the selected . At run time, when the user clicks on the button labeled **Test GrowStyle**, a control is added to the control. If the control is full, it expands by adding a row or column, or it raises an exception, depending on the value of . - +> If an attempt is made to add a control to a full control, and the value of is , then an is thrown. + + + +## Examples + The following code example sets the value of the property depending on the selected . At run time, when the user clicks on the button labeled **Test GrowStyle**, a control is added to the control. If the control is full, it expands by adding a row or column, or it raises an exception, depending on the value of . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet7"::: + ]]> The property value is invalid for the enumeration. @@ -1228,14 +1228,14 @@ Setting this value causes the panel to redraw itself and its contents. A that provides data for the event. Receives a call when the cell should be refreshed. - method to create a custom appearance for a cell. - + method to create a custom appearance for a cell. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet100"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet100"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet100"::: + ]]> @@ -1275,11 +1275,11 @@ Setting this value causes the panel to redraw itself and its contents. A that contains the event data. Raises the event. - @@ -1351,17 +1351,17 @@ Setting this value causes the panel to redraw itself and its contents. Gets or sets the maximum number of rows allowed in the table. The maximum number of rows in the control. The default is 0. - property does not create rows or allocate any backing memory. Memory allocation occurs when the rows are created, so you can set this property to . - - Setting this property causes the table to undergo another layout operation. - You can specify both the and the properties for layouts with a known and fixed number of cells. You can also specify one property or the other if you expect the number of cells in your layout to grow, assuming that the property allows for such growth. If the value of is 0, the panel will grow by adding rows, and if the value of is 0, the panel will grow by adding columns. Specifying panel growth with the property is preferred to setting or to 0, however. - - Controls can be added or deleted from the table using the property. - + Setting this property causes the table to undergo another layout operation. + + You can specify both the and the properties for layouts with a known and fixed number of cells. You can also specify one property or the other if you expect the number of cells in your layout to grow, assuming that the property allows for such growth. If the value of is 0, the panel will grow by adding rows, and if the value of is 0, the panel will grow by adding columns. Specifying panel growth with the property is preferred to setting or to 0, however. + + Controls can be added or deleted from the table using the property. + ]]> @@ -1418,32 +1418,32 @@ Setting this value causes the panel to redraw itself and its contents. Gets a collection of row styles for the . A containing a for each row in the control. - property to access the style properties of specific rows. You can use members of the class to set the characteristics of individual rows in the table. - - When the control arranges its rows, it assigns priorities to each in the following order: - -1. Rows with set to are considered first, and their fixed heights are allocated. - -2. Rows with set to are sized to their contents. - -3. Remaining space is divided among rows with set to . - - - -## Examples - The following code example sets the properties of each row when a is clicked. - + property to access the style properties of specific rows. You can use members of the class to set the characteristics of individual rows in the table. + + When the control arranges its rows, it assigns priorities to each in the following order: + +1. Rows with set to are considered first, and their fixed heights are allocated. + +2. Rows with set to are sized to their contents. + +3. Remaining space is divided among rows with set to . + + + +## Examples + The following code example sets the properties of each row when a is clicked. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet9"::: + ]]> - AutoSize Behavior in the TableLayoutPanel Control + AutoSize Behavior in the TableLayoutPanel Control @@ -1516,11 +1516,11 @@ Setting this value causes the panel to redraw itself and its contents. The ratio by which to scale the control vertically. Performs the work of scaling the entire panel and any child controls. - method uses the `dx` and `dy` parameter values to scale both the height and width of the panel independently. - + method uses the `dx` and `dy` parameter values to scale both the height and width of the panel independently. + ]]> @@ -1589,23 +1589,23 @@ Setting this value causes the panel to redraw itself and its contents. The column to which will be moved. Sets the column position of the specified child control. - method moves the control to another column in the . The columns and rows have zero-based indexes. Setting the column position to -1 specifies that the control will flow to the first empty cell. - - This method reapplies the table layout to all controls in the . - - This method is called by the `Column` property, which the panel adds to its child controls at design time. - - - -## Examples - The following code example uses the method to swap two controls contained within a control. The example assumes a control with at least two rows. - + method moves the control to another column in the . The columns and rows have zero-based indexes. Setting the column position to -1 specifies that the control will flow to the first empty cell. + + This method reapplies the table layout to all controls in the . + + This method is called by the `Column` property, which the panel adds to its child controls at design time. + + + +## Examples + The following code example uses the method to swap two controls contained within a control. The example assumes a control with at least two rows. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet12"::: + ]]> @@ -1644,21 +1644,21 @@ Setting this value causes the panel to redraw itself and its contents. The number of columns to span. Sets the number of columns spanned by the child control. - and methods to set the width of a control in a . - + and methods to set the width of a control in a . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet11"::: + ]]> @@ -1700,23 +1700,23 @@ Setting this value causes the panel to redraw itself and its contents. The row to which will be moved. Sets the row position of the specified child control. - method moves the control to another row in the control. The columns and rows have zero-based indexes. Setting the row position to -1 specifies that the control will flow to the first empty cell. - - This method reapplies the table layout to all controls in the . - - This method is called by the `Row` property, which the panel adds to its child controls at design time. - - - -## Examples - The following code example uses the method to swap two controls contained within a control. The example assumes a control with at least two rows. - + method moves the control to another row in the control. The columns and rows have zero-based indexes. Setting the row position to -1 specifies that the control will flow to the first empty cell. + + This method reapplies the table layout to all controls in the . + + This method is called by the `Row` property, which the panel adds to its child controls at design time. + + + +## Examples + The following code example uses the method to swap two controls contained within a control. The example assumes a control with at least two rows. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet13"::: + ]]> @@ -1755,21 +1755,21 @@ Setting this value causes the panel to redraw itself and its contents. The number of rows to span. Sets the number of rows spanned by the child control. - and methods to set the width of a control in a . - + and methods to set the width of a control in a . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ColumnStyle/Overview/form1.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TableLayoutPanel/VB/form1.vb" id="Snippet11"::: + ]]> @@ -1814,11 +1814,11 @@ Setting this value causes the panel to redraw itself and its contents. if this object can provide extender properties to the specified object; otherwise, . - instance is cast to an interface. - + instance is cast to an interface. + ]]> diff --git a/xml/System.Windows.Forms/TableLayoutPanelCellPosition.xml b/xml/System.Windows.Forms/TableLayoutPanelCellPosition.xml index 3ef22e689c9..b86eea3a342 100644 --- a/xml/System.Windows.Forms/TableLayoutPanelCellPosition.xml +++ b/xml/System.Windows.Forms/TableLayoutPanelCellPosition.xml @@ -37,14 +37,14 @@ Represents a cell in a . - to set the position of a child control in a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/framework/winforms/controls/how-to-implement-a-custom-toolstriprenderer). - + to set the position of a child control in a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/desktop/winforms/controls/how-to-implement-a-custom-toolstriprenderer). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: + ]]> @@ -78,14 +78,14 @@ The row position of the cell. Initializes a new instance of the class. - to set the position of a child control in a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/framework/winforms/controls/how-to-implement-a-custom-toolstriprenderer). - + to set the position of a child control in a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/desktop/winforms/controls/how-to-implement-a-custom-toolstriprenderer). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Windows.Forms/TableLayoutSettings.xml b/xml/System.Windows.Forms/TableLayoutSettings.xml index f17f55cb04a..98e6470ccc8 100644 --- a/xml/System.Windows.Forms/TableLayoutSettings.xml +++ b/xml/System.Windows.Forms/TableLayoutSettings.xml @@ -41,27 +41,27 @@ Collects the characteristics associated with table layouts. - class collects and manages the characteristics associated with the table layout scheme. This class is used internally by the and classes, as well as the table layout engine. The class is used by the layout engine to determine how to lay out the container's child controls. - - The class manages the following information: - -- The being used. - -- The maximum number of columns and rows in the layout. - -- The collection of styles used for the contained columns and rows. - - - -## Examples - The following example shows how to initialize a object for a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/framework/winforms/controls/how-to-implement-a-custom-toolstriprenderer). - + class collects and manages the characteristics associated with the table layout scheme. This class is used internally by the and classes, as well as the table layout engine. The class is used by the layout engine to determine how to lay out the container's child controls. + + The class manages the following information: + +- The being used. + +- The maximum number of columns and rows in the layout. + +- The collection of styles used for the contained columns and rows. + + + +## Examples + The following example shows how to initialize a object for a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/desktop/winforms/controls/how-to-implement-a-custom-toolstriprenderer). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: + ]]> @@ -102,21 +102,21 @@ Gets or sets the maximum number of columns allowed in the table layout. The maximum number of columns allowed in the table layout. The default is 0. - property does not create columns or allocate any backing memory. Memory allocation occurs when the columns are created, so you can set this property to . - - Setting this property causes the table to undergo another layout operation. - - - -## Examples - The following example shows how to initialize a object for a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/framework/winforms/controls/how-to-implement-a-custom-toolstriprenderer). - + + Setting this property causes the table to undergo another layout operation. + + + +## Examples + The following example shows how to initialize a object for a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/desktop/winforms/controls/how-to-implement-a-custom-toolstriprenderer). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: + ]]> The property value is less than 0. @@ -160,11 +160,11 @@ Gets the collection of styles used to determine the look and feel of the table layout columns. A that contains the column styles for the layout table. - property to access the style properties of specific columns. The order of the styles in a matches the order of the corresponding columns in the layout table. - + property to access the style properties of specific columns. The order of the styles in a matches the order of the corresponding columns in the layout table. + ]]> @@ -208,14 +208,14 @@ Gets the that represents the row and the column of the cell. A that represents the cell position. - object to get a cell position in a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/framework/winforms/controls/how-to-implement-a-custom-toolstriprenderer). - + object to get a cell position in a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/desktop/winforms/controls/how-to-implement-a-custom-toolstriprenderer). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: + ]]> @@ -403,11 +403,11 @@ Gets or sets a value indicating how the table layout should expand to accommodate new cells when all existing cells are occupied. One of the values. The default is . - property determines how the layout engine should add a new cell to a full table. This property can be set to to indicate that rows should be added, to indicate that columns should be added, or to disallow expansion. - + property determines how the layout engine should add a new cell to a full table. This property can be set to to indicate that rows should be added, to indicate that columns should be added, or to disallow expansion. + ]]> .NET Framework only: The property value is not valid for the enumeration type. @@ -449,15 +449,15 @@ Gets the current table layout engine. The currently being used. - property is typically used in two contexts: - -- A container that uses a table layout. - -- A control contained within a table layout container, such as a button contained in a cell of a . - + property is typically used in two contexts: + +- A container that uses a table layout. + +- A control contained within a table layout container, such as a button contained in a cell of a . + ]]> @@ -496,21 +496,21 @@ Gets or sets the maximum number of rows allowed in the table layout. The maximum number of rows allowed in the table layout. The default is 0. - property does not create rows or allocate any backing memory. Memory allocation occurs when the rows are created, so you can set this property to . - - Setting this property causes the table to undergo another layout operation. - - - -## Examples - The following example shows how to initialize a object for a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/framework/winforms/controls/how-to-implement-a-custom-toolstriprenderer). - + + Setting this property causes the table to undergo another layout operation. + + + +## Examples + The following example shows how to initialize a object for a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/desktop/winforms/controls/how-to-implement-a-custom-toolstriprenderer). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: + ]]> The property value is less than 0. @@ -554,11 +554,11 @@ Gets the collection of styles used to determine the look and feel of the table layout rows. A that contains the row styles for the layout table. - property to access the style properties of specific rows. The order of the styles in a matches the order of the corresponding rows in the layout table. - + property to access the style properties of specific rows. The order of the styles in a matches the order of the corresponding rows in the layout table. + ]]> @@ -603,14 +603,14 @@ A that represents the cell position. Sets the that represents the row and the column of the cell. - object to set a cell position in a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/framework/winforms/controls/how-to-implement-a-custom-toolstriprenderer). - + object to set a cell position in a control. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/desktop/winforms/controls/how-to-implement-a-custom-toolstriprenderer). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet2"::: + ]]> @@ -804,11 +804,11 @@ The destination context of the serialization. For a description of this member, see . - instance is cast to an interface. - + instance is cast to an interface. + ]]> diff --git a/xml/System.Windows.Forms/TableLayoutStyle.xml b/xml/System.Windows.Forms/TableLayoutStyle.xml index cd6f3de777d..f94929d1600 100644 --- a/xml/System.Windows.Forms/TableLayoutStyle.xml +++ b/xml/System.Windows.Forms/TableLayoutStyle.xml @@ -37,13 +37,13 @@ Implements the basic functionality that represents the appearance and behavior of a table layout. - class is a common base class for the and classes, which describe the appearance and behavior of columns and rows, respectively, in a . - - The series of styles that represent the current columns and rows in the current table layout are aggregated in a and , respectively. - + class is a common base class for the and classes, which describe the appearance and behavior of columns and rows, respectively, in a . + + The series of styles that represent the current columns and rows in the current table layout are aggregated in a and , respectively. + ]]> @@ -52,7 +52,7 @@ - AutoSize Behavior in the TableLayoutPanel Control + AutoSize Behavior in the TableLayoutPanel Control @@ -83,11 +83,11 @@ Initializes a new instance of the class. - class. It effectively sets the property to . - + class. It effectively sets the property to . + ]]> @@ -128,21 +128,21 @@ Gets or sets a flag indicating how a row or column should be sized relative to its containing table. One of the values that specifies how rows or columns of user interface (UI) elements should be sized relative to their container. The default is . - ). - -- As a percentage of the parent container (). - -- To share equal space with its peers (). - + ). + +- As a percentage of the parent container (). + +- To share equal space with its peers (). + ]]> - AutoSize Behavior in the TableLayoutPanel Control + AutoSize Behavior in the TableLayoutPanel Control diff --git a/xml/System.Windows.Forms/TextBoxRenderer.xml b/xml/System.Windows.Forms/TextBoxRenderer.xml index 23ed0631a93..35221b67959 100644 --- a/xml/System.Windows.Forms/TextBoxRenderer.xml +++ b/xml/System.Windows.Forms/TextBoxRenderer.xml @@ -33,24 +33,24 @@ Provides methods used to render a text box control with visual styles. This class cannot be inherited. - class provides a set of `static` methods that can be used to render a text box control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a text box, use one of the methods. These methods provide a variety of options, such as applying text formatting or specifying text bounds. - - If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, will draw the text box with the current visual style. Otherwise, will throw an . To determine whether the members of this class can be used, you can check the value of the property. - - This class wraps the functionality of a that is set to one of the elements of the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - - - -## Examples - The following code example demonstrates how to create a custom control that uses the method to draw a text box. The control also allows the user to select one of the values to apply to the text box text. - + class provides a set of `static` methods that can be used to render a text box control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. To draw a text box, use one of the methods. These methods provide a variety of options, such as applying text formatting or specifying text bounds. + + If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, will draw the text box with the current visual style. Otherwise, will throw an . To determine whether the members of this class can be used, you can check the value of the property. + + This class wraps the functionality of a that is set to one of the elements of the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + + + +## Examples + The following code example demonstrates how to create a custom control that uses the method to draw a text box. The control also allows the user to select one of the values to apply to the text box text. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TextBoxRenderer/cpp/form1.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TextBoxRenderer/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TextBoxRenderer/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TextBoxRenderer/VB/form1.vb" id="Snippet0"::: + ]]> @@ -99,21 +99,21 @@ One of the values that specifies the visual state of the text box. Draws a text box control in the specified state and bounds. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -168,21 +168,21 @@ One of the values that specifies the visual state of the text box. Draws a text box control in the specified state and bounds, and with the specified text. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -239,21 +239,21 @@ One of the values that specifies the visual state of the text box. Draws a text box control in the specified state and bounds, and with the specified text and text bounds. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -304,21 +304,21 @@ One of the values that specifies the visual state of the text box. Draws a text box control in the specified state and bounds, and with the specified text and text formatting. - property returns `true`. - + property returns `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -371,30 +371,30 @@ One of the values that specifies the visual state of the text box. Draws a text box control in the specified state and bounds, and with the specified text, text bounds, and text formatting. - property returns `true`. - - - -## Examples - The following code example demonstrates how to use the method in a custom control's method to draw a text box. This code example is part of a larger example provided for the class. - + property returns `true`. + + + +## Examples + The following code example demonstrates how to use the method in a custom control's method to draw a text box. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TextBoxRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TextBoxRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TextBoxRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TextBoxRenderer/VB/form1.vb" id="Snippet2"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -425,20 +425,20 @@ if the user has enabled visual styles in the operating system and visual styles are applied to the client area of application windows; otherwise, . - method will throw an . - - - -## Examples - The following code example uses the property to determine whether to use the method. This code example is part of a larger example provided for the class. - + method will throw an . + + + +## Examples + The following code example uses the property to determine whether to use the method. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TextBoxRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TextBoxRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TextBoxRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TextBoxRenderer/VB/form1.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Windows.Forms/TextFormatFlags.xml b/xml/System.Windows.Forms/TextFormatFlags.xml index 94761327274..4bfe84c16f2 100644 --- a/xml/System.Windows.Forms/TextFormatFlags.xml +++ b/xml/System.Windows.Forms/TextFormatFlags.xml @@ -28,22 +28,22 @@ Specifies the display and layout information for text strings. - when drawing and measuring text. The does not support adding tab stops to drawn text, although you can expand existing tab stops using the `ExpandTabs` flag. - - - -## Examples - The following example demonstrates how to use the `TextFormatFlags` enumeration. To run this example, paste the following code into a Windows Form. Call `RenderText6` from the form's event handler, passing `e` as . - + when drawing and measuring text. The does not support adding tab stops to drawn text, although you can expand existing tab stops using the `ExpandTabs` flag. + + + +## Examples + The following example demonstrates how to use the `TextFormatFlags` enumeration. To run this example, paste the following code into a Windows Form. Call `RenderText6` from the form's event handler, passing `e` as . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TextFormatFlags/Overview/Form1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TextRendererExamples/VB/Form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TextRendererExamples/VB/Form1.vb" id="Snippet7"::: + ]]> - Using Fonts and Text + Using Fonts and Text diff --git a/xml/System.Windows.Forms/ToolStrip.xml b/xml/System.Windows.Forms/ToolStrip.xml index 70932ee8486..accc213546a 100644 --- a/xml/System.Windows.Forms/ToolStrip.xml +++ b/xml/System.Windows.Forms/ToolStrip.xml @@ -109,7 +109,7 @@ - ToolStrip Control (Windows Forms) + ToolStrip Control (Windows Forms) @@ -334,7 +334,7 @@ - How to: Enable Reordering of ToolStrip Items at Run Time in Windows Forms + How to: Enable Reordering of ToolStrip Items at Run Time in Windows Forms @@ -965,7 +965,7 @@ ]]> - How to: Manage ToolStrip Overflow in Windows Forms + How to: Manage ToolStrip Overflow in Windows Forms @@ -1859,7 +1859,7 @@ ]]> - How to: Define Z-Ordering of Docked ToolStrip Controls + How to: Define Z-Ordering of Docked ToolStrip Controls @@ -2167,7 +2167,7 @@ Returns the item located at the specified point in the client area of the . The at the specified location, or if the is not found. To be added. - Windows Forms Coordinates + Windows Forms Coordinates @@ -4313,10 +4313,10 @@ When overriding in a derived class, be sure to call the base class's method so that registered delegates receive the event. - How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms - How to: Set the ToolStrip Renderer at Run Time - How to: Set the ToolStrip Renderer for an Application - How to: Create a Professionally Styled ToolStrip Control + How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms + How to: Set the ToolStrip Renderer at Run Time + How to: Set the ToolStrip Renderer for an Application + How to: Create a Professionally Styled ToolStrip Control @@ -4783,10 +4783,10 @@ ]]> - How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms - How to: Set the ToolStrip Renderer at Run Time - How to: Set the ToolStrip Renderer for an Application - How to: Create a Professionally Styled ToolStrip Control + How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms + How to: Set the ToolStrip Renderer at Run Time + How to: Set the ToolStrip Renderer for an Application + How to: Create a Professionally Styled ToolStrip Control @@ -4836,10 +4836,10 @@ ]]> - How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms - How to: Set the ToolStrip Renderer at Run Time - How to: Set the ToolStrip Renderer for an Application - How to: Create a Professionally Styled ToolStrip Control + How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms + How to: Set the ToolStrip Renderer at Run Time + How to: Set the ToolStrip Renderer for an Application + How to: Create a Professionally Styled ToolStrip Control @@ -4885,10 +4885,10 @@ is set to without the property being assigned to a new instance of . - How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms - How to: Set the ToolStrip Renderer at Run Time - How to: Set the ToolStrip Renderer for an Application - How to: Create a Professionally Styled ToolStrip Control + How To: Create and Set a Custom Renderer for the ToolStrip Control in Windows Forms + How to: Set the ToolStrip Renderer at Run Time + How to: Set the ToolStrip Renderer for an Application + How to: Create a Professionally Styled ToolStrip Control @@ -5333,7 +5333,7 @@ ]]> - How to: Use ToolTips in ToolStrip Controls + How to: Use ToolTips in ToolStrip Controls diff --git a/xml/System.Windows.Forms/ToolStripButton.xml b/xml/System.Windows.Forms/ToolStripButton.xml index 2030f0d0791..ea16df920c0 100644 --- a/xml/System.Windows.Forms/ToolStripButton.xml +++ b/xml/System.Windows.Forms/ToolStripButton.xml @@ -33,29 +33,29 @@ Represents a selectable that can contain text and images. - to create a toolbar button that supports both text and images. Use the and properties to get or set the positioning of images and text. - - You can display a with various border styles, and you can use it to represent and activate operational states. You can also define it to have the focus by default. - - Although replaces and extends the control of previous versions, is retained for both backward compatibility and future use. - - - -## Examples - The following code example shows two controls with both image and text on a . Clicking the **New** displays a message box. - + to create a toolbar button that supports both text and images. Use the and properties to get or set the positioning of images and text. + + You can display a with various border styles, and you can use it to represent and activate operational states. You can also define it to have the focus by default. + + Although replaces and extends the control of previous versions, is retained for both backward compatibility and future use. + + + +## Examples + The following code example shows two controls with both image and text on a . Clicking the **New** displays a message box. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripButton/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripButton/vb/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripButton/vb/Form1.vb" id="Snippet1"::: + ]]> - MenuStrip Control (Windows Forms) - ToolStrip Control (Windows Forms) + MenuStrip Control (Windows Forms) + ToolStrip Control (Windows Forms) @@ -118,11 +118,11 @@ The image to display on the . Initializes a new instance of the class that displays the specified image. - that displays only an image on the . - + that displays only an image on the . + ]]> @@ -154,11 +154,11 @@ The text to display on the . Initializes a new instance of the class that displays the specified text. - that displays only text on the . - + that displays only text on the . + ]]> @@ -192,11 +192,11 @@ The image to display on the . Initializes a new instance of the class that displays the specified text and image. - that displays both an image and text. - + that displays both an image and text. + ]]> @@ -232,11 +232,11 @@ An event handler that raises the event. Initializes a new instance of the class that displays the specified text and image and that raises the event. - that displays both an image and text and raises the event when clicked. - + that displays both an image and text and raises the event when clicked. + ]]> @@ -274,11 +274,11 @@ The name of the . Initializes a new instance of the class with the specified name that displays the specified text and image and that raises the event. - with the specified name that displays both an image and text and raises the event when clicked. - + with the specified name that displays both an image and text and raises the event when clicked. + ]]> @@ -316,19 +316,19 @@ if default text is displayed; otherwise, . The default is . - property to `false` to display custom on a . - - - -## Examples - The following code example turns off the automatic text for a and sets custom . - + property to `false` to display custom on a . + + + +## Examples + The following code example turns off the automatic text for a and sets custom . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStrip/ShowItemToolTips/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripToolTip/vb/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripToolTip/vb/Form1.vb" id="Snippet1"::: + ]]> @@ -392,15 +392,15 @@ if the is pressed in or not pressed in; otherwise, . The default is . - property to `true` and uses the property in a event to change the font of the button text to bold when the button is clicked. - + property to `true` and uses the property in a event to change the font of the button text to bold when the button is clicked. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/CPP/form1.cpp" id="Snippet50"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripButton/Checked/form1.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet50"::: + ]]> @@ -431,20 +431,20 @@ Occurs when the value of the property changes. - property to `true` and uses the property in a event to change the font of the button text to bold when the button is clicked. - + property to `true` and uses the property in a event to change the font of the button text to bold when the button is clicked. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/CPP/form1.cpp" id="Snippet50"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripButton/Checked/form1.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet50"::: + ]]> @@ -490,15 +490,15 @@ if the should automatically appear pressed in and not pressed in when clicked; otherwise, . The default is . - property to `true` and uses the property in a event to change the font of the button text to bold when the button is clicked. - + property to `true` and uses the property in a event to change the font of the button text to bold when the button is clicked. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/CPP/form1.cpp" id="Snippet50"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripButton/Checked/form1.cs" id="Snippet50"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet50"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet50"::: + ]]> @@ -539,11 +539,11 @@ Gets or sets a value indicating whether the is in the pressed or not pressed state by default, or is in an indeterminate state. One of the values. The default is . - to `Indeterminate` when you do not want to set a default state. - + to `Indeterminate` when you do not want to set a default state. + ]]> The value assigned is not one of the values. @@ -575,21 +575,21 @@ Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripButton1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripButton1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet568"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet568"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet568"::: + ]]> @@ -627,14 +627,14 @@ Creates a new accessibility object for the . A new for the . - , it will be called when the property is referenced. - + , it will be called when the property is referenced. + > [!NOTE] -> To get or set the property, you must add a reference to the `Accessibility` assembly installed with the .NET Framework. - +> To get or set the property, you must add a reference to the `Accessibility` assembly installed with the .NET Framework. + ]]> @@ -730,13 +730,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -773,13 +773,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -816,13 +816,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -859,13 +859,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> diff --git a/xml/System.Windows.Forms/ToolStripComboBox.xml b/xml/System.Windows.Forms/ToolStripComboBox.xml index 4bb6c344873..67f8c5a7908 100644 --- a/xml/System.Windows.Forms/ToolStripComboBox.xml +++ b/xml/System.Windows.Forms/ToolStripComboBox.xml @@ -37,31 +37,31 @@ Represents a that is properly rendered in a . - is the optimized for hosting in a . A subset of the hosted control's properties and events are exposed at the level, but the underlying control is fully accessible through the property. - - A displays an editing field combined with a , allowing the user to select from the list or to enter new text. By default, a displays an edit field with a hidden drop-down list. The property determines the style of combo box to display. You can enter a value that allows for a simple drop-down, where the list always displays, a drop-down list box, where the text portion is not editable and you must select an arrow to view the drop-down list box, or the default drop-down list box, where the text portion is editable and the user must press the arrow key to view the list. To always display a list that the user cannot edit, use a control. - - To add objects to the list at run time, assign an array of object references with the method. The list then displays the default string value for each object. You can add individual objects with the method. - - In addition to display and selection functionality, the also provides features that enable you to efficiently add items to the and to find text within the items of the list. The and methods enable you to add a large number of items to the without the control being repainted each time an item is added to the list. The and methods enable you to search for an item in the list that contains a specific search string. - - Use the property to get or set the current item in the drop-down list, and use the property to get or set a reference to the current item in the drop-down list. - - - -## Examples - The following code example demonstrates a with various property settings, including automatic completion. - + is the optimized for hosting in a . A subset of the hosted control's properties and events are exposed at the level, but the underlying control is fully accessible through the property. + + A displays an editing field combined with a , allowing the user to select from the list or to enter new text. By default, a displays an edit field with a hidden drop-down list. The property determines the style of combo box to display. You can enter a value that allows for a simple drop-down, where the list always displays, a drop-down list box, where the text portion is not editable and you must select an arrow to view the drop-down list box, or the default drop-down list box, where the text portion is editable and the user must press the arrow key to view the list. To always display a list that the user cannot edit, use a control. + + To add objects to the list at run time, assign an array of object references with the method. The list then displays the default string value for each object. You can add individual objects with the method. + + In addition to display and selection functionality, the also provides features that enable you to efficiently add items to the and to find text within the items of the list. The and methods enable you to add a large number of items to the without the control being repainted each time an item is added to the list. The and methods enable you to search for an item in the list that contains a specific search string. + + Use the property to get or set the current item in the drop-down list, and use the property to get or set a reference to the current item in the drop-down list. + + + +## Examples + The following code example demonstrates a with various property settings, including automatic completion. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripComboBox/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet0"::: + ]]> - ToolStrip Technology Summary - ToolStrip Control Architecture + ToolStrip Technology Summary + ToolStrip Control Architecture @@ -217,23 +217,23 @@ Gets or sets the custom string collection to use when the property is set to . An that contains the strings. - , , and properties to create a that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source. This is useful for controls in which URLs, addresses, file names, or commands will be frequently entered. - - The use of the property is optional, but you must set the property to in order to use . - - You must use the and properties together. - - - -## Examples - The following code example demonstrates the syntax for setting various properties, including the property. - + , , and properties to create a that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source. This is useful for controls in which URLs, addresses, file names, or commands will be frequently entered. + + The use of the property is optional, but you must set the property to in order to use . + + You must use the and properties together. + + + +## Examples + The following code example demonstrates the syntax for setting various properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripComboBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -280,19 +280,19 @@ Gets or sets a value that indicates the text completion behavior of the . One of the values. The default is . - property to get or set the behavior of automatic completion. - - - -## Examples - The following code example demonstrates the syntax for setting various properties, including the property. - + property to get or set the behavior of automatic completion. + + + +## Examples + The following code example demonstrates the syntax for setting various properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripComboBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -339,19 +339,19 @@ Gets or sets the source of complete strings used for automatic completion. One of the values. The default is . - property to get or set automatic completion strings. - - - -## Examples - The following code example demonstrates the syntax for setting various properties, including the property. - + property to get or set automatic completion strings. + + + +## Examples + The following code example demonstrates the syntax for setting various properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripComboBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -407,11 +407,11 @@ This property is not relevant to this class. The background image displayed in the control. - @@ -460,11 +460,11 @@ This property is not relevant to this class. One of the values of . - @@ -495,13 +495,13 @@ Maintains performance when items are added to the one at a time. - method is called. - - The preferred way to add items to the is to use the method through the property of the . This enables you to add an array of items to the list at one time. However, if you want to add items one at a time using the method, you can use the method to prevent the control from repainting the each time an item is added to the list. Once you have completed the task of adding items to the list, call the method to enable the to repaint. This way of adding items can prevent flicker during the drawing of the when a large number of items are being added to the list. - + method is called. + + The preferred way to add items to the is to use the method through the property of the . This enables you to add an array of items to the list at one time. However, if you want to add items one at a time using the method, you can use the method to prevent the control from repainting the each time an item is added to the list. Once you have completed the task of adding items to the list, call the method to enable the to repaint. This way of adding items can prevent flicker during the drawing of the when a large number of items are being added to the list. + ]]> @@ -546,11 +546,11 @@ Gets a in which the user can enter text, along with a list from which the user can select. A for a . - property to get properties, methods, and events that have not been wrapped into . - + property to get properties, methods, and events that have not been wrapped into . + ]]> @@ -603,11 +603,11 @@ Gets the default spacing, in pixels, between the and an adjacent item. A value. - property to configure a default size for your . This is more efficient than setting the size in the constructor. - + property to configure a default size for your . This is more efficient than setting the size in the constructor. + ]]> @@ -638,13 +638,13 @@ Gets the default size of the . The default of the in pixels. The default size is 100 x 20 pixels. - [!NOTE] -> In order to maintain better performance, you should not set the of a in its constructor. The preferred method is to override the property. - +> In order to maintain better performance, you should not set the of a in its constructor. The preferred method is to override the property. + ]]> @@ -692,11 +692,11 @@ This event is not relevant to this class. - @@ -733,21 +733,21 @@ Occurs when the drop-down portion of a is shown. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripComboBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripComboBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet578"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet578"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet578"::: + ]]> @@ -784,21 +784,21 @@ Occurs when the drop-down portion of the has closed. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripComboBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripComboBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet579"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet579"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet579"::: + ]]> @@ -843,19 +843,19 @@ Gets or sets the height, in pixels, of the drop-down portion box of a . The height, in pixels, of the drop-down box. - property resets the property to `false`. - - - -## Examples - The following code example demonstrates the syntax for setting various properties, including the property. - + property resets the property to `false`. + + + +## Examples + The following code example demonstrates the syntax for setting various properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripComboBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -900,19 +900,19 @@ Gets or sets a value specifying the style of the . One of the values. The default is . - property controls the interface that is presented to the user. You can enter a value that allows for a simple drop-down list box, where the list always displays, a drop-down list box, where the text portion is not editable and you must select an arrow to view the drop-down, or the default drop-down list box, where the text portion is editable and the user must press the arrow key to view the list. To always display a list that the user cannot edit, use a control. - - - -## Examples - The following code example demonstrates the syntax for setting various properties, including the property. - + property controls the interface that is presented to the user. You can enter a value that allows for a simple drop-down list box, where the list always displays, a drop-down list box, where the text portion is not editable and you must select an arrow to view the drop-down, or the default drop-down list box, where the text portion is editable and the user must press the arrow key to view the list. To always display a list that the user cannot edit, use a control. + + + +## Examples + The following code example demonstrates the syntax for setting various properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripComboBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -949,21 +949,21 @@ Occurs when the property has changed. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripComboBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripComboBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet580"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet580"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet580"::: + ]]> @@ -994,19 +994,19 @@ Gets or sets the width, in pixels, of the drop-down portion of a . The width, in pixels, of the drop-down box. - property to get or set the width of the drop-down portion of a . - - - -## Examples - The following code example demonstrates the syntax for setting various properties, including the property. - + property to get or set the width of the drop-down portion of a . + + + +## Examples + The following code example demonstrates the syntax for setting various properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripComboBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1080,11 +1080,11 @@ Resumes painting the control after painting is suspended by the method. - is to use the method through the property of the . This enables you to add an array of items to the list at one time. However, if you want to add items one at a time using the method, you can use the method to prevent the control from repainting the each time an item is added to the list. Once you have completed the task of adding items to the list, call the method to enable the to repaint. This way of adding items can prevent flicker during the drawing of the when a large number of items are being added to the list. - + is to use the method through the property of the . This enables you to add an array of items to the list at one time. However, if you want to add items one at a time using the method, you can use the method to prevent the control from repainting the each time an item is added to the list. Once you have completed the task of adding items to the list, call the method to enable the to repaint. This way of adding items can prevent flicker during the drawing of the when a large number of items are being added to the list. + ]]> @@ -1129,11 +1129,11 @@ Finds the first item in the that starts with the specified string. The zero-based index of the first item found; returns -1 if no match is found. - , use method to specify a starting index within the . If you want to perform a search for an exact word match instead of a partial match, use the method. - + , use method to specify a starting index within the . If you want to perform a search for an exact word match instead of a partial match, use the method. + ]]> @@ -1171,11 +1171,11 @@ Finds the first item after the given index which starts with the given string. The zero-based index of the first item found; returns -1 if no match is found. - , use this method to specify a starting index within the . If you want to perform a search for an exact word match instead of a partial match, use the method. - + , use this method to specify a starting index within the . If you want to perform a search for an exact word match instead of a partial match, use the method. + ]]> @@ -1220,11 +1220,11 @@ Finds the first item in the that exactly matches the specified string. The zero-based index of the first item found; -1 if no match is found. - , use method to specify a starting index within the . If you want to search for a partial match instead of the exact word, use the method. - + , use method to specify a starting index within the . If you want to search for a partial match instead of the exact word, use the method. + ]]> @@ -1262,11 +1262,11 @@ Finds the first item after the specified index that exactly matches the specified string. The zero-based index of the first item found; returns -1 if no match is found. - , use this method to specify a starting index within the . If you want to search for a partial match instead of the exact word, use the method. - + , use this method to specify a starting index within the . If you want to search for a partial match instead of the exact word, use the method. + ]]> @@ -1307,27 +1307,27 @@ Gets or sets the appearance of the . One of the values of . The options are , , , and . The default is . - property to get or set the display style of the . - - Starting with the .NET Framework 4.5.2, if the property is set to or , the drop-down arrow may be resized. Resizing is determined by the system DPI setting when the app.config file contains the following entry: - -``` - - -``` - - - -## Examples - The following code example demonstrates the syntax for setting various properties, including the property. - + property to get or set the display style of the . + + Starting with the .NET Framework 4.5.2, if the property is set to or , the drop-down arrow may be resized. Resizing is determined by the system DPI setting when the app.config file contains the following entry: + +``` + + +``` + + + +## Examples + The following code example demonstrates the syntax for setting various properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripComboBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1433,13 +1433,13 @@ if the list portion can contain only complete items; otherwise, . The default is . - based on the space requirements of your form, set this property to `false`. If the does not contain any items, this property has no effect. - - Setting the property resets the property to `false`. - + based on the space requirements of your form, set this property to `false`. If the does not contain any items, this property has no effect. + + Setting the property resets the property to `false`. + ]]> @@ -1530,19 +1530,19 @@ Gets or sets the maximum number of items to be shown in the drop-down portion of the . The maximum number of items in the drop-down portion. The minimum for this property is 1 and the maximum is 100. - property to get or set the maximum number of items to show in the drop-down portion of the . - - - -## Examples - The following code example demonstrates the syntax for setting various properties, including the property. - + property to get or set the maximum number of items to show in the drop-down portion of the . + + + +## Examples + The following code example demonstrates the syntax for setting various properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripComboBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1614,13 +1614,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1657,13 +1657,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1700,13 +1700,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1743,13 +1743,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1786,15 +1786,15 @@ An that contains the event data. Raises the event. - is raised only when the user changes the combo box selection. Do not use or to capture user changes, because those events are also raised when the selection changes programmatically. This event is also raised when you set . - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + is raised only when the user changes the combo box selection. Do not use or to capture user changes, because those events are also raised when the selection changes programmatically. This event is also raised when you set . + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1832,17 +1832,17 @@ The control from which to subscribe events. Subscribes events from the specified control. - method to add or prevent the synchronizing of control events. - - If you override and hook up events here, unhook them by using the method. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method to add or prevent the synchronizing of control events. + + If you override and hook up events here, unhook them by using the method. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1879,13 +1879,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1923,15 +1923,15 @@ The control from which to unsubscribe events. Unsubscribes events from the specified control. - method to unsubscribe events subscribed in . - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method to unsubscribe events subscribed in . + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1970,17 +1970,17 @@ The number of characters to select. Selects a range of text in the editable portion of the . - - The is less than zero. - - -or- - + The is less than zero. + + -or- + minus is less than zero. @@ -2052,13 +2052,13 @@ Gets or sets the index specifying the currently selected item. A zero-based index of the currently selected item. A value of negative one (-1) is returned if no item is selected. - event. - - **Note** To deselect the currently selected item, set the to -1. - + event. + + **Note** To deselect the currently selected item, set the to -1. + ]]> @@ -2095,21 +2095,21 @@ Occurs when the value of the property has changed. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripComboBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripComboBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet581"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet581"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet581"::: + ]]> @@ -2163,11 +2163,11 @@ Gets or sets currently selected item in the . The object that is the currently selected item or if there is no currently selected item. - property to an object, the attempts to make that object the currently selected one in the list. If the object is found in the list, it is displayed in the edit portion of the and the property is set to the corresponding index. If the object does not exist in the list, the property is left at its current value. - + property to an object, the attempts to make that object the currently selected one in the list. If the object is found in the list, it is displayed in the edit portion of the and the property is set to the corresponding index. If the object does not exist in the list, the property is left at its current value. + ]]> @@ -2212,11 +2212,11 @@ Gets or sets the text that is selected in the editable portion of a . A string that represents the currently selected text in the combo box. If is set to , the return value is an empty string (""). - @@ -2261,11 +2261,11 @@ Gets or sets the number of characters selected in the editable portion of the . The number of characters selected in the . - property is set to a value that is larger than the number of characters within the text of the control, the value of the property is set to the entire length of text within the control minus the value of the property (if any value is specified for the property). - + property is set to a value that is larger than the number of characters within the text of the control, the value of the property is set to the entire length of text within the control minus the value of the property (if any value is specified for the property). + ]]> @@ -2310,11 +2310,11 @@ Gets or sets the starting index of text selected in the . The zero-based index of the first character in the string of the current text selection. - property. If the remaining text in the control after the position indicated by the property is less than the value of the property, the value of the property is automatically decreased. The value of the property never causes an increase in the property. - + property. If the remaining text in the control after the position indicated by the property is less than the value of the property, the value of the property is automatically decreased. The value of the property never causes an increase in the property. + ]]> @@ -2352,19 +2352,19 @@ if the combo box is sorted; otherwise, . The default is . - sorts existing entries and add new entries to the appropriate sorted position in the list. You can use this property to automatically sort items in a . As items are added to a sorted , the items are moved to the appropriate location in the sorted list. When you set the property to `false`, new items are added to the end of the existing list. The sort is case-insensitive and in alphabetically ascending order. - - - -## Examples - The following code example demonstrates the syntax for setting various properties, including the property. - + sorts existing entries and add new entries to the appropriate sorted position in the list. You can use this property to automatically sort items in a . As items are added to a sorted , the items are moved to the appropriate location in the sorted list. When you set the property to `false`, new items are added to the end of the existing list. The sort is case-insensitive and in alphabetically ascending order. + + + +## Examples + The following code example demonstrates the syntax for setting various properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripComboBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripComboBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -2401,21 +2401,21 @@ Occurs when the text has changed. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripComboBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripComboBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet582"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet582"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet582"::: + ]]> diff --git a/xml/System.Windows.Forms/ToolStripContainer.xml b/xml/System.Windows.Forms/ToolStripContainer.xml index d3b0eb6878e..3eff9dc6e68 100644 --- a/xml/System.Windows.Forms/ToolStripContainer.xml +++ b/xml/System.Windows.Forms/ToolStripContainer.xml @@ -45,27 +45,27 @@ Provides panels on each side of the form and a central panel that can hold one or more controls. - is similar to . It uses four docked side panels (instances of ) and one central panel (an instance of ) to create a typical arrangement. You cannot remove the side panels, but you can hide them by setting their respective , , , and properties to `false`. By default, each of these properties is `true` at design time. Also at design time, the appears with its top panel already expanded. You can neither remove nor hide the . You can arrange one or more , , or controls in the side panels, and you can use the central panel for other controls. The also provides a way to get renderer support into the body of your form for a consistent appearance. - - does not support Multiple Document Interface (MDI) applications. Use for MDI applications. - - - -## Examples - The following code example demonstrates adding a and a to a Windows Forms, adding items to the , and adding the to the of the . - + is similar to . It uses four docked side panels (instances of ) and one central panel (an instance of ) to create a typical arrangement. You cannot remove the side panels, but you can hide them by setting their respective , , , and properties to `false`. By default, each of these properties is `true` at design time. Also at design time, the appears with its top panel already expanded. You can neither remove nor hide the . You can arrange one or more , , or controls in the side panels, and you can use the central panel for other controls. The also provides a way to get renderer support into the body of your form for a consistent appearance. + + does not support Multiple Document Interface (MDI) applications. Use for MDI applications. + + + +## Examples + The following code example demonstrates adding a and a to a Windows Forms, adding items to the , and adding the to the of the . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStrip/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/system.windows.forms.toolstripcontainer2/vb/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/system.windows.forms.toolstripcontainer2/vb/form1.vb" id="Snippet1"::: + ]]> - ToolStrip Control (Windows Forms) + ToolStrip Control (Windows Forms) @@ -137,11 +137,11 @@ to enable automatic scrolling; otherwise, . - @@ -190,11 +190,11 @@ This property is not relevant for this class. A value. - @@ -243,11 +243,11 @@ This property is not relevant for this class. A value. - @@ -296,11 +296,11 @@ This property is not relevant for this class. A value. - @@ -349,11 +349,11 @@ This event is not relevant for this class. - @@ -403,11 +403,11 @@ This property is not relevant for this class. TTThe background image displayed in the control. - @@ -456,11 +456,11 @@ This event is not relevant for this class. - @@ -509,11 +509,11 @@ This property is not relevant for this class. The background image layout as defined in the ImageLayout enumeration. - @@ -562,11 +562,11 @@ This event is not relevant for this class. - @@ -619,11 +619,11 @@ Gets the bottom panel of the . A representing the bottom panel of the . - property to add , , or controls or move them from another . - + property to add , , or controls or move them from another . + ]]> @@ -661,11 +661,11 @@ if the bottom panel of the is visible; otherwise, . The default is . - property to `false` to use a without a bottom panel. - + property to `false` to use a without a bottom panel. + ]]> @@ -715,11 +715,11 @@ if the control causes validation; otherwise, . - @@ -760,11 +760,11 @@ Occurs when the value of the property changes. - @@ -817,11 +817,11 @@ Gets the center panel of the . A representing the center panel of the . - to hold , , or controls. Controls other than , , or are automatically added to the . - + to hold , , or controls. Controls other than , , or are automatically added to the . + ]]> @@ -871,11 +871,11 @@ This property is not relevant for this class. The ContextMenuStrip associated with this control. - @@ -916,11 +916,11 @@ Occurs when the value of the property changes. - @@ -969,11 +969,11 @@ This property is not relevant for this class. The collection of controls contained within the control. - @@ -1086,11 +1086,11 @@ This property is not relevant for this class. The cursor that is displayed when the mouse pointer is over the control. - @@ -1139,11 +1139,11 @@ This event is not relevant for this class. - @@ -1220,11 +1220,11 @@ This property is not relevant for this class. The foreground color of the control. - @@ -1273,11 +1273,11 @@ This event is not relevant for this class. - @@ -1330,11 +1330,11 @@ Gets the left panel of the . A representing the left panel of the . - property to add , , or controls or move them from another . - + property to add , , or controls or move them from another . + ]]> @@ -1372,11 +1372,11 @@ if the left panel of the is visible; otherwise, . The default is . - property to `false` to use a without a left panel. - + property to `false` to use a without a left panel. + ]]> @@ -1441,13 +1441,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1503,11 +1503,11 @@ Gets the right panel of the . A representing the right panel of the . - property to add , , or controls or move them from another . - + property to add , , or controls or move them from another . + ]]> @@ -1545,11 +1545,11 @@ if the right panel of the is visible; otherwise, . The default is . - property to `false` to use a without a right panel. - + property to `false` to use a without a right panel. + ]]> @@ -1602,11 +1602,11 @@ Gets the top panel of the . A representing the top panel of the . - property to add , , or controls or move them from another . - + property to add , , or controls or move them from another . + ]]> @@ -1644,11 +1644,11 @@ if the top panel of the is visible; otherwise, . The default is . - property to `false` to use a without a top panel. - + property to `false` to use a without a top panel. + ]]> diff --git a/xml/System.Windows.Forms/ToolStripContentPanel.xml b/xml/System.Windows.Forms/ToolStripContentPanel.xml index 0701b1d5b22..79db69591a3 100644 --- a/xml/System.Windows.Forms/ToolStripContentPanel.xml +++ b/xml/System.Windows.Forms/ToolStripContentPanel.xml @@ -61,24 +61,24 @@ Represents the center panel of a control. - to hold , , or controls. Use the to hold controls other than these. - - - -## Examples - The following code example demonstrates adding a to a . - + to hold , , or controls. Use the to hold controls other than these. + + + +## Examples + The following code example demonstrates adding a to a . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripContentPanel/Overview/Form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripContainer/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripContainer/VB/Form1.vb" id="Snippet1"::: + ]]> - ToolStrip Control (Windows Forms) + ToolStrip Control (Windows Forms) @@ -149,11 +149,11 @@ This property is not relevant to this class. The edges of the container to which a control is bound and determines how a control is resized with its parent. - @@ -195,11 +195,11 @@ to enable automatic scrolling; otherwise, . - @@ -248,11 +248,11 @@ This property is not relevant to this class. The distance between any child controls and the edges of the scrollable parent control. - @@ -301,11 +301,11 @@ This property is not relevant to this class. The minimum size of the auto-scroll. - @@ -355,11 +355,11 @@ to enable automatic sizing; otherwise, . - @@ -408,11 +408,11 @@ This event is not relevant to this class. - @@ -465,11 +465,11 @@ This property is not relevant to this class. The mode by which the content panel automatically resizes itself. - @@ -547,11 +547,11 @@ if the control causes validation; otherwise, . - @@ -592,11 +592,11 @@ This event is not relevant for this class. - @@ -645,11 +645,11 @@ This property is not relevant to this class. One of the values. - @@ -698,11 +698,11 @@ This event is not relevant to this class. - @@ -733,21 +733,21 @@ Occurs when the content panel loads. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripContentPanel1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripContentPanel1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet604"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet604"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet604"::: + ]]> @@ -796,11 +796,11 @@ This property is not relevant to this class. The coordinates of the upper-left corner of the control relative to the upper-left corner of its container. - @@ -849,11 +849,11 @@ This event is not relevant to this class. - @@ -902,11 +902,11 @@ This property is not relevant to this class. The size that is the upper limit that GetPreferredSize can specify. - @@ -955,11 +955,11 @@ This property is not relevant to this class. The size that is the lower limit that GetPreferredSize can specify. - @@ -1012,11 +1012,11 @@ This property is not relevant to this class. The name of the control. - @@ -1088,13 +1088,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1137,15 +1137,15 @@ A that contains the event data. Renders the . - , which contains all the information necessary to render the . - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + , which contains all the information necessary to render the . + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1182,13 +1182,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1268,21 +1268,21 @@ Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripContentPanel1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripContentPanel1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet605"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet605"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet605"::: + ]]> @@ -1359,11 +1359,11 @@ This property is not relevant to this class. The tab order of the control within its container. - @@ -1404,11 +1404,11 @@ This event is not relevant for this class. - @@ -1458,11 +1458,11 @@ if the can be tabbed to; otherwise, . - @@ -1503,11 +1503,11 @@ This event is not relevant for this class. - diff --git a/xml/System.Windows.Forms/ToolStripControlHost.xml b/xml/System.Windows.Forms/ToolStripControlHost.xml index 04a1e4851b8..e4ec8827f0f 100644 --- a/xml/System.Windows.Forms/ToolStripControlHost.xml +++ b/xml/System.Windows.Forms/ToolStripControlHost.xml @@ -53,8 +53,8 @@ ]]> - ToolStrip Control (Windows Forms) - How To: Wrap a Windows Forms Control with ToolStripControlHost + ToolStrip Control (Windows Forms) + How To: Wrap a Windows Forms Control with ToolStripControlHost diff --git a/xml/System.Windows.Forms/ToolStripDropDown.xml b/xml/System.Windows.Forms/ToolStripDropDown.xml index 14bad68ddd5..d21ece2eae1 100644 --- a/xml/System.Windows.Forms/ToolStripDropDown.xml +++ b/xml/System.Windows.Forms/ToolStripDropDown.xml @@ -70,7 +70,7 @@ Use the to display drop-down lists - ToolStrip Control (Windows Forms) + ToolStrip Control (Windows Forms) diff --git a/xml/System.Windows.Forms/ToolStripDropDownButton.xml b/xml/System.Windows.Forms/ToolStripDropDownButton.xml index d9f8e9859c2..3838aeececd 100644 --- a/xml/System.Windows.Forms/ToolStripDropDownButton.xml +++ b/xml/System.Windows.Forms/ToolStripDropDownButton.xml @@ -33,26 +33,26 @@ Represents a control that when clicked displays an associated from which the user can select a single item. - looks like , but it shows a drop-down area when the user clicks it. Hide or show the drop-down arrow by setting the property. hosts a that displays items that overflow the . - - Use the to activate familiar drop-down controls such as color pickers. Set the property to `true` to more clearly indicate to the user that further options are available on the drop-down list. - - - -## Examples - The following code example displays three controls when the is clicked. The buttons change the foreground color of the form. - + looks like , but it shows a drop-down area when the user clicks it. Hide or show the drop-down arrow by setting the property. hosts a that displays items that overflow the . + + Use the to activate familiar drop-down controls such as color pickers. Set the property to `true` to more clearly indicate to the user that further options are available on the drop-down list. + + + +## Examples + The following code example displays three controls when the is clicked. The buttons change the foreground color of the form. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/CPP/form1.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripButton/Checked/form1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet5"::: + ]]> - ToolStrip Control (Windows Forms) + ToolStrip Control (Windows Forms) @@ -86,15 +86,15 @@ Initializes a new instance of the class. - control. - + control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/CPP/form1.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripButton/Checked/form1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet5"::: + ]]> @@ -361,14 +361,14 @@ Creates a new accessibility object for this instance. A new accessibility object for this instance. - instance returned by this method supports the UI Automation expand/collapse pattern. +However, it's only available in applications that are running on the .NET Framework 4.7.1 or later versions and are either recompiled to target the .NET Framework 4.7.1 or opt in to this .NET Framework accessibility enhancements by using an AppCompat switch. +For more information, see the [migration guide](/dotnet/framework/migration-guide/retargeting/4.7-4.7.1#windows-forms). -The instance returned by this method supports the UI Automation expand/collapse pattern. -However, it's only available in applications that are running on the .NET Framework 4.7.1 or later versions and are either recompiled to target the .NET Framework 4.7.1 or opt in to this .NET Framework accessibility enhancements by using an AppCompat switch. -For more information, see the [migration guide](/dotnet/framework/migration-guide/retargeting/4.7-4.7.1#windows-forms). - ]]> @@ -460,13 +460,13 @@ For more information, see the [migration guide](/dotnet/framework/migration-guid A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -503,13 +503,13 @@ For more information, see the [migration guide](/dotnet/framework/migration-guid An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -577,13 +577,13 @@ For more information, see the [migration guide](/dotnet/framework/migration-guid A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -661,15 +661,15 @@ For more information, see the [migration guide](/dotnet/framework/migration-guid to show an arrow on the ; otherwise, . The default is . - control. The property is set to `false`. - + control. The property is set to `false`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/CPP/form1.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripButton/Checked/form1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip1/VB/form1.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Windows.Forms/ToolStripDropDownItem.xml b/xml/System.Windows.Forms/ToolStripDropDownItem.xml index 41fe39810eb..b27881f210b 100644 --- a/xml/System.Windows.Forms/ToolStripDropDownItem.xml +++ b/xml/System.Windows.Forms/ToolStripDropDownItem.xml @@ -56,9 +56,9 @@ ]]> - MenuStrip Control (Windows Forms) - ToolStrip Control (Windows Forms) - How To: Insert a MenuStrip into an MDI Drop-Down Menu (Windows Forms) + MenuStrip Control (Windows Forms) + ToolStrip Control (Windows Forms) + How To: Insert a MenuStrip into an MDI Drop-Down Menu (Windows Forms) @@ -585,7 +585,7 @@ ## Examples - The following code example demonstrates how to use the property to create a menu with sub-menus. For the complete code example, see [How to: Display Option Buttons in a MenuStrip](/dotnet/framework/winforms/controls/how-to-display-option-buttons-in-a-menustrip-windows-forms). + The following code example demonstrates how to use the property to create a menu with sub-menus. For the complete code example, see [How to: Display Option Buttons in a MenuStrip](/dotnet/desktop/winforms/controls/how-to-display-option-buttons-in-a-menustrip-windows-forms). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripDropDownItem/DropDownItems/ToolStripRadioButtonMenuItem.cs" id="Snippet200"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolStripRadioButtonMenuItem/vb/ToolStripRadioButtonMenuItem.vb" id="Snippet200"::: diff --git a/xml/System.Windows.Forms/ToolStripDropDownMenu.xml b/xml/System.Windows.Forms/ToolStripDropDownMenu.xml index d80b7f0a7c5..092f098f247 100644 --- a/xml/System.Windows.Forms/ToolStripDropDownMenu.xml +++ b/xml/System.Windows.Forms/ToolStripDropDownMenu.xml @@ -45,30 +45,30 @@ Provides basic functionality for the control. - is the base class for , providing necessary painting and layout properties and methods. The properties of this class that you are most likely to use directly are the and properties, which determine whether the shortcut menu will be able to display a check mark, an image, or both. - + and replace and extend the control, which was removed in .NET Core 3.1. -## Examples - The following code example demonstrates how to create and initialize a control by setting the check and image margins. - +## Examples + The following code example demonstrates how to create and initialize a control by setting the check and image margins. + > [!IMPORTANT] -> This code is not a complete sample, so it won't compile. For a full code listing, see [How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls](/dotnet/framework/winforms/controls/how-to-enable-check-margins-and-image-margins-in-contextmenustrip-controls). - +> This code is not a complete sample, so it won't compile. For a full code listing, see [How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls](/dotnet/desktop/winforms/controls/how-to-enable-check-margins-and-image-margins-in-contextmenustrip-controls). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenuStrip/Overview/Program.cs" id="Snippet61"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet61"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet61"::: + ]]> - ToolStrip Control Overview (Windows Forms) - ToolStrip Control Architecture - ToolStrip Technology Summary - How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls + ToolStrip Control Overview (Windows Forms) + ToolStrip Control Architecture + ToolStrip Technology Summary + How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls @@ -93,14 +93,14 @@ Initializes a new instance of the class. - control. For a full code listing, see [How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls](/dotnet/framework/winforms/controls/how-to-enable-check-margins-and-image-margins-in-contextmenustrip-controls). - + control. For a full code listing, see [How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls](/dotnet/desktop/winforms/controls/how-to-enable-check-margins-and-image-margins-in-contextmenustrip-controls). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenuStrip/Overview/Program.cs" id="Snippet62"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet62"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet62"::: + ]]> @@ -165,11 +165,11 @@ Creates a default with the specified text, image, and event handler on a new . A , or a if the parameter is a hyphen (-). - method to add a with commonly used characteristics to a . - + method to add a with commonly used characteristics to a . + ]]> @@ -298,11 +298,11 @@ Gets or sets a value indicating how the items of are displayed. One of the values. The default is . - items flow horizontally or vertically as necessary. See the enumeration for the other possibilities. - + items flow horizontally or vertically as necessary. See the enumeration for the other possibilities. + ]]> @@ -364,13 +364,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -407,13 +407,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -514,21 +514,21 @@ if the check margin is shown; otherwise, . The default is . - property to `true` to display a check mark when the user chooses the . -## Examples - The following code example demonstrates how to create and initialize a control by setting the check and image margins. For a full code listing, see [How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls](/dotnet/framework/winforms/controls/how-to-enable-check-margins-and-image-margins-in-contextmenustrip-controls). - +## Examples + The following code example demonstrates how to create and initialize a control by setting the check and image margins. For a full code listing, see [How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls](/dotnet/desktop/winforms/controls/how-to-enable-check-margins-and-image-margins-in-contextmenustrip-controls). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenuStrip/Overview/Program.cs" id="Snippet61"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet61"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet61"::: + ]]> - How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls + How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls @@ -564,21 +564,21 @@ if the image margin is shown; otherwise, . The default is . - property to `true` to display a graphic image with the . -## Examples - The following code example demonstrates how to create and initialize a control by setting the check and image margins. For a full code listing, see [How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls](/dotnet/framework/winforms/controls/how-to-enable-check-margins-and-image-margins-in-contextmenustrip-controls). - +## Examples + The following code example demonstrates how to create and initialize a control by setting the check and image margins. For a full code listing, see [How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls](/dotnet/desktop/winforms/controls/how-to-enable-check-margins-and-image-margins-in-contextmenustrip-controls). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenuStrip/Overview/Program.cs" id="Snippet61"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet61"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.Misc/VB/Program.vb" id="Snippet61"::: + ]]> - How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls + How to: Enable Check Margins and Image Margins in ContextMenuStrip Controls diff --git a/xml/System.Windows.Forms/ToolStripItem.xml b/xml/System.Windows.Forms/ToolStripItem.xml index de5e6b553fd..e5a25ae8a3b 100644 --- a/xml/System.Windows.Forms/ToolStripItem.xml +++ b/xml/System.Windows.Forms/ToolStripItem.xml @@ -112,7 +112,7 @@ - ToolStrip Control (Windows Forms) + ToolStrip Control (Windows Forms) @@ -7748,7 +7748,7 @@ If you set the property, t uses the property as the default source for the content. Set to `false` to use as the source for content. diff --git a/xml/System.Windows.Forms/ToolStripItemRenderEventArgs.xml b/xml/System.Windows.Forms/ToolStripItemRenderEventArgs.xml index 24648ba0efc..49e6f02ef41 100644 --- a/xml/System.Windows.Forms/ToolStripItemRenderEventArgs.xml +++ b/xml/System.Windows.Forms/ToolStripItemRenderEventArgs.xml @@ -29,53 +29,53 @@ Provides data for the events that render the background of objects derived from in the class. - class provides data for the following events: - -- - -- - -- - -- - -- - -- - -- - - In addition, it provides data for the following methods: - -- - -- - -- - -- - -- - -- - + class provides data for the following events: + +- + +- + +- + +- + +- + +- + +- + + In addition, it provides data for the following methods: + +- + +- + +- + +- + +- + +- + - - -## Examples - The following code example demonstrates how to override the method to draw a border around a control's . This code example is part of a larger example provided for the class. - + +## Examples + The following code example demonstrates how to override the method to draw a border around a control's . This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet14"::: + ]]> - How to: Implement a Custom ToolStripRenderer + How to: Implement a Custom ToolStripRenderer @@ -148,20 +148,20 @@ Gets the graphics used to paint the . The used to paint the . - method to draw a border around a control's . This code example is part of a larger example provided for the class. - + method to draw a border around a control's . This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet14"::: + ]]> - How to: Implement a Custom ToolStripRenderer + How to: Implement a Custom ToolStripRenderer @@ -196,20 +196,20 @@ Gets the to paint. The to paint. - method to draw a border around a control's . This code example is part of a larger example provided for the class. - + method to draw a border around a control's . This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet14"::: + ]]> - How to: Implement a Custom ToolStripRenderer + How to: Implement a Custom ToolStripRenderer @@ -245,25 +245,25 @@ Gets the value of the property for the to paint. The that is the owner of the . - is in the overflow area of the , the property returns an empty string. - - - -## Examples - The following code example demonstrates how to override the method to draw a border around a control's . This code example is part of a larger example provided for the class. - + is in the overflow area of the , the property returns an empty string. + + + +## Examples + The following code example demonstrates how to override the method to draw a border around a control's . This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet14"::: + ]]> - How to: Implement a Custom ToolStripRenderer + How to: Implement a Custom ToolStripRenderer diff --git a/xml/System.Windows.Forms/ToolStripLabel.xml b/xml/System.Windows.Forms/ToolStripLabel.xml index b563b5c141b..f9d0a5298fd 100644 --- a/xml/System.Windows.Forms/ToolStripLabel.xml +++ b/xml/System.Windows.Forms/ToolStripLabel.xml @@ -33,30 +33,30 @@ Represents a nonselectable that renders text and images and can display hyperlinks. - class to create a label that can render text and images that can implement the and properties. The also has many properties that enable it to display one or more hyperlinks, and other properties that modify the appearance and behavior of hyperlinks. - - The is like a that does not get focus by default and that does not render as pushed or highlighted. - - as a hosted item supports access keys. - - Use the , , and properties on a to support link control in a . - - - -## Examples - The following code example demonstrates how to initialize a to contain a link by setting the , , , , and properties. - + class to create a label that can render text and images that can implement the and properties. The also has many properties that enable it to display one or more hyperlinks, and other properties that modify the appearance and behavior of hyperlinks. + + The is like a that does not get focus by default and that does not render as pushed or highlighted. + + as a hosted item supports access keys. + + Use the , , and properties on a to support link control in a . + + + +## Examples + The following code example demonstrates how to initialize a to contain a link by setting the , , , , and properties. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/Tag/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: + ]]> - ToolStrip Control Overview (Windows Forms) - ToolStrip Control Architecture - ToolStrip Technology Summary + ToolStrip Control Overview (Windows Forms) + ToolStrip Control Architecture + ToolStrip Technology Summary @@ -327,24 +327,24 @@ Gets or sets the color used to display an active link. A that represents the color to display an active link. The default color is specified by the system. Typically, this color is . - control. You can use this property to specify the color that the link is displayed in when the link is in the process of being clicked. - - There are a number of colors associated with a link. The specifies the color of all links displayed in the control. The property enables you to specify the color of a link after it has been visited by the user. - + control. You can use this property to specify the color that the link is displayed in when the link is in the process of being clicked. + + There are a number of colors associated with a link. The specifies the color of all links displayed in the control. The property enables you to specify the color of a link after it has been visited by the user. + > [!NOTE] -> When setting this property, ensure that the color you are setting the property to does not conflict with the color of the control's background or the text does not display properly. For example, if the background color of the control is `Color.Red` and this property is set to `Color.Red`, the text is not shown properly when the link is in the process of being clicked. - - - -## Examples - The following code example demonstrates how to initialize a to contain a link by setting the , , , , and properties. - +> When setting this property, ensure that the color you are setting the property to does not conflict with the color of the control's background or the text does not display properly. For example, if the background color of the control is `Color.Red` and this property is set to `Color.Red`, the text is not shown properly when the link is in the process of being clicked. + + + +## Examples + The following code example demonstrates how to initialize a to contain a link by setting the , , , , and properties. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/Tag/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: + ]]> @@ -376,11 +376,11 @@ in all cases. - is a nonselectable . - + is a nonselectable . + ]]> @@ -458,14 +458,14 @@ if the is a hyperlink; otherwise, . The default is . - to contain a link by setting the , , , , and properties. - + to contain a link by setting the , , , , and properties. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/Tag/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: + ]]> @@ -506,19 +506,19 @@ Gets or sets a value that represents the behavior of a link. One of the values. The default is . - . - - - -## Examples - The following code example demonstrates how to initialize a to contain a link by setting the , , , , and properties. - + . + + + +## Examples + The following code example demonstrates how to initialize a to contain a link by setting the , , , , and properties. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/Tag/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: + ]]> @@ -549,14 +549,14 @@ Gets or sets the color used when displaying a normal link. A that represents the color used to displaying a normal link. The default color is specified by the system. Typically, this color is . - to contain a link by setting the , , , , and properties. - + to contain a link by setting the , , , , and properties. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/Tag/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: + ]]> @@ -598,19 +598,19 @@ if links should display as though they were visited; otherwise, . The default is . - control does not automatically denote that a link is a visited link. To display the link as a visited link, you can set the value of this property to `true` in an event handler for the click event of the . A visited link is displayed using the color specified in the property of the control. - - - -## Examples - The following code example demonstrates how to initialize a to contain a link by setting the , , , , and properties. - + control does not automatically denote that a link is a visited link. To display the link as a visited link, you can set the value of this property to `true` in an event handler for the click event of the . A visited link is displayed using the color specified in the property of the control. + + + +## Examples + The following code example demonstrates how to initialize a to contain a link by setting the , , , , and properties. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/Tag/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: + ]]> @@ -644,13 +644,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -687,13 +687,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -730,13 +730,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -773,13 +773,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -818,13 +818,13 @@ if the character was processed as a mnemonic by the control; otherwise, . - implementation relies on the host control to call the method to determine whether the given character matches a mnemonic in the item's text. In this case, the method selects the item associated with the label, or raises the event if the item cannot be selected. - + implementation relies on the host control to call the method to determine whether the given character matches a mnemonic in the item's text. In this case, the method selects the item associated with the label, or raises the event if the item cannot be selected. + ]]> @@ -855,22 +855,22 @@ Gets or sets the color used when displaying a link that has been previously visited. A that represents the color used to display links that have been visited. The default color is specified by the system. Typically, this color is . - that have been visited by the user. - + that have been visited by the user. + > [!NOTE] -> When setting this property, ensure that the color you are setting the property to does not conflict with the color of the control's background or the text does not display properly. For example, if the background color of the control is `Color.Red` and this property is set to `Color.Red`, the text is not shown properly when the link is displayed as a visited link. - - - -## Examples - The following code example demonstrates how to initialize a to contain a link by setting the , , , , and properties. - +> When setting this property, ensure that the color you are setting the property to does not conflict with the color of the control's background or the text does not display properly. For example, if the background color of the control is `Color.Red` and this property is set to `Color.Red`, the text is not shown properly when the link is displayed as a visited link. + + + +## Examples + The following code example demonstrates how to initialize a to contain a link by setting the , , , , and properties. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/Tag/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripLabel/VB/form1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/ToolStripMenuItem.xml b/xml/System.Windows.Forms/ToolStripMenuItem.xml index 9b4469752ee..0b8015048d8 100644 --- a/xml/System.Windows.Forms/ToolStripMenuItem.xml +++ b/xml/System.Windows.Forms/ToolStripMenuItem.xml @@ -1729,7 +1729,7 @@ ## Examples - The following code example demonstrates how to use the property to assign the key combination CTRL+P to a menu item called `printToolStripMenuItem`. For the complete example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + The following code example demonstrates how to use the property to assign the key combination CTRL+P to a menu item called `printToolStripMenuItem`. For the complete example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet100"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet100"::: diff --git a/xml/System.Windows.Forms/ToolStripProfessionalRenderer.xml b/xml/System.Windows.Forms/ToolStripProfessionalRenderer.xml index cc483133190..4bd380e4fea 100644 --- a/xml/System.Windows.Forms/ToolStripProfessionalRenderer.xml +++ b/xml/System.Windows.Forms/ToolStripProfessionalRenderer.xml @@ -29,19 +29,19 @@ Handles the painting functionality for objects, applying a custom palette and a streamlined style. - creates pens and brushes based on a replaceable color table called . - - - -## Examples - The following code example demonstrates how to create a composite control that mimics the **Navigation Pane** provided by Microsoft® Outlook®. For a full code listing, see [How to: Create a Professionally Styled ToolStrip Control](/dotnet/framework/winforms/controls/how-to-create-a-professionally-styled-toolstrip-control). - + creates pens and brushes based on a replaceable color table called . + + + +## Examples + The following code example demonstrates how to create a composite control that mimics the **Navigation Pane** provided by Microsoft® Outlook®. For a full code listing, see [How to: Create a Professionally Styled ToolStrip Control](/dotnet/desktop/winforms/controls/how-to-create-a-professionally-styled-toolstrip-control). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripProfessionalRenderer/Overview/StackView.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.StackView/VB/StackView.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.StackView/VB/StackView.vb" id="Snippet10"::: + ]]> @@ -77,14 +77,14 @@ Initializes a new instance of the class. - class. This code example is part of a larger example provided for the class. - + class. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripProfessionalRenderer/Overview/StackView.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.StackView/VB/StackView.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.StackView/VB/StackView.vb" id="Snippet5"::: + ]]> @@ -654,13 +654,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -697,13 +697,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -740,13 +740,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> diff --git a/xml/System.Windows.Forms/ToolStripRenderEventArgs.xml b/xml/System.Windows.Forms/ToolStripRenderEventArgs.xml index 095423be432..26177f39ed8 100644 --- a/xml/System.Windows.Forms/ToolStripRenderEventArgs.xml +++ b/xml/System.Windows.Forms/ToolStripRenderEventArgs.xml @@ -29,25 +29,25 @@ Provides data for the , , and methods. - class also provides data for the , , and methods. - - - -## Examples - The following code example demonstrates how to override the method to draw a custom border around a control. This code example is part of a larger example provided for the class. - + class also provides data for the , , and methods. + + + +## Examples + The following code example demonstrates how to override the method to draw a custom border around a control. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet12"::: + ]]> - How to: Implement a Custom ToolStripRenderer + How to: Implement a Custom ToolStripRenderer @@ -155,20 +155,20 @@ Gets the representing the bounds of the area to be painted. The representing the bounds of the area to be painted. - method to draw a custom border around a control. This code example is part of a larger example provided for the class. - + method to draw a custom border around a control. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet12"::: + ]]> - How to: Implement a Custom ToolStripRenderer + How to: Implement a Custom ToolStripRenderer @@ -197,16 +197,16 @@ Gets the that the background of the is painted with. The that the background of the is painted with. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet584"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet584"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet584"::: + ]]> @@ -237,21 +237,21 @@ Gets the representing the overlap area between a and its . The representing the overlap area between a and its . - is not a or the is `null`, the property returns an empty . - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + is not a or the is `null`, the property returns an empty . + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet584"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet584"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet584"::: + ]]> @@ -288,20 +288,20 @@ Gets the used to paint. The used to paint. - method to draw a custom border around a control. This code example is part of a larger example provided for the class. - + method to draw a custom border around a control. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet12"::: + ]]> - How to: Implement a Custom ToolStripRenderer + How to: Implement a Custom ToolStripRenderer @@ -336,20 +336,20 @@ Gets the to be painted. The to be painted. - method to paint a gradient in the background of a control. This code example is part of a larger example provided for the class. - + method to paint a gradient in the background of a control. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet13"::: + ]]> - How to: Implement a Custom ToolStripRenderer + How to: Implement a Custom ToolStripRenderer diff --git a/xml/System.Windows.Forms/ToolStripRenderer.xml b/xml/System.Windows.Forms/ToolStripRenderer.xml index e517a230386..2634e04e3ae 100644 --- a/xml/System.Windows.Forms/ToolStripRenderer.xml +++ b/xml/System.Windows.Forms/ToolStripRenderer.xml @@ -29,29 +29,29 @@ Handles the painting functionality for objects. - class to apply a particular style or theme to a . Rather than custom painting a and the objects it contains, you set the property to an object that inherits from . The painting specified by the is applied to the , as well as the items it contains. - - You can do custom painting in controls in several ways. As with other Windows Forms controls, the and both have overridable `OnPaint` methods and `Paint` events. As with regular painting, the coordinate system is relative to the client area of the control; that is, the upper left-hand corner of the control is 0, 0. The `Paint` event and `OnPaint` method for a behave like other control paint events. - - The class has overridable methods for painting the background, item background, item image, item arrow, item text, and border of the . The event arguments for these methods expose several properties such as rectangles, colors, and text formats that you can adjust as desired. - - To adjust just a few aspects of how an item is painted, you typically override the . - - If you are writing a new item and want to control all aspects of the painting, override the `OnPaint` method. From within `OnPaint`, you can use methods from the . - - By default, the is double buffered, taking advantage of the setting. - - - -## Examples - The following code example demonstrates how to implement a custom class. The `GridStripRenderer` class customizes three aspects of the `GridStrip` control's appearance: `GridStrip` border, border, and image. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/framework/winforms/controls/how-to-implement-a-custom-toolstriprenderer). - + class to apply a particular style or theme to a . Rather than custom painting a and the objects it contains, you set the property to an object that inherits from . The painting specified by the is applied to the , as well as the items it contains. + + You can do custom painting in controls in several ways. As with other Windows Forms controls, the and both have overridable `OnPaint` methods and `Paint` events. As with regular painting, the coordinate system is relative to the client area of the control; that is, the upper left-hand corner of the control is 0, 0. The `Paint` event and `OnPaint` method for a behave like other control paint events. + + The class has overridable methods for painting the background, item background, item image, item arrow, item text, and border of the . The event arguments for these methods expose several properties such as rectangles, colors, and text formats that you can adjust as desired. + + To adjust just a few aspects of how an item is painted, you typically override the . + + If you are writing a new item and want to control all aspects of the painting, override the `OnPaint` method. From within `OnPaint`, you can use methods from the . + + By default, the is double buffered, taking advantage of the setting. + + + +## Examples + The following code example demonstrates how to implement a custom class. The `GridStripRenderer` class customizes three aspects of the `GridStrip` control's appearance: `GridStrip` border, border, and image. For a full code listing, see [How to: Implement a Custom ToolStripRenderer](/dotnet/desktop/winforms/controls/how-to-implement-a-custom-toolstriprenderer). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet10"::: + ]]> @@ -89,11 +89,11 @@ Initializes a new instance of the class. - is an abstract class, so the constructor is only available to classes derived from it. - + is an abstract class, so the constructor is only available to classes derived from it. + ]]> @@ -159,11 +159,11 @@ A that contains data to draw the arrow. Draws an arrow on a . - method provides an entry point to the arrow rendering code. Use this method to draw an arrow when overriding the method, or to force an arrow to be drawn in a custom . To change the way an arrow is rendered, override the method in a class derived from . - + method provides an entry point to the arrow rendering code. Use this method to draw an arrow when overriding the method, or to force an arrow to be drawn in a custom . To change the way an arrow is rendered, override the method in a class derived from . + ]]> @@ -197,11 +197,11 @@ The that contains data to draw the button's background. Draws the background for a . - method provides an entry point to the rendering code for the background of a . Use this method to draw the background of a button when overriding the method, or to force the background of a button to be drawn in a custom . To change the way the background is rendered, override the method in a class derived from . - + method provides an entry point to the rendering code for the background of a . Use this method to draw the background of a button when overriding the method, or to force the background of a button to be drawn in a custom . To change the way the background is rendered, override the method in a class derived from . + ]]> @@ -235,11 +235,11 @@ A that contains the data to draw the drop-down button's background. Draws the background for a . - method provides the entry point to the rendering code for the background of a . Use this method to draw the background of a drop-down button when overriding the method, or to force the background of a drop-down button to be drawn in a custom . To change the way the background is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for the background of a . Use this method to draw the background of a drop-down button when overriding the method, or to force the background of a drop-down button to be drawn in a custom . To change the way the background is rendered, override the method in a class derived from . + ]]> @@ -273,11 +273,11 @@ A that contains the data to draw the move handle. Draws a move handle on a . - method provides an entry point to the rendering code for a move handle located on a . Use this method when overriding the method, or to force a move handle to be drawn in a custom . To change the way a move handle is rendered, override the method in a class derived from . - + method provides an entry point to the rendering code for a move handle located on a . Use this method when overriding the method, or to force a move handle to be drawn in a custom . To change the way a move handle is rendered, override the method in a class derived from . + ]]> @@ -311,11 +311,11 @@ A that contains the data to draw the space around the image. Draws the space around an image on a . - method provides the entry point to the rendering code for the image. Use this method to draw the image margin when overriding the method, or to force the image margin to be drawn in a custom . To change the way the image margin is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for the image. Use this method to draw the image margin when overriding the method, or to force the image margin to be drawn in a custom . To change the way the image margin is rendered, override the method in a class derived from . + ]]> @@ -349,11 +349,11 @@ A that contains the data to draw the background of the item. Draws the background for a . - method provides the entry point to the rendering code for the background of an item. Use this method to draw the background of an item when overriding the method, or to force the background of an item to be drawn in a custom . To change the way the background of an item is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for the background of an item. Use this method to draw the background of an item when overriding the method, or to force the background of an item to be drawn in a custom . To change the way the background of an item is rendered, override the method in a class derived from . + ]]> @@ -387,11 +387,11 @@ A that contains the data to draw the selected image. Draws an image on a that indicates the item is in a selected state. - method provides the entry point to the rendering code for an image in a selected state. Use this method to draw a selected image when overriding the method, or to force a selected image to be drawn in a custom . To change the way a selected image is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for an image in a selected state. Use this method to draw a selected image when overriding the method, or to force a selected image to be drawn in a custom . To change the way a selected image is rendered, override the method in a class derived from . + ]]> @@ -425,11 +425,11 @@ A that contains the data to draw the image. Draws an image on a . - method provides the entry point to the rendering code for an image. Use this method to draw an image when overriding the method or to force the image to be drawn in a custom . To change the way the image is rendered, override the `OnDrawItem` method in a class derived from . - + method provides the entry point to the rendering code for an image. Use this method to draw an image when overriding the method or to force the image to be drawn in a custom . To change the way the image is rendered, override the `OnDrawItem` method in a class derived from . + ]]> @@ -463,11 +463,11 @@ A that contains the data to draw the text. Draws text on a . - method provides the entry point to the rendering code for the text of a . Use this method to draw the item text when overriding the method, or to force the item text to be drawn in a custom . To change the way the item text is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for the text of a . Use this method to draw the item text when overriding the method, or to force the item text to be drawn in a custom . To change the way the item text is rendered, override the method in a class derived from . + ]]> @@ -501,11 +501,11 @@ A that contains the data to draw the background for the label. Draws the background for a . - method provides the entry point to the rendering code for the background of a . Use this method to draw the background of a when overriding the method, or to force the background of a to be drawn in a custom . To change the way the background of a is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for the background of a . Use this method to draw the background of a when overriding the method, or to force the background of a to be drawn in a custom . To change the way the background of a is rendered, override the method in a class derived from . + ]]> @@ -539,11 +539,11 @@ A that contains the data to draw the background for the menu item. Draws the background for a . - method provides the entry point to the rendering code for the background of a . Use this method to draw the background of a when overriding the method, or to force the background of a to be drawn in a custom . To change the way the background for a is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for the background of a . Use this method to draw the background of a when overriding the method, or to force the background of a to be drawn in a custom . To change the way the background for a is rendered, override the method in a class derived from . + ]]> @@ -577,11 +577,11 @@ A that contains the event data. Draws the background for an overflow button. - method provides the entry point to the rendering code for the background of an overflow button. Use this method to draw the background of an overflow button when overriding the method, or to force the background for an overflow button to be drawn in a custom . To change the way the background for an overflow button is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for the background of an overflow button. Use this method to draw the background of an overflow button when overriding the method, or to force the background for an overflow button to be drawn in a custom . To change the way the background for an overflow button is rendered, override the method in a class derived from . + ]]> @@ -615,11 +615,11 @@ A that contains the data to draw the . Draws a . - method provides the entry point to the rendering code for a . Use this method to draw the when overriding the method, or to force a to be drawn in a custom . To change the way the is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for a . Use this method to draw the when overriding the method, or to force a to be drawn in a custom . To change the way the is rendered, override the method in a class derived from . + ]]> @@ -653,11 +653,11 @@ A that contains the event data. Draws a . - method provides the entry point to the rendering code for a . Use this method to draw a when overriding the method, or to force a to be drawn in a custom . To change the way the is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for a . Use this method to draw a when overriding the method, or to force a to be drawn in a custom . To change the way the is rendered, override the method in a class derived from . + ]]> @@ -722,11 +722,11 @@ A that contains the data to draw the background for the . Draws the background for a . - method provides the entry point to the rendering code for the background of a . Use this method to draw the background of a when overriding the method, or to force the background of a to be drawn in a custom . To change the way the background of a is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for the background of a . Use this method to draw the background of a when overriding the method, or to force the background of a to be drawn in a custom . To change the way the background of a is rendered, override the method in a class derived from . + ]]> @@ -760,11 +760,11 @@ A that contains the data to draw the border for the . Draws the border for a . - method provides the entry point to the rendering code for the border of a . Use this method to draw the border of a when overriding the method, or to force the border of a to be drawn in a custom . To change the way the border of a is rendered, override the method in a class derived from . - + method provides the entry point to the rendering code for the border of a . Use this method to draw the border of a when overriding the method, or to force the border of a to be drawn in a custom . To change the way the border of a is rendered, override the method in a class derived from . + ]]> @@ -891,11 +891,11 @@ The to be initialized. When overridden in a derived class, provides for custom initialization of the given . - method to set properties, such as the or , when a is rendered. - + method to set properties, such as the or , when a is rendered. + ]]> @@ -960,19 +960,19 @@ The to be initialized. When overridden in a derived class, provides for custom initialization of the given . - method to set properties, such as the or , when a is rendered. - - - -## Examples - The following code example demonstrates how to initialize individual controls. This code example is part of a larger example provided for the class. - + method to set properties, such as the or , when a is rendered. + + + +## Examples + The following code example demonstrates how to initialize individual controls. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet11"::: + ]]> How to: Implement a Custom ToolStripRenderer @@ -1090,13 +1090,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> .NET 5 and later: The argument is . @@ -1134,19 +1134,19 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - -## Examples - The following code example demonstrates how to override the method to draw a border around a control's . This code example is part of a larger example provided for the class. - + +## Examples + The following code example demonstrates how to override the method to draw a border around a control's . This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet14"::: + ]]> @@ -1184,13 +1184,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1227,13 +1227,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1270,13 +1270,13 @@ A that contains the event data. Draws the item background. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1313,13 +1313,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1356,13 +1356,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> .NET 5 and later: The argument is . @@ -1400,13 +1400,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> .NET 5 and later: The argument is . @@ -1444,13 +1444,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> .NET 5 and later: The argument is . @@ -1488,13 +1488,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1531,13 +1531,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1574,13 +1574,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1617,13 +1617,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1660,13 +1660,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1703,13 +1703,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> .NET 5 and later: The argument is . @@ -1747,21 +1747,21 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - - - -## Examples - The following code example demonstrates how to override the method to paint a gradient in the background of a control. This code example is part of a larger example provided for the class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + + + +## Examples + The following code example demonstrates how to override the method to paint a gradient in the background of a control. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet13"::: + ]]> @@ -1799,21 +1799,21 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - - - -## Examples - The following code example demonstrates how to override the method to draw a custom border around a control. This code example is part of a larger example provided for the class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + + + +## Examples + The following code example demonstrates how to override the method to draw a custom border around a control. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/LayoutSettings/Overview/GridStrip.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStrip.GridStrip/VB/GridStrip.vb" id="Snippet12"::: + ]]> @@ -1851,13 +1851,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1894,13 +1894,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1937,13 +1937,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1976,21 +1976,21 @@ Occurs when an arrow on a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet583"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet583"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet583"::: + ]]> @@ -2020,21 +2020,21 @@ Occurs when the background for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet588"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet588"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet588"::: + ]]> @@ -2064,21 +2064,21 @@ Occurs when the background for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet589"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet589"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet589"::: + ]]> @@ -2108,21 +2108,21 @@ Occurs when the move handle for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet591"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet591"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet591"::: + ]]> @@ -2152,21 +2152,21 @@ Draws the margin between an image and its container. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet596"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet596"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet596"::: + ]]> @@ -2196,21 +2196,21 @@ Occurs when the background for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet592"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet592"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet592"::: + ]]> @@ -2240,21 +2240,21 @@ Occurs when the image for a selected is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet594"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet594"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet594"::: + ]]> @@ -2284,21 +2284,21 @@ Occurs when the image for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet593"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet593"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet593"::: + ]]> @@ -2328,21 +2328,21 @@ Occurs when the text for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet595"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet595"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet595"::: + ]]> @@ -2372,21 +2372,21 @@ Occurs when the background for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet597"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet597"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet597"::: + ]]> @@ -2416,21 +2416,21 @@ Occurs when the background for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet598"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet598"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet598"::: + ]]> @@ -2460,21 +2460,21 @@ Occurs when the background for an overflow button is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet590"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet590"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet590"::: + ]]> @@ -2504,21 +2504,21 @@ Occurs when a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet602"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet602"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet602"::: + ]]> @@ -2548,21 +2548,21 @@ Occurs when the background for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet601"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet601"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet601"::: + ]]> @@ -2592,21 +2592,21 @@ Occurs when the display style changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet600"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet600"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet600"::: + ]]> @@ -2636,21 +2636,21 @@ Occurs when the background for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet584"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet584"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet584"::: + ]]> @@ -2680,21 +2680,21 @@ Occurs when the border for a is rendered. - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet587"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet587"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet587"::: + ]]> @@ -2724,21 +2724,21 @@ Draws the background of a . - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet586"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet586"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet586"::: + ]]> @@ -2768,21 +2768,21 @@ Draws the background of a . - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet585"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet585"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet585"::: + ]]> @@ -2812,21 +2812,21 @@ Draws the background of a . - event. This report helps you to learn when the event occurs and can assist you in debugging. - - To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. + + To run the example code, paste it into a project that contains an instance of a type that inherits from , such as a or . Then name the instance `ToolStripRenderer1` and ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet599"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet599"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet599"::: + ]]> @@ -2886,9 +2886,9 @@ The DPI value to use for scaling. Applies the and values to scaling the arrow icon based on the specified DPI value. - about the new DPI and allows the offsets for rendering arrows in the right dimensions to be calculated. +This overload of the `ScaleArrowOffsetsIfNeeded` method should be called in a derived class only when an application opts into [per-monitor version 2](/dotnet/framework/whats-new/whats-new-in-accessibility#accessibility-switches), targets .NET Framework 4.7.1 or later, and has the `EnableDpiChangedMessageHandling` and `EnableDpiChangedHighDpiImprovements` configuration switches turned on. It informs the about the new DPI and allows the offsets for rendering arrows in the right dimensions to be calculated. ]]> diff --git a/xml/System.Windows.Forms/ToolStripSeparator.xml b/xml/System.Windows.Forms/ToolStripSeparator.xml index 24bc110ea9e..1256c5c3960 100644 --- a/xml/System.Windows.Forms/ToolStripSeparator.xml +++ b/xml/System.Windows.Forms/ToolStripSeparator.xml @@ -33,18 +33,18 @@ Represents a line used to group items of a or the drop-down items of a or or other control. - to group related items on a menu or . The is automatically spaced and oriented horizontally or vertically to accord with its container. - - You can add a at design time by choosing it from a drop-down list. However, you can also automatically create a by typing a hyphen (-) in either the designer template node or in the method. - + to group related items on a menu or . The is automatically spaced and oriented horizontally or vertically to accord with its container. + + You can add a at design time by choosing it from a drop-down list. However, you can also automatically create a by typing a hyphen (-) in either the designer template node or in the method. + ]]> - ToolStrip Control (Windows Forms) - MenuStrip Control (Windows Forms) - How to: Add Enhancements to ToolStripMenuItems + ToolStrip Control (Windows Forms) + MenuStrip Control (Windows Forms) + How to: Add Enhancements to ToolStripMenuItems @@ -116,11 +116,11 @@ if enabled; otherwise, . - @@ -170,11 +170,11 @@ This property is not relevant to this class. The image to display in the background of the separator. - @@ -223,11 +223,11 @@ This property is not relevant to this class. One of the values. - @@ -402,11 +402,11 @@ This property is not relevant to this class. One of the values. - @@ -447,11 +447,11 @@ This event is not relevant to this class. - @@ -501,11 +501,11 @@ if enabled; otherwise, . - @@ -555,11 +555,11 @@ if enabled; otherwise, . - @@ -600,11 +600,11 @@ This event is not relevant to this class. - @@ -657,11 +657,11 @@ This property is not relevant to this class. The to apply to the text displayed by the . - @@ -743,11 +743,11 @@ This property is not relevant to this class. The image to be displayed. - @@ -796,11 +796,11 @@ This property is not relevant to this class. One of the values. - @@ -857,11 +857,11 @@ This property is not relevant to this class. The index of the image that is displayed. - @@ -914,11 +914,11 @@ This property is not relevant to this class. The key for the image that is displayed for the . - @@ -967,11 +967,11 @@ This property is not relevant to this class. One of the value. - @@ -1020,11 +1020,11 @@ This property is not relevant to this class. One of the values. - @@ -1064,11 +1064,11 @@ A that contains the event data. This method is not relevant to this class. - @@ -1149,11 +1149,11 @@ if enabled; otherwise, . - @@ -1234,11 +1234,11 @@ This property is not relevant to this class. A representing the item's text. - @@ -1287,11 +1287,11 @@ This property is not relevant to this class. One of the value. - @@ -1332,11 +1332,11 @@ This event is not relevant to this class. - @@ -1381,11 +1381,11 @@ This property is not relevant to this class. One of the values. - @@ -1434,11 +1434,11 @@ This property is not relevant to this class. One of the values. - @@ -1488,11 +1488,11 @@ This property is not relevant to this class. A string representing the ToolTip text. - diff --git a/xml/System.Windows.Forms/ToolStripSplitButton.xml b/xml/System.Windows.Forms/ToolStripSplitButton.xml index 3953cd50ed1..0969b6f86dc 100644 --- a/xml/System.Windows.Forms/ToolStripSplitButton.xml +++ b/xml/System.Windows.Forms/ToolStripSplitButton.xml @@ -37,18 +37,18 @@ Represents a combination of a standard button on the left and a drop-down button on the right, or the other way around if the value of is . - combines button and drop-down button functionality. - - Use the property to synchronize the event of the chosen drop-down item with the item shown on the button. - + combines button and drop-down button functionality. + + Use the property to synchronize the event of the chosen drop-down item with the item shown on the button. + ]]> - ToolStrip Control Overview (Windows Forms) - ToolStrip Control Architecture - ToolStrip Technology Summary + ToolStrip Control Overview (Windows Forms) + ToolStrip Control Architecture + ToolStrip Technology Summary @@ -318,11 +318,11 @@ if default text is displayed; otherwise, . The default is . - property to `false` to display custom text on a . - + property to `false` to display custom text on a . + ]]> @@ -394,21 +394,21 @@ Occurs when the standard button portion of a is clicked. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripSplitButton1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripSplitButton1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet609"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet609"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet609"::: + ]]> @@ -445,21 +445,21 @@ Occurs when the standard button portion of a is double-clicked. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripSplitButton1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripSplitButton1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet610"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet610"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet610"::: + ]]> @@ -668,13 +668,13 @@ Gets or sets the portion of the that is activated when the control is first selected. A representing the portion of the that is activated when first selected. The default value is . - has a , the ENTER key activates the button. Otherwise, the ENTER key activates the drop-down. - - Use the property to synchronize the event of the chosen drop-down item with the item shown on the button. - + has a , the ENTER key activates the button. Otherwise, the ENTER key activates the drop-down. + + Use the property to synchronize the event of the chosen drop-down item with the item shown on the button. + ]]> @@ -711,21 +711,21 @@ Occurs when the has changed. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripSplitButton1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripSplitButton1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet611"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet611"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet611"::: + ]]> @@ -966,13 +966,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1009,13 +1009,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1052,13 +1052,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1095,13 +1095,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1138,13 +1138,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1181,13 +1181,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1256,13 +1256,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1329,13 +1329,13 @@ if the key was processed by the item; otherwise, . - event. However, if the is not enabled, this method calls the base class implementation instead. - - This method is called only if the method indicates that the item is not processing the key. - + event. However, if the is not enabled, this method calls the base class implementation instead. + + This method is called only if the method indicates that the item is not processing the key. + ]]> @@ -1408,11 +1408,11 @@ This method is not relevant to this class. - @@ -1454,11 +1454,11 @@ Gets the boundaries of the separator between the standard and drop-down button portions of a . A that represents the size and location of the separator. - property to do custom painting. - + property to do custom painting. + ]]> diff --git a/xml/System.Windows.Forms/ToolStripStatusLabel.xml b/xml/System.Windows.Forms/ToolStripStatusLabel.xml index cc8de7b33cf..c94e116c12d 100644 --- a/xml/System.Windows.Forms/ToolStripStatusLabel.xml +++ b/xml/System.Windows.Forms/ToolStripStatusLabel.xml @@ -42,21 +42,21 @@ Represents a panel in a control. - is a version of designed specifically for use in . The special features include , , and . - - A can contain text or an icon that reflects the status of an application. Use the class to find, add, or remove objects. - + is a version of designed specifically for use in . The special features include , , and . + + A can contain text or an icon that reflects the status of an application. Use the class to find, add, or remove objects. + replaces and extends the control, which was removed in .NET 5. -## Examples - The following code example demonstrates a with various common properties set. - +## Examples + The following code example demonstrates a with various common properties set. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/RightToLeftAutoMirrorImage/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripStatusLabel.CommonProps/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripStatusLabel.CommonProps/VB/form1.vb" id="Snippet0"::: + ]]> @@ -287,17 +287,17 @@ Gets or sets a value that determines where the is aligned on the . One of the values. - property is affected by the setting of the property. -## Examples - The following code example demonstrates the syntax for various common properties, including the property. - +## Examples + The following code example demonstrates the syntax for various common properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/RightToLeftAutoMirrorImage/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripStatusLabel.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripStatusLabel.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -338,14 +338,14 @@ Gets or sets a value that indicates which sides of the show borders. One of the values. The default is . - common properties, including the property. - + common properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/RightToLeftAutoMirrorImage/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripStatusLabel.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripStatusLabel.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -386,14 +386,14 @@ Gets or sets the border style of the . One of the values. The default is . - common properties, including the property. - + common properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/RightToLeftAutoMirrorImage/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripStatusLabel.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripStatusLabel.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> The value of is not one of the values. @@ -632,20 +632,20 @@ if the automatically fills the available space on the as the form is resized; otherwise, . The default is . - property to `true` to enable the to smoothly resize along with its container. -## Examples - The following code example demonstrates the syntax for various common properties, including the property. - +## Examples + The following code example demonstrates the syntax for various common properties, including the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripItem/RightToLeftAutoMirrorImage/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripStatusLabel.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripStatusLabel.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> - How to: Use the Spring Property Interactively in a StatusStrip + How to: Use the Spring Property Interactively in a StatusStrip diff --git a/xml/System.Windows.Forms/ToolStripTextBox.xml b/xml/System.Windows.Forms/ToolStripTextBox.xml index 4dcd268475b..15e258cdd68 100644 --- a/xml/System.Windows.Forms/ToolStripTextBox.xml +++ b/xml/System.Windows.Forms/ToolStripTextBox.xml @@ -33,30 +33,30 @@ Represents a text box in a that allows the user to enter text. - is the optimized for hosting in a . A subset of the hosted control's properties and events are exposed at the level, but the underlying control is fully accessible through the property. - - The control allows the user to enter text in an application. This control has additional functionality that is not found in the standard Windows text box control, including multiline editing. - - Typically, a control is used to display a single line of text or accept it as input. You can use the to enable multiple lines of text to be displayed or entered. Set the and properties to `true` to allow greater text manipulation in a multiline control. - - You can limit the amount of text entered into a control by setting the property to a specific number of characters. Use the property to allow the user to type only uppercase, only lowercase, or a combination of uppercase and lowercase characters into the control. - - To restrict text from being entered in a control, you can create an event handler for the event in order to validate each character entered in the control. You can also restrict all entry of data in a control by setting the property to `true`. - - - -## Examples - The following code example demonstrates a with various common property settings, including automatic completion options. - + is the optimized for hosting in a . A subset of the hosted control's properties and events are exposed at the level, but the underlying control is fully accessible through the property. + + The control allows the user to enter text in an application. This control has additional functionality that is not found in the standard Windows text box control, including multiline editing. + + Typically, a control is used to display a single line of text or accept it as input. You can use the to enable multiple lines of text to be displayed or entered. Set the and properties to `true` to allow greater text manipulation in a multiline control. + + You can limit the amount of text entered into a control by setting the property to a specific number of characters. Use the property to allow the user to type only uppercase, only lowercase, or a combination of uppercase and lowercase characters into the control. + + To restrict text from being entered in a control, you can create an event handler for the event in order to validate each character entered in the control. You can also restrict all entry of data in a control by setting the property to `true`. + + + +## Examples + The following code example demonstrates a with various common property settings, including automatic completion options. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet0"::: + ]]> - ToolStrip Control (Windows Forms) + ToolStrip Control (Windows Forms) ToolStrip Sample @@ -189,19 +189,19 @@ if the ENTER key creates a new line of text in a multiline version of the control; if the ENTER key activates the default button for the form. The default is . - control. If there is no default button for the form, then the ENTER key will always create a new line of text in the control, no matter what the value of this property. - - - -## Examples - The following code example demonstrates the syntax for setting various common property settings, including the property . - + control. If there is no default button for the form, then the ENTER key will always create a new line of text in the control, no matter what the value of this property. + + + +## Examples + The following code example demonstrates the syntax for setting various common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -239,19 +239,19 @@ if users can enter tabs in a multiline text box using the TAB key; if pressing the TAB key moves the focus. The default is . - property is set to `true`, the user must press CTRL+TAB to move the focus to the next control in the tab order. - - - -## Examples - The following code example demonstrates the syntax for setting various common property settings, including the property . - + property is set to `true`, the user must press CTRL+TAB to move the focus to the next control in the tab order. + + + +## Examples + The following code example demonstrates the syntax for setting various common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -289,21 +289,21 @@ Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet612"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet612"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet612"::: + ]]> @@ -398,23 +398,23 @@ Gets or sets a custom string collection to use when the property is set to . An to use with . - , , and properties to create a that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source. This is useful for controls in which URLs, addresses, file names, or commands will be frequently entered. - - The use of the property is optional, but you must set the property to `CustomSource` in order to use . - - You must use the and properties together. - - - -## Examples - The following code example demonstrates the syntax for setting various common property settings, including the property . - + , , and properties to create a that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source. This is useful for controls in which URLs, addresses, file names, or commands will be frequently entered. + + The use of the property is optional, but you must set the property to `CustomSource` in order to use . + + You must use the and properties together. + + + +## Examples + The following code example demonstrates the syntax for setting various common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -461,23 +461,23 @@ Gets or sets an option that controls how automatic completion works for the . One of the values. The default is . - , , and properties to create a that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source. This is useful for controls in which URLs, addresses, file names, or commands will be frequently entered. - - The use of the property is optional, but you must set the property to `CustomSource` in order to use . - - You must use the and properties together. - - - -## Examples - The following code example demonstrates the syntax for setting various common property settings, including the property . - + , , and properties to create a that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source. This is useful for controls in which URLs, addresses, file names, or commands will be frequently entered. + + The use of the property is optional, but you must set the property to `CustomSource` in order to use . + + You must use the and properties together. + + + +## Examples + The following code example demonstrates the syntax for setting various common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -524,23 +524,23 @@ Gets or sets a value specifying the source of complete strings used for automatic completion. One of the values. The default is . - , , and properties to create a that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source. This is useful for controls in which URLs, addresses, file names, or commands will be frequently entered. - - The use of the property is optional, but you must set the property to `CustomSource` in order to use . - - You must use the and properties together. - - - -## Examples - The following code example demonstrates the syntax for setting various common property settings, including the property . - + , , and properties to create a that automatically completes input strings by comparing the prefix being entered to the prefixes of all strings in a maintained source. This is useful for controls in which URLs, addresses, file names, or commands will be frequently entered. + + The use of the property is optional, but you must set the property to `CustomSource` in order to use . + + You must use the and properties together. + + + +## Examples + The following code example demonstrates the syntax for setting various common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -596,11 +596,11 @@ This property is not relevant to this class. The background image displayed in the control. - @@ -649,11 +649,11 @@ This property is not relevant to this class. An value. - @@ -694,19 +694,19 @@ Gets or sets the border type of the control. One of the values. The default is . - property to create borderless and flat style controls, in addition to the default three-dimensional control. - - - -## Examples - The following code example demonstrates the syntax for setting various common property settings, including the property . - + property to create borderless and flat style controls, in addition to the default three-dimensional control. + + + +## Examples + The following code example demonstrates the syntax for setting various common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -743,21 +743,21 @@ Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet613"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet613"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet613"::: + ]]> @@ -803,11 +803,11 @@ if the user can undo the previous operation performed in a text box control; otherwise, . - method to undo the last operation in a . - + method to undo the last operation in a . + ]]> @@ -849,19 +849,19 @@ Gets or sets whether the control modifies the case of characters as they are typed. One of the values. The default is . - property to change the case of characters as required by your application. - - - -## Examples - The following code example demonstrates the syntax for setting various common property settings, including the property . - + property to change the case of characters as required by your application. + + + +## Examples + The following code example demonstrates the syntax for setting various common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -925,11 +925,11 @@ Clears information about the most recent operation from the undo buffer of the . - @@ -965,11 +965,11 @@ Copies the current selection in the to the Clipboard. - class, to copy text in the and place it in the Clipboard. - + class, to copy text in the and place it in the Clipboard. + ]]> @@ -1033,11 +1033,11 @@ Moves the current selection in the to the Clipboard. - if text is selected in the control. You can use this method, instead of using the class, to copy text in the and move it to the Clipboard. - + if text is selected in the control. You can use this method, instead of using the class, to copy text in the and move it to the Clipboard. + ]]> @@ -1101,13 +1101,13 @@ Gets the default size of the . The default of the in pixels. The default size is 100 pixels by 25 pixels. - [!NOTE] -> In order to maintain better performance, you should not set the of a in its constructor. The preferred method is to override the property. - +> In order to maintain better performance, you should not set the of a in its constructor. The preferred method is to override the property. + ]]> @@ -1173,14 +1173,14 @@ Retrieves the character that is closest to the specified location within the control. The character at the specified location. - [!NOTE] -> If the specified location in the `pt` parameter is located on the right side of the client area of the control, the last character of the string closest to the point specified in `pt` is returned. - +> If the specified location in the `pt` parameter is located on the right side of the client area of the control, the last character of the string closest to the point specified in `pt` is returned. + ]]> @@ -1219,11 +1219,11 @@ Retrieves the index of the character nearest to the specified location. The zero-based character index at the specified location. - @@ -1262,13 +1262,13 @@ Retrieves the index of the first character of a given line. The zero-based character index in the specified line. - returns 0. If the `lineNum` parameter exceeds the number of lines in the control, returns the first character index for the last line in the control. - - returns the first character index of a physical line. The physical line is the displayed line, not the assigned line. The number of displayed lines can be greater than the number of assigned lines due to word wrap. For example, if you assign two long lines to a control and set and to `true`, the two long assigned lines result in four physical (or displayed lines). - + returns 0. If the `lineNum` parameter exceeds the number of lines in the control, returns the first character index for the last line in the control. + + returns the first character index of a physical line. The physical line is the displayed line, not the assigned line. The number of displayed lines can be greater than the number of assigned lines due to word wrap. For example, if you assign two long lines to a control and set and to `true`, the two long assigned lines result in four physical (or displayed lines). + ]]> @@ -1336,14 +1336,14 @@ Retrieves the line number from the specified character position within the text of the control. The zero-based line number in which the character index is located. - method returns the physical line number where the indexed character is located within the control. For example, if a portion of the first logical line of text in the control wraps to the next line, the method returns 1 if the character at the specified character index has wrapped to the second physical line. If is set to `false`, no portion of the line wraps to the next, and the method returns 0 for the specified character index. You can use this method to determine which line a specific character index is located within. For example, after calling the method to search for text, you can obtain the character index to where the search results are found. You can call this method with the character index returned by the method to determine which line the word was found. - + method returns the physical line number where the indexed character is located within the control. For example, if a portion of the first logical line of text in the control wraps to the next line, the method returns 1 if the character at the specified character index has wrapped to the second physical line. If is set to `false`, no portion of the line wraps to the next, and the method returns 0 for the specified character index. You can use this method to determine which line a specific character index is located within. For example, after calling the method to search for text, you can obtain the character index to where the search results are found. You can call this method with the character index returned by the method to determine which line the word was found. + > [!NOTE] -> If the character index specified in the `index` parameter is beyond the available number of lines contained within the control, the last line number is returned. - +> If the character index specified in the `index` parameter is beyond the available number of lines contained within the control, the last line number is returned. + ]]> @@ -1382,11 +1382,11 @@ Retrieves the location within the control at the specified character index. The location of the specified character. - control. - + control. + ]]> @@ -1461,19 +1461,19 @@ if the selected text does not appear highlighted when the text box control loses focus; , if the selected text remains highlighted when the text box control loses focus. The default is . - common property settings, including the property . - + common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1510,21 +1510,21 @@ Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet614"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet614"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet614"::: + ]]> @@ -1577,11 +1577,11 @@ Gets or sets the lines of text in a control. An array of strings that contains the text in a text box control. - property of the text box control is set to `true` and a newline character appears in the text, the text following the newline character is added to a new element in the array and displayed on a separate line. - + property of the text box control is set to `true` and a newline character appears in the text, the text following the newline character is added to a new element in the array and displayed on a separate line. + ]]> @@ -1622,19 +1622,19 @@ Gets or sets the maximum number of characters the user can type or paste into the text box control. The number of characters that can be entered into the control. The default is 32767 characters. - common property settings, including the property . - + common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1680,11 +1680,11 @@ if the control's contents have been modified; otherwise, . - control. You can also set this property in code to indicate that changes were made to the control by the application. This property can be used by validation and data-saving methods to determine if changes were made in a control so the changed contents can be validated or saved. - + control. You can also set this property in code to indicate that changes were made to the control by the application. This property can be used by validation and data-saving methods to determine if changes were made in a control so the changed contents can be validated or saved. + ]]> @@ -1721,21 +1721,21 @@ Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet615"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet615"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet615"::: + ]]> @@ -1793,11 +1793,11 @@ if enabled; otherwise, . - @@ -1842,11 +1842,11 @@ This event is not relevant to this class. - @@ -1880,13 +1880,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1923,13 +1923,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -1966,13 +1966,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2009,13 +2009,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2052,13 +2052,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2095,13 +2095,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2201,11 +2201,11 @@ Replaces the current selection in the text box with the contents of the Clipboard. - method will only paste text into the control if text is currently stored in the Clipboard. - + method will only paste text into the control if text is currently stored in the Clipboard. + ]]> @@ -2248,11 +2248,11 @@ if the is read-only; otherwise, . The default is . - property to allow the contents to be copied. - + property to allow the contents to be copied. + ]]> @@ -2289,21 +2289,21 @@ Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet616"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet616"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet616"::: + ]]> @@ -2334,14 +2334,14 @@ Scrolls the contents of the control to the current caret position. - method will scroll the contents of the control until the caret is visible at the bottom of the control. If the caret is positioned above the visible region of the control, this method scrolls the contents of the control until the caret is visible at the top of the control. You can use this method in a multiline text box to ensure that the current text entry point is within the visible region of the control. - + method will scroll the contents of the control until the caret is visible at the bottom of the control. If the caret is positioned above the visible region of the control, this method scrolls the contents of the control until the caret is visible at the top of the control. You can use this method in a multiline text box to ensure that the current text entry point is within the visible region of the control. + > [!NOTE] -> This method has no effect if the control does not have focus or if the caret is already positioned in the visible region of the control. - +> This method has no effect if the control does not have focus or if the caret is already positioned in the visible region of the control. + ]]> @@ -2377,14 +2377,14 @@ The number of characters to select. Selects a range of text in the text box. - [!NOTE] -> You can programmatically move the caret within the text box by setting the `start` parameter to the position within the text box where you want the caret to move to and set the `length` parameter to a value of zero (0). The text box must have focus in order for the caret to be moved. - +> You can programmatically move the caret within the text box by setting the `start` parameter to the position within the text box where you want the caret to move to and set the `length` parameter to a value of zero (0). The text box must have focus in order for the caret to be moved. + ]]> @@ -2415,11 +2415,11 @@ Selects all text in the text box. - method, which requires text to be selected in the control, to cut the entire contents of the control and paste them into the Clipboard. - + method, which requires text to be selected in the control, to cut the entire contents of the control and paste them into the Clipboard. + ]]> @@ -2464,11 +2464,11 @@ Gets or sets a value indicating the currently selected text in the control. A string that represents the currently selected text in the text box. - . If no text is currently selected in the , this property returns a zero-length string. - + . If no text is currently selected in the , this property returns a zero-length string. + ]]> @@ -2515,14 +2515,14 @@ Gets or sets the number of characters selected in the . The number of characters selected in the . - property is set to a value that is larger than the number of characters within the text of the control, the value of the property is set to the entire length of text within the control minus the value of the property (if any value is specified for the property). - + property is set to a value that is larger than the number of characters within the text of the control, the value of the property is set to the entire length of text within the control minus the value of the property (if any value is specified for the property). + > [!NOTE] -> You can programmatically move the caret within the text box by setting the to the position within the text box where you want the caret to move to and set the property to a value of zero (0). The text box must have focus in order for the caret to be moved. - +> You can programmatically move the caret within the text box by setting the to the position within the text box where you want the caret to move to and set the property to a value of zero (0). The text box must have focus in order for the caret to be moved. + ]]> @@ -2569,14 +2569,14 @@ Gets or sets the starting point of text selected in the . The starting position of text selected in the . - property. If the remaining text in the control after the position indicated by the property is less than the value of the property, the value of the property is automatically decreased. The value of the property never causes an increase in the property. - + property. If the remaining text in the control after the position indicated by the property is less than the value of the property, the value of the property is automatically decreased. The value of the property never causes an increase in the property. + > [!NOTE] -> You can programmatically move the caret within the text box by setting the to the position within the text box where you want the caret to move to and set the property to a value of zero (0). The text box must have focus in order for the caret to be moved. - +> You can programmatically move the caret within the text box by setting the to the position within the text box where you want the caret to move to and set the property to a value of zero (0). The text box must have focus in order for the caret to be moved. + ]]> @@ -2614,31 +2614,31 @@ to enable the shortcuts; otherwise, . - property to enable or disable the following shortcut key combinations: - -|Shortcut keys|Shortcut keys| -|-------------------|-------------------| -|CTRL+Z|CTRL+E| -|CTRL+C|CTRL+I| -|CTRL+X|CTRL+Y| -|CTRL+V|CTRL+BACKSPACE| -|CTRL+A|CTRL+DELETE| -|CTRL+L|SHIFT+DELETE| -|CTRL+R|SHIFT+INSERT| - - You can override this property to specify other shortcut keys. - - - -## Examples - The following code example demonstrates the syntax for setting various common property settings, including the property . - + property to enable or disable the following shortcut key combinations: + +|Shortcut keys|Shortcut keys| +|-------------------|-------------------| +|CTRL+Z|CTRL+E| +|CTRL+C|CTRL+I| +|CTRL+X|CTRL+Y| +|CTRL+V|CTRL+BACKSPACE| +|CTRL+A|CTRL+DELETE| +|CTRL+L|SHIFT+DELETE| +|CTRL+R|SHIFT+INSERT| + + You can override this property to specify other shortcut keys. + + + +## Examples + The following code example demonstrates the syntax for setting various common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -2721,19 +2721,19 @@ Gets or sets how text is aligned in a control. One of the enumeration values that specifies how text is aligned in the control. The default is . - to match the layout of text on your form. For example, if your controls are all located on the right side of the form, you can set the property to , and the text will be aligned with the right side of the control instead of the default left alignment. - - - -## Examples - The following code example demonstrates the syntax for setting various common property settings, including the property . - + to match the layout of text on your form. For example, if your controls are all located on the right side of the form, you can set the property to , and the text will be aligned with the right side of the control instead of the default left alignment. + + + +## Examples + The following code example demonstrates the syntax for setting various common property settings, including the property . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripTextBox/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolStripTextBox.CommonProps/VB/form1.vb" id="Snippet1"::: + ]]> @@ -2770,21 +2770,21 @@ Occurs when the value of the property changes. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolStripTextBox1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet617"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet617"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet617"::: + ]]> @@ -2821,11 +2821,11 @@ Gets the length of text in the control. The number of characters contained in the text of the . - property to determine the number of characters in a string for tasks such as searching for specific strings of text within the text of the control, where knowledge of the total number of characters is needed. - + property to determine the number of characters in a string for tasks such as searching for specific strings of text within the text of the control, where knowledge of the total number of characters is needed. + ]]> @@ -2856,11 +2856,11 @@ Undoes the last edit operation in the text box. - property returns `true`. - + property returns `true`. + ]]> @@ -2915,11 +2915,11 @@ if enabled; otherwise, . - diff --git a/xml/System.Windows.Forms/ToolTip.xml b/xml/System.Windows.Forms/ToolTip.xml index 12b8663095c..91bd67b5ec8 100644 --- a/xml/System.Windows.Forms/ToolTip.xml +++ b/xml/System.Windows.Forms/ToolTip.xml @@ -50,44 +50,44 @@ Represents a small rectangular pop-up window that displays a brief description of a control's purpose when the user rests the pointer on the control. - class, you can provide hints to a user when the user places the pointer on a control. The class is typically used to alert users to the intended use of a control. For example, you can specify ToolTip text for a control that accepts a name, specifying the format of the name to be typed into the control. In addition to providing hints, you can also use the class to provide run time status information. For example, you can use the class to display connection speed and line quality data when the user moves the pointer onto a control that displays Internet connection status. - - The class can be used in any container. To explicitly specify a container, use the constructor. A single component typically is used to create ToolTips for multiple controls on a single form. After you create a , use a separate call to the method to associate ToolTip display text to an individual control. Then when the user moves the pointer on a control, the ToolTip with its text is displayed. You can call more than once for the same control to change the text that is associated with the control. To get the text that is associated with a control, use the method. To remove all ToolTip text associations with an instance of the class, use the method. - + class, you can provide hints to a user when the user places the pointer on a control. The class is typically used to alert users to the intended use of a control. For example, you can specify ToolTip text for a control that accepts a name, specifying the format of the name to be typed into the control. In addition to providing hints, you can also use the class to provide run time status information. For example, you can use the class to display connection speed and line quality data when the user moves the pointer onto a control that displays Internet connection status. + + The class can be used in any container. To explicitly specify a container, use the constructor. A single component typically is used to create ToolTips for multiple controls on a single form. After you create a , use a separate call to the method to associate ToolTip display text to an individual control. Then when the user moves the pointer on a control, the ToolTip with its text is displayed. You can call more than once for the same control to change the text that is associated with the control. To get the text that is associated with a control, use the method. To remove all ToolTip text associations with an instance of the class, use the method. + > [!NOTE] -> ToolTip text is not displayed for controls that are disabled. Unless the property is set to `true`, ToolTips are not displayed when their container is inactive. - - The class provides the following properties and methods to modify the default behavior and appearance of a ToolTip. - -|Category|Associated members| -|--------------|------------------------| -|Manual display|, , , , , | -|ToolTip timing|, , , , | -|Content|, , , , , | -|Appearance|, , , , , | - - If you want to disable all ToolTip text so that it cannot be displayed in your application, you can use the property. Usually the ToolTip is drawn by the operating system, but to customize the appearance of the , you can set the property to `true` and handle the event. - - The class implements the interface, which has a single method, . ToolTips extend controls on the same form at design time, adding a `ToolTip` property. For more information about extender providers, see [Extender Providers](https://learn.microsoft.com/previous-versions/visualstudio/visual-studio-2013/ms171835(v=vs.120)). - - - -## Examples - The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to always be display regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1`, and that the method is called from the constructor of the . - +> ToolTip text is not displayed for controls that are disabled. Unless the property is set to `true`, ToolTips are not displayed when their container is inactive. + + The class provides the following properties and methods to modify the default behavior and appearance of a ToolTip. + +|Category|Associated members| +|--------------|------------------------| +|Manual display|, , , , , | +|ToolTip timing|, , , , | +|Content|, , , , , | +|Appearance|, , , , , | + + If you want to disable all ToolTip text so that it cannot be displayed in your application, you can use the property. Usually the ToolTip is drawn by the operating system, but to customize the appearance of the , you can set the property to `true` and handle the event. + + The class implements the interface, which has a single method, . ToolTips extend controls on the same form at design time, adding a `ToolTip` property. For more information about extender providers, see [Extender Providers](https://learn.microsoft.com/previous-versions/visualstudio/visual-studio-2013/ms171835(v=vs.120)). + + + +## Examples + The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to always be display regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1`, and that the method is called from the constructor of the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ToolTip Example/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolTip/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: + ]]> Extender Providers - ToolTip Component (Windows Forms) + ToolTip Component (Windows Forms) @@ -122,20 +122,20 @@ Initializes a new instance of the without a specified container. - class. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1,` and that the method is called from the constructor of the . - + class. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1,` and that the method is called from the constructor of the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ToolTip Example/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolTip/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: + ]]> @@ -169,11 +169,11 @@ An that represents the container of the . Initializes a new instance of the class with a specified container. - constructor enables you to associate a with any object. By associating the in this manner, you hand over control of the lifetime of the ToolTip to the . This can be useful if you use several components in your application, and want to dispose of all of them at the same time. For example, if you associate a , an , and a with a , calling on the will also force disposal of all of these components. - + constructor enables you to associate a with any object. By associating the in this manner, you hand over control of the lifetime of the ToolTip to the . This can be useful if you use several components in your application, and want to dispose of all of them at the same time. For example, if you associate a , an , and a with a , calling on the will also force disposal of all of these components. + ]]> @@ -217,11 +217,11 @@ if the ToolTip is currently active; otherwise, . The default is . - property, you can enable or disable the display of ToolTip text for all controls that have text specified by this particular component. Although more than one component can be created and assigned to a form, setting the property to `false` only affects the current . You can enable users to set the value of this property in a form that provides application options. These options, in turn, provide the user with the ability to enable or disable the display of ToolTips in your application. - + property, you can enable or disable the display of ToolTip text for all controls that have text specified by this particular component. Although more than one component can be created and assigned to a form, setting the property to `false` only affects the current . You can enable users to set the value of this property in a form that provides application options. These options, in turn, provide the user with the ability to enable or disable the display of ToolTips in your application. + ]]> @@ -271,19 +271,19 @@ Gets or sets the automatic delay for the ToolTip. The automatic delay, in milliseconds. The default is 500. - property enables you to set a single delay value, which is then used to set the values of the , , and properties. Each time the property is set, the following values are set by default. - -|Property|Default Value| -|--------------|-------------------| -||10 times the property value.| -||Equal to the property value.| -||1/5 of the property value.| - - These properties can also be set independently once the property has been set. For more information, see the , , and properties. This property is typically used to provide a consistent delay pattern for your ToolTip windows. - + property enables you to set a single delay value, which is then used to set the values of the , , and properties. Each time the property is set, the following values are set by default. + +|Property|Default Value| +|--------------|-------------------| +||10 times the property value.| +||Equal to the property value.| +||1/5 of the property value.| + + These properties can also be set independently once the property has been set. For more information, see the , , and properties. This property is typically used to provide a consistent delay pattern for your ToolTip windows. + ]]> @@ -330,24 +330,24 @@ Gets or sets the period of time the ToolTip remains visible if the pointer is stationary on a control with specified ToolTip text. The period of time, in milliseconds, that the remains visible when the pointer is stationary on a control. The default value is 5000. - property enables you to shorten or lengthen the time that the window is displayed when the pointer is on a control. For example, if you display extensive Help in a ToolTip window, you can increase the value of this property to ensure that the user has sufficient time to read the text. - - If you want to have a consistent delay pattern for your ToolTip windows, you can set the property. The property sets the , , and properties to initial values based on a single value. Every time the property is set, the property is set to 10 times the property value. Once the property is set, you can independently set the property, overriding the default value. - - The maximum time you can delay a popup is 5000 milliseconds. For longer durations, use the method to control the exact moment when the ToolTip is displayed. - - - -## Examples - The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1,` and that the method is called from the constructor of the . - + property enables you to shorten or lengthen the time that the window is displayed when the pointer is on a control. For example, if you display extensive Help in a ToolTip window, you can increase the value of this property to ensure that the user has sufficient time to read the text. + + If you want to have a consistent delay pattern for your ToolTip windows, you can set the property. The property sets the , , and properties to initial values based on a single value. Every time the property is set, the property is set to 10 times the property value. Once the property is set, you can independently set the property, overriding the default value. + + The maximum time you can delay a popup is 5000 milliseconds. For longer durations, use the method to control the exact moment when the ToolTip is displayed. + + + +## Examples + The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1,` and that the method is called from the constructor of the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ToolTip Example/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolTip/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: + ]]> @@ -393,13 +393,13 @@ Gets or sets the background color for the ToolTip. The background . - property. - + property. + ]]> @@ -443,11 +443,11 @@ if the class can offer one or more extender properties; otherwise, . - method is the only member of the interface. This method returns `true` if the `target` parameter is of type . - + method is the only member of the interface. This method returns `true` if the `target` parameter is of type . + ]]> @@ -479,14 +479,14 @@ Gets the creation parameters for the ToolTip window. A containing the information needed to create the ToolTip. - property should only be extended when you are wrapping a standard Windows control class or to set styles not provided by the namespace. For more information about creating control parameters, see [CreateWindowA](/windows/win32/api/winuser/nf-winuser-createwindowa), [CreateWindowEx](/windows/win32/api/winuser/nf-winuser-createwindowexa), and [CREATESTRUCT](/windows/win32/api/winuser/ns-winuser-createstructa). - + > [!NOTE] -> When overriding the property in a derived class, use the base class's property to extend the base implementation. - +> When overriding the property in a derived class, use the base class's property to extend the base implementation. + ]]> @@ -558,24 +558,24 @@ Occurs when the ToolTip is drawn and the property is set to and the property is . - event, you can customize the appearance of the . - - The event is raised by the class when the is drawn and the property value is `true` and the property is `false`. The class contains all the information needed to paint the , including the ToolTip text, the , and the object on which the drawing should be done. To customize the look of the ToolTip, use the to determine the bounds of the ToolTip, and the object to perform your customized drawing. You can increase the bounds of the before it is shown by handling the event. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates how to custom draw the . The example creates a and associates it to three controls located on the . The example sets the property to `true` and handles the event. In the event handler, the is custom drawn differently, depending on what button the is being displayed for as indicated by the property. - + event, you can customize the appearance of the . + + The event is raised by the class when the is drawn and the property value is `true` and the property is `false`. The class contains all the information needed to paint the , including the ToolTip text, the , and the object on which the drawing should be done. To customize the look of the ToolTip, use the to determine the bounds of the ToolTip, and the object to perform your customized drawing. You can increase the bounds of the before it is shown by handling the event. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates how to custom draw the . The example creates a and associates it to three controls located on the . The example sets the property to `true` and handles the event. In the event handler, the is custom drawn differently, depending on what button the is being displayed for as indicated by the property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ToolTip.OwnerDraw/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DrawToolTipEventArgs/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolTip.OwnerDraw/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolTip.OwnerDraw/VB/form1.vb" id="Snippet1"::: + ]]> @@ -614,11 +614,11 @@ Releases the unmanaged resources and performs other cleanup operations before the is reclaimed by the garbage collector. - . Application code should not call this method; an object's method is automatically invoked during garbage collection, unless finalization by the garbage collector has been disabled by a call to the method. For more information, see [Finalize Methods and Destructors](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/0s71x931(v%3dvs.100)), [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged), and [Overriding the Finalize Method](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/ddae83kx(v=vs.100)). - + . Application code should not call this method; an object's method is automatically invoked during garbage collection, unless finalization by the garbage collector has been disabled by a call to the method. For more information, see [Finalize Methods and Destructors](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/0s71x931(v%3dvs.100)), [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged), and [Overriding the Finalize Method](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/ddae83kx(v=vs.100)). + ]]> @@ -662,11 +662,11 @@ Gets or sets the foreground color for the ToolTip. The foreground . - and properties to modify the color scheme used by ToolTips. The system default font is automatically used and can only be overridden by owner-drawing the ToolTip. For more information, see the property. - + and properties to modify the color scheme used by ToolTips. The system default font is automatically used and can only be overridden by owner-drawing the ToolTip. For more information, see the property. + ]]> @@ -729,11 +729,11 @@ Retrieves the ToolTip text associated with the specified control. A containing the ToolTip text for the specified control. - method, you can retrieve the ToolTip text for any control. If the ToolTip text changes dynamically in an application, you can use this method to find out what text is displayed at any point, depending on the state of the application. To change the text that a control is displaying, use the method. - + method, you can retrieve the ToolTip text for any control. If the ToolTip text changes dynamically in an application, you can use this method to find out what text is displayed at any point, depending on the state of the application. To change the text that a control is displaying, use the method. + ]]> @@ -772,13 +772,13 @@ The of the associated window or control that the ToolTip is associated with. Hides the specified ToolTip window. - method hides the ToolTip for the specified if it is currently being displayed. It does not disable or otherwise prevent the same ToolTip from being displayed in the future. To instead disable all ToolTip windows associated with the current component, set the property to `false`. - - Applications running in partial trust must assert the permission to use this method, as can hide the tip independent of user action. - + method hides the ToolTip for the specified if it is currently being displayed. It does not disable or otherwise prevent the same ToolTip from being displayed in the future. To instead disable all ToolTip windows associated with the current component, set the property to `false`. + + Applications running in partial trust must assert the permission to use this method, as can hide the tip independent of user action. + ]]> @@ -833,24 +833,24 @@ Gets or sets the time that passes before the ToolTip appears. The period of time, in milliseconds, that the pointer must remain stationary on a control before the ToolTip window is displayed. - property, you can shorten or lengthen the time that the waits before displaying a ToolTip window. If the value of the property is set to a value that is too long in duration, the user of your application might not know that your application provides ToolTip Help. You can use this property to ensure that the user has ToolTips displayed quickly by shortening the time specified. - - The value for this property cannot exceed 32767. - - If you want to have a consistent delay pattern for your ToolTip windows, you can set the property. The property sets the , , and properties to initial values based on a single time value. Every time the property is set, the property is set to the same value as the property. Once the property is set, you can independently set the property, overriding the default value. - - - -## Examples - The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1,` and that the method is called from the constructor of the . - + property, you can shorten or lengthen the time that the waits before displaying a ToolTip window. If the value of the property is set to a value that is too long in duration, the user of your application might not know that your application provides ToolTip Help. You can use this property to ensure that the user has ToolTips displayed quickly by shortening the time specified. + + The value for this property cannot exceed 32767. + + If you want to have a consistent delay pattern for your ToolTip windows, you can set the property. The property sets the , , and properties to initial values based on a single time value. Every time the property is set, the property is set to the same value as the property. Once the property is set, you can independently set the property, overriding the default value. + + + +## Examples + The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1,` and that the method is called from the constructor of the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ToolTip Example/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolTip/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: + ]]> @@ -897,11 +897,11 @@ if a balloon window should be used; otherwise, if a standard rectangular window should be used. The default is . - property to `true`, the ToolTip will be displayed using a balloon window. - + property to `true`, the ToolTip will be displayed using a balloon window. + ]]> @@ -955,22 +955,22 @@ if the is drawn by code that you provide; if the is drawn by the operating system. The default is . - is drawn by the operating system, but to customize the appearance of the you can set the property to `true` and handle the event. - - The property takes precedence over the property. If both are set to `true`, the will be displayed using a balloon window rather than an owner drawn window. - - - -## Examples - The following code example demonstrates how to owner draw the . The example creates a and associates it to three controls located on the . The example sets the property to `true` and handles the event. In the event handler, the is custom drawn differently depending upon what button the is being displayed for as indicated by the property. - + is drawn by the operating system, but to customize the appearance of the you can set the property to `true` and handle the event. + + The property takes precedence over the property. If both are set to `true`, the will be displayed using a balloon window rather than an owner drawn window. + + + +## Examples + The following code example demonstrates how to owner draw the . The example creates a and associates it to three controls located on the . The example sets the property to `true` and handles the event. In the event handler, the is custom drawn differently depending upon what button the is being displayed for as indicated by the property. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ToolTip.OwnerDraw/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/DrawToolTipEventArgs/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolTip.OwnerDraw/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ToolTip.OwnerDraw/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1013,23 +1013,23 @@ Occurs before a ToolTip is initially displayed. This is the default event for the class. - event is raised whenever a ToolTip is displayed, either through an explicit call to one of the methods or when the class implicitly displays a ToolTip. This event can be canceled. - - Calling properties in this event that cause the underlying window handle to be recreated, such as , will result in an exception being thrown. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `ToolTip1`. Then ensure that the event handler is associated with the event. - + event is raised whenever a ToolTip is displayed, either through an explicit call to one of the methods or when the class implicitly displays a ToolTip. This event can be canceled. + + Calling properties in this event that cause the underlying window handle to be recreated, such as , will result in an exception being thrown. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `ToolTip1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet619"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet619"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet619"::: + ]]> @@ -1067,11 +1067,11 @@ Removes all ToolTip text currently associated with the ToolTip component. - component for all associated controls. To disable the display of text instead, use the property. To change the text for a single associated control, use the method. - + component for all associated controls. To disable the display of text instead, use the property. To change the text for a single associated control, use the method. + ]]> @@ -1120,22 +1120,22 @@ Gets or sets the length of time that must transpire before subsequent ToolTip windows appear as the pointer moves from one control to another. The length of time, in milliseconds, that it takes subsequent ToolTip windows to appear. - property, you can shorten or lengthen the time that the waits before displaying a ToolTip window after a previous ToolTip window is displayed. The first time a ToolTip window is displayed, the value of the property is used to determine the delay to apply before initially showing the ToolTip window. When a ToolTip window is currently being displayed and the user moves the pointer to another control that displays a ToolTip window, the value of the property is used before showing the ToolTip for the new control. The ToolTip window from the previous control must still be displayed in order for the delay specified in the property to be used; otherwise the property value is used. - - If you want to have a consistent delay pattern for ToolTip windows, you can set the property. The property sets the , , and properties to initial values based on a single time value. Every time the property is set, the property is set to 1/5 of the property value. Once the property is set, you can independently set the property, overriding the default value. - - - -## Examples - The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1,` and that the method is called from the constructor of the . - + property, you can shorten or lengthen the time that the waits before displaying a ToolTip window after a previous ToolTip window is displayed. The first time a ToolTip window is displayed, the value of the property is used to determine the delay to apply before initially showing the ToolTip window. When a ToolTip window is currently being displayed and the user moves the pointer to another control that displays a ToolTip window, the value of the property is used before showing the ToolTip for the new control. The ToolTip window from the previous control must still be displayed in order for the delay specified in the property to be used; otherwise the property value is used. + + If you want to have a consistent delay pattern for ToolTip windows, you can set the property. The property sets the , , and properties to initial values based on a single time value. Every time the property is set, the property is set to 1/5 of the property value. Once the property is set, you can independently set the property, overriding the default value. + + + +## Examples + The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1,` and that the method is called from the constructor of the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ToolTip Example/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolTip/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1185,22 +1185,22 @@ The ToolTip text to display when the pointer is on the control. Associates ToolTip text with the specified control. - method more than once for a given control does not specify multiple ToolTip text to display for a control, but instead changes the current ToolTip text for the control. To determine the ToolTip text that is associated with a control at run time, use the method. - - As a general rule the text used should be short; however, you can insert line breaks by using the `\r\n` escape character sequence. Ampersands (&) in the text are handled as described by the property. - - - -## Examples - The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . This example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1`, and that the method is called from the constructor of the . - + method more than once for a given control does not specify multiple ToolTip text to display for a control, but instead changes the current ToolTip text for the control. To determine the ToolTip text that is associated with a control at run time, use the method. + + As a general rule the text used should be short; however, you can insert line breaks by using the `\r\n` escape character sequence. Ampersands (&) in the text are handled as described by the property. + + + +## Examples + The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . This example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1`, and that the method is called from the constructor of the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ToolTip Example/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolTip/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1258,13 +1258,13 @@ The to display the ToolTip for. Sets the ToolTip text associated with the specified control, and displays the ToolTip modally. - method displays the ToolTip for the specified control modally; that is, the ToolTip will be displayed until the method is called, or until the parent form is minimized, hidden, or closed. The ToolTip is positioned in the center of the associated control. - - Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. - + method displays the ToolTip for the specified control modally; that is, the ToolTip will be displayed until the method is called, or until the parent form is minimized, hidden, or closed. The ToolTip is positioned in the center of the associated control. + + Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. + ]]> The parameter is . @@ -1320,13 +1320,13 @@ A containing the offset, in pixels, relative to the upper-left corner of the associated control window, to display the ToolTip. Sets the ToolTip text associated with the specified control, and then displays the ToolTip modally at the specified relative position. - method displays the ToolTip for the specified control modally; that is, the ToolTip will be displayed until the method is called, or until the parent form is minimized, hidden, or dismissed. - - Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. - + method displays the ToolTip for the specified control modally; that is, the ToolTip will be displayed until the method is called, or until the parent form is minimized, hidden, or dismissed. + + Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. + ]]> The parameter is . @@ -1382,13 +1382,13 @@ An containing the duration, in milliseconds, to display the ToolTip. Sets the ToolTip text associated with the specified control, and then displays the ToolTip for the specified duration. - overloaded version of this method instead. - - Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. - + overloaded version of this method instead. + + Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. + ]]> The parameter is . @@ -1448,13 +1448,13 @@ An containing the duration, in milliseconds, to display the ToolTip. Sets the ToolTip text associated with the specified control, and then displays the ToolTip for the specified duration at the specified relative position. - overloaded version of this method instead. - - Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. - + overloaded version of this method instead. + + Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. + ]]> The parameter is . @@ -1514,13 +1514,13 @@ The vertical offset, in pixels, relative to the upper-left corner of the associated control window, to display the ToolTip. Sets the ToolTip text associated with the specified control, and then displays the ToolTip modally at the specified relative position. - method operates identically to the version, except that the offset is specified as separate x- and y-coordinates instead of a . - - Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. - + method operates identically to the version, except that the offset is specified as separate x- and y-coordinates instead of a . + + Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. + ]]> @@ -1579,13 +1579,13 @@ An containing the duration, in milliseconds, to display the ToolTip. Sets the ToolTip text associated with the specified control, and then displays the ToolTip for the specified duration at the specified relative position. - method operates identically to the version, except that the offset is specified as separate x and y coordinates instead of a . To display the ToolTip modally, call the overloaded version of this method instead. - - Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. - + method operates identically to the version, except that the offset is specified as separate x and y coordinates instead of a . To display the ToolTip modally, call the overloaded version of this method instead. + + Applications running in partial trust must assert the permission to use this method, as can control the display and location of a ToolTip independent of user action. + ]]> The parameter is . @@ -1644,20 +1644,20 @@ if the ToolTip is always displayed; otherwise, . The default is . - property, you can display a ToolTip window even when the container of the is not active. You can use this feature in a modeless window application to enable ToolTip windows to be displayed regardless of which modeless window is active. This feature is also useful when you want to create a control by using the , which contains a number of controls within it that display ToolTip windows. Because the is often not the active window on a form, setting this property to `true` enables the controls within the to display ToolTip windows at any time. - - - -## Examples - The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1`, and that the method is called from the constructor of the . - + property, you can display a ToolTip window even when the container of the is not active. You can use this feature in a modeless window application to enable ToolTip windows to be displayed regardless of which modeless window is active. This feature is also useful when you want to create a control by using the , which contains a number of controls within it that display ToolTip windows. Because the is often not the active window on a form, setting this property to `true` enables the controls within the to display ToolTip windows at any time. + + + +## Examples + The following code example creates an instance of the class and associates the instance with the that the instance is created within. The code then initializes the delay properties , , and . In addition the instance of the class sets the property to `true` to enable ToolTip text to be displayed regardless of whether the form is active. Finally, the example associates ToolTip text with two controls on a form, a and a . The code example requires that the method defined in the example is located within a that contains a control named `button1` and a control named `checkBox1`, and that the method is called from the constructor of the . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/ToolTip Example/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolTip/Overview/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/ToolTip Example/VB/form1.vb" id="Snippet1"::: + ]]> @@ -1691,11 +1691,11 @@ Stops the timer that hides displayed ToolTips. - class has an internal timer that it uses to set the display duration for ToolTips. Set the duration of the timer through the property. The method stops this internal timer, causing any displayed ToolTip to be shown modally until the method is called or the parent form is minimized, hidden, or closed. - + class has an internal timer that it uses to set the display duration for ToolTips. Set the duration of the timer through the property. The method stops this internal timer, causing any displayed ToolTip to be shown modally until the method is called or the parent form is minimized, hidden, or closed. + ]]> @@ -1745,11 +1745,11 @@ if ampersand characters are stripped from the ToolTip text; otherwise, . The default is false. - property to `true` removes all ampersands from the ToolTip text. - + property to `true` removes all ampersands from the ToolTip text. + ]]> @@ -1817,11 +1817,11 @@ Gets or sets the object that contains programmer-supplied data associated with the . An that contains data about the . The default is . - property to store data that is closely associated with the . For example, if you are displaying a for a control that displays customer information, you might store the that contains the customer's information in the property so the data can be accessed quickly. - + property to store data that is closely associated with the . For example, if you are displaying a for a control that displays customer information, you might store the that contains the customer's information in the property so the data can be accessed quickly. + ]]> @@ -1867,11 +1867,11 @@ Gets or sets a value that defines the type of icon to be displayed alongside the ToolTip text. One of the enumerated values. - enumeration, you must owner-draw the entire ToolTip. For more information, see the property. - + enumeration, you must owner-draw the entire ToolTip. For more information, see the property. + ]]> @@ -1923,13 +1923,13 @@ Gets or sets a title for the ToolTip window. A containing the window title. - @@ -1967,11 +1967,11 @@ Returns a string representation for this control. A containing a description of the . - method displays the class name, followed by the values of the and properties. - + method displays the class name, followed by the values of the and properties. + ]]> diff --git a/xml/System.Windows.Forms/TrackBarRenderer.xml b/xml/System.Windows.Forms/TrackBarRenderer.xml index ce20cf90dbd..9c333e9714f 100644 --- a/xml/System.Windows.Forms/TrackBarRenderer.xml +++ b/xml/System.Windows.Forms/TrackBarRenderer.xml @@ -33,24 +33,24 @@ Provides methods used to render a track bar control with visual styles. This class cannot be inherited. - class provides a set of `static` methods that can be used to render each part of a track bar control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. - - If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, the methods in this class will draw the track bar with the current visual style. Otherwise, the methods in this class will throw an . To determine whether the members of this class can be used, you can check the value of the property. - - This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - - - -## Examples - The following code example demonstrates how to create a custom control that uses the methods to draw a horizontal track bar that responds to mouse clicks. - + class provides a set of `static` methods that can be used to render each part of a track bar control with the current visual style of the operating system. Rendering a control refers to drawing the user interface of a control. This is useful if you are drawing a custom control that should have the appearance of the current visual style. + + If visual styles are enabled in the operating system and visual styles are applied to the client area of application windows, the methods in this class will draw the track bar with the current visual style. Otherwise, the methods in this class will throw an . To determine whether the members of this class can be used, you can check the value of the property. + + This class wraps the functionality of a that is set to one of the elements exposed by the class. For more information, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + + + +## Examples + The following code example demonstrates how to create a custom control that uses the methods to draw a horizontal track bar that responds to mouse clicks. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/cpp/form1.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TrackBarRenderer/Overview/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/VB/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/VB/form1.vb" id="Snippet0"::: + ]]> @@ -90,21 +90,21 @@ One of the values that specifies the visual state of the track bar slider. Draws a downward-pointing track bar slider (also known as the thumb) with visual styles. - property is `true`. - + property is `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -141,21 +141,21 @@ One of the values that specifies the visual state of the track bar slider. Draws a horizontal track bar slider (also known as the thumb) with visual styles. - property is `true`. - + property is `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -194,23 +194,23 @@ One of the values. Draws the specified number of horizontal track bar ticks with visual styles. - property is `true`. - - If width or height of the bounding rectangle or the number of ticks is less than or equal to zero, or `g` is `null`, returns without rendering. - + property is `true`. + + If width or height of the bounding rectangle or the number of ticks is less than or equal to zero, or `g` is `null`, returns without rendering. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -245,30 +245,30 @@ The that specifies the bounds of the track. Draws the track for a horizontal track bar with visual styles. - property is `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw a track bar. This code example is part of a larger example provided for the class. - + property is `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw a track bar. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TrackBarRenderer/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/VB/form1.vb" id="Snippet4"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -305,21 +305,21 @@ One of the values that specifies the visual state of the track bar slider. Draws a left-pointing track bar slider (also known as the thumb) with visual styles. - property is `true`. - + property is `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -356,21 +356,21 @@ One of the values that specifies the visual state of the track bar slider. Draws a right-pointing track bar slider (also known as the thumb) with visual styles. - property is `true`. - + property is `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -407,30 +407,30 @@ One of the values that specifies the visual state of the track bar slider. Draws an upward-pointing track bar slider (also known as the thumb) with visual styles. - property is `true`. - - - -## Examples - The following code example uses the method in a custom control's method to draw an upward-pointing track bar slider. This code example is part of a larger example provided for the class. - + property is `true`. + + + +## Examples + The following code example uses the method in a custom control's method to draw an upward-pointing track bar slider. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TrackBarRenderer/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/VB/form1.vb" id="Snippet4"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -467,21 +467,21 @@ One of the values that specifies the visual state of the track bar slider. Draws a vertical track bar slider (also known as the thumb) with visual styles. - property is `true`. - + property is `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -520,23 +520,23 @@ One of the values. Draws the specified number of vertical track bar ticks with visual styles. - returns without rendering. - - Before calling this method, you should verify that the value of the property is `true`. - + returns without rendering. + + Before calling this method, you should verify that the value of the property is `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -571,21 +571,21 @@ The that specifies the bounds of the track. Draws the track for a vertical track bar with visual styles. - property is `true`. - + property is `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -621,23 +621,23 @@ Returns the size, in pixels, of the track bar slider (also known as the thumb) that points down. A that specifies the size, in pixels, of the slider. - property is `true`. - + property is `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -673,23 +673,23 @@ Returns the size, in pixels, of the track bar slider (also known as the thumb) that points to the left. A that specifies the size, in pixels, of the slider. - property is `true`. - + property is `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -725,23 +725,23 @@ Returns the size, in pixels, of the track bar slider (also known as the thumb) that points to the right. A that specifies the size, in pixels, of the slider. - property is `true`. - + property is `true`. + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -777,32 +777,32 @@ Returns the size, in pixels, of the track bar slider (also known as the thumb) that points up. A that specifies the size, in pixels, of the slider. - property is `true`. - - - -## Examples - The following code example uses the method to determine the size of the rectangle used by the method to draw the slider. This code example is part of a larger example provided for the class. - + property is `true`. + + + +## Examples + The following code example uses the method to determine the size of the rectangle used by the method to draw the slider. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/cpp/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TrackBarRenderer/Overview/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/VB/form1.vb" id="Snippet2"::: + ]]> - The operating system does not support visual styles. - - -or- - - Visual styles are disabled by the user in the operating system. - - -or- - + The operating system does not support visual styles. + + -or- + + Visual styles are disabled by the user in the operating system. + + -or- + Visual styles are not applied to the client area of application windows. @@ -833,20 +833,20 @@ if the user has enabled visual styles in the operating system and visual styles are applied to the client area of application windows; otherwise, . - . - - - -## Examples - The following code example uses the property to determine whether to use the methods. This code example is part of a larger example provided for the class. - + . + + + +## Examples + The following code example uses the property to determine whether to use the methods. This code example is part of a larger example provided for the class. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/cpp/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TrackBarRenderer/Overview/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TrackBarRenderer/VB/form1.vb" id="Snippet4"::: + ]]> diff --git a/xml/System.Windows.Forms/TreeNode.xml b/xml/System.Windows.Forms/TreeNode.xml index f79134c6b9b..63c9183e174 100644 --- a/xml/System.Windows.Forms/TreeNode.xml +++ b/xml/System.Windows.Forms/TreeNode.xml @@ -53,35 +53,35 @@ Represents a node of a . - collection holds all the child objects assigned to the current . You can add, remove, or clone a ; when you do this, all child tree nodes are added, removed, or cloned. Each can contain a collection of other objects. This can make it difficult to determine where you are in the when iterating through the collection. To determine your location in a tree structure, use the property. The string can be parsed using the string value to determine where a label begins and ends. - - The label is set by setting the property explicitly. The alternative is to create the tree node using one of the constructors that has a string parameter that represents the property. The label is displayed next to the image, if one is displayed. - - To display images next to the tree nodes, assign an to the property of the parent control and assign an by referencing its index value in the property. Set the property to the index value of the you want to display when the is in an unselected state. Likewise, set the property to the index value of the you want to display when the is selected. - - Selecting specific tree nodes and iterating through the collection can be achieved by using the following property values: , , , , , . Assign the returned by one of aforementioned properties to the property to select that tree node in the control. - - Tree nodes can be expanded to display the next level of child tree nodes. The user can expand the by pressing the plus (+) button next to the , if one is displayed, or you can expand the by calling the method. To expand all child tree node levels in the collection, call the method. You can collapse the child level by calling the method, or the user can press the minus (-) button next to the , if one is displayed. You can also call the method to alternate the between the expanded and collapsed states. - - Tree nodes can optionally display a check box. To display the check boxes, set the property of the to `true`. The property is set to `true` for tree nodes that are in a checked state. - - - -## Examples - The following code example displays customer information in a control. The root tree nodes display customer names, and the child tree nodes display the order numbers assigned to each customer. In this example, 1,000 customers are displayed with 15 orders each. The repainting of the is suppressed by using the and methods, and a wait is displayed while the creates and paints the objects. This example requires that you have a `Customer` object that can hold a collection of `Order` objects. It also requires that you have created an instance of a control on a . - + collection holds all the child objects assigned to the current . You can add, remove, or clone a ; when you do this, all child tree nodes are added, removed, or cloned. Each can contain a collection of other objects. This can make it difficult to determine where you are in the when iterating through the collection. To determine your location in a tree structure, use the property. The string can be parsed using the string value to determine where a label begins and ends. + + The label is set by setting the property explicitly. The alternative is to create the tree node using one of the constructors that has a string parameter that represents the property. The label is displayed next to the image, if one is displayed. + + To display images next to the tree nodes, assign an to the property of the parent control and assign an by referencing its index value in the property. Set the property to the index value of the you want to display when the is in an unselected state. Likewise, set the property to the index value of the you want to display when the is selected. + + Selecting specific tree nodes and iterating through the collection can be achieved by using the following property values: , , , , , . Assign the returned by one of aforementioned properties to the property to select that tree node in the control. + + Tree nodes can be expanded to display the next level of child tree nodes. The user can expand the by pressing the plus (+) button next to the , if one is displayed, or you can expand the by calling the method. To expand all child tree node levels in the collection, call the method. You can collapse the child level by calling the method, or the user can press the minus (-) button next to the , if one is displayed. You can also call the method to alternate the between the expanded and collapsed states. + + Tree nodes can optionally display a check box. To display the check boxes, set the property of the to `true`. The property is set to `true` for tree nodes that are in a checked state. + + + +## Examples + The following code example displays customer information in a control. The root tree nodes display customer names, and the child tree nodes display the order numbers assigned to each customer. In this example, 1,000 customers are displayed with 15 orders each. The repainting of the is suppressed by using the and methods, and a wait is displayed while the creates and paints the objects. This example requires that you have a `Customer` object that can hold a collection of `Order` objects. It also requires that you have created an instance of a control on a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeView/CPP/treeview.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Cursor/Overview/treeview.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeView/VB/treeview.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeView/VB/treeview.vb" id="Snippet1"::: + ]]> - How to: Add and Remove Nodes with the Windows Forms TreeView Control + How to: Add and Remove Nodes with the Windows Forms TreeView Control @@ -116,15 +116,15 @@ Initializes a new instance of the class. - is added to the root tree node as well as a child tree node for each `Order` object assigned to the `Customer` object. The `Customer` object is assigned to the property, and the tree nodes representing `Customer` objects are displayed with text. This example requires that you have a `Customer` and `Order` object defined, a control on a , and an named `customerArray` that contains `Customer` objects. - + is added to the root tree node as well as a child tree node for each `Order` object assigned to the `Customer` object. The `Customer` object is assigned to the property, and the tree nodes representing `Customer` objects are displayed with text. This example requires that you have a `Customer` and `Order` object defined, a control on a , and an named `customerArray` that contains `Customer` objects. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Bounds/CPP/treenode_bounds.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_bounds.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet1"::: + ]]> @@ -165,20 +165,20 @@ The label of the new tree node. Initializes a new instance of the class with the specified label text. - property and becomes the tree node label. - - - -## Examples - The following code example displays customer information in a control. The root tree nodes display customer names, and the child tree nodes display the order numbers assigned to each customer. In this example, 1,000 customers are displayed with 15 orders each. The repainting of the is suppressed by using the and methods, and a wait is displayed while the creates and paints the objects. This example requires that you have a `Customer` object that can hold a collection of `Order` objects. It also requires that you have created an instance of a control on a . - + property and becomes the tree node label. + + + +## Examples + The following code example displays customer information in a control. The root tree nodes display customer names, and the child tree nodes display the order numbers assigned to each customer. In this example, 1,000 customers are displayed with 15 orders each. The repainting of the is suppressed by using the and methods, and a wait is displayed while the creates and paints the objects. This example requires that you have a `Customer` object that can hold a collection of `Order` objects. It also requires that you have created an instance of a control on a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeView/CPP/treeview.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/Cursor/Overview/treeview.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeView/VB/treeview.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeView/VB/treeview.vb" id="Snippet1"::: + ]]> @@ -252,20 +252,20 @@ An array of child objects. Initializes a new instance of the class with the specified label text and child tree nodes. - property and becomes the tree node label. The tree nodes that are contained in the `children` array are added to the that is stored in the property. - - - -## Examples - The following code example creates a root tree node to assign child tree nodes to. A child tree node for each `Customer` object in an is added to the root tree node as well as a child tree node for each `Order` object assigned to the `Customer` object. The `Customer` object is assigned to the property, and the tree nodes representing `Customer` objects are displayed with text. This example requires that you have a `Customer` and `Order` object defined, a control on a , and an named `customerArray` that contains `Customer` objects. - + property and becomes the tree node label. The tree nodes that are contained in the `children` array are added to the that is stored in the property. + + + +## Examples + The following code example creates a root tree node to assign child tree nodes to. A child tree node for each `Customer` object in an is added to the root tree node as well as a child tree node for each `Order` object assigned to the `Customer` object. The `Customer` object is assigned to the property, and the tree nodes representing `Customer` objects are displayed with text. This example requires that you have a `Customer` and `Order` object defined, a control on a , and an named `customerArray` that contains `Customer` objects. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Bounds/CPP/treenode_bounds.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_bounds.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet1"::: + ]]> @@ -304,20 +304,20 @@ The index value of to display when the tree node is selected. Initializes a new instance of the class with the specified label text and images to display when the tree node is in a selected and unselected state. - property and becomes the tree node label. The `imageIndex` and `selectedImageIndex` values are the index values of an stored in the assigned to the property. The image referenced in the `imageIndex` property is displayed when the tree node is not selected. Likewise, the image referenced in the `selectedImageIndex` property is displayed when the tree node is in a selected state. - - - -## Examples - The following code example creates and assigns an to a control and fills the control with objects. The tree nodes are assigned images from the that is displayed when the tree node is in a selected or unselected state. This example requires that you have a that contains a , and an that contains `Customer` objects that each contain `Order` objects. It also requires that the `Customer` and `Order` objects are defined. - + property and becomes the tree node label. The `imageIndex` and `selectedImageIndex` values are the index values of an stored in the assigned to the property. The image referenced in the `imageIndex` property is displayed when the tree node is not selected. Likewise, the image referenced in the `selectedImageIndex` property is displayed when the tree node is in a selected state. + + + +## Examples + The following code example creates and assigns an to a control and fills the control with objects. The tree nodes are assigned images from the that is displayed when the tree node is in a selected or unselected state. This example requires that you have a that contains a , and an that contains `Customer` objects that each contain `Order` objects. It also requires that the `Customer` and `Order` objects are defined. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_TreeNode/CPP/treenode_treenode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_treenode.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_TreeNode/VB/treenode_treenode.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_TreeNode/VB/treenode_treenode.vb" id="Snippet1"::: + ]]> @@ -365,20 +365,20 @@ An array of child objects. Initializes a new instance of the class with the specified label text, child tree nodes, and images to display when the tree node is in a selected and unselected state. - property and becomes the tree node label. The `imageIndex` and `selectedImageIndex` values are the index values of an stored in the assigned to the property. The image referenced in the `imageIndex` parameter is displayed when the tree node is not selected. Likewise, the image referenced in the `selectedImageIndex` parameter is displayed when the tree node is in a selected state. The tree nodes that are contained in the `children` array are added to the that is stored in the property. - - - -## Examples - The following code example creates and assigns an to a control and fills the control with objects. The tree nodes are assigned images from the that is displayed when the tree node is in a selected or unselected state. This example requires that you have a that contains a , and an that contains `Customer` objects that each contain `Order` objects. It also requires that the `Customer` and `Order` objects are defined. - + property and becomes the tree node label. The `imageIndex` and `selectedImageIndex` values are the index values of an stored in the assigned to the property. The image referenced in the `imageIndex` parameter is displayed when the tree node is not selected. Likewise, the image referenced in the `selectedImageIndex` parameter is displayed when the tree node is in a selected state. The tree nodes that are contained in the `children` array are added to the that is stored in the property. + + + +## Examples + The following code example creates and assigns an to a control and fills the control with objects. The tree nodes are assigned images from the that is displayed when the tree node is in a selected or unselected state. This example requires that you have a that contains a , and an that contains `Customer` objects that each contain `Order` objects. It also requires that the `Customer` and `Order` objects are defined. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_TreeNode/CPP/treenode_treenode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_treenode.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_TreeNode/VB/treenode_treenode.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_TreeNode/VB/treenode_treenode.vb" id="Snippet1"::: + ]]> @@ -412,20 +412,20 @@ Gets or sets the background color of the tree node. The background of the tree node. The default is . - property is set to , the used is the property value of the control that the tree node is assigned to. - - - -## Examples - The following code example highlights any objects a control that has its property set to `true` by setting its property to . This code requires that you have a control on a with a collection of objects. - + property is set to , the used is the property value of the control that the tree node is assigned to. + + + +## Examples + The following code example highlights any objects a control that has its property set to `true` by setting its property to . This code requires that you have a control on a with a collection of objects. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Checked/CPP/treenode_checked.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/BackColor/treenode_checked.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Checked/VB/treenode_checked.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Checked/VB/treenode_checked.vb" id="Snippet1"::: + ]]> @@ -458,23 +458,23 @@ Initiates the editing of the tree node label. - event of a or . - + event of a or . + > [!NOTE] -> This method only works if the property of the is set to `true`. If is set to `false`, an exception is thrown and the tree node will not be put into an editable state. - - - -## Examples - The following code example lets the user edit nonroot tree nodes by using a . When the user right-clicks the mouse, the at that position is determined and stored in a variable named `mySelectedNode`. If a nonroot tree node was selected, it is put into an editable state, allowing the user to edit the node label. After the user stops editing the tree node label, the new label text is evaluated and saved. For this example, several characters are considered not valid in the label text. If one of the invalid characters is in the label string, or the string is empty, the user is notified of the error and the label is returned to its previous text. - +> This method only works if the property of the is set to `true`. If is set to `false`, an exception is thrown and the tree node will not be put into an editable state. + + + +## Examples + The following code example lets the user edit nonroot tree nodes by using a . When the user right-clicks the mouse, the at that position is determined and stored in a variable named `mySelectedNode`. If a nonroot tree node was selected, it is put into an editable state, allowing the user to edit the node label. After the user stops editing the tree node label, the new label text is evaluated and saved. For this example, several characters are considered not valid in the label text. If one of the invalid characters is in the label string, or the string is empty, the user is notified of the error and the label is returned to its previous text. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TreeNode.BeginEdit Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/NodeLabelEditEventArgs/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TreeNode.BeginEdit Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TreeNode.BeginEdit Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -516,20 +516,20 @@ Gets the bounds of the tree node. The that represents the bounds of the tree node. - control. - - - -## Examples - The following code example changes the size to the specified size and adjusts the of the tree node's parent control. This example requires that you have a that contains a control with a collection of objects, and a that contains font sizes. - + control. + + + +## Examples + The following code example changes the size to the specified size and adjusts the of the tree node's parent control. This example requires that you have a that contains a control with a collection of objects, and a that contains font sizes. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Bounds/CPP/treenode_bounds.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_bounds.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet2"::: + ]]> @@ -572,15 +572,15 @@ if the tree node is in a checked state; otherwise, . - objects a control that has its property set to `true` by setting its property to . This code requires that you have a control on a with a collection of objects. - + objects a control that has its property set to `true` by setting its property to . This code requires that you have a control on a with a collection of objects. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Checked/CPP/treenode_checked.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/BackColor/treenode_checked.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Checked/VB/treenode_checked.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Checked/VB/treenode_checked.vb" id="Snippet1"::: + ]]> @@ -617,22 +617,22 @@ Copies the tree node and the entire subtree rooted at this tree node. The that represents the cloned . - being cloned are included in the new tree node and subtree. - - The method performs a shallow copy of the node. If the value of the property is a reference type, both the original and cloned copy will point to the same single instance of the value. - - - -## Examples - The following code example clones the last child tree node of the last root tree node and inserts the clone as the first root tree node in the `TreeNodeCollection`. This example requires that you have a control on a that contains a collection of objects and a . - + being cloned are included in the new tree node and subtree. + + The method performs a shallow copy of the node. If the value of the property is a reference type, both the original and cloned copy will point to the same single instance of the value. + + + +## Examples + The following code example clones the last child tree node of the last root tree node and inserts the clone as the first root tree node in the `TreeNodeCollection`. This example requires that you have a control on a that contains a collection of objects and a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/CPP/treenode_ensurevisible_4.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/Clone/treenode_ensurevisible_4.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet3"::: + ]]> @@ -680,23 +680,23 @@ Collapses the tree node. - method collapses the current and its child nodes. If you want to collapse only the current , use the overload, passing `true` to ignore its child nodes. - + method collapses the current and its child nodes. If you want to collapse only the current , use the overload, passing `true` to ignore its child nodes. + > [!NOTE] -> The state of a is persisted. For example, if the next level of child nodes was not collapsed previously, when the method is called, the child nodes appear in their previously expanded state. - - - -## Examples - The following code example toggles the selected node when a button is clicked. If the selected node is collapsed, it is expanded, if it is expanded by calling the method, it is collapsed by calling the method. This example requires that you have a with a control that has at least one with at least one child . - +> The state of a is persisted. For example, if the next level of child nodes was not collapsed previously, when the method is called, the child nodes appear in their previously expanded state. + + + +## Examples + The following code example toggles the selected node when a button is clicked. If the selected node is collapsed, it is expanded, if it is expanded by calling the method, it is collapsed by calling the method. This example requires that you have a with a control that has at least one with at least one child . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/CPP/treenode_ensurevisible_4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/Clone/treenode_ensurevisible_4.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet1"::: + ]]> @@ -741,11 +741,11 @@ to leave the child nodes in their current state; to collapse the child nodes. Collapses the and optionally collapses its children. - method, passing `true`, when you want to collapse a node but leave its child nodes in their expanded state. - + method, passing `true`, when you want to collapse a node but leave its child nodes in their expanded state. + ]]> @@ -784,11 +784,11 @@ Gets the shortcut menu that is associated with this tree node. The that is associated with the tree node. - property. - + property. + ]]> @@ -838,11 +838,11 @@ Gets or sets the shortcut menu associated with this tree node. The associated with the tree node. - @@ -911,15 +911,15 @@ if the editing of the tree node label text was canceled without being saved; otherwise, . Ends the editing of the tree node label. - . When the user right clicks the mouse, the at that position is determined and stored in a variable named `mySelectedNode`. If a nonroot tree node was selected, it is put into an editable state, allowing the user to edit the node label. After the user stops editing the tree node label, the new label text is evaluated and saved. For this example, several characters are considered not valid in the label text. If one of the invalid characters is in the label string, or the string is empty, the user is notified of the error and the label is returned to its previous text. - + . When the user right clicks the mouse, the at that position is determined and stored in a variable named `mySelectedNode`. If a nonroot tree node was selected, it is put into an editable state, allowing the user to edit the node label. After the user stops editing the tree node label, the new label text is evaluated and saved. For this example, several characters are considered not valid in the label text. If one of the invalid characters is in the label string, or the string is empty, the user is notified of the error and the label is returned to its previous text. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TreeNode.BeginEdit Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/NodeLabelEditEventArgs/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TreeNode.BeginEdit Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TreeNode.BeginEdit Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -953,23 +953,23 @@ Ensures that the tree node is visible, expanding tree nodes and scrolling the tree view control as necessary. - method is called, the tree is expanded and scrolled to ensure that the current tree node is visible in the . This method is useful if you are selecting a tree node in code based on certain criteria. By calling this method after you select the node, the user can see and interact with the selected node. - + method is called, the tree is expanded and scrolled to ensure that the current tree node is visible in the . This method is useful if you are selecting a tree node in code based on certain criteria. By calling this method after you select the node, the user can see and interact with the selected node. + > [!NOTE] -> If the property is set to a value that is larger than the height of the tree view control, calling this method has unexpected results. - - - -## Examples - The following code example brings the last child tree node of the last root tree node into view in the tree view when a button is clicked. This example requires that you have a control on a that contains a collection of objects, and a . There should be enough tree nodes so that they are not all visible in the tree view control. - +> If the property is set to a value that is larger than the height of the tree view control, calling this method has unexpected results. + + + +## Examples + The following code example brings the last child tree node of the last root tree node into view in the tree view when a button is clicked. This example requires that you have a control on a that contains a collection of objects, and a . There should be enough tree nodes so that they are not all visible in the tree view control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/CPP/treenode_ensurevisible_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/Clone/treenode_ensurevisible_4.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet2"::: + ]]> @@ -1004,23 +1004,23 @@ Expands the tree node. - method expands the current down to the next level of nodes. - + method expands the current down to the next level of nodes. + > [!NOTE] -> The state of a is persisted. For example, if the next level of child nodes was not collapsed previously, when the method is called, the child nodes appear in their previously expanded state. - - - -## Examples - The following code example toggles the selected node when a button is clicked. If the selected node is collapsed, it is expanded, if it is expanded by calling the method, it is collapsed by calling the method. This example requires that you have a with a control that has at least one with at least one child . - +> The state of a is persisted. For example, if the next level of child nodes was not collapsed previously, when the method is called, the child nodes appear in their previously expanded state. + + + +## Examples + The following code example toggles the selected node when a button is clicked. If the selected node is collapsed, it is expanded, if it is expanded by calling the method, it is collapsed by calling the method. This example requires that you have a with a control that has at least one with at least one child . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/CPP/treenode_ensurevisible_4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/Clone/treenode_ensurevisible_4.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet1"::: + ]]> @@ -1056,23 +1056,23 @@ Expands all the child tree nodes. - method expands all the child tree nodes assigned to the collection. - + method expands all the child tree nodes assigned to the collection. + > [!NOTE] -> The state of a is persisted. For example, if the next level of child nodes was not collapsed previously, when the method is called, the child nodes appear in their previously expanded state. - - - -## Examples - The following code example expands all the tree nodes in a control when a is checked, and collapses the when the is cleared. This example requires that you have a with a , and a control with a that has several objects (preferably with three or more levels). - +> The state of a is persisted. For example, if the next level of child nodes was not collapsed previously, when the method is called, the child nodes appear in their previously expanded state. + + + +## Examples + The following code example expands all the tree nodes in a control when a is checked, and collapses the when the is cleared. This example requires that you have a with a , and a control with a that has several objects (preferably with three or more levels). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_ForeColor/CPP/treenode_forecolor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/ExpandAll/treenode_forecolor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_ForeColor/VB/treenode_forecolor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_ForeColor/VB/treenode_forecolor.vb" id="Snippet1"::: + ]]> @@ -1119,20 +1119,20 @@ Gets the first child tree node in the tree node collection. The first child in the collection. - is the first child in the stored in the property of the current tree node. If the has no child tree node, the property returns `null`. - - - -## Examples - The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". - + is the first child in the stored in the property of the current tree node. If the has no child tree node, the property returns `null`. + + + +## Examples + The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Parent/CPP/treenode_parent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FirstNode/treenode_parent.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: + ]]> @@ -1164,20 +1164,20 @@ Gets or sets the foreground color of the tree node. The foreground of the tree node. - used is the property value of the control that the tree node is assigned to. - - - -## Examples - The following code example creates a root tree node to assign child tree nodes to. A child tree node for each `Customer` object in an is added to the root tree node as well as a child tree node for each `Order` object assigned to the `Customer` object. The `Customer` object is assigned to the property, and the tree nodes representing `Customer` objects are displayed with text. This example requires that you have a `Customer` and `Order` object defined, a control on a , and an named `customerArray` that contains `Customer` objects. - + used is the property value of the control that the tree node is assigned to. + + + +## Examples + The following code example creates a root tree node to assign child tree nodes to. A child tree node for each `Customer` object in an is added to the root tree node as well as a child tree node for each `Order` object assigned to the `Customer` object. The `Customer` object is assigned to the property, and the tree nodes representing `Customer` objects are displayed with text. This example requires that you have a `Customer` and `Order` object defined, a control on a , and an named `customerArray` that contains `Customer` objects. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Bounds/CPP/treenode_bounds.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_bounds.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet1"::: + ]]> @@ -1217,20 +1217,20 @@ Returns the tree node with the specified handle and assigned to the specified tree view control. A that represents the tree node assigned to the specified control with the specified handle. - collection, the control sends an NM_CUSTOMDRAW notification before the node handle is available. If you override the method of the to provide custom drawing in response to this notification, you should always check the return value of this method for `null` before you attempt to access the node. - - - -## Examples - The following code example gets the that was collapsed and creates a copy of it using its property. The original is removed from the , and the copy is added to the collection. This example requires that you have a with a control on it. The control should have two or more root nodes, each having at least one child node. - + collection, the control sends an NM_CUSTOMDRAW notification before the node handle is available. If you override the method of the to provide custom drawing in response to this notification, you should always check the return value of this method for `null` before you attempt to access the node. + + + +## Examples + The following code example gets the that was collapsed and creates a copy of it using its property. The original is removed from the , and the copy is added to the collection. This example requires that you have a with a control on it. The control should have two or more root nodes, each having at least one child node. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Windows.Forms.TreeNode/CPP/treenode.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FromHandle/treenode.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet3"::: + ]]> @@ -1270,20 +1270,20 @@ Gets the path from the root tree node to the current tree node. The path from the root tree node to the current tree node. - property of the control that contains this node. For example, if the delimiter character of the tree view control named "Location" is set to the backslash character, (\\), the property value is "Country\Region\State". - - - -## Examples - The following code example sets the property of a and displays the number of child tree nodes that are contained in the of the . The percentage of child tree node to total tree nodes in the tree view control is also displayed. This example requires that you have a with a , and a control with a that has several objects (preferably with three or more levels). - + property of the control that contains this node. For example, if the delimiter character of the tree view control named "Location" is set to the backslash character, (\\), the property value is "Country\Region\State". + + + +## Examples + The following code example sets the property of a and displays the number of child tree nodes that are contained in the of the . The percentage of child tree node to total tree nodes in the tree view control is also displayed. This example requires that you have a with a , and a control with a that has several objects (preferably with three or more levels). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_ForeColor/CPP/treenode_forecolor.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/ExpandAll/treenode_forecolor.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_ForeColor/VB/treenode_forecolor.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_ForeColor/VB/treenode_forecolor.vb" id="Snippet2"::: + ]]> The node is not contained in a . @@ -1322,15 +1322,15 @@ Returns the number of child tree nodes. The number of child tree nodes assigned to the collection. - property of a and displays the number of child tree nodes that are contained in the of the . The percentage of child tree node to total tree nodes in the tree view control is also displayed. This example requires that you have a with a , and a control with a that has several objects (preferably with three or more levels). - + property of a and displays the number of child tree nodes that are contained in the of the . The percentage of child tree node to total tree nodes in the tree view control is also displayed. This example requires that you have a with a , and a control with a that has several objects (preferably with three or more levels). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_ForeColor/CPP/treenode_forecolor.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/ExpandAll/treenode_forecolor.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_ForeColor/VB/treenode_forecolor.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_ForeColor/VB/treenode_forecolor.vb" id="Snippet2"::: + ]]> @@ -1370,20 +1370,20 @@ Gets the handle of the tree node. The tree node handle. - property is referenced, it is created. - - - -## Examples - The following code example gets the that was collapsed and creates a copy of it using its property. The original is removed from the , and the copy is added to the collection. This example requires that you have a with a control on it. The control should have two or more root nodes, each having at least one child node. - + property is referenced, it is created. + + + +## Examples + The following code example gets the that was collapsed and creates a copy of it using its property. The original is removed from the , and the copy is added to the collection. This example requires that you have a with a control on it. The control should have two or more root nodes, each having at least one child node. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Windows.Forms.TreeNode/CPP/treenode.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FromHandle/treenode.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet3"::: + ]]> @@ -1449,27 +1449,27 @@ Gets or sets the image list index value of the image displayed when the tree node is in the unselected state. A zero-based index value that represents the image position in the assigned . - value is the index value of an stored in the assigned to the property. - + value is the index value of an stored in the assigned to the property. + > [!NOTE] -> The default value of the property is the same as the property of the control that the is assigned to. - +> The default value of the property is the same as the property of the control that the is assigned to. + and are mutually exclusive, meaning if one is set, the other is set to an invalid value and ignored. -If you set the property, the property is automatically set to -1. Alternatively, if you set the property, the is automatically set to an empty string (""). - +If you set the property, the property is automatically set to -1. Alternatively, if you set the property, the is automatically set to an empty string (""). + **.NET 5 and later versions:** If the associated property value is changed to `null`, the property returns its default value, -1. However, the assigned value is retained internally and used when another object is assigned to the property. If the new assigned to the property has an property value that is less than or equal to the value assigned to the property minus one (to account for the collection being a zero-based index), the property value is adjusted to one less than the property value. -For example, consider a button control whose has three images and whose property is set to 2. If a new that has only two images is assigned to the button, the value changes to 1. - -## Examples - The following code example creates and assigns an to a control and fills the control with objects. The tree nodes are assigned images from the that is displayed when the tree node is in a selected or unselected state. This example requires that you have a that contains a , and an that contains `Customer` objects that each contain `Order` objects. It also requires that the `Customer` and `Order` objects are defined. - +For example, consider a button control whose has three images and whose property is set to 2. If a new that has only two images is assigned to the button, the value changes to 1. + +## Examples + The following code example creates and assigns an to a control and fills the control with objects. The tree nodes are assigned images from the that is displayed when the tree node is in a selected or unselected state. This example requires that you have a that contains a , and an that contains `Customer` objects that each contain `Order` objects. It also requires that the `Customer` and `Order` objects are defined. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_TreeNode/CPP/treenode_treenode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_treenode.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_TreeNode/VB/treenode_treenode.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_TreeNode/VB/treenode_treenode.vb" id="Snippet1"::: + ]]> .NET 5 and later: is less than -2. @@ -1538,16 +1538,16 @@ For example, consider a button control whose Gets or sets the key for the image associated with this tree node when the node is in an unselected state. The key for the image associated with this tree node when the node is in an unselected state. - property of the containing control. - - The is case-insensitive. - + property of the containing control. + + The is case-insensitive. + and are mutually exclusive, meaning if one is set, the other is set to an invalid value and ignored. -If you set the property, the property is automatically set to -1. Alternatively, if you set the property, the is automatically set to an empty string (""). - +If you set the property, the property is automatically set to -1. Alternatively, if you set the property, the is automatically set to an empty string (""). + ]]> @@ -1585,15 +1585,15 @@ If you set the property, the Gets the position of the tree node in the tree node collection. A zero-based index value that represents the position of the tree node in the collection. - and property values of the represented by the property of the . This example requires that you have a with a control on it. The should have at least two root nodes, each having at least one child node. - + and property values of the represented by the property of the . This example requires that you have a with a control on it. The should have at least two root nodes, each having at least one child node. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Windows.Forms.TreeNode/CPP/treenode.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FromHandle/treenode.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet2"::: + ]]> @@ -1632,15 +1632,15 @@ If you set the property, the if the tree node is in editable state; otherwise, . - . When the user right clicks the mouse, the at that position is determined and stored in a variable named `mySelectedNode`. If a nonroot tree node was selected, it is put into an editable state, letting the user edit the node label. After the user stops editing the tree node label, the new label text is evaluated and saved. For this example, several characters are considered not valid in the label text. If one of the invalid characters is in the label string, or the string is empty, the user is notified of the error and the label is returned to its previous text. - + . When the user right clicks the mouse, the at that position is determined and stored in a variable named `mySelectedNode`. If a nonroot tree node was selected, it is put into an editable state, letting the user edit the node label. After the user stops editing the tree node label, the new label text is evaluated and saved. For this example, several characters are considered not valid in the label text. If one of the invalid characters is in the label string, or the string is empty, the user is notified of the error and the label is returned to its previous text. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic TreeNode.BeginEdit Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/NodeLabelEditEventArgs/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TreeNode.BeginEdit Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic TreeNode.BeginEdit Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1681,15 +1681,15 @@ If you set the property, the if the tree node is in the expanded state; otherwise, . - method, it is collapsed by calling the method. This example requires that you have a with a control that has at least one with at least one child . - + method, it is collapsed by calling the method. This example requires that you have a with a control that has at least one with at least one child . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/CPP/treenode_ensurevisible_4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/Clone/treenode_ensurevisible_4.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet1"::: + ]]> @@ -1730,15 +1730,15 @@ If you set the property, the if the tree node is in the selected state; otherwise, . - after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a containing several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". - + after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a containing several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Parent/CPP/treenode_parent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FirstNode/treenode_parent.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: + ]]> @@ -1778,15 +1778,15 @@ If you set the property, the if the tree node is visible or partially visible; otherwise, . - control on a that contains a collection of objects, and a . There should be enough tree nodes so that they are not all visible in the tree view control. - + control on a that contains a collection of objects, and a . There should be enough tree nodes so that they are not all visible in the tree view control. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/CPP/treenode_ensurevisible_4.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/Clone/treenode_ensurevisible_4.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_EnsureVisible_4/VB/treenode_ensurevisible_4.vb" id="Snippet2"::: + ]]> @@ -1831,20 +1831,20 @@ If you set the property, the Gets the last child tree node. A that represents the last child tree node. - is the last child in the stored in the property of the current tree node. If the has no child tree node, the property returns `null`. - - - -## Examples - The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". - + is the last child in the stored in the property of the current tree node. If the has no child tree node, the property returns `null`. + + + +## Examples + The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Parent/CPP/treenode_parent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FirstNode/treenode_parent.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: + ]]> @@ -1884,11 +1884,11 @@ If you set the property, the Gets the zero-based depth of the tree node in the control. The zero-based depth of the tree node in the control. - property, the root node is considered the first level of nesting and returns 0. - + property, the root node is considered the first level of nesting and returns 0. + ]]> @@ -1925,11 +1925,11 @@ If you set the property, the Gets or sets the name of the tree node. A that represents the name of the tree node. - of a is also the node's key, when the node is part of a . If the node does not have a name, returns an empty string (""). - + of a is also the node's key, when the node is part of a . If the node does not have a name, returns an empty string (""). + ]]> @@ -1972,20 +1972,20 @@ If you set the property, the Gets the next sibling tree node. A that represents the next sibling tree node. - is the next sibling in the stored in the property of the tree node's parent . If there is no next tree node, the property returns `null`. - - - -## Examples - The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". - + is the next sibling in the stored in the property of the tree node's parent . If there is no next tree node, the property returns `null`. + + + +## Examples + The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Parent/CPP/treenode_parent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FirstNode/treenode_parent.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: + ]]> @@ -2031,20 +2031,20 @@ If you set the property, the Gets the next visible tree node. A that represents the next visible tree node. - can be a child, sibling, or a tree node from another branch. If there is no next tree node, the property returns `null`. - - - -## Examples - The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". - + can be a child, sibling, or a tree node from another branch. If there is no next tree node, the property returns `null`. + + + +## Examples + The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Parent/CPP/treenode_parent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FirstNode/treenode_parent.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: + ]]> @@ -2093,23 +2093,23 @@ If you set the property, the Gets or sets the font that is used to display the text on the tree node label. The that is used to display the text on the tree node label. - used is the property value of the control that this node is attached to. - + used is the property value of the control that this node is attached to. + > [!NOTE] -> If the node font is larger than the property value that is set in the control, the tree node label text is clipped. - - - -## Examples - The following code example changes the size of to the specified size and adjusts the of the tree node's parent control. This example requires that you have a with a control that contains a collection of objects, and a that contains font sizes. - +> If the node font is larger than the property value that is set in the control, the tree node label text is clipped. + + + +## Examples + The following code example changes the size of to the specified size and adjusts the of the tree node's parent control. This example requires that you have a with a control that contains a collection of objects, and a that contains font sizes. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Bounds/CPP/treenode_bounds.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_bounds.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet2"::: + ]]> @@ -2153,20 +2153,20 @@ If you set the property, the Gets the collection of objects assigned to the current tree node. A that represents the tree nodes assigned to the current tree node. - property can hold a collection of other objects. Each of the tree node in the collection has a property that can contain its own . This nesting of tree nodes can make it difficult to navigate a tree structure. The property makes it easier to determine your location in a tree. - - - -## Examples - The following code example removes the selected tree node from one and adds it to another if both tree node collections are not read-only. When a is clicked, the is deleted from one using the method and added to the other using the method. This example requires that you have two controls named `treeView1` and `treeView2`, and a on a . - + property can hold a collection of other objects. Each of the tree node in the collection has a property that can contain its own . This nesting of tree nodes can make it difficult to navigate a tree structure. The property makes it easier to determine your location in a tree. + + + +## Examples + The following code example removes the selected tree node from one and adds it to another if both tree node collections are not read-only. When a is clicked, the is deleted from one using the method and added to the other using the method. This example requires that you have two controls named `treeView1` and `treeView2`, and a on a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNodeCollection/CPP/treenodecollection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/Nodes/treenodecollection.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNodeCollection/VB/treenodecollection.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNodeCollection/VB/treenodecollection.vb" id="Snippet1"::: + ]]> @@ -2211,20 +2211,20 @@ If you set the property, the Gets the parent tree node of the current tree node. A that represents the parent of the current tree node. - property returns `null`. - - - -## Examples - The following code example displays the and property values of the represented by the property of the . This example requires that you have a with a control on it. The should have at least two root nodes, each having at least one child node. - + property returns `null`. + + + +## Examples + The following code example displays the and property values of the represented by the property of the . This example requires that you have a with a control on it. The should have at least two root nodes, each having at least one child node. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Windows.Forms.TreeNode/CPP/treenode.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FromHandle/treenode.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet2"::: + ]]> @@ -2267,20 +2267,20 @@ If you set the property, the Gets the previous sibling tree node. A that represents the previous sibling tree node. - is the previous sibling in the stored in the property of the tree node's parent . If there is no previous tree node, the property returns `null`. - - - -## Examples - The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". - + is the previous sibling in the stored in the property of the tree node's parent . If there is no previous tree node, the property returns `null`. + + + +## Examples + The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Parent/CPP/treenode_parent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FirstNode/treenode_parent.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: + ]]> @@ -2326,20 +2326,20 @@ If you set the property, the Gets the previous visible tree node. A that represents the previous visible tree node. - can be a child, sibling, or a tree node from another branch. If there is no previous tree node, the property returns `null`. - - - -## Examples - The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". - + can be a child, sibling, or a tree node from another branch. If there is no previous tree node, the property returns `null`. + + + +## Examples + The following code example selects the appropriate after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Parent/CPP/treenode_parent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FirstNode/treenode_parent.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: + ]]> @@ -2379,20 +2379,20 @@ If you set the property, the Removes the current tree node from the tree view control. - method is called, the tree node, and any child tree nodes that are assigned to the , are removed from the . The removed child nodes are removed from the but are still attached to this tree node. - - - -## Examples - The following code example removes a when the user right-clicks the mouse over it and toggles it from expanded to collapsed when the user clicks the mouse wheel over it. This example requires that you have a with a control on it. The should have two or more root tree nodes, each having at least one child node. - + method is called, the tree node, and any child tree nodes that are assigned to the , are removed from the . The removed child nodes are removed from the but are still attached to this tree node. + + + +## Examples + The following code example removes a when the user right-clicks the mouse over it and toggles it from expanded to collapsed when the user clicks the mouse wheel over it. This example requires that you have a with a control on it. The should have two or more root tree nodes, each having at least one child node. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Windows.Forms.TreeNode/CPP/treenode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FromHandle/treenode.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet1"::: + ]]> @@ -2460,27 +2460,27 @@ If you set the property, the Gets or sets the image list index value of the image that is displayed when the tree node is in the selected state. A zero-based index value that represents the image position in an . - value is the index value of an stored in the assigned to the property. - + value is the index value of an stored in the assigned to the property. + and are mutually exclusive, meaning if one is set, the other is set to an invalid value and ignored. -If you set the property, the property is automatically set to -1. Alternatively, if you set the property, the is automatically set to an empty string (""). - +If you set the property, the property is automatically set to -1. Alternatively, if you set the property, the is automatically set to an empty string (""). + **.NET 5 and later versions:** If the associated property value is changed to `null`, the property returns its default value, -1. However, the assigned value is retained internally and used when another object is assigned to the property. If the new assigned to the property has an property value that is less than or equal to the value assigned to the property minus one (to account for the collection being a zero-based index), the property value is adjusted to one less than the property value. -For example, consider a button control whose has three images and whose property is set to 2. If a new that has only two images is assigned to the button, the value changes to 1. - +For example, consider a button control whose has three images and whose property is set to 2. If a new that has only two images is assigned to the button, the value changes to 1. + > [!NOTE] > The default value of the property is the same as the property of the control that the is assigned to. - -## Examples - The following code example creates and assigns an to a control and fills the control with objects. The tree nodes are assigned images from the that is displayed when the tree node is in a selected or unselected state. This example requires that you have a containing a , and an containing `Customer` objects that each contain `Order` objects. It also requires that the `Customer` and `Order` objects are defined. - + +## Examples + The following code example creates and assigns an to a control and fills the control with objects. The tree nodes are assigned images from the that is displayed when the tree node is in a selected or unselected state. This example requires that you have a containing a , and an containing `Customer` objects that each contain `Order` objects. It also requires that the `Customer` and `Order` objects are defined. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_TreeNode/CPP/treenode_treenode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_treenode.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_TreeNode/VB/treenode_treenode.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_TreeNode/VB/treenode_treenode.vb" id="Snippet1"::: + ]]> .NET 5 and later: is less than -2. @@ -2547,13 +2547,13 @@ For example, consider a button control whose Gets or sets the key of the image displayed in the tree node when it is in a selected state. The key of the image displayed when the tree node is in a selected state. - property of the parent control. - + property of the parent control. + and are mutually exclusive, meaning if one is set, the other is set to an invalid value and ignored. -If you set the property, the property is automatically set to -1. Alternatively, if you set the property, is automatically set to an empty string (""). +If you set the property, the property is automatically set to -1. Alternatively, if you set the property, is automatically set to an empty string (""). ]]> @@ -2652,15 +2652,15 @@ If you set the property, t Gets or sets the index of the image that is used to indicate the state of the when the parent has its property set to . The index of the image that is used to indicate the state of the . - property of the parent control. - - If the parent has check boxes enabled, the is ignored and the node will display the first or second image in the set on the parent to indicate an unchecked or checked state, respectively. Toggling the property does not affect the value of the . - - The returns -1 when not set. The and properties are mutually exclusive, meaning if one is set, the other is ignored. If you set the property, the property is automatically set to -1. Alternatively, if you set , is automatically set to an empty string (""). - + property of the parent control. + + If the parent has check boxes enabled, the is ignored and the node will display the first or second image in the set on the parent to indicate an unchecked or checked state, respectively. Toggling the property does not affect the value of the . + + The returns -1 when not set. The and properties are mutually exclusive, meaning if one is set, the other is ignored. If you set the property, the property is automatically set to -1. Alternatively, if you set , is automatically set to an empty string (""). + ]]> The specified index is less than -1 or greater than 14. @@ -2727,15 +2727,15 @@ If you set the property, t Gets or sets the key of the image that is used to indicate the state of the when the parent has its property set to . The key of the image that is used to indicate the state of the . - property of the parent control. - - If the parent has check boxes enabled, the is ignored and the node will display the first or second image in the set on the parent to indicate an unchecked or checked state, respectively. Toggling the property does not affect the value of the . - - The and properties are mutually exclusive, meaning if one is set, the other is ignored. If you set the property, the property is automatically set to -1. Alternatively, if you set , is automatically set to an empty string (""). You should set the to an image with a corresponding index between 0 and 14. You can set the to an image with an index value greater than 14 (an exception will not be thrown), but the image may not be displayed - + property of the parent control. + + If the parent has check boxes enabled, the is ignored and the node will display the first or second image in the set on the parent to indicate an unchecked or checked state, respectively. Toggling the property does not affect the value of the . + + The and properties are mutually exclusive, meaning if one is set, the other is ignored. If you set the property, the property is automatically set to -1. Alternatively, if you set , is automatically set to an empty string (""). You should set the to an image with a corresponding index between 0 and 14. You can set the to an image with an index value greater than 14 (an exception will not be thrown), but the image may not be displayed + ]]> @@ -2842,23 +2842,23 @@ If you set the property, t Gets or sets the object that contains data about the tree node. An that contains data about the tree node. The default is . - derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned. - + derived type can be assigned to this property. If this property is being set through the Windows Forms designer, only text can be assigned. + > [!CAUTION] -> The method performs a shallow copy of the node. If the value of the property is a reference type, both the original and cloned copy will point to the same single instance of the value. - - - -## Examples - The following code example creates a root tree node to assign child tree nodes to. A child tree node for each `Customer` object in an is added to the root tree node as well as a child tree node for each `Order` object assigned to the `Customer` object. The `Customer` object is assigned to the property, and the tree nodes representing `Customer` objects are displayed with text. This example requires that you have a `Customer` and `Order` object defined, a control on a , and an named `customerArray` that contains `Customer` objects. - +> The method performs a shallow copy of the node. If the value of the property is a reference type, both the original and cloned copy will point to the same single instance of the value. + + + +## Examples + The following code example creates a root tree node to assign child tree nodes to. A child tree node for each `Customer` object in an is added to the root tree node as well as a child tree node for each `Order` object assigned to the `Customer` object. The `Customer` object is assigned to the property, and the tree nodes representing `Customer` objects are displayed with text. This example requires that you have a `Customer` and `Order` object defined, a control on a , and an named `customerArray` that contains `Customer` objects. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Bounds/CPP/treenode_bounds.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_bounds.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet1"::: + ]]> @@ -2897,22 +2897,22 @@ If you set the property, t Gets or sets the text displayed in the label of the tree node. The text displayed in the label of the tree node. - can display is 259. If a that has more than 259 characters is assigned to this property, only the first 259 characters are displayed. - - This property cannot be set by the user if the property of the parent is set to `false`. The alternative to explicitly setting this property is to create the tree node by using one of the constructors that has a string parameter that represents the property. The label is displayed next to the image, if one is displayed. - - - -## Examples - The following code example creates a root tree node to assign child tree nodes to. A child tree node for each `Customer` object in an is added to the root tree node as well as a child tree node for each `Order` object assigned to the `Customer` object. The `Customer` object is assigned to the property, and the tree nodes representing `Customer` objects are displayed with text. This example requires that you have a `Customer` and `Order` object defined, a control on a , and an named `customerArray` that contains `Customer` objects. - + can display is 259. If a that has more than 259 characters is assigned to this property, only the first 259 characters are displayed. + + This property cannot be set by the user if the property of the parent is set to `false`. The alternative to explicitly setting this property is to create the tree node by using one of the constructors that has a string parameter that represents the property. The label is displayed next to the image, if one is displayed. + + + +## Examples + The following code example creates a root tree node to assign child tree nodes to. A child tree node for each `Customer` object in an is added to the root tree node as well as a child tree node for each `Order` object assigned to the `Customer` object. The `Customer` object is assigned to the property, and the tree nodes representing `Customer` objects are displayed with text. This example requires that you have a `Customer` and `Order` object defined, a control on a , and an named `customerArray` that contains `Customer` objects. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Bounds/CPP/treenode_bounds.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/.ctor/treenode_bounds.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Bounds/VB/treenode_bounds.vb" id="Snippet1"::: + ]]> @@ -2947,23 +2947,23 @@ If you set the property, t Toggles the tree node to either the expanded or collapsed state. - [!NOTE] -> The state of a is persisted. For example, if the next level of child nodes was not collapsed previously, when the method is called, the child nodes appear in their previously expanded state. - - - -## Examples - The following code example removes a when the user right-clicks the mouse over it and toggles it from expanded to collapsed when the user clicks the mouse wheel over it. This example requires that you have a with a control on it. The should have two or more root tree nodes, each having at least one child node. - +> The state of a is persisted. For example, if the next level of child nodes was not collapsed previously, when the method is called, the child nodes appear in their previously expanded state. + + + +## Examples + The following code example removes a when the user right-clicks the mouse over it and toggles it from expanded to collapsed when the user clicks the mouse wheel over it. This example requires that you have a with a control on it. The should have two or more root tree nodes, each having at least one child node. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Windows.Forms.TreeNode/CPP/treenode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FromHandle/treenode.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Windows.Forms.TreeNode/VB/treenode.vb" id="Snippet1"::: + ]]> @@ -3016,21 +3016,21 @@ If you set the property, t Gets or sets the text that appears when the mouse pointer hovers over a . Gets the text that appears when the mouse pointer hovers over a . - property of the parent to `true` for the to be visible at run time. - - If the control has a ToolTip and also contains a that has a , only the for the node will be shown. - - - -## Examples - The following code example demonstrates how to use the and properties. To run this example, paste the following code into a Windows Form and call `InitializeTreeViewWithToolTips` from the form's constructor or event handler. - + property of the parent to `true` for the to be visible at run time. + + If the control has a ToolTip and also contains a that has a , only the for the node will be shown. + + + +## Examples + The following code example demonstrates how to use the and properties. To run this example, paste the following code into a Windows Form and call `InitializeTreeViewWithToolTips` from the form's constructor or event handler. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/ToolTipText/Form1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TreeViewWhidbeyMembers/VB/Form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.TreeViewWhidbeyMembers/VB/Form1.vb" id="Snippet7"::: + ]]> @@ -3104,15 +3104,15 @@ If you set the property, t Gets the parent tree view that the tree node is assigned to. A that represents the parent tree view that the tree node is assigned to, or if the node has not been assigned to a tree view. - after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". - + after determining if the passed in is selected and which to select. This example requires that you have a with a control that has a that contains several objects. It also requires that you have a with the following items: "Previous", "PreviousVisible", "Next", "NextVisible", "First", and "Last". + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/TreeNode_Parent/CPP/treenode_parent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/TreeNode/FirstNode/treenode_parent.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/TreeNode_Parent/VB/treenode_parent.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/UserControl.xml b/xml/System.Windows.Forms/UserControl.xml index 39ba458d679..a3fad041166 100644 --- a/xml/System.Windows.Forms/UserControl.xml +++ b/xml/System.Windows.Forms/UserControl.xml @@ -70,28 +70,28 @@ Provides an empty control that can be used to create other controls. - , inherits all the standard positioning and mnemonic-handling code that is necessary in a user control. - - The gives you the ability to create controls that can be used in multiple places within an application or organization. You can include all the code needed for validation of common data you ask the user to input; some examples of this are email addresses (see Example section), telephone numbers, and postal codes. Another efficient use of the user control is to simply preload a or with static items you commonly use in almost every application; some examples of this are countries/regions, cities, states, and office locations. For more information about authoring custom controls, see [Developing Custom Windows Forms Controls with the .NET Framework](/dotnet/framework/winforms/controls/developing-custom-windows-forms-controls). - + , inherits all the standard positioning and mnemonic-handling code that is necessary in a user control. + + The gives you the ability to create controls that can be used in multiple places within an application or organization. You can include all the code needed for validation of common data you ask the user to input; some examples of this are email addresses (see Example section), telephone numbers, and postal codes. Another efficient use of the user control is to simply preload a or with static items you commonly use in almost every application; some examples of this are countries/regions, cities, states, and office locations. For more information about authoring custom controls, see [Developing Custom Windows Forms Controls with the .NET Framework](/dotnet/desktop/winforms/controls/developing-custom-windows-forms-controls). + > [!NOTE] -> You might consider creating a namespace that contains several classes of user controls and compiling it into one DLL. This DLL can be referenced and distributed with the application or all applications within an organization. This gives you the ability to reference the user control in many applications and save time laying out and coding the contained elements of the user control. A user control also gives you consistency within or across applications; for example, all address information input blocks will all have the same appearance and behavior. Consistency gives your application a more polished and professional appearance. -> -> You can host Windows Forms -derived classes inside of a form, on another , inside of Internet Explorer on a web page, or inside a control hosted on a form. - +> You might consider creating a namespace that contains several classes of user controls and compiling it into one DLL. This DLL can be referenced and distributed with the application or all applications within an organization. This gives you the ability to reference the user control in many applications and save time laying out and coding the contained elements of the user control. A user control also gives you consistency within or across applications; for example, all address information input blocks will all have the same appearance and behavior. Consistency gives your application a more polished and professional appearance. +> +> You can host Windows Forms -derived classes inside of a form, on another , inside of Internet Explorer on a web page, or inside a control hosted on a form. + > [!NOTE] -> When hosting a inside of the control, you cannot turn off Visual Styles using the `META` tag value `MSThemeCompatible`. For more information about Visual Styles, see [Rendering Controls with Visual Styles](/dotnet/framework/winforms/controls/rendering-controls-with-visual-styles). - -## Examples - The following code example creates a that can be reused in multiple applications to get user information. This example adds several controls, controls and an to the to gather the user's information. Additionally, the user's email address is validated in the event of the and the object is used to give the user feedback if the data fails validation. The code is intended to be compiled into a DLL for reference in other applications. - +> When hosting a inside of the control, you cannot turn off Visual Styles using the `META` tag value `MSThemeCompatible`. For more information about Visual Styles, see [Rendering Controls with Visual Styles](/dotnet/desktop/winforms/controls/rendering-controls-with-visual-styles). + +## Examples + The following code example creates a that can be reused in multiple applications to get user information. This example adds several controls, controls and an to the to gather the user's information. Additionally, the user's email address is validated in the event of the and the object is used to give the user feedback if the data fails validation. The code is intended to be compiled into a DLL for reference in other applications. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic UserControl Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/UserControl/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic UserControl Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic UserControl Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -121,20 +121,20 @@ Initializes a new instance of the class. - . To create your own user control class, inherit from the class. - - - -## Examples - The following code example creates an instance of the derived class, `MyCustomerInfoUserControl`, which was created in the example section of the class overview. The user control is added to a control and has its property set to . The is then added to a . - + . To create your own user control class, inherit from the class. + + + +## Examples + The following code example creates an instance of the derived class, `MyCustomerInfoUserControl`, which was created in the example section of the class overview. The user control is added to a control and has its property set to . The is then added to a . + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic UserControl.UserControl Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/UserControl/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic UserControl.UserControl Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic UserControl.UserControl Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -265,11 +265,11 @@ Gets or sets how the control will resize itself. A value from the enumeration. The default is . - property will function as though was set to . All controls that recognize the property will, by default, grow to fit available space, but will not shrink below the value specified by the property. - + property will function as though was set to . All controls that recognize the property will, by default, grow to fit available space, but will not shrink below the value specified by the property. + ]]> @@ -348,21 +348,21 @@ Occurs when the property changes. - property so that you can change your control's validation behavior accordingly. - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `UserControl1`. Then ensure that the event handler is associated with the event. - + property so that you can change your control's validation behavior accordingly. + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `UserControl1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet641"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet641"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet641"::: + ]]> @@ -413,11 +413,11 @@ Gets or sets the border style of the user control. One of the values. The default is . - property is set to , the control has a sunken, three-dimensional appearance. To display a flat, thin border, set the property to . - + property is set to , the control has a sunken, three-dimensional appearance. To display a flat, thin border, set the property to . + ]]> The assigned value is not one of the values. @@ -516,29 +516,29 @@ Occurs before the control becomes visible for the first time. - [!NOTE] -> If the is part of an MDI child form, the event will occur each time the child form is shown. In this case, you should put any one-time initialization code in the instead of a event handler. - +> If the is part of an MDI child form, the event will occur each time the child form is shown. In this case, you should put any one-time initialization code in the instead of a event handler. + > [!CAUTION] -> The event occurs when the handle for the is created. In some circumstances, this can cause the event to occur more than one time. For example, the event occurs when the is loaded, and again if the handle is recreated. (One way that a handle is recreated is by calling the method.) To account for the event occurring more than one time, you should put any one time initialization code in the constructor instead of a event handler. In addition, you should not add data bindings to the in a event handler. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `UserControl1`. Then ensure that the event handler is associated with the event. - +> The event occurs when the handle for the is created. In some circumstances, this can cause the event to occur more than one time. For example, the event occurs when the is loaded, and again if the handle is recreated. (One way that a handle is recreated is by calling the method.) To account for the event occurring more than one time, you should put any one time initialization code in the constructor instead of a event handler. In addition, you should not add data bindings to the in a event handler. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `UserControl1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet642"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet642"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet642"::: + ]]> @@ -578,13 +578,13 @@ Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -628,15 +628,15 @@ An that contains the event data. Raises the event. - event occurs after the control is created, but before the control becomes visible for the first time. - - Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). - - The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + event occurs after the control is created, but before the control becomes visible for the first time. + + Raising an event invokes the event handler through a delegate. For more information, see [Handling and Raising Events](/dotnet/standard/events/). + + The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> diff --git a/xml/System.Windows.Forms/WebBrowser.xml b/xml/System.Windows.Forms/WebBrowser.xml index b149eb82ab7..da7c0890794 100644 --- a/xml/System.Windows.Forms/WebBrowser.xml +++ b/xml/System.Windows.Forms/WebBrowser.xml @@ -57,57 +57,57 @@ Enables a user to navigate Web pages inside a form. - [!NOTE] > For new Windows Forms projects, we recommend using the Microsoft Edge [WebView2 control](/microsoft-edge/webview2/) instead of the control. - The control lets you host Web pages and other browser-enabled documents in your Windows Forms applications. You can use the control, for example, to provide integrated HTML-based user assistance or Web browsing capabilities in your application. Additionally, you can use the control to add your existing Web-based controls to your Windows Forms client applications. - + The control lets you host Web pages and other browser-enabled documents in your Windows Forms applications. You can use the control, for example, to provide integrated HTML-based user assistance or Web browsing capabilities in your application. Additionally, you can use the control to add your existing Web-based controls to your Windows Forms client applications. + > [!IMPORTANT] -> The control is resource-intensive. To ensure that all resources are released in a timely fashion, call the method when you're finished using the control. You must call the method on the same thread that attached the events, which should always be the message or user-interface (UI) thread. - - The control cannot be used by partially trusted code. For more information, see [Using Libraries from Partially Trusted Code](/dotnet/framework/misc/using-libraries-from-partially-trusted-code). - - The control has several properties, methods, and events related to navigation. The following members let you navigate the control to a specific URL, move backward and forward through the navigation history list, and load the home page and search page of the current user: - -- -- -- -- -- +> The control is resource-intensive. To ensure that all resources are released in a timely fashion, call the method when you're finished using the control. You must call the method on the same thread that attached the events, which should always be the message or user-interface (UI) thread. + + The control cannot be used by partially trusted code. For more information, see [Using Libraries from Partially Trusted Code](/dotnet/framework/misc/using-libraries-from-partially-trusted-code). + + The control has several properties, methods, and events related to navigation. The following members let you navigate the control to a specific URL, move backward and forward through the navigation history list, and load the home page and search page of the current user: + +- +- +- +- +- - - - If the navigation is unsuccessful, a page indicating the problem is displayed. Navigation with any of these members causes the , , and events to occur at different stages of navigation. - - These and other members, such as the and methods, let you implement user interface controls in your application similar to those in Internet Explorer. Some members are useful even when you don't want to display the control on your form. For example, you can use the method to print the latest version of a Web page without displaying the page to the user. - - The control also lets you display content that you create in your application or you retrieve from a database or resource file. Use the or property to get or set the contents of the current document as a string or data stream. - - You can also manipulate the contents of a Web page through the property, which contains an object that provides managed access to the HTML document object model (DOM) for the current page. This property is useful, when used in combination with the property, to implement two-way communication between your application code and dynamic HTML (DHTML) code in a Web page, letting you combine Web-based controls and Windows Forms controls in a single user interface. You can use the property to call scripting code methods from your application. Your scripting code can access your application through the `window.external` object, which is a built-in DOM object provided for host access, and which maps to the object that you specify for the property. - - The control is a managed wrapper for the ActiveX [WebBrowser control](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752040(v=vs.85)), and uses whichever version of the control is installed on the user's computer. - + + If the navigation is unsuccessful, a page indicating the problem is displayed. Navigation with any of these members causes the , , and events to occur at different stages of navigation. + + These and other members, such as the and methods, let you implement user interface controls in your application similar to those in Internet Explorer. Some members are useful even when you don't want to display the control on your form. For example, you can use the method to print the latest version of a Web page without displaying the page to the user. + + The control also lets you display content that you create in your application or you retrieve from a database or resource file. Use the or property to get or set the contents of the current document as a string or data stream. + + You can also manipulate the contents of a Web page through the property, which contains an object that provides managed access to the HTML document object model (DOM) for the current page. This property is useful, when used in combination with the property, to implement two-way communication between your application code and dynamic HTML (DHTML) code in a Web page, letting you combine Web-based controls and Windows Forms controls in a single user interface. You can use the property to call scripting code methods from your application. Your scripting code can access your application through the `window.external` object, which is a built-in DOM object provided for host access, and which maps to the object that you specify for the property. + + The control is a managed wrapper for the ActiveX [WebBrowser control](/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa752040(v=vs.85)), and uses whichever version of the control is installed on the user's computer. + > [!NOTE] > > - This class makes security demands at the class level. A is thrown when a derived class or any caller in the call stack does not have full trust permission. For details about security demands, see [Link Demands](/dotnet/framework/misc/link-demands) and [Inheritance Demands](/previous-versions/dotnet/netframework-4.0/x4yx82e6(v=vs.100)). -> - The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. +> - The class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your `Main` method is marked with the attribute. > - For accessibility purposes, the property should be set to `false` when there is no content to display in the control. Change the value to `true` to enable users to navigate via keyboard into the contents of the control. - -## Examples - The following code example demonstrates how to implement an address bar for use with the control. This example requires that you have a form that contains a control called `webBrowser1`, a control called `TextBoxAddress`, and a control called `ButtonGo`. When you type a URL into the text box and press Enter or click the **Go** button, the control navigates to the URL specified. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + +## Examples + The following code example demonstrates how to implement an address bar for use with the control. This example requires that you have a form that contains a control called `webBrowser1`, a control called `TextBoxAddress`, and a control called `ButtonGo`. When you type a URL into the text box and press Enter or click the **Go** button, the control navigates to the URL specified. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet6"::: + ]]> - WebBrowser Control (Windows Forms) + WebBrowser Control (Windows Forms) Using Libraries from Partially Trusted Code WebBrowser Control @@ -134,17 +134,17 @@ Initializes a new instance of the class. - control is empty. To navigate it to an initial document, set the property. - -## Examples - The following code example demonstrates the use of this member. - + control is empty. To navigate it to an initial document, set the property. + +## Examples + The following code example demonstrates the use of this member. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/.ctor/WebBrowserMisc.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet10"::: + ]]> The control is hosted inside Internet Explorer. @@ -183,11 +183,11 @@ if the control can navigate to another page; otherwise, . - , or property, but will prevent all subsequent navigation. - + , or property, but will prevent all subsequent navigation. + ]]> @@ -225,24 +225,24 @@ if the control accepts documents that are dropped onto it; otherwise, . The default is . - control automatically navigates to documents that are dropped onto it. This behavior is useful when you use the control as a generic browser. If you use the control to display content designed specifically for your application, such as HTML-based user assistance, set the property to `false` to prevent the display of other content. This is particularly useful when you want to conceal the fact that you are using the control, for example to create a user interface that seamlessly combines Web-based controls with Windows Forms controls. - - You can disable other standard browser features by setting the and properties to `false`. - + control automatically navigates to documents that are dropped onto it. This behavior is useful when you use the control as a generic browser. If you use the control to display content designed specifically for your application, such as HTML-based user assistance, set the property to `false` to prevent the display of other content. This is particularly useful when you want to conceal the fact that you are using the control, for example to create a user interface that seamlessly combines Web-based controls with Windows Forms controls. + + You can disable other standard browser features by setting the and properties to `false`. + > [!NOTE] -> This property is not related to the property and does not cause drag-and-drop events such as the event to occur for the control. - - - -## Examples - The following code example demonstrates how to use the property. - +> This property is not related to the property and does not cause drag-and-drop events such as the event to occur for the control. + + + +## Examples + The following code example demonstrates how to use the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/AllowWebBrowserDrop/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser.ObjectForScripting/vb/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser.ObjectForScripting/vb/form1.vb" id="Snippet1"::: + ]]> This instance is no longer valid. @@ -332,24 +332,24 @@ if the control can navigate backward; otherwise, . - control maintains a history list of all the Web pages visited during a browsing session. The method navigates the control to the previous page in this history, if one is available. Use the property to determine whether navigation history is available and contains a previous page. If this property is `true`, the method will succeed. Otherwise, calling the method will return a value of `false` and no navigation will occur. - - You can also handle the event to receive a notification when the property changes. Handling this event is useful, for example, to change the enabled state of a **Back** button when the control navigates to or leaves the beginning of the navigation history. - - - -## Examples - The following code example demonstrates how to use the property to implement a **Back** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `backButton`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + control maintains a history list of all the Web pages visited during a browsing session. The method navigates the control to the previous page in this history, if one is available. Use the property to determine whether navigation history is available and contains a previous page. If this property is `true`, the method will succeed. Otherwise, calling the method will return a value of `false` and no navigation will occur. + + You can also handle the event to receive a notification when the property changes. Handling this event is useful, for example, to change the enabled state of a **Back** button when the control navigates to or leaves the beginning of the navigation history. + + + +## Examples + The following code example demonstrates how to use the property to implement a **Back** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `backButton`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet7"::: + ]]> @@ -389,24 +389,24 @@ Occurs when the property value changes. - control maintains a history list of all the Web pages visited during a browsing session. The method navigates the control to the previous page in this history, if one is available. The property indicates whether navigation history is available and contains a previous page. Handle the event to receive a notification when the property changes. Handling this event is useful, for example, to change the enabled state of a **Back** button when the control navigates to or leaves the beginning of the navigation history. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates how to use a handler for the event to implement a **Back** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `backButton`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + control maintains a history list of all the Web pages visited during a browsing session. The method navigates the control to the previous page in this history, if one is available. The property indicates whether navigation history is available and contains a previous page. Handle the event to receive a notification when the property changes. Handling this event is useful, for example, to change the enabled state of a **Back** button when the control navigates to or leaves the beginning of the navigation history. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates how to use a handler for the event to implement a **Back** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `backButton`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet7"::: + ]]> @@ -460,26 +460,26 @@ if the control can navigate forward; otherwise, . - control maintains a history list of all the Web pages visited during a browsing session. The method navigates the control to the next page in this history, if one is available as a result of a previous backward navigation. If this property is `true`, the method will succeed. Otherwise, calling the method will return a value of `false` and no navigation will occur. - - Use the property to determine whether navigation history is available and contains a page located after the current one, allowing the method to succeed. - - You can also handle the event to receive a notification when the property changes. Handling this event is useful, for example, to change the enabled state of a **Forward** button when the control navigates to or leaves the end of the navigation history. - - - -## Examples - The following code example demonstrates how to use a handler for the event to implement a **Forward** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonForward`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + control maintains a history list of all the Web pages visited during a browsing session. The method navigates the control to the next page in this history, if one is available as a result of a previous backward navigation. If this property is `true`, the method will succeed. Otherwise, calling the method will return a value of `false` and no navigation will occur. + + Use the property to determine whether navigation history is available and contains a page located after the current one, allowing the method to succeed. + + You can also handle the event to receive a notification when the property changes. Handling this event is useful, for example, to change the enabled state of a **Forward** button when the control navigates to or leaves the end of the navigation history. + + + +## Examples + The following code example demonstrates how to use a handler for the event to implement a **Forward** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonForward`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet8"::: + ]]> @@ -519,24 +519,24 @@ Occurs when the property value changes. - control maintains a history list of all the Web pages visited during a browsing session. The method navigates the control to the next page in this history, if one is available as a result of a previous backward navigation. The property indicates whether navigation history is available and contains a page located after the current one, allowing the method to succeed. Handle the event to receive a notification when the property changes. Handling this event is useful, for example, to change the enabled state of a **Forward** button when the control navigates to or leaves the end of the navigation history. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates how to use the method to implement a **Forward** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonForward`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + control maintains a history list of all the Web pages visited during a browsing session. The method navigates the control to the next page in this history, if one is available as a result of a previous backward navigation. The property indicates whether navigation history is available and contains a page located after the current one, allowing the method to succeed. Handle the event to receive a notification when the property changes. Handling this event is useful, for example, to change the enabled state of a **Forward** button when the control navigates to or leaves the end of the navigation history. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates how to use the method to implement a **Forward** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonForward`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet8"::: + ]]> @@ -596,19 +596,19 @@ Associates the underlying ActiveX control with a client that can handle control events. - control, which is a managed wrapper for the ActiveX control. You can use this extensibility to implement events from the ActiveX control that are not provided by the wrapper control. - - - -## Examples - The following code example illustrates the use of this method in a class derived from that supplements the normal events with the `NavigateError` event from the OLE `DWebBrowserEvents2` interface. - + control, which is a managed wrapper for the ActiveX control. You can use this extensibility to implement events from the ActiveX control that are not provided by the wrapper control. + + + +## Examples + The following code example illustrates the use of this method in a class derived from that supplements the normal events with the `NavigateError` event from the OLE `DWebBrowserEvents2` interface. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/CreateSink/WB2.cs" id="Snippet00"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserExtensibility/VB/WB2.vb" id="Snippet00"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserExtensibility/VB/WB2.vb" id="Snippet00"::: + ]]> @@ -643,16 +643,16 @@ Returns a reference to the unmanaged ActiveX control site, which you can extend to customize the managed control. A that represents the ActiveX control site. - control, which is a managed wrapper for the ActiveX control. You can use this extensibility, for example, to customize the browser shortcut menu and shortcut keys or to provide a custom security configuration for hosted documents. - - To use this feature, implement classes that inherit from the and classes. The unmanaged `WebBrowser` ActiveX control uses the protected method to retrieve extensibility interfaces implemented by the class. Override the method to return an instance of your own class that inherits from the class. The class provides default implementations of the OLE `IDocHostUIHandler` interface. You can provide your own implementation of this interface or implement any other `WebBrowser` ActiveX control interface in order to customize the behavior of the control. - + control, which is a managed wrapper for the ActiveX control. You can use this extensibility, for example, to customize the browser shortcut menu and shortcut keys or to provide a custom security configuration for hosted documents. + + To use this feature, implement classes that inherit from the and classes. The unmanaged `WebBrowser` ActiveX control uses the protected method to retrieve extensibility interfaces implemented by the class. Override the method to return an instance of your own class that inherits from the class. The class provides default implementations of the OLE `IDocHostUIHandler` interface. You can provide your own implementation of this interface or implement any other `WebBrowser` ActiveX control interface in order to customize the behavior of the control. + > [!NOTE] -> If you provide your own implementation for any `IDocHostUIHandler` members, you must implement all the members of that interface. - +> If you provide your own implementation for any `IDocHostUIHandler` members, you must implement all the members of that interface. + ]]> @@ -745,21 +745,21 @@ Releases the event-handling client attached in the method from the underlying ActiveX control. - control, which is a managed wrapper for the ActiveX control. You can use this extensibility to implement events from the ActiveX control that are not provided by the wrapper control. - - - -## Examples - The following code example illustrates the use of this method in a class derived from that supplements the standard events with the `NavigateError` event from the OLE `DWebBrowserEvents2` interface. - - For the complete code example, see . - + control, which is a managed wrapper for the ActiveX control. You can use this extensibility to implement events from the ActiveX control that are not provided by the wrapper control. + + + +## Examples + The following code example illustrates the use of this method in a class derived from that supplements the standard events with the `NavigateError` event from the OLE `DWebBrowserEvents2` interface. + + For the complete code example, see . + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/CreateSink/WB2.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserExtensibility/VB/WB2.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserExtensibility/VB/WB2.vb" id="Snippet10"::: + ]]> @@ -840,25 +840,25 @@ Gets an representing the Web page currently displayed in the control. An representing the current page, or if no page is loaded. - control through the HTML document object model (DOM). This is useful, for example, when you want to use Web-based controls in your Windows Forms application. - - You can use this property, in combination with the property, to implement two-way communication between a Web page displayed in the control and your application. Use the method to call script methods implemented in a Web page from your client application code. Your scripting code can access your application through the `window.external` object, which is a built-in DOM object provided for host access, and which maps to an object that you specify for the property. - - To access the contents of a Web page as a string, use the property. To access the contents of a Web page as a , use the property. - - - -## Examples - The following code example demonstrates how to use the property in a handler for the event to determine whether a Web page form has been filled in. If the input field does not contain a value, the navigation is canceled. - - This example requires that your form contains a control called `webBrowser1`. - + control through the HTML document object model (DOM). This is useful, for example, when you want to use Web-based controls in your Windows Forms application. + + You can use this property, in combination with the property, to implement two-way communication between a Web page displayed in the control and your application. Use the method to call script methods implemented in a Web page from your client application code. Your scripting code can access your application through the `window.external` object, which is a built-in DOM object provided for host access, and which maps to an object that you specify for the property. + + To access the contents of a Web page as a string, use the property. To access the contents of a Web page as a , use the property. + + + +## Examples + The following code example demonstrates how to use the property in a handler for the event to determine whether a Web page form has been filled in. If the input field does not contain a value, the navigation is canceled. + + This example requires that your form contains a control called `webBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/.ctor/WebBrowserMisc.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet30"::: + ]]> This instance is no longer valid. @@ -899,41 +899,41 @@ Occurs when the control finishes loading a document. - control navigates to a new document whenever one of the following properties is set or methods is called: - -- - -- - -- - -- - -- - -- - -- - -- - - Handle the event to receive notification when the new document finishes loading. When the event occurs, the new document is fully loaded, which means you can access its contents through the , , or property. - - To receive notification before navigation begins, handle the event. Handling this event lets you cancel navigation if certain conditions have not been met, for example, when the user has not completely filled out a form. Handle the event to receive notification when the control finishes navigation and has begun loading the document at the new location. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates the use of this event to print a document after it has fully loaded. - + control navigates to a new document whenever one of the following properties is set or methods is called: + +- + +- + +- + +- + +- + +- + +- + +- + + Handle the event to receive notification when the new document finishes loading. When the event occurs, the new document is fully loaded, which means you can access its contents through the , , or property. + + To receive notification before navigation begins, handle the event. Handling this event lets you cancel navigation if certain conditions have not been met, for example, when the user has not completely filled out a form. Handle the event to receive notification when the control finishes navigation and has begun loading the document at the new location. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates the use of this event to print a document after it has fully loaded. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/.ctor/WebBrowserMisc.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet10"::: + ]]> @@ -991,16 +991,16 @@ Gets or sets a stream containing the contents of the Web page displayed in the control. A containing the contents of the current Web page, or if no page is loaded. The default is . - control from a object. You can use this property, for example, to load Web pages from a database or resource file. When you set this property, the control automatically navigates to the about:blank URL before loading the specified text. This means that the , , and events occur when you set this property, and the value of the property is no longer meaningful. - + control from a object. You can use this property, for example, to load Web pages from a database or resource file. When you set this property, the control automatically navigates to the about:blank URL before loading the specified text. This means that the , , and events occur when you set this property, and the value of the property is no longer meaningful. + > [!NOTE] -> This property contains the contents of the current document, even if another document has been requested. If you set the value of this property and then immediately retrieve it again, the value retrieved may be different than the value set if the control has not had time to load the new content. You can retrieve the new value in a event handler. - - To access the contents of a Web page as a string, use the property. You can also access the page contents using the HTML document object model (DOM) through the property. - +> This property contains the contents of the current document, even if another document has been requested. If you set the value of this property and then immediately retrieve it again, the value retrieved may be different than the value set if the control has not had time to load the new content. You can retrieve the new value in a event handler. + + To access the contents of a Web page as a string, use the property. You can also access the page contents using the HTML document object model (DOM) through the property. + ]]> This instance is no longer valid. @@ -1056,24 +1056,24 @@ Gets or sets the HTML contents of the page displayed in the control. The HTML text of the displayed page, or the empty string ("") if no document is loaded. - control using string processing tools. You can use this property, for example, to load pages from a database or to analyze pages using regular expressions. When you set this property, the control automatically navigates to the about:blank URL before loading the specified text. This means that the , , and events occur when you set this property, and the value of the property is no longer meaningful. - + control using string processing tools. You can use this property, for example, to load pages from a database or to analyze pages using regular expressions. When you set this property, the control automatically navigates to the about:blank URL before loading the specified text. This means that the , , and events occur when you set this property, and the value of the property is no longer meaningful. + > [!NOTE] -> This property contains the text of the current document, even if another document has been requested. If you set the value of this property and then immediately retrieve it again, the value retrieved may be different than the value set if the control has not had time to load the new content. You can retrieve the new value in a event handler. Alternatively, you can block the thread until the document is loaded by calling the method in a loop until the property returns the value that you originally set it to. - - To access the contents of a Web page as a , use the property. You can also access the page contents using the HTML document object model (DOM) through the property. - - - -## Examples - The following code example demonstrates how to use the property to programmatically display document content of your choosing. This example requires that your form contains a control called `webBrowser1`. - +> This property contains the text of the current document, even if another document has been requested. If you set the value of this property and then immediately retrieve it again, the value retrieved may be different than the value set if the control has not had time to load the new content. You can retrieve the new value in a event handler. Alternatively, you can block the thread until the document is loaded by calling the method in a loop until the property returns the value that you originally set it to. + + To access the contents of a Web page as a , use the property. You can also access the page contents using the HTML document object model (DOM) through the property. + + + +## Examples + The following code example demonstrates how to use the property to programmatically display document content of your choosing. This example requires that your form contains a control called `webBrowser1`. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/.ctor/WebBrowserMisc.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet30"::: + ]]> This instance is no longer valid. @@ -1129,24 +1129,24 @@ Gets the title of the document currently displayed in the control. The title of the current document, or the empty string ("") if no document is loaded. - event to update the title in the title bar when the control navigates to a new document. - - - -## Examples - The following code example demonstrates how to use the property to update the form title bar with the title of the current document. This example requires that your form contains a control called `webBrowser1`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + event to update the title in the title bar when the control navigates to a new document. + + + +## Examples + The following code example demonstrates how to use the property to update the form title bar with the title of the current document. This example requires that your form contains a control called `webBrowser1`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet15"::: + ]]> This instance is no longer valid. @@ -1189,24 +1189,24 @@ Occurs when the property value changes. - property. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates how to use a handler for the event to update the form title bar with the title of the current document. This example requires that your form contains a control called `webBrowser1`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + property. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates how to use a handler for the event to update the form title bar with the title of the current document. This example requires that your form contains a control called `webBrowser1`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet15"::: + ]]> @@ -1258,11 +1258,11 @@ Gets the type of the document currently displayed in the control. The type of the current document. - This instance is no longer valid. @@ -1311,11 +1311,11 @@ Gets a value indicating the encryption method used by the document currently displayed in the control. One of the values. - event to implement an indicator in the user interface of your application similar to the lock icon in Internet Explorer. When the current document is not encrypted, the value of this property is . When the control displays a Web page containing multiple frames with content of different encryption levels, the value of this property is . When the encryption level is unknown, the value of this property is . Other values indicate the type of encryption present. To mimic the behavior of the lock icon in Internet Explorer, display the encryption type in a ToolTip that appears when the mouse pointer hovers over the indicator. - + event to implement an indicator in the user interface of your application similar to the lock icon in Internet Explorer. When the current document is not encrypted, the value of this property is . When the control displays a Web page containing multiple frames with content of different encryption levels, the value of this property is . When the encryption level is unknown, the value of this property is . Other values indicate the type of encryption present. To mimic the behavior of the lock icon in Internet Explorer, display the encryption type in a ToolTip that appears when the mouse pointer hovers over the indicator. + ]]> This instance is no longer valid. @@ -1359,21 +1359,21 @@ Occurs when the control navigates to or away from a Web site that uses encryption. - property to implement an indicator in the user interface of your application similar to the lock icon in Internet Explorer. In a handler for this event, check the value of the property to determine whether you should hide or display the indicator. To mimic the behavior of the lock icon in Internet Explorer, you can also provide a ToolTip that shows the encryption level when the mouse pointer hovers over the indicator. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `WebBrowser1`. Then ensure that the event handler is associated with the event. - + property to implement an indicator in the user interface of your application similar to the lock icon in Internet Explorer. In a handler for this event, check the value of the property to determine whether you should hide or display the indicator. To mimic the behavior of the lock icon in Internet Explorer, you can also provide a ToolTip that shows the encryption level when the mouse pointer hovers over the indicator. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `WebBrowser1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet647"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet647"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet647"::: + ]]> @@ -1408,21 +1408,21 @@ Occurs when the control downloads a file. - event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `WebBrowser1`. Then ensure that the event handler is associated with the event. - + event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `WebBrowser1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet648"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet648"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet648"::: + ]]> @@ -1489,22 +1489,22 @@ if the navigation succeeds; if a previous page in the navigation history is not available. - control maintains a history list of all the Web pages visited during a browsing session. You can use the method to implement a **Back** button similar to the one in Internet Explorer, which will allow your users to return to a previous page in the navigation history. - - Use the property to determine whether the navigation history is available and contains a previous page. Handle the event to receive a notification when the property value changes. Handling this event is useful, for example, to change the enabled state of a **Back** button when the control navigates to or leaves the beginning of the navigation history. - -## Examples - The following code example demonstrates how to use the method to implement a **Back** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `backButton`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + control maintains a history list of all the Web pages visited during a browsing session. You can use the method to implement a **Back** button similar to the one in Internet Explorer, which will allow your users to return to a previous page in the navigation history. + + Use the property to determine whether the navigation history is available and contains a previous page. Handle the event to receive a notification when the property value changes. Handling this event is useful, for example, to change the enabled state of a **Back** button when the control navigates to or leaves the beginning of the navigation history. + +## Examples + The following code example demonstrates how to use the method to implement a **Back** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `backButton`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet7"::: + ]]> @@ -1544,24 +1544,24 @@ if the navigation succeeds; if a subsequent page in the navigation history is not available. - control maintains a history list of all the Web pages visited during a browsing session. You can use the method to implement a **Forward** button similar to the one in Internet Explorer, allowing your users to return to the next page in the navigation history after navigating backward. - - Use the property to determine whether the navigation history is available and contains a page located after the current one. Handle the event to receive a notification when the property value changes. Handling this event is useful, for example, to change the enabled state of a **Forward** button when the control navigates to or leaves the end of the navigation history. - - - -## Examples - The following code example demonstrates how to use the method to implement a **Forward** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonForward`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + control maintains a history list of all the Web pages visited during a browsing session. You can use the method to implement a **Forward** button similar to the one in Internet Explorer, allowing your users to return to the next page in the navigation history after navigating backward. + + Use the property to determine whether the navigation history is available and contains a page located after the current one. Handle the event to receive a notification when the property value changes. Handling this event is useful, for example, to change the enabled state of a **Forward** button when the control navigates to or leaves the end of the navigation history. + + + +## Examples + The following code example demonstrates how to use the method to implement a **Forward** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonForward`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet8"::: + ]]> @@ -1599,20 +1599,20 @@ Navigates the control to the home page of the current user. - method to implement a **Home** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonHome`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + method to implement a **Home** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonHome`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet11"::: + ]]> This instance is no longer valid. @@ -1652,22 +1652,22 @@ Navigates the control to the default search page of the current user. - method or specify the property. - -## Examples - The following code example demonstrates how to use the method to implement a **Search** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonSearch`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + +## Examples + The following code example demonstrates how to use the method to implement a **Search** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonSearch`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet12"::: + ]]> This instance is no longer valid. @@ -1724,11 +1724,11 @@ if the control is busy loading a document; otherwise, . - method to halt the current navigation before the new document is fully loaded. Use the property to determine the exact navigation state of the control. The property value is false when the property value is . - + method to halt the current navigation before the new document is fully loaded. Use the property to determine the exact navigation state of the control. The property value is false when the property value is . + ]]> This instance is no longer valid. @@ -1780,11 +1780,11 @@ if the control is in offline mode; otherwise, . - control is forced to load Web pages from the local cache rather than downloading them. - + control is forced to load Web pages from the local cache rather than downloading them. + ]]> This instance is no longer valid. @@ -1826,21 +1826,21 @@ if the control shortcut menu is enabled; otherwise, . The default is . - control displays a shortcut menu when a user right-clicks it. This behavior is useful when you use the control as a generic browser. If you want to conceal the fact that you are using the control, for example to create a user interface that seamlessly combines Web-based controls with Windows Forms controls, set the property to false. - - You can disable other standard browser features by setting the and properties to false. - - - -## Examples - The following code example demonstrates how to use the property. - + control displays a shortcut menu when a user right-clicks it. This behavior is useful when you use the control as a generic browser. If you want to conceal the fact that you are using the control, for example to create a user interface that seamlessly combines Web-based controls with Windows Forms controls, set the property to false. + + You can disable other standard browser features by setting the and properties to false. + + + +## Examples + The following code example demonstrates how to use the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/AllowWebBrowserDrop/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser.ObjectForScripting/vb/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser.ObjectForScripting/vb/form1.vb" id="Snippet2"::: + ]]> @@ -1885,15 +1885,15 @@ The URL of the document to load. Loads the document at the specified Uniform Resource Locator (URL) into the control, replacing the previous document. - control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control navigates to the specified URI and adds it to the end of the history list. Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. - - The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. - - You can use the method to implement an address bar similar to the one in Internet Explorer. - + control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control navigates to the specified URI and adds it to the end of the history list. Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. + + The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. + + You can use the method to implement an address bar similar to the one in Internet Explorer. + ]]> This instance is no longer valid. @@ -1941,24 +1941,24 @@ A representing the URL of the document to load. Loads the document at the location indicated by the specified into the control, replacing the previous document. - control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control navigates to the specified URI and adds it to the end of the history list. Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. - - The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. - - You can use the method to implement an address bar similar to the one in Internet Explorer. - -## Examples - The following code example demonstrates how to use the method to implement an address bar for the control. This example requires that your form contains a control called `webBrowser1`, a control called `TextBoxAddress`, and a control called `ButtonGo`. When you type a URL into the text box and press ENTER or click the **Go** button, the control navigates to the URL specified. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control navigates to the specified URI and adds it to the end of the history list. Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. + + The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. + + You can use the method to implement an address bar similar to the one in Internet Explorer. + +## Examples + The following code example demonstrates how to use the method to implement an address bar for the control. This example requires that your form contains a control called `webBrowser1`, a control called `TextBoxAddress`, and a control called `ButtonGo`. When you type a URL into the text box and press ENTER or click the **Go** button, the control navigates to the URL specified. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet6"::: + ]]> This instance is no longer valid. @@ -2003,13 +2003,13 @@ to load the document into a new browser window; to load the document into the control. Loads the document at the specified Uniform Resource Locator (URL) into a new browser window or into the control. - control maintains a history list of all the Web pages visited during a browsing session. When you call this overload with a `newWindow` parameter value of `false`, the control navigates to the specified URI normally and adds the URI to the end of the history list. When you call this overload with a `newWindow` parameter value of `true`, the control loads the document at the specified URI into a new Internet Explorer window, which maintains its own navigation history. You can handle the event to receive notification before a new browser window is opened, allowing you to cancel the action if necessary. - - The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page or loads a page into a separate browser window, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. When a page is loaded into a separate Internet Explorer window, the user can retrieve the latest version by clicking the **Refresh** button. - + control maintains a history list of all the Web pages visited during a browsing session. When you call this overload with a `newWindow` parameter value of `false`, the control navigates to the specified URI normally and adds the URI to the end of the history list. When you call this overload with a `newWindow` parameter value of `true`, the control loads the document at the specified URI into a new Internet Explorer window, which maintains its own navigation history. You can handle the event to receive notification before a new browser window is opened, allowing you to cancel the action if necessary. + + The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page or loads a page into a separate browser window, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. When a page is loaded into a separate Internet Explorer window, the user can retrieve the latest version by clicking the **Refresh** button. + ]]> This instance is no longer valid. @@ -2059,15 +2059,15 @@ The name of the frame in which to load the document. Loads the document at the specified Uniform Resource Locator (URL) into the control, replacing the contents of the Web page frame with the specified name. - control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window. - - Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. - - The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. - + control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window. + + Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. + + The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. + ]]> This instance is no longer valid. @@ -2112,13 +2112,13 @@ to load the document into a new browser window; to load the document into the control. Loads the document at the location indicated by the specified into a new browser window or into the control. - control maintains a history list of all the Web pages visited during a browsing session. When you call this overload with a `newWindow` parameter value of `false`, the control navigates to the specified URI normally and adds the URI to the end of the history list. When you call this overload with a `newWindow` parameter value of `true`, the control loads the document at the specified URI into a new Internet Explorer window, which maintains its own navigation history. You can handle the event to receive notification before a new browser window is opened, allowing you to cancel the action if necessary. - - The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page or loads a page into a separate browser window, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. When a page is loaded into a separate Internet Explorer window, the user can retrieve the latest version by clicking the **Refresh** button. - + control maintains a history list of all the Web pages visited during a browsing session. When you call this overload with a `newWindow` parameter value of `false`, the control navigates to the specified URI normally and adds the URI to the end of the history list. When you call this overload with a `newWindow` parameter value of `true`, the control loads the document at the specified URI into a new Internet Explorer window, which maintains its own navigation history. You can handle the event to receive notification before a new browser window is opened, allowing you to cancel the action if necessary. + + The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page or loads a page into a separate browser window, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. When a page is loaded into a separate Internet Explorer window, the user can retrieve the latest version by clicking the **Refresh** button. + ]]> This instance is no longer valid. @@ -2164,15 +2164,15 @@ The name of the frame in which to load the document. Loads the document at the location indicated by the specified into the control, replacing the contents of the Web page frame with the specified name. - control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window. - - Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. - - The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. - + control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window. + + Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. + + The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. + ]]> This instance is no longer valid. @@ -2228,15 +2228,15 @@ HTTP headers to add to the default headers. Loads the document at the specified Uniform Resource Locator (URL) into the control, requesting it using the specified HTTP data and replacing the contents of the Web page frame with the specified name. - control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window. - - Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. - - The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. - + control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window. + + Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. + + The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. + ]]> This instance is no longer valid. @@ -2284,15 +2284,15 @@ HTTP headers to add to the default headers. Loads the document at the location indicated by the specified into the control, requesting it using the specified HTTP data and replacing the contents of the Web page frame with the specified name. - control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window. - - Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. - - The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. - + control maintains a history list of all the Web pages visited during a browsing session. When you call this overload, the control loads the document at the specified URI into the Web page frame with the specified name, and adds the URI to the end of the history list. If the frame name specified is invalid, the document is loaded into a new Internet Explorer window. + + Use the method to return the control to a previous page in the navigation history. Use the method to return to a later page in the navigation history after navigating backward. + + The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. + ]]> This instance is no longer valid. @@ -2332,35 +2332,35 @@ Occurs when the control has navigated to a new document and has begun loading it. - control navigates to a new document whenever one of the following properties is set or methods is called: - -- -- -- -- -- -- -- + control navigates to a new document whenever one of the following properties is set or methods is called: + +- +- +- +- +- +- +- - - - Handle the event to receive notification when the control has navigated to a new document. When the event occurs, the new document has begun loading, which means you can access the loaded content through the , , and properties. Handle the event to receive notification when the control finishes loading the new document. - - You can also receive notification before navigation begins by handling the event. Handling this event lets you cancel navigation if certain conditions have not been met, for example, the user has not completely filled out a form. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - -## Examples - The following code example demonstrates how to use a handler for the event to implement an address bar for the control. This example requires that your form contains a control called `webBrowser1`, a control called `TextBoxAddress`, and a control called `ButtonGo`. When you type a URL into the text box and press ENTER or click the **Go** button, the control navigates to the URL specified. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + + Handle the event to receive notification when the control has navigated to a new document. When the event occurs, the new document has begun loading, which means you can access the loaded content through the , , and properties. Handle the event to receive notification when the control finishes loading the new document. + + You can also receive notification before navigation begins by handling the event. Handling this event lets you cancel navigation if certain conditions have not been met, for example, the user has not completely filled out a form. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + +## Examples + The following code example demonstrates how to use a handler for the event to implement an address bar for the control. This example requires that your form contains a control called `webBrowser1`, a control called `TextBoxAddress`, and a control called `ButtonGo`. When you type a URL into the text box and press ENTER or click the **Go** button, the control navigates to the URL specified. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet6"::: + ]]> @@ -2404,45 +2404,45 @@ Occurs before the control navigates to a new document. - control navigates to a new document whenever one of the following properties is set or methods is called: - -- - -- - -- - -- - -- - -- - -- - -- - - You can handle the event to cancel navigation if certain conditions have not been met, for example, when the user has not completely filled out a form. To cancel navigation, set the property of the object passed to the event handler to `true`. You can also use this object to retrieve the URL of the new document through the property. If the new document will be displayed in a Web page frame, you can retrieve the name of the frame through the property. - - Handle the event to receive notification when the control finishes navigation and has begun loading the document at the new location. Handle the event to receive notification when the control finishes loading the new document. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates how to use a handler for the event to cancel navigation when a Web page form has not been filled in. The property is used to determine whether the form input field contains a value. - - This example requires that your form contains a control called `webBrowser1` and that your form class has a making it accessible to COM. - - For a complete code example that you can paste the following code into, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + control navigates to a new document whenever one of the following properties is set or methods is called: + +- + +- + +- + +- + +- + +- + +- + +- + + You can handle the event to cancel navigation if certain conditions have not been met, for example, when the user has not completely filled out a form. To cancel navigation, set the property of the object passed to the event handler to `true`. You can also use this object to retrieve the URL of the new document through the property. If the new document will be displayed in a Web page frame, you can retrieve the name of the frame through the property. + + Handle the event to receive notification when the control finishes navigation and has begun loading the document at the new location. Handle the event to receive notification when the control finishes loading the new document. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates how to use a handler for the event to cancel navigation when a Web page form has not been filled in. The property is used to determine whether the form input field contains a value. + + This example requires that your form contains a control called `webBrowser1` and that your form class has a making it accessible to COM. + + For a complete code example that you can paste the following code into, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/.ctor/WebBrowserMisc.cs" id="Snippet30"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet30"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet30"::: + ]]> @@ -2486,25 +2486,25 @@ Occurs before a new browser window is opened. - control opens a separate browser window when the appropriate overload of the method is called or when the user clicks the **Open in New Window** option of the browser shortcut menu when the mouse pointer hovers over a hyperlink. You can disable the shortcut menu by setting the property to false. - - The event occurs before the new browser window is opened. You can handle this event, for example, to prevent the window from opening when certain conditions have not been met. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `WebBrowser1`. Then ensure that the event handler is associated with the event. - + control opens a separate browser window when the appropriate overload of the method is called or when the user clicks the **Open in New Window** option of the browser shortcut menu when the mouse pointer hovers over a hyperlink. You can disable the shortcut menu by setting the property to false. + + The event occurs before the new browser window is opened. You can handle this event, for example, to prevent the window from opening when certain conditions have not been met. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `WebBrowser1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet651"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet651"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet651"::: + ]]> @@ -2558,29 +2558,29 @@ Gets or sets an object that can be accessed by scripting code that is contained within a Web page displayed in the control. The object being made available to the scripting code. - control and the application that contains the control. This property lets you integrate dynamic HTML (DHTML) code with your client application code. The object specified for this property is available to Web page script as the `window.external` object, which is a built-in DOM object provided for host access. - - You can set this property to any COM-visible object for which you want its public properties and methods available to scripting code. You can make a class COM-visible by marking it with the . - - To call functions defined in your Web page from your client application code, use the method of the object you can retrieve from the property. - - - -## Examples - The following code example demonstrates how to use the property. In the example, the property is set to the current form. - + control and the application that contains the control. This property lets you integrate dynamic HTML (DHTML) code with your client application code. The object specified for this property is available to Web page script as the `window.external` object, which is a built-in DOM object provided for host access. + + You can set this property to any COM-visible object for which you want its public properties and methods available to scripting code. You can make a class COM-visible by marking it with the . + + To call functions defined in your Web page from your client application code, use the method of the object you can retrieve from the property. + + + +## Examples + The following code example demonstrates how to use the property. In the example, the property is set to the current form. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/AllowWebBrowserDrop/form1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser.ObjectForScripting/vb/form1.vb" id="Snippet0"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser.ObjectForScripting/vb/form1.vb" id="Snippet0"::: + ]]> - The specified value when setting this property is an instance of a non-public type. - - -or- - + The specified value when setting this property is an instance of a non-public type. + + -or- + The specified value when setting this property is an instance of a type that is not COM-visible. For more information, see . @@ -2615,13 +2615,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2660,13 +2660,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2705,13 +2705,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> This instance is no longer valid. @@ -2754,13 +2754,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2799,13 +2799,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2844,13 +2844,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2888,13 +2888,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2933,13 +2933,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -2978,13 +2978,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3022,13 +3022,13 @@ A that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3067,13 +3067,13 @@ An that contains the event data. Raises the event. - method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. - + method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class. + ]]> @@ -3175,11 +3175,11 @@ Occurs when the value of the property changes. - property and respond to changes by handling this event, the Padding property is not meaningful for this control. - + property and respond to changes by handling this event, the Padding property is not meaningful for this control. + ]]> @@ -3211,18 +3211,18 @@ Prints the document currently displayed in the control using the current print and page settings. - method. To display the **Page Setup** dialog box, which lets your users specify header and footer values and other page settings, use the method. To display the **Print Preview** dialog box, use the method. - -## Examples - The following code example demonstrates how to use the method to implement a **Print** button for the control that's similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonPrint`. - + method. To display the **Page Setup** dialog box, which lets your users specify header and footer values and other page settings, use the method. To display the **Print Preview** dialog box, use the method. + +## Examples + The following code example demonstrates how to use the method to implement a **Print** button for the control that's similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonPrint`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet13"::: + ]]> @@ -3257,21 +3257,21 @@ Occurs when the control has updated information on the download progress of a document it is navigating to. - property to determine the number of bytes that have been downloaded successfully. Use the property to determine the total number of bytes available for downloading. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - -## Examples - The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . - - To run the example code, paste it into a project that contains an instance of type named `WebBrowser1`. Then ensure that the event handler is associated with the event. - + property to determine the number of bytes that have been downloaded successfully. Use the property to determine the total number of bytes available for downloading. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + +## Examples + The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing with or appending the message to a multiline . + + To run the example code, paste it into a project that contains an instance of type named `WebBrowser1`. Then ensure that the event handler is associated with the event. + :::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet652"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet652"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet652"::: + ]]> @@ -3318,13 +3318,13 @@ Gets a value indicating the current state of the control. One of the values. - property to retrieve the specific state of the control when you need more information than the property provides. - - When the control does not contain a document, the value of this property is . Other values indicate the control state when it navigates to a new document. These values include , , , and . - + property to retrieve the specific state of the control when you need more information than the property provides. + + When the control does not contain a document, the value of this property is . Other values indicate the control state when it navigates to a new document. These values include , , , and . + ]]> This instance is no longer valid. @@ -3370,23 +3370,23 @@ Reloads the document currently displayed in the control by checking the server for an updated version. - control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. The method forces the control to reload the current page by downloading it, ensuring that the control displays the latest version. You can use this method to implement a **Refresh** button similar to the one in Internet Explorer. - + control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. The method forces the control to reload the current page by downloading it, ensuring that the control displays the latest version. You can use this method to implement a **Refresh** button similar to the one in Internet Explorer. + > [!NOTE] -> A document refresh simply reloads the current page, so the , , and events do not occur when you call the method. - -## Examples - The following code example demonstrates how to use the method to implement a **Refresh** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonRefresh`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - +> A document refresh simply reloads the current page, so the , , and events do not occur when you call the method. + +## Examples + The following code example demonstrates how to use the method to implement a **Refresh** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonRefresh`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet10"::: + ]]> @@ -3425,14 +3425,14 @@ One of the values. Reloads the document currently displayed in the control using the specified refresh options. - control stores recently visited Web pages in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. The method forces the control to reload the current page. The type of reload depends on the value specified. If you call the method with the value, the latest version of the document is downloaded. If you use the value, the latest version is downloaded only if the current document has expired. If you use the value, the server sends a copy of the document stored in its own cache. - + control stores recently visited Web pages in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. The method forces the control to reload the current page. The type of reload depends on the value specified. If you call the method with the value, the latest version of the document is downloaded. If you use the value, the latest version is downloaded only if the current document has expired. If you use the value, the server sends a copy of the document stored in its own cache. + > [!NOTE] -> A document refresh simply reloads the current page, so the , , and events do not occur when you call the method. - +> A document refresh simply reloads the current page, so the , , and events do not occur when you call the method. + ]]> @@ -3475,22 +3475,22 @@ if the control does not display its dialog boxes; otherwise, . The default is . - control. This is useful when you use the control to add Web-based controls and scripting code to your application. It is less useful when you use the control as a generic browser. When you have finished debugging your application, set this property to `true` to suppress script errors. - + control. This is useful when you use the control to add Web-based controls and scripting code to your application. It is less useful when you use the control as a generic browser. When you have finished debugging your application, set this property to `true` to suppress script errors. + > [!NOTE] -> When is set to `true`, the control hides all its dialog boxes that originate from the underlying ActiveX control, not just script errors. Occasionally you might need to suppress script errors while displaying dialog boxes such as those used for browser security settings and user login. In this case, set to `false` and suppress script errors in a handler for the event. For more information, see the code example in this topic. - - - -## Examples - The following code example demonstrates how to suppress script errors without suppressing other dialog boxes. In the example, the property is set to `false` to ensure that dialog boxes are displayed. A handler for the event suppresses the error. This event is only accessible when a document is finished loading, so the handler is attached in a event handler. - +> When is set to `true`, the control hides all its dialog boxes that originate from the underlying ActiveX control, not just script errors. Occasionally you might need to suppress script errors while displaying dialog boxes such as those used for browser security settings and user login. In this case, set to `false` and suppress script errors in a handler for the event. For more information, see the code example in this topic. + + + +## Examples + The following code example demonstrates how to suppress script errors without suppressing other dialog boxes. In the example, the property is set to `false` to ensure that dialog boxes are displayed. A handler for the event suppresses the error. This event is only accessible when a document is finished loading, so the handler is attached in a event handler. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/.ctor/WebBrowserMisc.cs" id="Snippet40"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet40"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/WebBrowserMisc/vb/WebBrowserMisc.vb" id="Snippet40"::: + ]]> This instance is no longer valid. @@ -3532,11 +3532,11 @@ if scroll bars are displayed in the control; otherwise, . The default is true. - @@ -3567,18 +3567,18 @@ Opens the Internet Explorer **Page Setup** dialog box. - method or the method. To display the **Print Preview** dialog box, use the method. - -## Examples - The following code example demonstrates how to use the method to implement a **Page Setup** menu option that is similar to the one on the Internet Explorer **File** menu. This example requires that your form contains a menu with a menu item called `MenuItemFilePageSetup` and a control called `webBrowser1`. - + method or the method. To display the **Print Preview** dialog box, use the method. + +## Examples + The following code example demonstrates how to use the method to implement a **Page Setup** menu option that is similar to the one on the Internet Explorer **File** menu. This example requires that your form contains a menu with a menu item called `MenuItemFilePageSetup` and a control called `webBrowser1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet2"::: + ]]> @@ -3611,18 +3611,18 @@ Opens the Internet Explorer **Print** dialog box without setting header and footer values. - method. To display the **Print Preview** dialog box, use the method. - -## Examples - The following code example demonstrates how to use the method to implement a **Print** menu option that is similar to the one on the Internet Explorer **File** menu. This example requires that your form contains a menu with a menu item called `MenuItemFilePrint` and a control called `webBrowser1.` - + method. To display the **Print Preview** dialog box, use the method. + +## Examples + The following code example demonstrates how to use the method to implement a **Print** menu option that is similar to the one on the Internet Explorer **File** menu. This example requires that your form contains a menu with a menu item called `MenuItemFilePrint` and a control called `webBrowser1.` + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet3"::: + ]]> @@ -3655,20 +3655,20 @@ Opens the Internet Explorer **Print Preview** dialog box. - method. To print the current document, use the method or the method. - -## Examples - The following code example demonstrates how to use the method to implement a **Print Preview** menu option similar to the one on the Internet Explorer **File** menu. This example requires that your form contains a menu with a menu item called `MenuItemFilePrintPreview`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + method. To print the current document, use the method or the method. + +## Examples + The following code example demonstrates how to use the method to implement a **Print Preview** menu option similar to the one on the Internet Explorer **File** menu. This example requires that your form contains a menu with a menu item called `MenuItemFilePrintPreview`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet4"::: + ]]> @@ -3701,18 +3701,18 @@ Opens the Internet Explorer **Properties** dialog box for the current document. - method to implement a **Properties** menu option that is similar to the one on the Internet Explorer **File** menu. This example requires that your form contains a menu with a menu item called `MenuItemFileProperties` and a control called `webBrowser1.` - + method to implement a **Properties** menu option that is similar to the one on the Internet Explorer **File** menu. This example requires that your form contains a menu with a menu item called `MenuItemFileProperties` and a control called `webBrowser1.` + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet5"::: + ]]> @@ -3743,21 +3743,21 @@ Opens the Internet Explorer **Save Web Page** dialog box or the **Save** dialog box of the hosted document if it is not an HTML page. - [!NOTE] -> This method allows users to save only the contents of the document as it was originally loaded. Any modifications made to the document at run time through the property are not persisted. For information on retrieving the run-time modifications, see [How to: Access the HTML Source in the Managed HTML Document Object Model](/dotnet/framework/winforms/controls/how-to-access-the-html-source-in-the-managed-html-document-object-model). - -## Examples - The following code example demonstrates how to use the method to implement a **Save As** menu option that is similar to the one on the Internet Explorer **File** menu. This example requires that your form contains a menu with a menu item called `MenuItemFileSaveAs` and a control called `webBrowser1`. - +> This method allows users to save only the contents of the document as it was originally loaded. Any modifications made to the document at run time through the property are not persisted. For information on retrieving the run-time modifications, see [How to: Access the HTML Source in the Managed HTML Document Object Model](/dotnet/desktop/winforms/controls/how-to-access-the-html-source-in-the-managed-html-document-object-model). + +## Examples + The following code example demonstrates how to use the method to implement a **Save As** menu option that is similar to the one on the Internet Explorer **File** menu. This example requires that your form contains a menu with a menu item called `MenuItemFileSaveAs` and a control called `webBrowser1`. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet1"::: + ]]> @@ -3807,22 +3807,22 @@ Gets the status text of the control. The status text. - control in a status bar. The status text is a message that contains information such as the URL of a hyperlink when the mouse pointer hovers over it and the URL of the document currently being loaded. Handle the event to update the status bar when the value of the property changes. - - - -## Examples - The following code example demonstrates how to use the property to implement a status bar for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `StatusBar1`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + control in a status bar. The status text is a message that contains information such as the URL of a hyperlink when the mouse pointer hovers over it and the URL of the document currently being loaded. Handle the event to update the status bar when the value of the property changes. + + + +## Examples + The following code example demonstrates how to use the property to implement a status bar for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `StatusBar1`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet14"::: + ]]> This instance is no longer valid. @@ -3865,24 +3865,24 @@ Occurs when the property value changes. - property changes. - - For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates how to use a handler for the event to implement a status bar for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `StatusBar1`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + property changes. + + For more information about handling events, see [Handling and Raising Events](/dotnet/standard/events/). + + + +## Examples + The following code example demonstrates how to use a handler for the event to implement a status bar for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `StatusBar1`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet14"::: + ]]> @@ -3916,20 +3916,20 @@ Cancels any pending navigation and stops any dynamic page elements, such as background sounds and animations. - method to implement a **Stop** button that is similar to the one on the Internet Explorer **File** menu. - -## Examples - The following code example demonstrates how to use the method to implement a **Stop** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonStop`. - - For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/framework/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). - + method to implement a **Stop** button that is similar to the one on the Internet Explorer **File** menu. + +## Examples + The following code example demonstrates how to use the method to implement a **Stop** button for the control similar to the one in Internet Explorer. This example requires that your form contains a control called `webBrowser1` and a control called `ButtonStop`. + + For the complete code example, see [How to: Add Web Browser Capabilities to a Windows Forms Application](/dotnet/desktop/winforms/controls/how-to-add-web-browser-capabilities-to-a-windows-forms-application). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet9"::: + ]]> @@ -3980,25 +3980,25 @@ Gets or sets the URL of the current document. A representing the URL of the current document. - method and passing it the specified URL. - - The control maintains a history list of all the Web pages visited during a browsing session. When you set the property, the control navigates to the specified URL and adds it to the end of the history list. - - The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. - + method and passing it the specified URL. + + The control maintains a history list of all the Web pages visited during a browsing session. When you set the property, the control navigates to the specified URL and adds it to the end of the history list. + + The control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. Use the method to force the control to reload the current page by downloading it, ensuring that the control displays the latest version. + > [!NOTE] -> This property contains the URL of the current document, even if another document has been requested. If you set the value of this property and then immediately retrieve it again, the value retrieved may be different than the value set if the control has not had time to load the new document. You can retrieve the new value in a event handler. - -## Examples - The following code example demonstrates how to use the property to implement an address bar for the control. This example requires that your form contains a control called `webBrowser1`, a control called `TextBoxAddress`, and a control called `ButtonGo`. When you type a URL into the text box and press ENTER or click the **Go** button, the control navigates to the URL specified. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL. - +> This property contains the URL of the current document, even if another document has been requested. If you set the value of this property and then immediately retrieve it again, the value retrieved may be different than the value set if the control has not had time to load the new document. You can retrieve the new value in a event handler. + +## Examples + The following code example demonstrates how to use the property to implement an address bar for the control. This example requires that your form contains a control called `webBrowser1`, a control called `TextBoxAddress`, and a control called `ButtonGo`. When you type a URL into the text box and press ENTER or click the **Go** button, the control navigates to the URL specified. When you navigate by clicking a hyperlink, the text box automatically updates to display the current URL. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/CPP/form1.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ToolStripMenuItem/ShortcutKeys/form1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser/VB/form1.vb" id="Snippet6"::: + ]]> This instance is no longer valid. @@ -4054,11 +4054,11 @@ Gets the version of Internet Explorer installed. The version of Internet Explorer installed. - control is a managed wrapper around a component installed with Internet Explorer. Use this property to determine which version of Internet Explorer is installed. This is useful when your application uses a feature of Internet Explorer that is present only in certain versions. If the required version is not present on the local machine, you can provide alternative functionality or prompt the user to upgrade. - + control is a managed wrapper around a component installed with Internet Explorer. Use this property to determine which version of Internet Explorer is installed. This is useful when your application uses a feature of Internet Explorer that is present only in certain versions. If the required version is not present on the local machine, you can provide alternative functionality or prompt the user to upgrade. + ]]> @@ -4097,19 +4097,19 @@ if keyboard shortcuts are enabled within the control; otherwise, . The default is . - control. This is useful when you want to conceal the fact that you are using the control, for example to create a user interface that seamlessly combines DHTML-based controls with Windows Forms controls. - - You can disable other standard browser features by setting the and properties to `false`. - -## Examples - The following code example demonstrates how to use the property. - + control. This is useful when you want to conceal the fact that you are using the control, for example to create a user interface that seamlessly combines DHTML-based controls with Windows Forms controls. + + You can disable other standard browser features by setting the and properties to `false`. + +## Examples + The following code example demonstrates how to use the property. + :::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/WebBrowser/AllowWebBrowserDrop/form1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser.ObjectForScripting/vb/form1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.WebBrowser.ObjectForScripting/vb/form1.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Windows.Forms/WindowsFormsSection.xml b/xml/System.Windows.Forms/WindowsFormsSection.xml index d94f5caf2d7..5ae74da7a81 100644 --- a/xml/System.Windows.Forms/WindowsFormsSection.xml +++ b/xml/System.Windows.Forms/WindowsFormsSection.xml @@ -29,11 +29,11 @@ Defines a new for parsing application settings. This class cannot be inherited. - diff --git a/xml/System.Windows/ContentElement.xml b/xml/System.Windows/ContentElement.xml index 3f4f7fcc577..157730e3d0a 100644 --- a/xml/System.Windows/ContentElement.xml +++ b/xml/System.Windows/ContentElement.xml @@ -11915,7 +11915,7 @@ Note that by default a is not foc This `ShouldSerialize` method is provided because the property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are either developing a designer or developing your own control incorporating a . - For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/framework/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). + For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/desktop/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). ]]> @@ -11962,7 +11962,7 @@ Note that by default a is not foc This `ShouldSerialize` method is provided because the property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are either developing a designer or developing your own control incorporating a . - For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/framework/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). + For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/desktop/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). ]]> diff --git a/xml/System.Windows/UIElement.xml b/xml/System.Windows/UIElement.xml index 71dad0d6ccc..fc96c04f42a 100644 --- a/xml/System.Windows/UIElement.xml +++ b/xml/System.Windows/UIElement.xml @@ -14886,7 +14886,7 @@ For this call to be successful, some other element in the application needed to This `ShouldSerialize` method is provided because the property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are either developing a designer or developing your own control incorporating a . - For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/framework/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). + For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/desktop/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). ]]> @@ -14933,7 +14933,7 @@ For this call to be successful, some other element in the application needed to This `ShouldSerialize` method is provided because the property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are either developing a designer or developing your own control incorporating a . - For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/framework/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). + For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/desktop/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). ]]> diff --git a/xml/System.Windows/UIElement3D.xml b/xml/System.Windows/UIElement3D.xml index 3ad04cadfbc..d97a238936e 100644 --- a/xml/System.Windows/UIElement3D.xml +++ b/xml/System.Windows/UIElement3D.xml @@ -12075,7 +12075,7 @@ This `ShouldSerialize` method is provided because the property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are either developing a designer or developing your own control incorporating a . - For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/framework/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). + For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/desktop/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). ]]> @@ -12122,7 +12122,7 @@ This `ShouldSerialize` method is provided because the property does not have a simple default value. This method indicates whether the property has changed from its default value. You typically invoke this method if you are either developing a designer or developing your own control incorporating a . - For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/framework/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). + For more information, see [Defining Default Values with the ShouldSerialize and Reset Methods](/dotnet/desktop/winforms/controls/defining-default-values-with-the-shouldserialize-and-reset-methods). ]]> diff --git a/xml/System.Xml.Schema/ValidationEventArgs.xml b/xml/System.Xml.Schema/ValidationEventArgs.xml index 85829c5ec8e..11f40c0db17 100644 --- a/xml/System.Xml.Schema/ValidationEventArgs.xml +++ b/xml/System.Xml.Schema/ValidationEventArgs.xml @@ -54,11 +54,11 @@ Returns detailed information related to the . - method for the class. - + method for the class. + ]]> @@ -196,25 +196,24 @@ Gets the severity of the validation event. An value representing the severity of the validation event. - diff --git a/xml/System.Xml.Schema/XmlSchema.xml b/xml/System.Xml.Schema/XmlSchema.xml index 1bed338bba8..3aa973f5379 100644 --- a/xml/System.Xml.Schema/XmlSchema.xml +++ b/xml/System.Xml.Schema/XmlSchema.xml @@ -82,7 +82,6 @@ ## Examples The following example creates a schema definition. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchema Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchema/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchema Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/XmlSchemaAll.xml b/xml/System.Xml.Schema/XmlSchemaAll.xml index cb9e4d5eb96..30f830e5d48 100644 --- a/xml/System.Xml.Schema/XmlSchemaAll.xml +++ b/xml/System.Xml.Schema/XmlSchemaAll.xml @@ -50,24 +50,23 @@ Represents the World Wide Web Consortium (W3C) element (compositor). - class permits the elements in the group to appear (or not appear) in any order in the containing element. + + + +## Examples + The following example creates an `all` element. -## Remarks - The class permits the elements in the group to appear (or not appear) in any order in the containing element. - - - -## Examples - The following example creates an `all` element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaAll/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/VB/source.vb" id="Snippet1"::: - - The following XML file is generated for the preceding code example. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/VB/source.vb" id="Snippet1"::: + + The following XML file is generated for the preceding code example. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaAll Example/XML/source.xml" id="Snippet2"::: + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaAnnotation.xml b/xml/System.Xml.Schema/XmlSchemaAnnotation.xml index ad7b78c5c5e..40f9c1466c8 100644 --- a/xml/System.Xml.Schema/XmlSchemaAnnotation.xml +++ b/xml/System.Xml.Schema/XmlSchemaAnnotation.xml @@ -50,26 +50,25 @@ Represents the World Wide Web Consortium (W3C) element. - instances (information for applications) and instances (comments or text for humans). + + An annotation is used to store extra information about the schema or its elements. These notes are specified for human consumption, `xs:documentation`, or by software, `xs:appinfo`. Annotation can be the first element of most schema elements or anywhere under the schema element. + + + +## Examples + The following example creates the `annotation` element. -## Remarks - An `annotation` element can contain one or more instances (information for applications) and instances (comments or text for humans). - - An annotation is used to store extra information about the schema or its elements. These notes are specified for human consumption, `xs:documentation`, or by software, `xs:appinfo`. Annotation can be the first element of most schema elements or anywhere under the schema element. - - - -## Examples - The following example creates the `annotation` element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaAnnotation/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/VB/source.vb" id="Snippet1"::: - - The following XML file is generated for the preceding code example. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/VB/source.vb" id="Snippet1"::: + + The following XML file is generated for the preceding code example. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaAnnotation Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -224,11 +223,11 @@ Gets the collection that is used to store the and child elements. An of and child elements. - (information used by applications) or (comments or text used by humans). - + (information used by applications) or (comments or text used by humans). + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaAny.xml b/xml/System.Xml.Schema/XmlSchemaAny.xml index 36ccb8acad3..a8cfc652d64 100644 --- a/xml/System.Xml.Schema/XmlSchemaAny.xml +++ b/xml/System.Xml.Schema/XmlSchemaAny.xml @@ -50,24 +50,23 @@ Represents the World Wide Web Consortium (W3C) element. - @@ -169,19 +168,19 @@ Gets or sets the namespaces containing the elements that can be used. Namespaces for elements that are available for use. The default is . Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaAnyAttribute.xml b/xml/System.Xml.Schema/XmlSchemaAnyAttribute.xml index e66f85f9ca5..468da875653 100644 --- a/xml/System.Xml.Schema/XmlSchemaAnyAttribute.xml +++ b/xml/System.Xml.Schema/XmlSchemaAnyAttribute.xml @@ -50,24 +50,23 @@ Represents the World Wide Web Consortium (W3C) element. - @@ -169,19 +168,19 @@ Gets or sets the namespaces containing the attributes that can be used. Namespaces for attributes that are available for use. The default is . Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaAppInfo.xml b/xml/System.Xml.Schema/XmlSchemaAppInfo.xml index 45d178f8da2..c9ac0401886 100644 --- a/xml/System.Xml.Schema/XmlSchemaAppInfo.xml +++ b/xml/System.Xml.Schema/XmlSchemaAppInfo.xml @@ -50,24 +50,23 @@ Represents the World Wide Web Consortium (W3C) element. - @@ -229,11 +228,11 @@ Gets or sets the source of the application information. A Uniform Resource Identifier (URI) reference. The default is . Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaAttribute.xml b/xml/System.Xml.Schema/XmlSchemaAttribute.xml index 0c9725cc01a..b9f54576717 100644 --- a/xml/System.Xml.Schema/XmlSchemaAttribute.xml +++ b/xml/System.Xml.Schema/XmlSchemaAttribute.xml @@ -50,24 +50,23 @@ Represents the element from the XML Schema as specified by the World Wide Web Consortium (W3C). Attributes provide additional information for other document elements. The attribute tag is nested between the tags of a document's element for the schema. The XML document displays attributes as named items in the opening tag of an element. - @@ -158,11 +157,11 @@ Gets an object representing the type of the attribute based on the or of the attribute. An object. - @@ -225,14 +224,14 @@ Gets the common language runtime (CLR) object based on the or of the attribute that holds the post-compilation value of the property. The common runtime library (CLR) object that holds the post-compilation value of the property. - if the attribute has a built-in XML Schema type or if the attribute has a user-defined type. This property is a post-schema-validation infoset property. - + if the attribute has a built-in XML Schema type or if the attribute has a user-defined type. This property is a post-schema-validation infoset property. + > [!IMPORTANT] -> The property is obsolete in the 2.0 version of the .NET Framework and has been replaced by the property. - +> The property is obsolete in the 2.0 version of the .NET Framework and has been replaced by the property. + ]]> @@ -295,15 +294,15 @@ Gets or sets the default value for the attribute. The default value for the attribute. The default is a null reference. Optional. - @@ -366,13 +365,13 @@ Gets or sets the fixed value for the attribute. The fixed value for the attribute. The default is null. Optional. - @@ -490,13 +489,13 @@ Gets or sets the name of the attribute. The name of the attribute. - @@ -554,11 +553,11 @@ Gets the qualified name for the attribute. The post-compilation value of the property. - @@ -616,13 +615,13 @@ Gets or sets the name of an attribute declared in this schema (or another schema indicated by the specified namespace). The name of the attribute declared. - @@ -681,11 +680,11 @@ Gets or sets the attribute type to a simple type. The simple type defined in this schema. - @@ -743,13 +742,13 @@ Gets or sets the name of the simple type defined in this schema (or another schema indicated by the specified namespace). The name of the simple type. - properties cannot be set at the same time. The type must be a QName. The type can include a namespace prefix. - - Optional. - + properties cannot be set at the same time. The type must be a QName. The type can include a namespace prefix. + + Optional. + ]]> @@ -811,18 +810,18 @@ Gets or sets information about how the attribute is used. One of the following values: None, Prohibited, Optional, or Required. The default is Optional. Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaAttributeGroup.xml b/xml/System.Xml.Schema/XmlSchemaAttributeGroup.xml index 6633b5a9aa0..239af52157d 100644 --- a/xml/System.Xml.Schema/XmlSchemaAttributeGroup.xml +++ b/xml/System.Xml.Schema/XmlSchemaAttributeGroup.xml @@ -50,24 +50,23 @@ Represents the element from the XML Schema as specified by the World Wide Web Consortium (W3C). AttributesGroups provides a mechanism to group a set of attribute declarations so that they can be incorporated as a group into complex type definitions. - @@ -278,11 +277,11 @@ Gets or sets the name of the attribute group. The name of the attribute group. - diff --git a/xml/System.Xml.Schema/XmlSchemaChoice.xml b/xml/System.Xml.Schema/XmlSchemaChoice.xml index c97aa6caeb6..48e9b3bc46f 100644 --- a/xml/System.Xml.Schema/XmlSchemaChoice.xml +++ b/xml/System.Xml.Schema/XmlSchemaChoice.xml @@ -50,19 +50,18 @@ Represents the element (compositor) from the XML Schema as specified by the World Wide Web Consortium (W3C). The allows only one of its children to appear in an instance. - diff --git a/xml/System.Xml.Schema/XmlSchemaCollection.xml b/xml/System.Xml.Schema/XmlSchemaCollection.xml index 8f412e3fdf1..c733fae27a3 100644 --- a/xml/System.Xml.Schema/XmlSchemaCollection.xml +++ b/xml/System.Xml.Schema/XmlSchemaCollection.xml @@ -92,7 +92,6 @@ ## Examples The following example validates an XML document using the `XmlSchemaCollection`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Basic/CPP/aa.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Overview/aa.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Basic/VB/aa.vb" id="Snippet1"::: @@ -616,7 +615,6 @@ schemaColl.Add("urn:author", "names.xsd"); ## Examples The following example adds a schema to the collection. An is passed to the `Add` method that sets the necessary credentials required to access any external resources referenced in the schema. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaCollection.Add/CPP/schemacolladd.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Add/schemacolladd.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaCollection.Add/VB/schemacolladd.vb" id="Snippet1"::: @@ -781,7 +779,6 @@ schemaColl.Add("urn:author", "names.xsd"); ## Examples The following example checks to see if a schema is in the collection. If it is, it displays the schema. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Contains/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/VB/source.vb" id="Snippet1"::: @@ -1004,7 +1001,6 @@ schemaColl.Add("urn:author", "names.xsd"); ## Examples The following example displays each of the XML Schemas in the schema collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/GetEnumerator/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.GetEnumerator Example/VB/source.vb" id="Snippet1"::: @@ -1075,7 +1071,6 @@ schemaColl.Add("urn:author", "names.xsd"); ## Examples The following example checks to see if a schema is in the collection. If it is, it displays the schema. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/Contains/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaCollection.this Example/VB/source.vb" id="Snippet1"::: @@ -1449,7 +1444,6 @@ schemaColl.Add("urn:author", "names.xsd"); ## Examples The following example shows how to set an event handler to handle invalid XML Schemas. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchema.ValidationEventHandler/CPP/schemaevent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaCollection/ValidationEventHandler/schemaevent.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchema.ValidationEventHandler/VB/schemaevent.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/XmlSchemaCollectionEnumerator.xml b/xml/System.Xml.Schema/XmlSchemaCollectionEnumerator.xml index 1d6a94ed8dc..0f59d46291b 100644 --- a/xml/System.Xml.Schema/XmlSchemaCollectionEnumerator.xml +++ b/xml/System.Xml.Schema/XmlSchemaCollectionEnumerator.xml @@ -96,15 +96,14 @@ Gets the current in the collection. The current in the collection. - @@ -150,15 +149,14 @@ if the move was successful; if the enumerator has passed the end of the collection. - @@ -211,11 +209,11 @@ For a description of this member, see . The current node. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -263,11 +261,11 @@ For a description of this member, see . The next node. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -314,11 +312,11 @@ For a description of this member, see . - instance is cast to an interface. - + instance is cast to an interface. + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaComplexContent.xml b/xml/System.Xml.Schema/XmlSchemaComplexContent.xml index 6ee235eb17c..395065810d0 100644 --- a/xml/System.Xml.Schema/XmlSchemaComplexContent.xml +++ b/xml/System.Xml.Schema/XmlSchemaComplexContent.xml @@ -50,19 +50,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class represents the complex content model for complex types. It contains extensions or restrictions on a complex type that has either only elements or mixed content. - @@ -219,11 +218,11 @@ Gets or sets information that determines if the type has a mixed content model. If this property is , character data is allowed to appear between the child elements of the complex type (mixed content model). The default is . Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaComplexContentRestriction.xml b/xml/System.Xml.Schema/XmlSchemaComplexContentRestriction.xml index 845e205bc1c..db2f27c4f59 100644 --- a/xml/System.Xml.Schema/XmlSchemaComplexContentRestriction.xml +++ b/xml/System.Xml.Schema/XmlSchemaComplexContentRestriction.xml @@ -50,19 +50,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class is for complex types with a complex content model derived by restriction. It restricts the contents of the complex type to a subset of the inherited complex type. - @@ -272,11 +271,11 @@ Gets or sets the name of a complex type from which this type is derived by restriction. The name of the complex type from which this type is derived by restriction. - diff --git a/xml/System.Xml.Schema/XmlSchemaComplexType.xml b/xml/System.Xml.Schema/XmlSchemaComplexType.xml index d0de2b19018..92fbafa7fea 100644 --- a/xml/System.Xml.Schema/XmlSchemaComplexType.xml +++ b/xml/System.Xml.Schema/XmlSchemaComplexType.xml @@ -61,7 +61,6 @@ ## Examples The following example creates a `complexType` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaComplexType Example/CPP/complextype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaComplexType/Overview/complextype.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaComplexType Example/VB/complextype.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/XmlSchemaDatatype.xml b/xml/System.Xml.Schema/XmlSchemaDatatype.xml index 2aae8eb426f..afd49502c0f 100644 --- a/xml/System.Xml.Schema/XmlSchemaDatatype.xml +++ b/xml/System.Xml.Schema/XmlSchemaDatatype.xml @@ -55,7 +55,6 @@ ## Examples The following example shows use of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/CPP/datatype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaDatatype/Overview/datatype.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/VB/datatype.vb" id="Snippet1"::: @@ -360,7 +359,6 @@ ## Examples The following example retrieves the `LotteryNumber` simple type from the example.xsd file as an and then validates the `string` value of `5` using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/CPP/datatype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaDatatype/Overview/datatype.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaDatatype Example/VB/datatype.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/XmlSchemaDocumentation.xml b/xml/System.Xml.Schema/XmlSchemaDocumentation.xml index a22dca1b74f..9fb60372dcc 100644 --- a/xml/System.Xml.Schema/XmlSchemaDocumentation.xml +++ b/xml/System.Xml.Schema/XmlSchemaDocumentation.xml @@ -50,24 +50,23 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class specifies information to be read or used by humans within an . - @@ -281,13 +280,13 @@ Gets or sets the Uniform Resource Identifier (URI) source of the information. A URI reference. The default is . Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaElement.xml b/xml/System.Xml.Schema/XmlSchemaElement.xml index a6879630db7..b357e2361d5 100644 --- a/xml/System.Xml.Schema/XmlSchemaElement.xml +++ b/xml/System.Xml.Schema/XmlSchemaElement.xml @@ -50,28 +50,27 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class is the base class for all particle types and is used to describe an element in an XML document. - [!IMPORTANT] > - Do not use schemas from unknown or untrusted sources or locations. Doing so will compromise the security of your code. > - XML schemas (including inline schemas) are inherently vulnerable to denial of service attacks; do not accept them in untrusted scenarios. > - Schema validation error messages and exceptions may expose sensitive information about the content model or URI paths to the schema file. Be careful not to expose this information to untrusted callers. + + + +## Examples + The following example creates the `element` element. - - -## Examples - The following example creates the `element` element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/CPP/element.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaElement/Overview/element.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/VB/element.vb" id="Snippet1"::: - - The following XML file is used for the preceding code example. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/XML/example.xsd" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/VB/element.vb" id="Snippet1"::: + + The following XML file is used for the preceding code example. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic Webdata XmlSchemaElement Example/XML/example.xsd" id="Snippet2"::: + ]]> @@ -170,22 +169,22 @@ Gets or sets a derivation. The attribute used to block a type derivation. Default value is . Optional. - @@ -239,21 +238,21 @@ Gets the post-compilation value of the property. The post-compilation value of the property. The default is the value on the element. - @@ -315,11 +314,11 @@ Gets the collection of constraints on the element. The collection of constraints. - @@ -382,11 +381,11 @@ Gets or sets the default value of the element if its content is a simple type or content of the element is . The default value for the element. The default is a null reference. Optional. - @@ -440,11 +439,11 @@ Gets an object representing the type of the element based on the or values of the element. An object. - @@ -507,16 +506,16 @@ Gets a common language runtime (CLR) object based on the or of the element, which holds the post-compilation value of the property. The common language runtime object. The post-compilation value of the property. - if the element has a built-in XML Schema type or if the element has a user-defined type. - - This property is a post-schema-validation infoset property. - + if the element has a built-in XML Schema type or if the element has a user-defined type. + + This property is a post-schema-validation infoset property. + > [!IMPORTANT] -> The property is obsolete in the 2.0 version of the .NET Framework and has been replaced by the property. - +> The property is obsolete in the 2.0 version of the .NET Framework and has been replaced by the property. + ]]> @@ -578,21 +577,21 @@ Gets or sets the property to indicate that no further derivations are allowed. The property. The default is . Optional. - . `Substitution`, `List`, and `Union` derivation methods are not allowed for this property. - + . `Substitution`, `List`, and `Union` derivation methods are not allowed for this property. + ]]> @@ -646,20 +645,20 @@ Gets the post-compilation value of the property. The post-compilation value of the property. Default value is the value on the element. - @@ -722,11 +721,11 @@ Gets or sets the fixed value. The fixed value that is predetermined and unchangeable. The default is a null reference. Optional. - @@ -788,18 +787,18 @@ Gets or sets the form for the element. The form for the element. The default is the value. Optional. - @@ -912,11 +911,11 @@ Gets or sets information that indicates if can occur in the instance data. Indicates if an explicit nil value can be assigned to the element. If nillable is , this enables an instance of the element to have the attribute set to . The attribute is defined as part of the XML Schema namespace for instances. The default is . Optional. - @@ -979,11 +978,11 @@ Gets or sets the name of the element. The name of the element. The default is . - @@ -1041,11 +1040,11 @@ Gets the actual qualified name for the given element. The qualified name of the element. The post-compilation value of the property. - is the name that a `ref` attribute refers to. The qualified name consists of the NCName of the element. For example, element name = "NCName", and the prefix used to describe the `targetNamespace` of the schema. This property holds the post-compilation value of the `QualifiedName` property. - + is the name that a `ref` attribute refers to. The qualified name consists of the NCName of the element. For example, element name = "NCName", and the prefix used to describe the `targetNamespace` of the schema. This property holds the post-compilation value of the `QualifiedName` property. + ]]> @@ -1103,13 +1102,13 @@ Gets or sets the reference name of an element declared in this schema (or another schema indicated by the specified namespace). The reference name of the element. - @@ -1172,11 +1171,11 @@ Gets or sets the type of the element. This can either be a complex type or a simple type. The type of the element. - @@ -1289,13 +1288,13 @@ Gets or sets the name of an element that is being substituted by this element. The qualified name of an element that is being substituted by this element. Optional. - diff --git a/xml/System.Xml.Schema/XmlSchemaEnumerationFacet.xml b/xml/System.Xml.Schema/XmlSchemaEnumerationFacet.xml index 1282db15532..56da6396858 100644 --- a/xml/System.Xml.Schema/XmlSchemaEnumerationFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaEnumerationFacet.xml @@ -44,19 +44,18 @@ Represents the facet from XML Schema as specified by the World Wide Web Consortium (W3C). This class specifies a list of valid values for a simpleType element. Declaration is contained within a declaration. - diff --git a/xml/System.Xml.Schema/XmlSchemaException.xml b/xml/System.Xml.Schema/XmlSchemaException.xml index cb49ed69fe4..556233328be 100644 --- a/xml/System.Xml.Schema/XmlSchemaException.xml +++ b/xml/System.Xml.Schema/XmlSchemaException.xml @@ -55,22 +55,21 @@ Returns detailed information about the schema exception. - [!IMPORTANT] -> The class may contain sensitive information that should not be exposed in untrusted scenarios. For example, the property returns the URI path to the schema file that caused the exception. The property should not be exposed in untrusted scenarios. Exceptions should be properly handled so that this sensitive information is not exposed in untrusted scenarios. - - +> The class may contain sensitive information that should not be exposed in untrusted scenarios. For example, the property returns the URI path to the schema file that caused the exception. The property should not be exposed in untrusted scenarios. Exceptions should be properly handled so that this sensitive information is not exposed in untrusted scenarios. + + + +## Examples + The following example shows the use of the `XmlSchemaException` class. -## Examples - The following example shows the use of the `XmlSchemaException` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaException Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaException/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaException Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaException Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -567,11 +566,11 @@ The that produced the . A valid object instance represents a structural validation error in the XML Schema Object Model (SOM). - @@ -622,13 +621,13 @@ Gets the Uniform Resource Identifier (URI) location of the schema that caused the exception. The URI location of the schema that caused the exception. - [!IMPORTANT] -> The property returns the URI path to the schema file that caused the exception. The property should not be exposed in untrusted scenarios. - +> The property returns the URI path to the schema file that caused the exception. The property should not be exposed in untrusted scenarios. + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaFractionDigitsFacet.xml b/xml/System.Xml.Schema/XmlSchemaFractionDigitsFacet.xml index fac6149ebfb..852b2fdf845 100644 --- a/xml/System.Xml.Schema/XmlSchemaFractionDigitsFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaFractionDigitsFacet.xml @@ -44,19 +44,18 @@ Specifies a restriction on the number of digits that can be entered for the fraction value of a simpleType element. The value of fractionDigits must be a positive integer. Represents the World Wide Web Consortium (W3C) facet. - diff --git a/xml/System.Xml.Schema/XmlSchemaGroup.xml b/xml/System.Xml.Schema/XmlSchemaGroup.xml index 3ace44e5dcf..0b50537b53e 100644 --- a/xml/System.Xml.Schema/XmlSchemaGroup.xml +++ b/xml/System.Xml.Schema/XmlSchemaGroup.xml @@ -50,19 +50,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class defines groups at the level that are referenced from the complex types. It groups a set of element declarations so that they can be incorporated as a group into complex type definitions. - @@ -158,11 +157,11 @@ Gets or sets the name of the schema group. The name of the schema group. - diff --git a/xml/System.Xml.Schema/XmlSchemaInclude.xml b/xml/System.Xml.Schema/XmlSchemaInclude.xml index ada9e6e49a5..1960add284a 100644 --- a/xml/System.Xml.Schema/XmlSchemaInclude.xml +++ b/xml/System.Xml.Schema/XmlSchemaInclude.xml @@ -50,32 +50,31 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class is used to include declarations and definitions from an external schema. The included declarations and definitions are then available for processing in the containing schema. - diff --git a/xml/System.Xml.Schema/XmlSchemaInference.xml b/xml/System.Xml.Schema/XmlSchemaInference.xml index cae81f70c65..9a6918b2737 100644 --- a/xml/System.Xml.Schema/XmlSchemaInference.xml +++ b/xml/System.Xml.Schema/XmlSchemaInference.xml @@ -43,36 +43,35 @@ Infers an XML Schema Definition Language (XSD) schema from an XML document. The class cannot be inherited. - [!IMPORTANT] -> - Do not use schemas from unknown or untrusted sources or locations. Doing so will compromise the security of your code. -> - XML schemas (including inline schemas) are inherently vulnerable to denial of service attacks; do not accept them in untrusted scenarios. -> - Schema validation error messages and exceptions may expose sensitive information about the content model or URI paths to the schema file. Be careful not to expose this information to untrusted callers. - - The class in the namespace allows you to infer an XML Schema Definition Language (XSD) schema from the structure of an XML document. The class outputs an XML schema that can validate the XML document. - - The class supports the W3C XML and XML Schemas standards. It can be used to infer a new schema or to refine an existing schema. - - - -## Examples - This example takes an XML file as input, and generates a schema that can validate the example XML. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp" id="Snippet1"::: +> - Do not use schemas from unknown or untrusted sources or locations. Doing so will compromise the security of your code. +> - XML schemas (including inline schemas) are inherently vulnerable to denial of service attacks; do not accept them in untrusted scenarios. +> - Schema validation error messages and exceptions may expose sensitive information about the content model or URI paths to the schema file. Be careful not to expose this information to untrusted callers. + + The class in the namespace allows you to infer an XML Schema Definition Language (XSD) schema from the structure of an XML document. The class outputs an XML schema that can validate the XML document. + + The class supports the W3C XML and XML Schemas standards. It can be used to infer a new schema or to refine an existing schema. + + + +## Examples + This example takes an XML file as input, and generates a schema that can validate the example XML. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaInference/Overview/XmlSchemaInferenceExamples.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet1"::: - - The following is the input XML file. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xml" id="Snippet5"::: - - The following is the schema inferred from the XML document. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xsd" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet1"::: + + The following is the input XML file. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xml" id="Snippet5"::: + + The following is the schema inferred from the XML document. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xsd" id="Snippet6"::: + ]]> @@ -165,36 +164,35 @@ Infers an XML Schema Definition Language (XSD) schema from the XML document contained in the object specified. An object containing the inferred schemas. - method infers one or more W3C XML Schema Definition Language (XSD) schemas from the XML instance document contained in the object specified. If the XML document contains elements and attributes from multiple namespaces, then multiple schemas are generated: one for each namespace used in the document. The primary schema is the schema that can validate the entire XML document, and its target namespace is the same as the namespace of the document element of the XML document. - - The following are important notes to consider when using the method. - -- The method ignores any `xsi:type`, `xsi:schemaLocation`, or `xsi:noNamespaceSchemaLocation` attributes in the XML document. - -- If the object is typed, the type information it contains is ignored. - -- If the object is positioned on an element that is not the root element of the XML document, a schema is inferred for only that element. If the object is not positioned on an element, the method is called on the parameter until an element is encountered (for example, when is ). At this point, the inference process starts from that element. If no element is encountered until the end of the document, an is thrown. - - - -## Examples - This example takes an XML file as input, and generates a schema that can validate the example XML. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp" id="Snippet1"::: + method infers one or more W3C XML Schema Definition Language (XSD) schemas from the XML instance document contained in the object specified. If the XML document contains elements and attributes from multiple namespaces, then multiple schemas are generated: one for each namespace used in the document. The primary schema is the schema that can validate the entire XML document, and its target namespace is the same as the namespace of the document element of the XML document. + + The following are important notes to consider when using the method. + +- The method ignores any `xsi:type`, `xsi:schemaLocation`, or `xsi:noNamespaceSchemaLocation` attributes in the XML document. + +- If the object is typed, the type information it contains is ignored. + +- If the object is positioned on an element that is not the root element of the XML document, a schema is inferred for only that element. If the object is not positioned on an element, the method is called on the parameter until an element is encountered (for example, when is ). At this point, the inference process starts from that element. If no element is encountered until the end of the document, an is thrown. + + + +## Examples + This example takes an XML file as input, and generates a schema that can validate the example XML. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaInference/Overview/XmlSchemaInferenceExamples.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet1"::: - - The following is the input XML file. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xml" id="Snippet5"::: - - The following is the schema inferred from the XML document. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xsd" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet1"::: + + The following is the input XML file. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xml" id="Snippet5"::: + + The following is the schema inferred from the XML document. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/contosoBooks.xsd" id="Snippet6"::: + ]]> The XML document is not well-formed. @@ -245,48 +243,47 @@ Infers an XML Schema Definition Language (XSD) schema from the XML document contained in the object specified, and refines the inferred schema using an existing schema in the object specified with the same target namespace. An object containing the inferred schemas. - method infers one or more W3C XML Schema Definition Language (XSD) schemas from the XML instance document contained in the object specified. If the XML document contains elements and attributes from multiple namespaces, multiple schemas are generated: one for each namespace used in the document. The primary schema is the schema that can validate the entire XML document, and its target namespace is the same as the namespace of the document element of the XML document. - - The following are important notes to consider when using the method. - -- The method ignores any `xsi:type`, `xsi:schemaLocation`, or `xsi:noNamespaceSchemaLocation` attributes in the XML document. - -- If the object is typed, the type information it contains is ignored. - -- If the object is positioned on an element that is not the root element of the XML document, a schema is inferred for only that element. If the object is not positioned on an element, the method is called on the parameter until an element is encountered (for example, when is ). At this point, the inference process starts from that element. If no element is encountered until the end of the document, an is thrown. - -- If an object is passed as a parameter and the element upon which the object is positioned is defined in one of the schemas in the , the inferred schema is used to refine an existing schema in the parameter with the same target namespace; otherwise, a new schema is inferred for the namespace. - - - -## Examples - The following example code takes XML document 1 as an input and generates a schema that can validate XML document 1. The example code then takes XML document 2 and refines the schema generated from XML document 1, based on the changes found in XML document 2. - - The following is XML document 1. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/item1.xml" id="Snippet13"::: - - The following is XML document 2. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/item2.xml" id="Snippet14"::: - - The following example code infers a schema from the first XML document contained in `reader`, and then refines the inferred schema with the changes found in the second XML document contained in `reader1`. The example code uses the first overloaded method to infer the schema, and the second overloaded method to refine the existing schema in the object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp" id="Snippet4"::: + method infers one or more W3C XML Schema Definition Language (XSD) schemas from the XML instance document contained in the object specified. If the XML document contains elements and attributes from multiple namespaces, multiple schemas are generated: one for each namespace used in the document. The primary schema is the schema that can validate the entire XML document, and its target namespace is the same as the namespace of the document element of the XML document. + + The following are important notes to consider when using the method. + +- The method ignores any `xsi:type`, `xsi:schemaLocation`, or `xsi:noNamespaceSchemaLocation` attributes in the XML document. + +- If the object is typed, the type information it contains is ignored. + +- If the object is positioned on an element that is not the root element of the XML document, a schema is inferred for only that element. If the object is not positioned on an element, the method is called on the parameter until an element is encountered (for example, when is ). At this point, the inference process starts from that element. If no element is encountered until the end of the document, an is thrown. + +- If an object is passed as a parameter and the element upon which the object is positioned is defined in one of the schemas in the , the inferred schema is used to refine an existing schema in the parameter with the same target namespace; otherwise, a new schema is inferred for the namespace. + + + +## Examples + The following example code takes XML document 1 as an input and generates a schema that can validate XML document 1. The example code then takes XML document 2 and refines the schema generated from XML document 1, based on the changes found in XML document 2. + + The following is XML document 1. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/item1.xml" id="Snippet13"::: + + The following is XML document 2. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/item2.xml" id="Snippet14"::: + + The following example code infers a schema from the first XML document contained in `reader`, and then refines the inferred schema with the changes found in the second XML document contained in `reader1`. The example code uses the first overloaded method to infer the schema, and the second overloaded method to refine the existing schema in the object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaInference/Overview/XmlSchemaInferenceExamples.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet4"::: - - The following schema is the schema inferred from XML document 1. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/InferSchema1.xml" id="Snippet15"::: - - The following schema is the refined version of the schema above, based on XML document 2. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/InferSchema2.xml" id="Snippet16"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet4"::: + + The following schema is the schema inferred from XML document 1. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/InferSchema1.xml" id="Snippet15"::: + + The following schema is the refined version of the schema above, based on XML document 2. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/InferSchema2.xml" id="Snippet16"::: + ]]> The XML document is not well-formed. @@ -341,36 +338,35 @@ Gets or sets the value that affects schema occurrence declarations inferred from the XML document. An object. - property is set to , the first time elements are encountered in the XML document, the schema declaration is inferred as `minOccurs="1"`. When attributes are encountered, the schema declaration is inferred as `use="required"`. - - If the property is set to , element schema declarations are inferred as `minOccurs="0"`, and attribute schema declarations are inferred as `use="optional"`. - - The default value of the property is . - - - -## Examples - This example illustrates how occurrence is affected by the property. The example code infers occurrence from an XML file in two different ways: relaxed and restricted. The following is the example XML file. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence1.xml" id="Snippet7"::: - - The following example code instructs the class to infer occurrence of elements and attributes in a relaxed way. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp" id="Snippet2"::: + property is set to , the first time elements are encountered in the XML document, the schema declaration is inferred as `minOccurs="1"`. When attributes are encountered, the schema declaration is inferred as `use="required"`. + + If the property is set to , element schema declarations are inferred as `minOccurs="0"`, and attribute schema declarations are inferred as `use="optional"`. + + The default value of the property is . + + + +## Examples + This example illustrates how occurrence is affected by the property. The example code infers occurrence from an XML file in two different ways: relaxed and restricted. The following is the example XML file. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence1.xml" id="Snippet7"::: + + The following example code instructs the class to infer occurrence of elements and attributes in a relaxed way. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaInference/Overview/XmlSchemaInferenceExamples.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet2"::: - - Because the property was set to , the following schema was generated. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence2.xml" id="Snippet8"::: - - In the example code above, if the property was not set to , the class would have defaulted to and generated the following schema. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence3.xml" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet2"::: + + Because the property was set to , the following schema was generated. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence2.xml" id="Snippet8"::: + + In the example code above, if the property was not set to , the class would have defaulted to and generated the following schema. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/Occurrence3.xml" id="Snippet9"::: + ]]> @@ -423,34 +419,33 @@ Gets or sets the value that affects types inferred from the XML document. An object. - property is set to , the inferred type of elements and attributes in the XML document with simple content is always `xs:string`. If the property is set to , more specific types are inferred, such as `xs:date`, `xs:decimal`, `xs:unsignedByte`, and so on. - - The default value of the property is . - - - -## Examples - This example illustrates how type inference is affected by the property. The example code infers types from an XML file in two different ways: relaxed and restricted. The following is the example XML file. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference1.xml" id="Snippet10"::: - - The following example code instructs the class to infer `xs:string` for elements and attributes with simple content. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaInferenceExamples/CPP/XmlSchemaInferenceExamples.cpp" id="Snippet3"::: + property is set to , the inferred type of elements and attributes in the XML document with simple content is always `xs:string`. If the property is set to , more specific types are inferred, such as `xs:date`, `xs:decimal`, `xs:unsignedByte`, and so on. + + The default value of the property is . + + + +## Examples + This example illustrates how type inference is affected by the property. The example code infers types from an XML file in two different ways: relaxed and restricted. The following is the example XML file. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference1.xml" id="Snippet10"::: + + The following example code instructs the class to infer `xs:string` for elements and attributes with simple content. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaInference/Overview/XmlSchemaInferenceExamples.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet3"::: - - Because the property was set to , the following schema was generated. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference2.xml" id="Snippet11"::: - - In the example code above, if the property was not set to , the class would have defaulted to and generated the following schema. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference3.xml" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaInferenceExamples/VB/XmlSchemaInferenceExamples.vb" id="Snippet3"::: + + Because the property was set to , the following schema was generated. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference2.xml" id="Snippet11"::: + + In the example code above, if the property was not set to , the class would have defaulted to and generated the following schema. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlSchemaInferenceExamples/XML/TypeInference3.xml" id="Snippet12"::: + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaKeyref.xml b/xml/System.Xml.Schema/XmlSchemaKeyref.xml index bec03633cb6..e8a07349cd8 100644 --- a/xml/System.Xml.Schema/XmlSchemaKeyref.xml +++ b/xml/System.Xml.Schema/XmlSchemaKeyref.xml @@ -50,24 +50,23 @@ This class represents the element from XMLSchema as specified by the World Wide Web Consortium (W3C). - @@ -158,11 +157,11 @@ Gets or sets the name of the key that this constraint refers to in another simple or complex type. The QName of the key that this constraint refers to. - diff --git a/xml/System.Xml.Schema/XmlSchemaLengthFacet.xml b/xml/System.Xml.Schema/XmlSchemaLengthFacet.xml index 203f7dd1d73..f2f0d3b46eb 100644 --- a/xml/System.Xml.Schema/XmlSchemaLengthFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaLengthFacet.xml @@ -44,19 +44,18 @@ Represents the facet from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the length of a element on the data type. - diff --git a/xml/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.xml b/xml/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.xml index f6b44e9f3fb..38151274f1d 100644 --- a/xml/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMaxExclusiveFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the maximum value of a element. The element value must be less than the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.xml b/xml/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.xml index 8be1307f374..3f92fbf8451 100644 --- a/xml/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMaxInclusiveFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the maximum value of a element. The element value must be less than or equal to the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaMaxLengthFacet.xml b/xml/System.Xml.Schema/XmlSchemaMaxLengthFacet.xml index 4c7ced8b3af..70db5b41572 100644 --- a/xml/System.Xml.Schema/XmlSchemaMaxLengthFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMaxLengthFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the maximum length of the data value of a element. The length must be less than the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaMinExclusiveFacet.xml b/xml/System.Xml.Schema/XmlSchemaMinExclusiveFacet.xml index 91ea6a3fde4..4b80b2a11ba 100644 --- a/xml/System.Xml.Schema/XmlSchemaMinExclusiveFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMinExclusiveFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the minimum value of a element. The element value must be greater than the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaMinInclusiveFacet.xml b/xml/System.Xml.Schema/XmlSchemaMinInclusiveFacet.xml index 67172de5e26..6afab4dcfe2 100644 --- a/xml/System.Xml.Schema/XmlSchemaMinInclusiveFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMinInclusiveFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the minimum value of a simpleType element. The element value must be greater than or equal to the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaMinLengthFacet.xml b/xml/System.Xml.Schema/XmlSchemaMinLengthFacet.xml index 624b1302934..b3ac2f1caf4 100644 --- a/xml/System.Xml.Schema/XmlSchemaMinLengthFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaMinLengthFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the minimum length of the data value of a element. The length must be greater than the value of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaNotation.xml b/xml/System.Xml.Schema/XmlSchemaNotation.xml index ee99342a381..2e01ef0e61a 100644 --- a/xml/System.Xml.Schema/XmlSchemaNotation.xml +++ b/xml/System.Xml.Schema/XmlSchemaNotation.xml @@ -50,19 +50,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). An XML Schema declaration is a reconstruction of declarations. The purpose of notations is to describe the format of non-XML data within an XML document. - diff --git a/xml/System.Xml.Schema/XmlSchemaObject.xml b/xml/System.Xml.Schema/XmlSchemaObject.xml index fa883f92b7d..c95bc5905e3 100644 --- a/xml/System.Xml.Schema/XmlSchemaObject.xml +++ b/xml/System.Xml.Schema/XmlSchemaObject.xml @@ -50,19 +50,18 @@ Represents the root class for the Xml schema object model hierarchy and serves as a base class for classes such as the class. - @@ -108,11 +107,11 @@ Initializes a new instance of the class. - @@ -170,11 +169,11 @@ Gets or sets the line number in the file to which the element refers. The line number. - for error handling. - + for error handling. + ]]> @@ -232,11 +231,11 @@ Gets or sets the line position in the file to which the element refers. The line position. - for error handling. - + for error handling. + ]]> @@ -294,38 +293,37 @@ Gets or sets the to use with this schema object. The property for the schema object. - property to change namespace prefixes in a schema. For example, you can change the prefix used by a schema for the W3C XML Schema namespace from xs to xsd as illustrated in the following example. - -```vb -Dim namespaces As XmlSerializerNamespaces = New XmlSerializerNamespaces() -namespaces.Add("myChangedPrefix", "myImportNamespace"); -s.Namespaces = namespaces; -``` - -```csharp -XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(); -namespaces.Add("myChangedPrefix", "myImportNamespace"); -s.Namespaces = namespaces; -``` - - - -## Examples - In the following example, the prefix myImpPrefix is added at the schema element level. The prefix is then used to qualify definitions that are imported from myImportNamespace. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/CPP/namespaces.cpp" id="Snippet1"::: + property to change namespace prefixes in a schema. For example, you can change the prefix used by a schema for the W3C XML Schema namespace from xs to xsd as illustrated in the following example. + +```vb +Dim namespaces As XmlSerializerNamespaces = New XmlSerializerNamespaces() +namespaces.Add("myChangedPrefix", "myImportNamespace"); +s.Namespaces = namespaces; +``` + +```csharp +XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(); +namespaces.Add("myChangedPrefix", "myImportNamespace"); +s.Namespaces = namespaces; +``` + + + +## Examples + In the following example, the prefix myImpPrefix is added at the schema element level. The prefix is then used to qualify definitions that are imported from myImportNamespace. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaObject/Namespaces/namespaces.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/VB/namespaces.vb" id="Snippet1"::: - - The example produces the following XML. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/XML/example.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/VB/namespaces.vb" id="Snippet1"::: + + The example produces the following XML. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaObject.Namespaces Example/XML/example.xml" id="Snippet2"::: + ]]> @@ -439,11 +437,11 @@ s.Namespaces = namespaces; Gets or sets the source location for the file that loaded the schema. The source location (URI) for the file. - diff --git a/xml/System.Xml.Schema/XmlSchemaPatternFacet.xml b/xml/System.Xml.Schema/XmlSchemaPatternFacet.xml index 9ea16e71646..b74b949f371 100644 --- a/xml/System.Xml.Schema/XmlSchemaPatternFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaPatternFacet.xml @@ -44,19 +44,18 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to specify a restriction on the value entered for a element. - diff --git a/xml/System.Xml.Schema/XmlSchemaSequence.xml b/xml/System.Xml.Schema/XmlSchemaSequence.xml index 27e1763caeb..55fae32d4c4 100644 --- a/xml/System.Xml.Schema/XmlSchemaSequence.xml +++ b/xml/System.Xml.Schema/XmlSchemaSequence.xml @@ -50,19 +50,18 @@ Represents the element (compositor) from the XML Schema as specified by the World Wide Web Consortium (W3C). The requires the elements in the group to appear in the specified sequence within the containing element. - diff --git a/xml/System.Xml.Schema/XmlSchemaSet.xml b/xml/System.Xml.Schema/XmlSchemaSet.xml index 3183460fe49..04de7a9187f 100644 --- a/xml/System.Xml.Schema/XmlSchemaSet.xml +++ b/xml/System.Xml.Schema/XmlSchemaSet.xml @@ -1710,7 +1710,6 @@ foreach (XmlSchema schema in schemaSet.Schemas("http://www.contoso.com/books")) ## Examples The following code example illustrates adding a to capture errors and warnings when validating an XML document against a schema. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaSetOverall Example/CPP/xmlschemasetexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlReaderSettings/Schemas/xmlschemasetexample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaSetOverall Example/VB/xmlschemasetexample.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Schema/XmlSchemaSimpleContent.xml b/xml/System.Xml.Schema/XmlSchemaSimpleContent.xml index 88024bf014f..d82f13c7fb0 100644 --- a/xml/System.Xml.Schema/XmlSchemaSimpleContent.xml +++ b/xml/System.Xml.Schema/XmlSchemaSimpleContent.xml @@ -50,24 +50,23 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class is for simple and complex types with simple content model. - is used to indicate that the content model of the new type contains only character data and no elements. It does this through or . + + + +## Examples + The following example shows the `XmlSchemaSimpleContent` class. -## Remarks - is used to indicate that the content model of the new type contains only character data and no elements. It does this through or . - - - -## Examples - The following example shows the `XmlSchemaSimpleContent` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaSimpleContent/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/VB/source.vb" id="Snippet1"::: - - The following XML file is generated for the preceding code example. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/VB/source.vb" id="Snippet1"::: + + The following XML file is generated for the preceding code example. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlSchemaSimpleContent Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -173,35 +172,35 @@ Gets one of the or . The content contained within the or class. - - - - - - - - - - - - - - - - -``` - + + + + + + + + + + + + + + + + +``` + ]]> diff --git a/xml/System.Xml.Schema/XmlSchemaSimpleType.xml b/xml/System.Xml.Schema/XmlSchemaSimpleType.xml index 00fbf4fc647..e0c3b29d311 100644 --- a/xml/System.Xml.Schema/XmlSchemaSimpleType.xml +++ b/xml/System.Xml.Schema/XmlSchemaSimpleType.xml @@ -50,24 +50,23 @@ Represents the element for simple content from XML Schema as specified by the World Wide Web Consortium (W3C). This class defines a simple type. Simple types can specify information and constraints for the value of attributes or elements with text-only content. - @@ -177,17 +176,17 @@ Gets or sets one of , , or . One of , , or . - diff --git a/xml/System.Xml.Schema/XmlSchemaSimpleTypeUnion.xml b/xml/System.Xml.Schema/XmlSchemaSimpleTypeUnion.xml index f52f45243d2..4f9aae7aea6 100644 --- a/xml/System.Xml.Schema/XmlSchemaSimpleTypeUnion.xml +++ b/xml/System.Xml.Schema/XmlSchemaSimpleTypeUnion.xml @@ -50,24 +50,23 @@ Represents the element for simple types from XML Schema as specified by the World Wide Web Consortium (W3C). A datatype can be used to specify the content of a . The value of the element must be any one of a set of alternative datatypes specified in the union. Union types are always derived types and must comprise at least two alternative datatypes. - @@ -162,11 +161,11 @@ Gets an array of objects representing the type of the element based on the and values of the simple type. An array of objects representing the type of the element. - diff --git a/xml/System.Xml.Schema/XmlSchemaUnique.xml b/xml/System.Xml.Schema/XmlSchemaUnique.xml index 2396b93d637..3bb0fc7f0b5 100644 --- a/xml/System.Xml.Schema/XmlSchemaUnique.xml +++ b/xml/System.Xml.Schema/XmlSchemaUnique.xml @@ -44,24 +44,23 @@ Represents the element from XML Schema as specified by the World Wide Web Consortium (W3C). This class can be used to identify a unique constraint among a set of elements. - diff --git a/xml/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.xml b/xml/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.xml index 6602203ccea..61ac0d2b648 100644 --- a/xml/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.xml +++ b/xml/System.Xml.Schema/XmlSchemaWhiteSpaceFacet.xml @@ -44,24 +44,23 @@ Represents the World Wide Web Consortium (W3C) facet. - class defines how the simpleType value's white space will be treated. The `whiteSpace` facet value can be one of `preserve`, `replace`, or `collapse`. + + + +## Examples + The following example shows the use of the `XmlSchemaWhiteSpaceFacet` class. -## Remarks - The class defines how the simpleType value's white space will be treated. The `whiteSpace` facet value can be one of `preserve`, `replace`, or `collapse`. - - - -## Examples - The following example shows the use of the `XmlSchemaWhiteSpaceFacet` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/CPP/whitespacefacet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Schema/XmlSchemaWhiteSpaceFacet/Overview/whitespacefacet.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/VB/whitespacefacet.vb" id="Snippet1"::: - - The following XML file is generated for the preceding code example. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/XML/example.xsd" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/VB/whitespacefacet.vb" id="Snippet1"::: + + The following XML file is generated for the preceding code example. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic Webdata XmlSchemaWhiteSpaceFacet Example/XML/example.xsd" id="Snippet2"::: + ]]> diff --git a/xml/System.Xml.Serialization/CodeGenerationOptions.xml b/xml/System.Xml.Serialization/CodeGenerationOptions.xml index 0943f5b061d..f01a4f5812b 100644 --- a/xml/System.Xml.Serialization/CodeGenerationOptions.xml +++ b/xml/System.Xml.Serialization/CodeGenerationOptions.xml @@ -52,7 +52,6 @@ object. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/WebServices_Description_Importer/CPP/import.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Web.Services.Description/ServiceDescriptionImporter/Overview/import.cs" id="Snippet4"::: ]]> diff --git a/xml/System.Xml.Serialization/IXmlSerializable.xml b/xml/System.Xml.Serialization/IXmlSerializable.xml index 197e4c33193..d1b6dfcaee3 100644 --- a/xml/System.Xml.Serialization/IXmlSerializable.xml +++ b/xml/System.Xml.Serialization/IXmlSerializable.xml @@ -77,7 +77,6 @@ ## Examples The following example code shows an implementation of the interface that serializes a private field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp" id="Snippet0"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/IXmlSerializable/Overview/person.cs" id="Snippet0"::: ]]> @@ -217,12 +216,10 @@ ## Examples The following example illustrates an implementation of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/IXmlSerializable/Overview/person.cs" id="Snippet2"::: The following example illustrates the use of the class to deserialize this object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/reader.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/IXmlSerializable/Overview/reader.cs" id="Snippet20"::: ]]> @@ -293,12 +290,10 @@ ## Examples The following example illustrates an implementation of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/person.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/IXmlSerializable/Overview/person.cs" id="Snippet1"::: The following example illustrates the use of the class to serialize this object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerialization_IXmlSerializable/CPP/writer.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/IXmlSerializable/Overview/writer.cs" id="Snippet10"::: ]]> diff --git a/xml/System.Xml.Serialization/SoapAttributeAttribute.xml b/xml/System.Xml.Serialization/SoapAttributeAttribute.xml index 91756dadad0..7128e48e6b8 100644 --- a/xml/System.Xml.Serialization/SoapAttributeAttribute.xml +++ b/xml/System.Xml.Serialization/SoapAttributeAttribute.xml @@ -54,29 +54,28 @@ Specifies that the must serialize the class member as an encoded SOAP attribute. - class belongs to a family of attributes that controls how the serializes, or deserializes, an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. - - Apply the to a public field to specify that the serializes the field as an XML attribute. You can specify an alternative name of the attribute by setting the property. Set the if the attribute must be given a specific XML Schema definition language (XSD) data type. If the attribute belongs to a specific XML namespace, set the property. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/) - + class belongs to a family of attributes that controls how the serializes, or deserializes, an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. + + Apply the to a public field to specify that the serializes the field as an XML attribute. You can specify an alternative name of the attribute by setting the property. Set the if the attribute must be given a specific XML Schema definition language (XSD) data type. If the attribute belongs to a specific XML namespace, set the property. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/) + > [!NOTE] -> You can use the word `SoapAttribute` in your code instead of the longer . - - - -## Examples - The following example serializes a class that contains several fields to which a is applied. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp" id="Snippet1"::: +> You can use the word `SoapAttribute` in your code instead of the longer . + + + +## Examples + The following example serializes a class that contains several fields to which a is applied. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/Overview/soapattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: + ]]> @@ -135,20 +134,19 @@ Initializes a new instance of the class. - when you override the serialization of a class member. Create the , set its properties, and set the object to the property of a object. For more details, see the class overview. - - - -## Examples - The following example creates a new that is used to override the serialization of a field. After creating a and setting its properties, the object is set to the property of a . The is then added to a that is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributeAttributeEx2/CPP/soapattributeex2.cpp" id="Snippet1"::: + when you override the serialization of a class member. Create the , set its properties, and set the object to the property of a object. For more details, see the class overview. + + + +## Examples + The following example creates a new that is used to override the serialization of a field. After creating a and setting its properties, the object is set to the property of a . The is then added to a that is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/.ctor/soapattributeex2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeAttributeEx2/VB/soapattributeex2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeAttributeEx2/VB/soapattributeex2.vb" id="Snippet1"::: + ]]> @@ -205,15 +203,14 @@ The name of the XML attribute. Initializes a new instance of the class using the specified value as the name of the XML attribute. - is applied. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp" id="Snippet1"::: + is applied. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/Overview/soapattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: + ]]> @@ -263,20 +260,19 @@ Gets or sets the name of the XML attribute generated by the . The name of the XML attribute. The default is the member identifier. - property to specify an XML attribute name when the default value cannot be used. For example, if the XML attribute name is invalid as a member identifier, use a valid name for the identifier while setting the to an invalid name. - - - -## Examples - The following example serializes a class that contains several fields to which the is applied. The property is set for the `Today` field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp" id="Snippet1"::: + property to specify an XML attribute name when the default value cannot be used. For example, if the XML attribute name is invalid as a member identifier, use a valid name for the identifier while setting the to an invalid name. + + + +## Examples + The following example serializes a class that contains several fields to which the is applied. The property is set for the `Today` field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/Overview/soapattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: + ]]> @@ -326,79 +322,78 @@ Gets or sets the XML Schema definition language (XSD) data type of the SOAP attribute generated by the . An XML Schema data type. - structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema data type. Note that this does not change the serialization format, only the schema for the member. - + structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema data type. Note that this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. - +> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient then passing it as an XML attribute. - - For more information about XML Schema data types, see the World Wide Consortium document named XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - The following example serializes a class that contains several fields to which a is applied. The property is set for the `GroupNumber` and the `Today` fields. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient then passing it as an XML attribute. + + For more information about XML Schema data types, see the World Wide Consortium document named XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples + The following example serializes a class that contains several fields to which a is applied. The property is set for the `GroupNumber` and the `Today` fields. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/Overview/soapattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: + ]]> The XML Schema data type you have specified cannot be mapped to the .NET data type. @@ -458,22 +453,21 @@ Gets or sets the XML namespace of the XML attribute. The XML namespace of the XML attribute. - property conforms to the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/). - - To create namespaces that are associated with prefixes, you must create an that contains the namespaces and prefixes used in the XML document. The namespace you set for each must match one of the namespaces in the . When the generates the XML code, it correctly prefixes each attribute name. - - - -## Examples - The following example serializes a class that contains several fields to which a is applied. The property is set for the `GroupName` the field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribute/CPP/soapattribute.cpp" id="Snippet1"::: + property conforms to the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/). + + To create namespaces that are associated with prefixes, you must create an that contains the namespaces and prefixes used in the XML document. The namespace you set for each must match one of the namespaces in the . When the generates the XML code, it correctly prefixes each attribute name. + + + +## Examples + The following example serializes a class that contains several fields to which a is applied. The property is set for the `GroupName` the field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeAttribute/Overview/soapattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribute/VB/soapattribute.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/SoapAttributeOverrides.xml b/xml/System.Xml.Serialization/SoapAttributeOverrides.xml index bc5e546655d..c593354fc2e 100644 --- a/xml/System.Xml.Serialization/SoapAttributeOverrides.xml +++ b/xml/System.Xml.Serialization/SoapAttributeOverrides.xml @@ -50,40 +50,39 @@ Allows you to override attributes applied to properties, fields, and classes when you use an to serialize or deserialize an object as encoded SOAP. - class enables an to override the default way of serializing a set of objects. Overriding serialization in this way has two uses: first, you can control and augment the serialization of objects found in a DLL, even if you do not have access to the source; second, you can create one set of serializable classes, but serialize the objects in multiple ways. For example, instead of serializing members of a class instance as XML elements, you can serialize them as XML attributes, resulting in a more efficient document to transport. - - After you create a , you create an using the method of the class. Pass the resulting object as an argument to the constructor. The resulting uses the data contained by the to override attributes that control how objects are serialized. To accomplish this, the contains a collection of the object types that are overridden, as well as a associated with each overridden object type. Each contains an appropriate set of attribute objects that control how each field, property, or class is serialized. - - The process for creating and using a is as follows: - -1. Create a . - -2. Create an attribute object that is appropriate to the object being overridden. For example, to override a field or property, create a , using the new, derived type. You can optionally assign a new that overrides the base class's attribute name or namespace. - -3. Add the attribute object to the appropriate property or collection. For example, you would set the property of the object to the and specify the member name that is being overridden. - -4. Create a . - -5. Add the to the using the method. If the object being overridden is a , you need only specify the type of the overridden object. But if you are overriding a field or property, you must also specify the name of the overridden member. - -6. Create an using the method of the class. - -7. When constructing the , pass the to the constructor. - -8. Use the resulting to serialize or deserialize the class objects. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + class enables an to override the default way of serializing a set of objects. Overriding serialization in this way has two uses: first, you can control and augment the serialization of objects found in a DLL, even if you do not have access to the source; second, you can create one set of serializable classes, but serialize the objects in multiple ways. For example, instead of serializing members of a class instance as XML elements, you can serialize them as XML attributes, resulting in a more efficient document to transport. + + After you create a , you create an using the method of the class. Pass the resulting object as an argument to the constructor. The resulting uses the data contained by the to override attributes that control how objects are serialized. To accomplish this, the contains a collection of the object types that are overridden, as well as a associated with each overridden object type. Each contains an appropriate set of attribute objects that control how each field, property, or class is serialized. + + The process for creating and using a is as follows: + +1. Create a . + +2. Create an attribute object that is appropriate to the object being overridden. For example, to override a field or property, create a , using the new, derived type. You can optionally assign a new that overrides the base class's attribute name or namespace. + +3. Add the attribute object to the appropriate property or collection. For example, you would set the property of the object to the and specify the member name that is being overridden. + +4. Create a . + +5. Add the to the using the method. If the object being overridden is a , you need only specify the type of the overridden object. But if you are overriding a field or property, you must also specify the name of the overridden member. + +6. Create an using the method of the class. + +7. When constructing the , pass the to the constructor. + +8. Use the resulting to serialize or deserialize the class objects. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -128,15 +127,14 @@ Initializes a new instance of the class. - is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -203,22 +201,21 @@ A that represents the overriding attributes. Adds a to a collection of objects. The parameter specifies an object to be overridden by the . - contains a union of attribute objects that cause the to override its default serialization behavior for a set of objects. You choose the attribute objects to place in the , depending on the particular behaviors you want to override. For example, the serializes a class member as an XML element by default. If you want the member to be serialized as an XML attribute instead, you would create a , assign it to the property of a , and add the to the . Use the method to add the to the . - - Use this overload to add a that contains a . Because the overrides the serialization of a class, you need not specify a member of the class to override, only the type of the class. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + contains a union of attribute objects that cause the to override its default serialization behavior for a set of objects. You choose the attribute objects to place in the , depending on the particular behaviors you want to override. For example, the serializes a class member as an XML element by default. If you want the member to be serialized as an XML attribute instead, you would create a , assign it to the property of a , and add the to the . Use the method to add the to the . + + Use this overload to add a that contains a . Because the overrides the serialization of a class, you need not specify a member of the class to override, only the type of the class. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -277,22 +274,21 @@ A that represents the overriding attributes. Adds a to the collection of objects contained by the . The parameter specifies the object to be overridden by the . The parameter specifies the name of a member that is overridden. - contains a union of attribute objects that cause the to override its default serialization behavior for a set of objects. You choose the attribute objects to place in the , depending on the particular behaviors you want to override. For example, the serializes a class member as an XML element by default. If you want the member to be serialized as a SOAP attribute instead, you would create a , assign it to the property of a , and add the to the . Use the method to add the to the . - - Use this method when the contains either a , , , or . - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + contains a union of attribute objects that cause the to override its default serialization behavior for a set of objects. You choose the attribute objects to place in the , depending on the particular behaviors you want to override. For example, the serializes a class member as an XML element by default. If you want the member to be serialized as a SOAP attribute instead, you would create a , assign it to the property of a , and add the to the . Use the method to add the to the . + + Use this method when the contains either a , , , or . + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -357,20 +353,19 @@ Gets the object associated with the specified (base class) type. A that represents the collection of overriding attributes. - that contains attributes for a . - - - -## Examples - The following example creates a that is used to override the serialization of an instance of the `Group` class. The example also uses the property to retrieve the that is used to specify how the serialization is being overridden. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/CPP/attadd2.cpp" id="Snippet1"::: + that contains attributes for a . + + + +## Examples + The following example creates a that is used to override the serialization of an instance of the `Group` class. The example also uses the property to retrieve the that is used to specify how the serialization is being overridden. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Item/attadd2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/VB/attadd2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 2/VB/attadd2.vb" id="Snippet1"::: + ]]> @@ -427,22 +422,21 @@ Gets the object associated with the specified (base class) type. The parameter specifies the base class member that is overridden. A that represents the collection of overriding attributes. - that contains attributes that override a , , , or . You can also return a that contains the override of a default value that uses a . - - If the contains a , you must use the overload that specifies only the overridden type. - - - -## Examples - The following example creates a used to override the serialization of an instance of the `Group` class. The example also uses the property to retrieve the that is used to specify how the serialization is being overridden. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/CPP/attadd.cpp" id="Snippet1"::: + that contains attributes that override a , , , or . You can also return a that contains the override of a default value that uses a . + + If the contains a , you must use the overload that specifies only the overridden type. + + + +## Examples + The following example creates a used to override the serialization of an instance of the `Group` class. The example also uses the property to retrieve the that is used to specify how the serialization is being overridden. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Item/attadd.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/VB/attadd.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributeOverrides.Item property 1/VB/attadd.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/SoapAttributes.xml b/xml/System.Xml.Serialization/SoapAttributes.xml index 85c84616858..a2ed22130e9 100644 --- a/xml/System.Xml.Serialization/SoapAttributes.xml +++ b/xml/System.Xml.Serialization/SoapAttributes.xml @@ -50,24 +50,23 @@ Represents a collection of attribute objects that control how the serializes and deserializes SOAP methods. - is part of a process that overrides the default way the serializes class instances. For example, suppose you want to serialize an object that is created from a DLL that has an inaccessible source. By using the class, you can augment or otherwise control how the object is serialized. - - The members of the class correspond directly to a family of attribute classes that control serialization. For example, the property must be set to a , which allows you to override serialization of a field or property by instructing the to serialize the property value as an encoded SOAP attribute. For a complete list of attributes that control encoded SOAP serialization, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - For more details about adding an instance of the class to an instance of the class, see the class overview. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + is part of a process that overrides the default way the serializes class instances. For example, suppose you want to serialize an object that is created from a DLL that has an inaccessible source. By using the class, you can augment or otherwise control how the object is serialized. + + The members of the class correspond directly to a family of attribute classes that control serialization. For example, the property must be set to a , which allows you to override serialization of a field or property by instructing the to serialize the property value as an encoded SOAP attribute. For a complete list of attributes that control encoded SOAP serialization, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + For more details about adding an instance of the class to an instance of the class, see the class overview. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -126,20 +125,19 @@ Initializes a new instance of the class. - . Set the properties for the as appropriate to the member or object, then add the to an instance of the class. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + . Set the properties for the as appropriate to the member or object, then add the to an instance of the class. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -238,22 +236,21 @@ Gets or sets the to override. A that overrides the behavior of the when the member is serialized. - to serialize a member as an encoded SOAP XML attribute by applying a to the field or property. (The must be created with an in order to serialize an object as an encoded SOAP XML stream.) - - The property allows you to override the serialization controlled by applying a to the member. For more details on this process, see the class overview. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + to serialize a member as an encoded SOAP XML attribute by applying a to the field or property. (The must be created with an in order to serialize an object as an encoded SOAP XML stream.) + + The property allows you to override the serialization controlled by applying a to the member. For more details on this process, see the class overview. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -311,20 +308,19 @@ Gets or sets the default value of an XML element or attribute. An object that represents the default value of an XML element or attribute. - attribute to the member. If the member is being serialized as an encoded SOAP message, you can change the default value by creating a new , setting its property, and setting the property to the object. Add the to a . For more details, see the class overview. - - - -## Examples - The following example serializes a class named `Group` that includes a field named `GroupName`. The default value is set with the to ".NET". By either not setting the field, or by setting it to ".NET", the value is not serialized (because the default value is already known). The sample also overrides the default value in the `CreateOverrideSerializer` method, which is called by the `SerializeOverride` method. The example calls both methods, `SerializeOriginal` and `SerializeOverride`, and sets the same value (".NET") for the `GroupName` field. Because of the override, the value is serialized only when calling the `SerializeOverride` method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/CPP/defvalue.cpp" id="Snippet1"::: + attribute to the member. If the member is being serialized as an encoded SOAP message, you can change the default value by creating a new , setting its property, and setting the property to the object. Add the to a . For more details, see the class overview. + + + +## Examples + The following example serializes a class named `Group` that includes a field named `GroupName`. The default value is set with the to ".NET". By either not setting the field, or by setting it to ".NET", the value is not serialized (because the default value is already known). The sample also overrides the default value in the `CreateOverrideSerializer` method, which is called by the `SerializeOverride` method. The example calls both methods, `SerializeOriginal` and `SerializeOverride`, and sets the same value (".NET") for the `GroupName` field. Because of the override, the value is serialized only when calling the `SerializeOverride` method. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapDefaultValue/defvalue.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/VB/defvalue.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttribues.SoapDefaultValue/VB/defvalue.vb" id="Snippet1"::: + ]]> @@ -382,22 +378,21 @@ Gets or sets a to override. The to override. - is used to control the serialization of a class member as an XML element. Set the property to a new to override the serialization of a class member as an XML element by creating a new and assigning it to the property. Then add the to a . Create an with the , then construct an with the . - - For more information, see the class overview. - - - -## Examples - The following example serializes a class named `Transportation`. The serialization of the `Vehicle` field is overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: + is used to control the serialization of a class member as an XML element. Set the property to a new to override the serialization of a class member as an XML element by creating a new and assigning it to the property. Then add the to a . Create an with the , then construct an with the . + + For more information, see the class overview. + + + +## Examples + The following example serializes a class named `Transportation`. The serialization of the `Vehicle` field is overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -455,22 +450,21 @@ Gets or sets an object that specifies how the serializes a SOAP enumeration. An object that specifies how the serializes an enumeration member. - is used to control the serialization of an enumeration member. Set the property to a new to override the serialization of such a member. - - For more information, see the class overview. - - - -## Examples - The following example serializes two classes named `Food` and `FoodType`. The `FoodType` class contains two enumerations that are overridden, and for each enumeration, the example creates a that it assigns to the property of a . The example then adds the to a , which is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp" id="Snippet1"::: + is used to control the serialization of an enumeration member. Set the property to a new to override the serialization of such a member. + + For more information, see the class overview. + + + +## Examples + The following example serializes two classes named `Food` and `FoodType`. The `FoodType` class contains two enumerations that are overridden, and for each enumeration, the example creates a that it assigns to the property of a . The example then adds the to a , which is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapEnum/soapenumoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: + ]]> @@ -528,24 +522,23 @@ if the must not serialize the field or property; otherwise, . - . That is, the value of each public field or property is persisted as an XML element or XML attribute in an XML document. - - To override the default serialization of a field or property, create a , and set its property to `true`. Use the method to add the object to a and specify the type of the object that contains the field or property to ignore and the name of the field or property to ignore. - - If a is applied to a field or property, the field or property is ignored. However you can override that behavior by creating a , setting its property to `false`, and adding it to a , specifying the type of the object that contains the field or property and the name of the field or property. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + . That is, the value of each public field or property is persisted as an XML element or XML attribute in an XML document. + + To override the default serialization of a field or property, create a , and set its property to `true`. Use the method to add the object to a and specify the type of the object that contains the field or property to ignore and the name of the field or property to ignore. + + If a is applied to a field or property, the field or property is ignored. However you can override that behavior by creating a , setting its property to `false`, and adding it to a , specifying the type of the object that contains the field or property and the name of the field or property. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -603,20 +596,19 @@ Gets or sets an object that instructs the how to serialize an object type into encoded SOAP XML. A that either overrides a applied to a class declaration, or is applied to a class declaration. - can be used to control the XML stream generated by the . Set the property to a new to control the schema for the XML that is generated when a class is serialized. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + can be used to control the XML stream generated by the . Set the property to a new to control the schema for the XML that is generated when a class is serialized. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/SoapElementAttribute.xml b/xml/System.Xml.Serialization/SoapElementAttribute.xml index 686751ef3b6..29f301acbaa 100644 --- a/xml/System.Xml.Serialization/SoapElementAttribute.xml +++ b/xml/System.Xml.Serialization/SoapElementAttribute.xml @@ -54,26 +54,25 @@ Specifies that the public member value be serialized by the as an encoded SOAP XML element. - class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. - - Apply the to a public field to direct the to serialize the field as an encoded SOAP XML element. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: + class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. + + Apply the to a public field to direct the to serialize the field as an encoded SOAP XML element. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + + + +## Examples + The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -129,15 +128,14 @@ Initializes a new instance of the class. - is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: + is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -188,15 +186,14 @@ The XML element name of the serialized member. Initializes a new instance of the class and specifies the name of the XML element. - is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: + is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -246,79 +243,78 @@ Gets or sets the XML Schema definition language (XSD) data type of the generated XML element. One of the XML Schema data types. - structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema type. Note that this does not change the serialization format, only the schema for the member. - + structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema type. Note that this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. - +> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient than passing it as an XML attribute. - - For more information about XML data types, see the World Wide Web Consortium document, [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient than passing it as an XML attribute. + + For more information about XML data types, see the World Wide Web Consortium document, [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples + The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -368,15 +364,14 @@ Gets or sets the name of the generated XML element. The name of the generated XML element. The default is the member identifier. - is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: + is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> @@ -431,22 +426,22 @@ if the generates the attribute; otherwise, . - property is set to `true`, the `xsi:null` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. - -``` - -``` - - If the property is `false`, no XML element is generated. - + property is set to `true`, the `xsi:null` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. + +``` + +``` + + If the property is `false`, no XML element is generated. + > [!NOTE] -> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. - +> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. + ]]> diff --git a/xml/System.Xml.Serialization/SoapEnumAttribute.xml b/xml/System.Xml.Serialization/SoapEnumAttribute.xml index 525d8345981..055a916b098 100644 --- a/xml/System.Xml.Serialization/SoapEnumAttribute.xml +++ b/xml/System.Xml.Serialization/SoapEnumAttribute.xml @@ -54,33 +54,32 @@ Controls how the serializes an enumeration member. - class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. - - Use the to change the enumeration that the generates or recognizes (when it serializes or deserializes a class, respectively). For example, if an enumeration contains a member named `One`, but you prefer that the XML output be named `Single`, apply the to the enumeration member and set the property to "Single". - - You can override the property value of a by creating an instance of the class and assigning it to the property of a . For details, see the class overview. - - To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. - + class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. + + Use the to change the enumeration that the generates or recognizes (when it serializes or deserializes a class, respectively). For example, if an enumeration contains a member named `One`, but you prefer that the XML output be named `Single`, apply the to the enumeration member and set the property to "Single". + + You can override the property value of a by creating an instance of the class and assigning it to the property of a . For details, see the class overview. + + To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. + > [!NOTE] -> You can use the word `SoapEnum` in your code instead of the longer . - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp" id="Snippet1"::: +> You can use the word `SoapEnum` in your code instead of the longer . + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + + + +## Examples + The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapEnum/soapenumoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: + ]]> @@ -136,23 +135,22 @@ Initializes a new instance of the class. - to override an existing enumeration. Create a new , set its properties and assign the object to the property of a . For each member of the enumeration, you must create a new and add it to the . For more details, see the class overview. - + to override an existing enumeration. Create a new , set its properties and assign the object to the property of a . For each member of the enumeration, you must create a new and add it to the . For more details, see the class overview. + > [!NOTE] -> You can use the word `SoapEnum` in your code instead of the longer . - - - -## Examples - The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp" id="Snippet1"::: +> You can use the word `SoapEnum` in your code instead of the longer . + + + +## Examples + The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapEnum/soapenumoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: + ]]> @@ -202,23 +200,22 @@ The XML element name generated by the . Initializes a new instance of the class using the specified element name. - when you want the generated XML enumerator to differ from the enumerator found in the enumeration. - + when you want the generated XML enumerator to differ from the enumerator found in the enumeration. + > [!NOTE] -> You can use the word `SoapEnum` in your code instead of the longer . - - - -## Examples - The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp" id="Snippet1"::: +> You can use the word `SoapEnum` in your code instead of the longer . + + + +## Examples + The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapEnum/soapenumoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: + ]]> @@ -268,23 +265,22 @@ Gets or sets the value generated in an XML document when the serializes an enumeration, or the value recognized when it deserializes the enumeration member. The value generated in an XML document when the serializes the enumeration, or the value recognized when it deserializes the enumeration member. - when you want the generated XML enumerator to differ from the enumerator found in the enumeration. - + when you want the generated XML enumerator to differ from the enumerator found in the enumeration. + > [!NOTE] -> You can use the word `SoapEnum` instead of the longer . - - - -## Examples - The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapEnumOverrides/CPP/soapenumoverrides.cpp" id="Snippet1"::: +> You can use the word `SoapEnum` instead of the longer . + + + +## Examples + The following example uses the to serialize a class named `Food` that includes an enumeration named `FoodType`. The `FoodType` enumeration is overridden by creating a for each enumeration and setting the property of a to the . The is added to a that is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapEnum/soapenumoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapEnumOverrides/VB/soapenumoverrides.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/SoapIgnoreAttribute.xml b/xml/System.Xml.Serialization/SoapIgnoreAttribute.xml index 407ab95442d..2fb512e8774 100644 --- a/xml/System.Xml.Serialization/SoapIgnoreAttribute.xml +++ b/xml/System.Xml.Serialization/SoapIgnoreAttribute.xml @@ -50,29 +50,28 @@ Instructs the not to serialize the public field or public read/write property value. - class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. - - Apply the to any class member that you want the to ignore when an instance of the class is serialized. For example, you may do this when the member is used to contain metadata about the object being serialized. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + To serialize an object as an encoded SOAP message, you must construct the using an created with the method of the class. + + Apply the to any class member that you want the to ignore when an instance of the class is serialized. For example, you may do this when the member is used to contain metadata about the object being serialized. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `SoapIgnore` in your code instead of the longer . - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: +> You can use the word `SoapIgnore` in your code instead of the longer . + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -118,15 +117,14 @@ Initializes a new instance of the class. - is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/SoapReflectionImporter.xml b/xml/System.Xml.Serialization/SoapReflectionImporter.xml index f26d87c315d..65d79d98d64 100644 --- a/xml/System.Xml.Serialization/SoapReflectionImporter.xml +++ b/xml/System.Xml.Serialization/SoapReflectionImporter.xml @@ -50,20 +50,19 @@ Generates mappings to SOAP-encoded messages from .NET types or Web service method information. - class provides type mappings to SOAP-encoded message parts, as defined in a Web Services Description Language (WSDL) document. It is used only when a Web service or client specifies SOAP encoding, as described in Section 5 of the SOAP 1.1 specification. - - - -## Examples - The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: + class provides type mappings to SOAP-encoded message parts, as defined in a Web Services Description Language (WSDL) document. It is used only when a Web service or client specifies SOAP encoding, as described in Section 5 of the SOAP 1.1 specification. + + + +## Examples + The following example serializes a class named `Group`. The serialization of the `GroupName` and `IgnoreThis` fields and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a is created, and for each overridden member or enumeration, a is created with the appropriate property set and added to the . An is created using the , and that is used to create the that overrides the default serialization. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: + ]]> @@ -345,21 +344,21 @@ Generates internal type mappings for information that is gathered from a Web service method. Internal .NET type mappings to the element parts of a WSDL message definition. - method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. - - The following list describes possible values for the `members` parameter: - -- Web service method input parameters. - -- Web service method output parameters, plus the return type, if not void, at index zero. - -- SOAP input headers. - -- SOAP output headers. - + method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. + + The following list describes possible values for the `members` parameter: + +- Web service method input parameters. + +- Web service method output parameters, plus the return type, if not void, at index zero. + +- SOAP input headers. + +- SOAP output headers. + ]]> @@ -442,21 +441,21 @@ Generates internal type mappings for information that is gathered from a Web service method. Internal .NET type mappings to the element parts of a WSDL message definition. - method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. - - The following list describes possible values for the `members` parameter: - -- Web service method input parameters. - -- Web service method output parameters, plus the return type, if not void, at index zero. - -- SOAP input headers. - -- SOAP output headers. - + method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. + + The following list describes possible values for the `members` parameter: + +- Web service method input parameters. + +- Web service method output parameters, plus the return type, if not void, at index zero. + +- SOAP input headers. + +- SOAP output headers. + ]]> @@ -542,21 +541,21 @@ Generates internal type mappings for information that is gathered from a Web service method. Internal .NET type mappings to the element parts of a WSDL message definition. - method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. - - The following list describes possible values for the `members` parameter: - -- Web service method input parameters. - -- Web service method output parameters, plus the return type, if not void, at index zero. - -- SOAP input headers. - -- SOAP output headers. - + method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. + + The following list describes possible values for the `members` parameter: + +- Web service method input parameters. + +- Web service method output parameters, plus the return type, if not void, at index zero. + +- SOAP input headers. + +- SOAP output headers. + ]]> @@ -639,21 +638,21 @@ Generates internal type mappings for information that is gathered from a Web service method. Internal .NET type mappings to the element parts of a WSDL message definition. - method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. - - The following list describes possible values for the `members` parameter: - -- Web service method input parameters. - -- Web service method output parameters, plus the return type, if not void, at index zero. - -- SOAP input headers. - -- SOAP output headers. - + method is called while initializing a Web service or client, or reflecting a Web service. You do not need to call it directly. + + The following list describes possible values for the `members` parameter: + +- Web service method input parameters. + +- Web service method output parameters, plus the return type, if not void, at index zero. + +- SOAP input headers. + +- SOAP output headers. + ]]> @@ -721,13 +720,13 @@ Generates a mapping to an XML Schema element for a .NET type. Internal .NET mapping of a type to an XML Schema element. - method directly. - + method directly. + ]]> @@ -791,13 +790,13 @@ Generates a mapping to an XML Schema element for a .NET type. Internal .NET mapping of a type to an XML Schema element. - method directly. - + method directly. + ]]> @@ -850,11 +849,11 @@ The .NET type for which to save type mapping information. Places mappings for a type in the instance's context for later use when import methods are invoked. - method directly. - + method directly. + ]]> diff --git a/xml/System.Xml.Serialization/SoapTypeAttribute.xml b/xml/System.Xml.Serialization/SoapTypeAttribute.xml index 600bb49a345..628f3c51f6a 100644 --- a/xml/System.Xml.Serialization/SoapTypeAttribute.xml +++ b/xml/System.Xml.Serialization/SoapTypeAttribute.xml @@ -54,28 +54,27 @@ Controls the schema generated by the when a class instance is serialized as SOAP encoded XML. - class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - To serialize an object as an encoded SOAP message, construct the using an created with the method of the class. - - The can only be applied to class declarations. - - The property determines whether the resulting XML element type is included in the XML Schema document (.xsd) for the generated XML stream. To see the schema, compile the class into a DLL file. Pass the resulting file as an argument to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool generates the XML Schema for the XML stream generated when the class is serialized by an instance of the class. - - Setting a different namespace causes Xsd.exe to write a different schema (.xsd) file for the XML stream generated when the class is serialized. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class, with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + class belongs to a family of attributes that controls how the serializes or deserializes an object as encoded SOAP XML. The resulting XML conforms to section 5 of the World Wide Web Consortium document, [Simple Object Access Protocol (SOAP) 1.1](https://www.w3.org/TR/2000/NOTE-SOAP-20000508/). For a complete list of similar attributes, see [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + To serialize an object as an encoded SOAP message, construct the using an created with the method of the class. + + The can only be applied to class declarations. + + The property determines whether the resulting XML element type is included in the XML Schema document (.xsd) for the generated XML stream. To see the schema, compile the class into a DLL file. Pass the resulting file as an argument to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool generates the XML Schema for the XML stream generated when the class is serialized by an instance of the class. + + Setting a different namespace causes Xsd.exe to write a different schema (.xsd) file for the XML stream generated when the class is serialized. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class, with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -125,20 +124,19 @@ Initializes a new instance of the class. - when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details about overriding SOAP serialization. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details about overriding SOAP serialization. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -183,20 +181,19 @@ The name of the XML type that the generates when it serializes the class instance (and recognizes when it deserializes the class instance). Initializes a new instance of the class and specifies the name of the XML type. - when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details about overriding SOAP serialization. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details about overriding SOAP serialization. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -243,22 +240,21 @@ The XML namespace of the type. Initializes a new instance of the class and specifies the name and XML namespace of the type. - when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details on overriding SOAP serialization. - - If you set a value for more than one type (that is, if you apply the attribute to more than one class with a different value for each one), the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) generates a separate schema file (.xsd) for each type. This is because setting a different namespace for each type renders each type distinct from the others, which makes it necessary for each type to be written out as an independent entity. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + when overriding the serialization of a type. Assign the object to the property of a and add the to a . See the class overview for more details on overriding SOAP serialization. + + If you set a value for more than one type (that is, if you apply the attribute to more than one class with a different value for each one), the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) generates a separate schema file (.xsd) for each type. This is because setting a different namespace for each type renders each type distinct from the others, which makes it necessary for each type to be written out as an independent entity. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -313,20 +309,19 @@ to include the type in SOAP-encoded XML Schema documents; otherwise, . The default is . - to a class declaration to specify whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition of the XML stream generated when the class is serialized. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + to a class declaration to specify whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition of the XML stream generated when the class is serialized. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -381,20 +376,19 @@ Gets or sets the namespace of the XML type. The namespace of the XML type. The default is an empty string (""). - value for more than one type (that is, if you apply the attribute to more than one class with a different value for each one), the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) generates a separate schema file (.xsd) for each type. This is because setting a different namespace for each type renders each type distinct from the others, which makes it necessary for each type to be written out as an independent entity. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + value for more than one type (that is, if you apply the attribute to more than one class with a different value for each one), the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) generates a separate schema file (.xsd) for each type. This is because setting a different namespace for each type renders each type distinct from the others, which makes it necessary for each type to be written out as an independent entity. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> @@ -448,20 +442,19 @@ Gets or sets the name of the XML type. The name of the XML type. The default is the class name. - to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML Schema document. To see the results of setting the object's properties, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. - - - -## Examples - The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapTypeAttribute Example/CPP/soaptype.cpp" id="Snippet1"::: + to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML Schema document. To see the results of setting the object's properties, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. + + + +## Examples + The following example serializes a class named `Group`. The is applied to the class with the set to "SoapGroupType". The is also overridden, changing the to "Team". Both versions are serialized, resulting in two files: SoapType.xml and SoapType2.xml. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapTypeAttribute/Overview/soaptype.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapTypeAttribute Example/VB/soaptype.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/UnreferencedObjectEventArgs.xml b/xml/System.Xml.Serialization/UnreferencedObjectEventArgs.xml index edefd9b2aee..dce71fba80c 100644 --- a/xml/System.Xml.Serialization/UnreferencedObjectEventArgs.xml +++ b/xml/System.Xml.Serialization/UnreferencedObjectEventArgs.xml @@ -50,37 +50,34 @@ Provides data for the known, but unreferenced, object found in an encoded SOAP XML stream during deserialization. - class, see the event of the . - - The event occurs only when you call the method. - - For more information about handling events, see [Events Overview](/dotnet/framework/winforms/events-overview-windows-forms) - - - -## Examples - The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. - -``` - - - - - ABCD - - - 1234 - - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: + class, see the event of the . + + The event occurs only when you call the method. + + For more information about handling events, see [Events Overview](/dotnet/desktop/winforms/events-overview-windows-forms) + +## Examples + The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. + +``` + + + + + ABCD + + + 1234 + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: + ]]> @@ -133,28 +130,27 @@ A unique string used to identify the unreferenced object. Initializes a new instance of the class. - to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. - -``` - - - - - ABCD - - - 1234 - - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: + to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. + +``` + + + + + ABCD + + + 1234 + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: + ]]> @@ -205,35 +201,34 @@ Gets the ID of the object. The ID of the object. - property when you need to know when more than one object raises the event. The property allows you to distinguish between multiple instances of unreferenced objects. - - For more information about the property, see the event. - - - -## Examples - The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. - -``` - - - - - ABCD - - - 1234 - - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: + property when you need to know when more than one object raises the event. The property allows you to distinguish between multiple instances of unreferenced objects. + + For more information about the property, see the event. + + + +## Examples + The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. + +``` + + + + + ABCD + + + 1234 + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: + ]]> @@ -284,35 +279,34 @@ Gets the deserialized, but unreferenced, object. The deserialized, but unreferenced, object. - can be cast to the known type if examining its properties is required. - - See the event for more information about the property. - - - -## Examples - The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. - -``` - - - - - ABCD - - - 1234 - - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: + can be cast to the known type if examining its properties is required. + + See the event for more information about the property. + + + +## Examples + The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. + +``` + + + + + ABCD + + + 1234 + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/UnreferencedObjectEventHandler.xml b/xml/System.Xml.Serialization/UnreferencedObjectEventHandler.xml index d2a0d08ac82..f05d8e09765 100644 --- a/xml/System.Xml.Serialization/UnreferencedObjectEventHandler.xml +++ b/xml/System.Xml.Serialization/UnreferencedObjectEventHandler.xml @@ -60,35 +60,34 @@ An that contains the event data. Represents the method that handles the event of an . - delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/) - - The event occurs only when you call the method. - - - -## Examples - The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. - -``` - - - - - ABCD - - - 1234 - - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: + delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/) + + The event occurs only when you call the method. + + + +## Examples + The following example adds an to an . The event is handled by the `Serializer_UnreferencedObject` method. To run the example, cut and paste the following XML into a file named UnrefObj.xml. + +``` + + + + + ABCD + + + 1234 + + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlAnyAttributeAttribute.xml b/xml/System.Xml.Serialization/XmlAnyAttributeAttribute.xml index 11eb0697484..f5ccac4ee90 100644 --- a/xml/System.Xml.Serialization/XmlAnyAttributeAttribute.xml +++ b/xml/System.Xml.Serialization/XmlAnyAttributeAttribute.xml @@ -73,38 +73,37 @@ Specifies that the member (a field that returns an array of objects) can contain any XML attributes. - to contain arbitrary data (as XML attributes) that is sent as part of an XML document, such as, metadata sent as part of the document. - - Apply the to a field that returns an array of or objects. When the method of the class is called, all XML attributes that do not have a corresponding member in the class being deserialized are collected in the array. After deserialization, you can iterate through the collection of items to process the data. - - The and events of the do not occur if you apply the to a member of a class. - + to contain arbitrary data (as XML attributes) that is sent as part of an XML document, such as, metadata sent as part of the document. + + Apply the to a field that returns an array of or objects. When the method of the class is called, all XML attributes that do not have a corresponding member in the class being deserialized are collected in the array. After deserialization, you can iterate through the collection of items to process the data. + + The and events of the do not occur if you apply the to a member of a class. + > [!NOTE] -> You can use the word `XmlAnyAttribute` in your code instead of the longer . - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example collects all unknown attributes into an array of objects. To try the example, create a file named `UnknownAttributes.xml` that contains the following XML: - -``` - - - MyGroup - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlAnyAttribute` in your code instead of the longer . + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + + + +## Examples + The following example collects all unknown attributes into an array of objects. To try the example, create a file named `UnknownAttributes.xml` that contains the following XML: + +``` + + + MyGroup + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyAttributeAttribute/Overview/anyattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/VB/anyattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyAttributeAttribute Example/VB/anyattribute.vb" id="Snippet1"::: + ]]> @@ -165,22 +164,21 @@ GroupType = 'Technical' GroupNumber = '42' GroupBase = 'Red'> Constructs a new instance of the class. - that is used to override the deserialization of an object. To try the example, create a file named UnknownAttributes.xml that contains the following XML: - -``` - - - MyGroup - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/CPP/anyattover.cpp" id="Snippet1"::: + that is used to override the deserialization of an object. To try the example, create a file named UnknownAttributes.xml that contains the following XML: + +``` + + + MyGroup + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyAttributeAttribute/.ctor/anyattover.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/VB/anyattover.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyAttributeAttribute_ctor Example/VB/anyattover.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlAnyElementAttribute.xml b/xml/System.Xml.Serialization/XmlAnyElementAttribute.xml index 076de633d20..d0c2fe370cb 100644 --- a/xml/System.Xml.Serialization/XmlAnyElementAttribute.xml +++ b/xml/System.Xml.Serialization/XmlAnyElementAttribute.xml @@ -73,39 +73,38 @@ Specifies that the member (a field that returns an array of or objects) contains objects that represent any XML element that has no corresponding member in the object being serialized or deserialized. - [!TIP] -> When working in a portable class library, such as in Silverlight, Windows Phone or Windows Store App project, and you are using the .NET Framework 4.0.3 and above, use or in place of and . - - Use the to contain arbitrary data (as XML elements) that can be sent as part of an XML document, such as metadata sent as part of the document. - - Apply the to a field that returns an array of or objects. Such a field can be used in two ways, depending on whether an object is being serialized or deserialized. When serialized, the object is generated as XML elements or nodes, even though they have no corresponding member (or members) in the object being serialized. If you specify a property value when applying the attribute, all or objects inserted into the array must have the same element name and default namespace, or an exception is thrown. If you set the property value, you must set the property as well, and the or objects must also have the same name and namespace values. If no value is specified, the or objects can have any element name. - - When you call the method of the class, all elements that do not have a corresponding member in the object being deserialized are collected in the array. After deserialization, iterate through the collection of items to process the data. If you specify a value, the array contains only XML elements with that name. If you do not specify a value, the array contains all elements that have no corresponding member in the class. If a class contains more than one field to which the attribute is applied, use the , or and properties to differentiate between the contents of the arrays. If such a class (with multiple fields) also contains one field that has no differentiating property values set (in other words, and ) during deserialization, this array contains any unknown XML elements that are not already contained in the other arrays. If a class contains more than one field that does not have a differentiating , or and value set, the behavior during deserialization is unspecified. - - You can also apply the to a field that returns a single object. If you do so, you must use the properties and methods of the class to recursively iterate through the unknown elements. - - You can apply multiple instances of the to a class member, but each instance must have a distinct property value. Or, if the same property is set for each instance, a distinct property value must be set for each instance. - - The and events of the do not occur if you apply the to a member of a class. - +> When working in a portable class library, such as in Silverlight, Windows Phone or Windows Store App project, and you are using the .NET Framework 4.0.3 and above, use or in place of and . + + Use the to contain arbitrary data (as XML elements) that can be sent as part of an XML document, such as metadata sent as part of the document. + + Apply the to a field that returns an array of or objects. Such a field can be used in two ways, depending on whether an object is being serialized or deserialized. When serialized, the object is generated as XML elements or nodes, even though they have no corresponding member (or members) in the object being serialized. If you specify a property value when applying the attribute, all or objects inserted into the array must have the same element name and default namespace, or an exception is thrown. If you set the property value, you must set the property as well, and the or objects must also have the same name and namespace values. If no value is specified, the or objects can have any element name. + + When you call the method of the class, all elements that do not have a corresponding member in the object being deserialized are collected in the array. After deserialization, iterate through the collection of items to process the data. If you specify a value, the array contains only XML elements with that name. If you do not specify a value, the array contains all elements that have no corresponding member in the class. If a class contains more than one field to which the attribute is applied, use the , or and properties to differentiate between the contents of the arrays. If such a class (with multiple fields) also contains one field that has no differentiating property values set (in other words, and ) during deserialization, this array contains any unknown XML elements that are not already contained in the other arrays. If a class contains more than one field that does not have a differentiating , or and value set, the behavior during deserialization is unspecified. + + You can also apply the to a field that returns a single object. If you do so, you must use the properties and methods of the class to recursively iterate through the unknown elements. + + You can apply multiple instances of the to a class member, but each instance must have a distinct property value. Or, if the same property is set for each instance, a distinct property value must be set for each instance. + + The and events of the do not occur if you apply the to a member of a class. + > [!NOTE] -> You can use the word `XmlAnyElement` in your code instead of the longer . - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example applies the to a field named `AllElements` that returns an array of objects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlAnyElement` in your code instead of the longer . + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + + + +## Examples + The following example applies the to a field named `AllElements` that returns an array of objects. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAnyElementAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -163,11 +162,11 @@ Initializes a new instance of the class. - constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. - + constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. + ]]> @@ -219,11 +218,11 @@ The name of the XML element that the generates. Initializes a new instance of the class and specifies the XML element name generated in the XML document. - constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. - + constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. + ]]> @@ -277,11 +276,11 @@ The XML namespace of the XML element. Initializes a new instance of the class and specifies the XML element name generated in the XML document and its XML namespace. - constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. - + constructor when you are overriding the serialization of a field. For more details about overriding serialization, see the class. + ]]> @@ -342,22 +341,21 @@ Gets or sets the XML element name. The name of the XML element. - property value when applying the attribute, all or objects inserted into the array must have the same element name and default namespace, or an exception is thrown. If you set the property value, you must set the property as well, and the or objects must also have the same name and namespace values. If no value is specified, the or objects can have any element name. - - When you call the method of the class, all attributes that do not have a corresponding member in the object being deserialized are collected in the array. If you specify a value, the array contains only XML elements with that name. If you do not specify a value, the array contains all elements that have no corresponding member in the class. If a class contains more than one field to which the attribute is applied, use the and properties to differentiate between the contents of the arrays. If such a class (with multiple fields) also contains one field that has no differentiating property values set (that is, and ) during deserialization, the array contains any XML elements that are not already contained in the other arrays. If you add more than one field that does not have a differentiating or value set, the last field in the class contains all unknown elements that are not already contained in the other arrays, and any other fields are set to `null`. - - You can apply multiple instances of the to a class member, but each instance must have a distinct property value. Or, if the same property is set for each instance, a distinct property value must be set for each instance. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp" id="Snippet1"::: + property value when applying the attribute, all or objects inserted into the array must have the same element name and default namespace, or an exception is thrown. If you set the property value, you must set the property as well, and the or objects must also have the same name and namespace values. If no value is specified, the or objects can have any element name. + + When you call the method of the class, all attributes that do not have a corresponding member in the object being deserialized are collected in the array. If you specify a value, the array contains only XML elements with that name. If you do not specify a value, the array contains all elements that have no corresponding member in the class. If a class contains more than one field to which the attribute is applied, use the and properties to differentiate between the contents of the arrays. If such a class (with multiple fields) also contains one field that has no differentiating property values set (that is, and ) during deserialization, the array contains any XML elements that are not already contained in the other arrays. If you add more than one field that does not have a differentiating or value set, the last field in the class contains all unknown elements that are not already contained in the other arrays, and any other fields are set to `null`. + + You can apply multiple instances of the to a class member, but each instance must have a distinct property value. Or, if the same property is set for each instance, a distinct property value must be set for each instance. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttribute/Name/anyelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyElementAttribute Example/VB/anyelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyElementAttribute Example/VB/anyelement.vb" id="Snippet1"::: + ]]> The element name of an array member does not match the element name specified by the property. @@ -416,20 +414,19 @@ Gets or sets the XML namespace generated in the XML document. An XML namespace. - property allows you to set a unique name for the XML attribute. The property conforms to the rules for creating an XML namespace as found in the [Namespaces in XML](https://www.w3.org/TR/xml-names/) document from the World Wide Web Consortium. - - To set the property to a prefixed name, create an that contains the namespaces and prefixes used in the XML document. Set the property to one of the namespaces in the . When the XML is generated, the attribute name is correctly prefixed with the prefix associated with the specified namespace. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAnyElementAttribute Example/CPP/anyelement.cpp" id="Snippet1"::: + + To set the property to a prefixed name, create an that contains the namespaces and prefixes used in the XML document. Set the property to one of the namespaces in the . When the XML is generated, the attribute name is correctly prefixed with the prefix associated with the specified namespace. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttribute/Name/anyelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyElementAttribute Example/VB/anyelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAnyElementAttribute Example/VB/anyelement.vb" id="Snippet1"::: + ]]> @@ -485,14 +482,14 @@ Gets or sets the explicit order in which the elements are serialized or deserialized. The order of the code generation. - enumeration to instruct the to generate code that sets the property. - + enumeration to instruct the to generate code that sets the property. + > [!IMPORTANT] -> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. - +> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. + ]]> diff --git a/xml/System.Xml.Serialization/XmlAnyElementAttributes.xml b/xml/System.Xml.Serialization/XmlAnyElementAttributes.xml index 09668bfef24..36b2b3f3f9a 100644 --- a/xml/System.Xml.Serialization/XmlAnyElementAttributes.xml +++ b/xml/System.Xml.Serialization/XmlAnyElementAttributes.xml @@ -101,7 +101,6 @@ ## Examples The following example creates a new and adds it to the collection of objects accessed through the property. The is then added to a , which is used to create an . The is used to serialize or deserialize an object. To see the effect of using the property, create an XML document named UnknownElements.xml by running the `SerializeObject` method in the `Main` method. Edit the resulting document to include other (unknown) elements. Comment out the `SerializeObject` call in the `Main` method, and uncomment the call to the `DeserializeObject` method, which prints out the name and value of any unknown XML element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttributes/Overview/xmlanyover.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/VB/xmlanyover.vb" id="Snippet1"::: @@ -209,7 +208,6 @@ ## Examples The following example creates a new and adds it to the collection of objects accessed through the property. The is then added to an , which is used to create an . The is used to serialize or deserialize an object. To see the effect of using the property, create an XML document named UnknownElements.xml by running the `SerializeObject` method in the `Main` method. Edit the resulting document to include other (unknown) elements. Comment out the `SerializeObject` call in the `Main` method, and uncomment the call to the `DeserializeObject` method, which prints out the name and value of any unknown XML element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttributes/Overview/xmlanyover.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/VB/xmlanyover.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/XmlArrayAttribute.xml b/xml/System.Xml.Serialization/XmlArrayAttribute.xml index 2a73f02e4fe..8b7b007563f 100644 --- a/xml/System.Xml.Serialization/XmlArrayAttribute.xml +++ b/xml/System.Xml.Serialization/XmlArrayAttribute.xml @@ -61,33 +61,32 @@ Specifies that the must serialize a particular class member as an array of XML elements. - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - You can apply the to a public field or read/write property that returns an array of objects. You can also apply it to collections and fields that return an or any field that returns an object that implements the interface. - - When you apply the to a class member, the method of the class generates a nested sequence of XML elements from that member. An XML schema document (an .xsd file), indicates such an array as a `complexType`. For example, if the class to be serialized represents a purchase order, you can generate an array of purchased items by applying the to a public field that returns an array of objects that represent order items. - - If no attributes are applied to a public field or property that returns an array of complex or primitive type objects, the generates a nested sequence of XML elements by default. To more precisely control what XML elements are generated, apply an and an to the field or property. For example, by default, the name of the generated XML element is derived from the member identifier You can change the name of the generated XML element by setting the property. - - If you serialize an array that contains items of a specific type and all the classes derived from that type, you must use the to declare each of the types. - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + You can apply the to a public field or read/write property that returns an array of objects. You can also apply it to collections and fields that return an or any field that returns an object that implements the interface. + + When you apply the to a class member, the method of the class generates a nested sequence of XML elements from that member. An XML schema document (an .xsd file), indicates such an array as a `complexType`. For example, if the class to be serialized represents a purchase order, you can generate an array of purchased items by applying the to a public field that returns an array of objects that represent order items. + + If no attributes are applied to a public field or property that returns an array of complex or primitive type objects, the generates a nested sequence of XML elements by default. To more precisely control what XML elements are generated, apply an and an to the field or property. For example, by default, the name of the generated XML element is derived from the member identifier You can change the name of the generated XML element by setting the property. + + If you serialize an array that contains items of a specific type and all the classes derived from that type, you must use the to declare each of the types. + > [!NOTE] -> You can use `XmlArray` in your code instead of the longer . - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example serializes a class instance into an XML document that contains several object arrays. The is applied to the members that become XML element arrays. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use `XmlArray` in your code instead of the longer . + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + + + +## Examples + The following example serializes a class instance into an XML document that contains several object arrays. The is applied to the members that become XML element arrays. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -150,20 +149,19 @@ Initializes a new instance of the class. - to two arrays. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/CPP/source.cpp" id="Snippet1"::: + to two arrays. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -214,21 +212,20 @@ The name of the XML element that the generates. Initializes a new instance of the class and specifies the XML element name generated in the XML document instance. - to two arrays, and serializes a class instance that contains those arrays. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/CPP/source.cpp" id="Snippet1"::: + to two arrays, and serializes a class instance that contains those arrays. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/.ctor/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/VB/source.vb" id="Snippet1"::: - :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/Common/MyClass1.xml" id="Snippet1"::: - + :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlArrayAttribute.XmlArrayAttribute1 Example/Common/MyClass1.xml" id="Snippet1"::: + ]]> @@ -288,22 +285,21 @@ Gets or sets the XML element name given to the serialized array. The XML element name of the serialized array. The default is the name of the member to which the is assigned. - when you want the generated XML element name to differ from the member's identifier. - - You can set the same value to more than one member as long as the generated XML document uses XML namespaces to distinguish between the identically named members. For more details about using namespaces and creating prefixed names in the XML document, see . - - - -## Examples - The following example serializes an instance of the `Library` class that contains a property named `Books` that returns an array of `Book` items. The example uses the property to specify that the array of XML elements should be named `My_Books` rather than `Books`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/CPP/source.cpp" id="Snippet1"::: + when you want the generated XML element name to differ from the member's identifier. + + You can set the same value to more than one member as long as the generated XML document uses XML namespaces to distinguish between the identically named members. For more details about using namespaces and creating prefixed names in the XML document, see . + + + +## Examples + The following example serializes an instance of the `Library` class that contains a property named `Books` that returns an array of `Book` items. The example uses the property to specify that the array of XML elements should be named `My_Books` rather than `Books`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/ElementName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -364,34 +360,33 @@ Gets or sets a value that indicates whether the XML element name generated by the is qualified or unqualified. One of the values. The default is . - property determines whether an XML element name is qualified or unqualified. The property conforms to the 1999 World Wide Web Consortium document titled [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). - - If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. - - The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: - -``` - - - - -``` - - When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. - - - -## Examples - The following example serializes an instance of the `Enterprises` class. Two XML elements have the same local name (`Company`) but different prefixes. The example sets the property is set to `XmlForm.Qualified` to ensure that the qualified names occur in the XML instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/CPP/source.cpp" id="Snippet1"::: + + If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. + + The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: + +``` + + + + +``` + + When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. + + + +## Examples + The following example serializes an instance of the `Enterprises` class. Two XML elements have the same local name (`Company`) but different prefixes. The example sets the property is set to `XmlForm.Qualified` to ensure that the qualified names occur in the XML instance. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/Form/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.Form Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -454,31 +449,30 @@ attributeFormDefault="unqualified"... > if the generates the attribute; otherwise, . - property is set to `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. - -``` - -``` - - If the property is `false`, no XML element is generated. - + + If the property is set to `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. + +``` + +``` + + If the property is `false`, no XML element is generated. + > [!NOTE] -> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. - - - -## Examples - The following example contains two arrays: one with the property set to `true`, and another with the property set to `false`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/CPP/source.cpp" id="Snippet1"::: +> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. + + + +## Examples + The following example contains two arrays: one with the property set to `true`, and another with the property set to `false`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/IsNullable/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -537,22 +531,21 @@ attributeFormDefault="unqualified"... > Gets or sets the namespace of the XML element. The namespace of the XML element. - property allows you to create qualified XML element names. The property conforms to the rules for creating an XML namespace as found in the 1999 World Wide Web Consortium document titled [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). - - To create namespaces that are associated with a prefix, you must create an instance of the class that contains the namespaces and prefixes used in the XML document. As you set the namespace for each , it must match one of the namespaces in the . When the XML is generated, each array is correctly prefixed with the prefix associated with the specified namespace. - - - -## Examples - The following example serializes an instance of the `Library` class that contains two members, one that contain book titles, and another that contain periodical titles. Although both XML elements are named `Titles`, each contains a different prefix. The example also includes an instance of the class that contains the namespaces and prefixes used to qualify the two element names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/CPP/source.cpp" id="Snippet1"::: + + To create namespaces that are associated with a prefix, you must create an instance of the class that contains the namespaces and prefixes used in the XML document. As you set the namespace for each , it must match one of the namespaces in the . When the XML is generated, each array is correctly prefixed with the prefix associated with the specified namespace. + + + +## Examples + The following example serializes an instance of the `Library` class that contains two members, one that contain book titles, and another that contain periodical titles. Although both XML elements are named `Titles`, each contains a different prefix. The example also includes an instance of the class that contains the namespaces and prefixes used to qualify the two element names. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayAttribute/Namespace/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -609,14 +602,14 @@ attributeFormDefault="unqualified"... > Gets or sets the explicit order in which the elements are serialized or deserialized. The order of the code generation. - enumeration to instruct the to generate code that sets the property. - + enumeration to instruct the to generate code that sets the property. + > [!IMPORTANT] -> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. - +> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. + ]]> diff --git a/xml/System.Xml.Serialization/XmlArrayItemAttribute.xml b/xml/System.Xml.Serialization/XmlArrayItemAttribute.xml index 491697c7708..98641f2a3fd 100644 --- a/xml/System.Xml.Serialization/XmlArrayItemAttribute.xml +++ b/xml/System.Xml.Serialization/XmlArrayItemAttribute.xml @@ -61,35 +61,34 @@ Represents an attribute that specifies the derived types that the can place in a serialized array. - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - You can apply the to any public read/write member that returns an array, or provides access to one. For example, a field that returns an array of objects, a collection, an , or any class that implements the interface. - - The supports polymorphism--in other words, it allows the to add derived objects to an array. For example, suppose a class named `Mammal` is derived from a base class named `Animal`. Further suppose that a class named `MyAnimals` contains a field that returns an array of `Animal` objects. To allow the to serialize both the `Animal` and `Mammal` type, apply the to the field twice, each time specifying one of the two acceptable types. - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + You can apply the to any public read/write member that returns an array, or provides access to one. For example, a field that returns an array of objects, a collection, an , or any class that implements the interface. + + The supports polymorphism--in other words, it allows the to add derived objects to an array. For example, suppose a class named `Mammal` is derived from a base class named `Animal`. Further suppose that a class named `MyAnimals` contains a field that returns an array of `Animal` objects. To allow the to serialize both the `Animal` and `Mammal` type, apply the to the field twice, each time specifying one of the two acceptable types. + > [!NOTE] -> You can apply multiple instances of the or to specify types of objects that can be inserted into the array. - +> You can apply multiple instances of the or to specify types of objects that can be inserted into the array. + > [!NOTE] -> The serialization of a field or property that returns an interface or array of interfaces is not supported. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - +> The serialization of a field or property that returns an interface or array of interfaces is not supported. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlArrayItem` in your code instead of the longer . - - - -## Examples - The following example serializes a class named `Group` that contains a field named `Employees` that returns an array of `Employee` objects. The example applies the to the field, thereby instructing the that it can insert objects of both the base class (`Employee`) type and derived class type (`Manager`) into the serialized array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlArrayItem` in your code instead of the longer . + + + +## Examples + The following example serializes a class named `Group` that contains a field named `Employees` that returns an array of `Employee` objects. The example applies the to the field, thereby instructing the that it can insert objects of both the base class (`Employee`) type and derived class type (`Manager`) into the serialized array. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -159,15 +158,14 @@ Initializes a new instance of the class. - to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/CPP/source.cpp" id="Snippet1"::: + to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -222,24 +220,23 @@ The name of the XML element. Initializes a new instance of the class and specifies the name of the XML element generated in the XML document. - property. - - Use this overload if you want the name of the generated XML element to differ from the member's identifier. - - An XML document that includes namespaces can contain more than one version of an element name. For details, see the property. - - - -## Examples - The following example serializes a class named `Transportation` that contains a field named `MyVehicles` that returns an array of `Vehicle` objects. The example applies the to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `elementName` parameter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/CPP/source.cpp" id="Snippet1"::: + property. + + Use this overload if you want the name of the generated XML element to differ from the member's identifier. + + An XML document that includes namespaces can contain more than one version of an element name. For details, see the property. + + + +## Examples + The following example serializes a class named `Transportation` that contains a field named `MyVehicles` that returns an array of `Vehicle` objects. The example applies the to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `elementName` parameter. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/.ctor/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -294,15 +291,14 @@ The of the object to serialize. Initializes a new instance of the class and specifies the that can be inserted into the serialized array. - to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `type` parameter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/CPP/source.cpp" id="Snippet1"::: + to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `type` parameter. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/.ctor/source2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute2 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -359,24 +355,23 @@ The of the object to serialize. Initializes a new instance of the class and specifies the name of the XML element generated in the XML document and the that can be inserted into the generated XML document. - and the properties. - - Use this overload if you want the name of the generated XML element to differ from the member's identifier. - - An XML document that includes namespaces can contain more than one version of an element name. For details, see the property. - - - -## Examples - The following example serializes a class named `Transportation` that contains a field named `MyVehicles` that returns an array of `Vehicle` objects. The example applies the to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `elementName` parameter, and the property using the `type` parameter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/CPP/source.cpp" id="Snippet1"::: + and the properties. + + Use this overload if you want the name of the generated XML element to differ from the member's identifier. + + An XML document that includes namespaces can contain more than one version of an element name. For details, see the property. + + + +## Examples + The following example serializes a class named `Transportation` that contains a field named `MyVehicles` that returns an array of `Vehicle` objects. The example applies the to the field, allowing the to insert instances of the `Car` class, which is derived from the `Vehicle` class, into the array. While applying the attribute, the example sets the property using the `elementName` parameter, and the property using the `type` parameter. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/.ctor/source3.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.XmlArrayItemAttribute3 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -434,79 +429,78 @@ Gets or sets the XML data type of the generated XML element. An XML schema definition (XSD) data type. - objects, and apply an with the property set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XML Schema type that is mapped to a string, apply the with its property set to the XML Schema type. However, this does not change the serialization format, only the schema for the member. - + objects, and apply an with the property set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XML Schema type that is mapped to a string, apply the with its property set to the XML Schema type. However, this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. - +> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient then passing it as an XML attribute. - - For more information about XML Schema data types, see the World Wide Web Consortium document [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - The following example serializes a class named `PurchaseOrder`. Several instances of the class are applied to three members, and the property for each instance is set to a type allowed in the array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlArrayItemAttribute Example/CPP/arrayitem.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient then passing it as an XML attribute. + + For more information about XML Schema data types, see the World Wide Web Consortium document [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples + The following example serializes a class named `PurchaseOrder`. Several instances of the class are applied to three members, and the property for each instance is set to a type allowed in the array. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/DataType/arrayitem.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlArrayItemAttribute Example/VB/arrayitem.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlArrayItemAttribute Example/VB/arrayitem.vb" id="Snippet1"::: + ]]> @@ -564,22 +558,21 @@ Gets or sets the name of the generated XML element. The name of the generated XML element. The default is the member identifier. - if you want the name of the generated XML element to differ from the member's identifier. - - You can set the same value to more than one class member if the generated XML document uses XML namespaces to distinguish between identically named members. For details about how to use namespaces and prefixed names in the XML document, see the class. - - - -## Examples - The following example sets the property for the `Vehicle` and `Car` class--thereby changing the names of XML elements that the generates for those classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/CPP/source.cpp" id="Snippet1"::: + if you want the name of the generated XML element to differ from the member's identifier. + + You can set the same value to more than one class member if the generated XML document uses XML namespaces to distinguish between identically named members. For details about how to use namespaces and prefixed names in the XML document, see the class. + + + +## Examples + The following example sets the property for the `Vehicle` and `Car` class--thereby changing the names of XML elements that the generates for those classes. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/ElementName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -637,32 +630,31 @@ Gets or sets a value that indicates whether the name of the generated XML element is qualified. One of the values. The default is . - property determines whether an XML element name is qualified, based on the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/xml-names/). - - If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. - - The default value, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. For elements, the checks the value of the schema-element attribute `elementFormDefault`. For attributes, it checks the value of the schema-element attribute `attributeFormDefault`. For example, the following XML Schema indicates that the `Name` element is qualified, while the `Number` element is unqualified. - -``` - - - - -``` - - - -## Examples - The following example sets the property for the `Vehicle` class to `XmlSchemaForm.Unqualified`, and the property for the `Car` class to `XmlSchemaForm.Qualified`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/CPP/source.cpp" id="Snippet1"::: + property determines whether an XML element name is qualified, based on the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/xml-names/). + + If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. + + The default value, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. For elements, the checks the value of the schema-element attribute `elementFormDefault`. For attributes, it checks the value of the schema-element attribute `attributeFormDefault`. For example, the following XML Schema indicates that the `Name` element is qualified, while the `Number` element is unqualified. + +``` + + + + +``` + + + +## Examples + The following example sets the property for the `Vehicle` class to `XmlSchemaForm.Unqualified`, and the property for the `Car` class to `XmlSchemaForm.Qualified`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/Form/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Form Example/VB/source.vb" id="Snippet1"::: + ]]> The property is set to and a value is specified. @@ -718,31 +710,30 @@ attributeFormDefault="unqualified"> if the generates the attribute; otherwise, , and no instance is generated. The default is . - property is `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. - -``` - -``` - - If the property is `false`, no XML element is generated. - + property is `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example, if you set a field named `MyStringArray` to `null`, the generates the following XML code. + +``` + +``` + + If the property is `false`, no XML element is generated. + > [!NOTE] -> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. - - - -## Examples - The following example serializes a class named `Group`, which contains a field named `Employees` that returns an array of `Employee` objects. A second class named `Manager` derives from `Employee`. An specifies that the can insert both `Employee` and `Manager` objects into the array. The example sets the property, thereby telling the not to generate the `xsi:nil` attribute objects in the array set to `null`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/CPP/source.cpp" id="Snippet1"::: +> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. + + + +## Examples + The following example serializes a class named `Group`, which contains a field named `Employees` that returns an array of `Employee` objects. A second class named `Manager` derives from `Employee`. An specifies that the can insert both `Employee` and `Manager` objects into the array. The example sets the property, thereby telling the not to generate the `xsi:nil` attribute objects in the array set to `null`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/IsNullable/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -801,22 +792,21 @@ attributeFormDefault="unqualified"> Gets or sets the namespace of the generated XML element. The namespace of the generated XML element. - property conforms to the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/xml-names/). - - To create namespaces to use in the XML document and associated prefixes, you must create an that contains all the prefix and namespace pairs. The namespace you set for each must be contained in the . When the generates the document, it correctly prefixes the element name for each array item. - - - -## Examples - The following example applies an and sets the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/CPP/source.cpp" id="Snippet1"::: + property conforms to the World Wide Web Consortium specification [Namespaces in XML](https://www.w3.org/TR/xml-names/). + + To create namespaces to use in the XML document and associated prefixes, you must create an that contains all the prefix and namespace pairs. The namespace you set for each must be contained in the . When the generates the document, it correctly prefixes the element name for each array item. + + + +## Examples + The following example applies an and sets the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/Namespace/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -874,21 +864,20 @@ attributeFormDefault="unqualified"> Gets or sets the level in a hierarchy of XML elements that the affects. The zero-based index of a set of indexes in an array of arrays. - property is only used when applying an to a field that returns an array of arrays. - - When applying the attribute, specify which hierarchy level the attribute affects by setting the . The first index always has the value of 0; therefore it is optional to set its --an without a value is applied to the first array index. Only the subsequent objects require values specified (as 1, 2, 3, and so forth). - - - -## Examples - The following example applies three attributes to an array of arrays. To specify which of the arrays each attribute applies to, the property is set to the index of the arrays. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NestingLevel/cpp/nestinglevel.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/NestingLevel/nestinglevel.cs" id="Snippet1"::: - + property is only used when applying an to a field that returns an array of arrays. + + When applying the attribute, specify which hierarchy level the attribute affects by setting the . The first index always has the value of 0; therefore it is optional to set its --an without a value is applied to the first array index. Only the subsequent objects require values specified (as 1, 2, 3, and so forth). + + + +## Examples + The following example applies three attributes to an array of arrays. To specify which of the arrays each attribute applies to, the property is set to the index of the arrays. + + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/NestingLevel/nestinglevel.cs" id="Snippet1"::: + ]]> @@ -947,81 +936,80 @@ attributeFormDefault="unqualified"> Gets or sets the type allowed in an array. A that is allowed in the array. - property to specify an overridden type for a public field or public read/write property value. - - If a field or property returns an array of type , apply multiple instances of the to the field or property. For each instance, set the property to a type of object that can be inserted into the array. - - If an array contains only primitive types, you do not need to apply the . By default, the generates a series of elements, each with the same element name, for each value, but the type of each element is set to the XML Schema data type. For example, the following code: - -``` -' Visual Basic code -Public Class Arrays - Public XSDTypes ()As Object= New Object(){"one", 2, 3.0} -End Class -// C# code -public class MyArray{ - // No XmlArrayItemAttribute is applied. - public object[] XSDTypes= new object[]{"one", 2, 3.2}; -} -``` - - results in this XML: - -``` - - - - one - 2 - 3 - - -``` - - However, if you specify the property for each primitive type, the element name for each value is generated using the .NET type name. For example this code: - -``` -' Visual Basic code -Public Class Arrays - _ - Public PrimitiveTypes () As Object = New Object(){"one", 2, 3.0} -End Class -// C# code -public class Arrays{ - [XmlArrayItem(typeof(string))] - [XmlArrayItem(typeof(int))] - [XmlArrayItem(typeof(double))] - public object [] PrimitiveTypes = new object[]{"one", 2, 3.0}; -} -``` - - results in this XML: - -``` - - - - one - 2 - 3 - - -``` - - - -## Examples - The following example serializes an array of objects. The field that returns the array is attributed with two instances. Each instance instructs the to accept the specified in the array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/CPP/source.cpp" id="Snippet1"::: + property to specify an overridden type for a public field or public read/write property value. + + If a field or property returns an array of type , apply multiple instances of the to the field or property. For each instance, set the property to a type of object that can be inserted into the array. + + If an array contains only primitive types, you do not need to apply the . By default, the generates a series of elements, each with the same element name, for each value, but the type of each element is set to the XML Schema data type. For example, the following code: + +``` +' Visual Basic code +Public Class Arrays + Public XSDTypes ()As Object= New Object(){"one", 2, 3.0} +End Class +// C# code +public class MyArray{ + // No XmlArrayItemAttribute is applied. + public object[] XSDTypes= new object[]{"one", 2, 3.2}; +} +``` + + results in this XML: + +``` + + + + one + 2 + 3 + + +``` + + However, if you specify the property for each primitive type, the element name for each value is generated using the .NET type name. For example this code: + +``` +' Visual Basic code +Public Class Arrays + _ + Public PrimitiveTypes () As Object = New Object(){"one", 2, 3.0} +End Class +// C# code +public class Arrays{ + [XmlArrayItem(typeof(string))] + [XmlArrayItem(typeof(int))] + [XmlArrayItem(typeof(double))] + public object [] PrimitiveTypes = new object[]{"one", 2, 3.0}; +} +``` + + results in this XML: + +``` + + + + one + 2 + 3 + + +``` + + + +## Examples + The following example serializes an array of objects. The field that returns the array is attributed with two instances. Each instance instructs the to accept the specified in the array. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlArrayItemAttribute/Type/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlArrayItemAttribute.Type Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlAttributeAttribute.xml b/xml/System.Xml.Serialization/XmlAttributeAttribute.xml index 611b1ddb359..77e839f0cdc 100644 --- a/xml/System.Xml.Serialization/XmlAttributeAttribute.xml +++ b/xml/System.Xml.Serialization/XmlAttributeAttribute.xml @@ -73,49 +73,48 @@ Specifies that the must serialize the class member as an XML attribute. - belongs to a family of attributes that controls how the serializes, or deserializes, an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - When applied to a public field or property, the informs the to serialize the member as an XML attribute. By default, the serializes public fields and properties as XML elements. - - You can assign the only to public fields or public properties that return a value (or array of values) that can be mapped to one of the XML Schema definition language (XSD) simple types (including all built-in datatypes derived from the XSD `anySimpleType` type). The possible types include any that can be mapped to the XSD simple types, including , , and enumerations. See the property for a list of XSD types and how they are mapped to.NET data types. - - There are two special attributes that can be set with the : the `xml:lang` (specifies language) and `xml:space` (specifies how to handle white space) attributes. These attributes are intended to convey information that is relevant only to an application processing the XML. Examples of setting these are shown in the following code. - -```csharp -[XmlAttribute("xml:lang")] - public string Lang; - // Set this to 'default' or 'preserve'. - [XmlAttribute("space", - Namespace = "http://www.w3.org/XML/1998/namespace")] - public string Space + belongs to a family of attributes that controls how the serializes, or deserializes, an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + When applied to a public field or property, the informs the to serialize the member as an XML attribute. By default, the serializes public fields and properties as XML elements. + + You can assign the only to public fields or public properties that return a value (or array of values) that can be mapped to one of the XML Schema definition language (XSD) simple types (including all built-in datatypes derived from the XSD `anySimpleType` type). The possible types include any that can be mapped to the XSD simple types, including , , and enumerations. See the property for a list of XSD types and how they are mapped to.NET data types. + + There are two special attributes that can be set with the : the `xml:lang` (specifies language) and `xml:space` (specifies how to handle white space) attributes. These attributes are intended to convey information that is relevant only to an application processing the XML. Examples of setting these are shown in the following code. + +```csharp +[XmlAttribute("xml:lang")] + public string Lang; + // Set this to 'default' or 'preserve'. + [XmlAttribute("space", + Namespace = "http://www.w3.org/XML/1998/namespace")] + public string Space ``` - ```vb - _ - Public Lang As String - ' Set this to 'default' or 'preserve'. - _ - Public Space As String -``` - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + ```vb + _ + Public Lang As String + ' Set this to 'default' or 'preserve'. + _ + Public Space As String +``` + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlAttribute` in your code instead of the longer . - - - -## Examples - The following example serializes a class that contains several fields to which the is applied. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlAttribute` in your code instead of the longer . + + + +## Examples + The following example serializes a class that contains several fields to which the is applied. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -177,13 +176,12 @@ Initializes a new instance of the class. - @@ -241,13 +239,12 @@ The name of the XML attribute that the generates. Initializes a new instance of the class and specifies the name of the generated XML attribute. - @@ -420,20 +417,19 @@ Gets or sets the name of the XML attribute. The name of the XML attribute. The default is the member name. - property to specify an XML attribute name when the default value cannot be used. For example, if the XML attribute name is invalid as a member identifier, you can use a valid name for the identifier while setting the to an invalid name. - - - -## Examples - The following example sets the property of an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/CPP/source.cpp" id="Snippet1"::: + property to specify an XML attribute name when the default value cannot be used. For example, if the XML attribute name is invalid as a member identifier, you can use a valid name for the identifier while setting the to an invalid name. + + + +## Examples + The following example sets the property of an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeAttribute/AttributeName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.AttributeName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -495,79 +491,78 @@ Gets or sets the XSD data type of the XML attribute generated by the . An XSD (XML Schema Document) data type. - structures, and apply a with the property set to "base64Binary" or "hexBinary", as appropriate. For the XSD `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XSD type that is mapped to a string, apply the with its property set to the XSD type. However, this does not change the serialization format, only the schema for the member. - + structures, and apply a with the property set to "base64Binary" or "hexBinary", as appropriate. For the XSD `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XSD type that is mapped to a string, apply the with its property set to the XSD type. However, this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XSD data types. - +> The property is case-sensitive, so you must set it exactly to one of the XSD data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient than passing it as an XML attribute. - - For more information about XML data types, see the [XML Schema Part 2: DataTypes](https://www.w3.org/TR/xmlschema-2/) document from the World Wide Web Consortium. - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - The following example applies the to two members, and sets the property set to different values. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/CPP/source.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient than passing it as an XML attribute. + + For more information about XML data types, see the [XML Schema Part 2: DataTypes](https://www.w3.org/TR/xmlschema-2/) document from the World Wide Web Consortium. + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples + The following example applies the to two members, and sets the property set to different values. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeAttribute/DataType/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.DataType Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -628,34 +623,33 @@ Gets or sets a value that indicates whether the XML attribute name generated by the is qualified. One of the values. The default is . - property determines whether an XML element is qualified or unqualified. The property conforms to the 1999 http://www.w3.org specification `Namespaces in XML`. - - If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. - - The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: - -```xml - - - - -``` - - When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. - - - -## Examples - The following example applies the to two fields contained in a class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/CPP/source.cpp" id="Snippet1"::: + property determines whether an XML element is qualified or unqualified. The property conforms to the 1999 http://www.w3.org specification `Namespaces in XML`. + + If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. + + The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: + +```xml + + + + +``` + + When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. + + + +## Examples + The following example applies the to two fields contained in a class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeAttribute/Form/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Form Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -717,22 +711,21 @@ attributeFormDefault="unqualified"... > Gets or sets the XML namespace of the XML attribute. The XML namespace of the XML attribute. - property conforms to the http://www.w3.org specification `Namespaces in XML`. - - To create namespaces that are associated with prefixes, you must create an object that contains the namespaces and prefixes used in the XML document. The namespace you set for each must match one of the namespaces in the object. When the generates the XML code, it correctly prefixes each attribute name. - - - -## Examples - The following example applies the to two fields contained in a class. The example sets the property for each attribute to a value different from the member identifier. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/CPP/source.cpp" id="Snippet1"::: + property conforms to the http://www.w3.org specification `Namespaces in XML`. + + To create namespaces that are associated with prefixes, you must create an object that contains the namespaces and prefixes used in the XML document. The namespace you set for each must match one of the namespaces in the object. When the generates the XML code, it correctly prefixes each attribute name. + + + +## Examples + The following example applies the to two fields contained in a class. The example sets the property for each attribute to a value different from the member identifier. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeAttribute/Namespace/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlAttributeEventArgs.xml b/xml/System.Xml.Serialization/XmlAttributeEventArgs.xml index a8caf2b1176..9f60d700c33 100644 --- a/xml/System.Xml.Serialization/XmlAttributeEventArgs.xml +++ b/xml/System.Xml.Serialization/XmlAttributeEventArgs.xml @@ -53,7 +53,7 @@ event occurs only when you call the method. @@ -69,7 +69,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: @@ -135,7 +134,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: @@ -242,7 +240,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: @@ -307,7 +304,6 @@ ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: @@ -370,7 +366,6 @@ ## Examples The following example prints the value returned by the method when the method encounters an unknown attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/ObjectBeingDeserialized/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeEventArgs.ObjectBeingDeserialized Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/XmlAttributeEventHandler.xml b/xml/System.Xml.Serialization/XmlAttributeEventHandler.xml index 3e567b92864..f6f32f211c9 100644 --- a/xml/System.Xml.Serialization/XmlAttributeEventHandler.xml +++ b/xml/System.Xml.Serialization/XmlAttributeEventHandler.xml @@ -60,29 +60,28 @@ An that contains the event data. Represents the method that handles the . - delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - The event occurs only when an object is being deserialized with the method. - - - -## Examples - The following example deserializes a class named `Group` from a file named UnknownAttributes.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownAttributes.xml. - -``` - - - MyGroup - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: + delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + The event occurs only when an object is being deserialized with the method. + + + +## Examples + The following example deserializes a class named `Group` from a file named UnknownAttributes.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownAttributes.xml. + +``` + + + MyGroup + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlAttributeOverrides.xml b/xml/System.Xml.Serialization/XmlAttributeOverrides.xml index 5ade2b5dacd..c5386f35a2b 100644 --- a/xml/System.Xml.Serialization/XmlAttributeOverrides.xml +++ b/xml/System.Xml.Serialization/XmlAttributeOverrides.xml @@ -85,7 +85,6 @@ ## Examples The following example serializes a class named `Orchestra`, which contains a single field named `Instruments` that returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example uses an instance of the class to override the `Instrument` field, allowing the field to accept `Brass` objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeOverrides/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeOverrides Example/VB/source.vb" id="Snippet1"::: @@ -213,7 +212,6 @@ ## Examples The following example serializes a class named `Band`, which is derived from a class named `Orchestra`. The example creates an object, and assigns it to the property of an object. The example then calls the method to add the object to the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeOverrides/Add/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add Example/VB/source.vb" id="Snippet1"::: @@ -293,7 +291,6 @@ ## Examples The following example creates an object, and assigns it to the property of an object. The example then adds the object to an object, before creating an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeOverrides/Add/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeOverrides.Add1 Example/VB/source.vb" id="Snippet1"::: @@ -379,7 +376,6 @@ ## Examples The following example creates an object, an object, and an object. The example assigns the to the property of the object, and adds the object to the object. Lastly, the example gets the object by passing the of the serialized class to the object. In this example, the is `Group`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeOverrides/Item/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this Example/VB/source.vb" id="Snippet1"::: @@ -455,7 +451,6 @@ ## Examples The following example creates an object, an , and an object. The example assigns the to the property of the object and adds the object to the object. Lastly, the example gets the object by passing the of the serialized class and member name to the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeOverrides/Item/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributeOverrides.this1 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/XmlAttributes.xml b/xml/System.Xml.Serialization/XmlAttributes.xml index 80c16cb2093..1140f63a8bd 100644 --- a/xml/System.Xml.Serialization/XmlAttributes.xml +++ b/xml/System.Xml.Serialization/XmlAttributes.xml @@ -69,7 +69,6 @@ ## Examples The following example serializes an instance of a class named `Orchestra`, which contains a single field named `Instruments` that returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example creates an object to override the `Instrument` field--allowing the field to accept `Brass` objects--and adds the object to an instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/VB/source.vb" id="Snippet1"::: @@ -138,7 +137,6 @@ ## Examples The following example serializes an instance of a class named `Orchestra`, which contains a single field named `Instruments` that returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example creates an object to override the `Instrument` field--allowing the field to accept `Brass` objects--and adds the object to an instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttributes Example/VB/source.vb" id="Snippet1"::: @@ -325,7 +323,6 @@ ## Examples The following example creates a new object and adds it to the collection of objects accessed through the property. The object is then added to a object which is used to create an object. The is used to serialize or deserialize an object. To see the effect of using the property, create an XML document named "UnknownElements.xml" by running the `SerializeObject` method in the `Main` method. Edit the resulting document to include other (unknown) elements. Comment out the `SerializeObject` call in the `Main` method, and uncomment the call to the `DeserializeObject` method, which prints out the name and value of any unknown XML element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/CPP/xmlanyover.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAnyElementAttributes/Overview/xmlanyover.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAttributes.XmlAnyElements/VB/xmlanyover.vb" id="Snippet1"::: @@ -404,7 +401,6 @@ ## Examples The following example serializes a class that contains a field named `Members` that returns an array of objects. The is used to override the serialization of the field, and rename the element name to `Staff`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlArray/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlArray Example/VB/source.vb" id="Snippet1"::: @@ -473,7 +469,6 @@ ## Examples The following example serializes a class that contains a field named `Members` that returns an array of objects. Two objects are created to allow the field to accept objects that derive from the base class named `Member`. Each object is added to the through the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlArrayItems/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlArrayItems Example/VB/source.vb" id="Snippet1"::: @@ -545,7 +540,6 @@ ## Examples The following example serializes a class named `Group` that contains a property named `GroupName`; the `GroupName` property is serialized as an XML attribute. The example creates an and an object to override the default serialization of the field. The example then creates an to specifically override the property, and the object is set to the property The object is added to the object with the name of the overridden member specified. Finally, an is constructed and returned using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlAttribute Example/VB/source.vb" id="Snippet1"::: @@ -688,7 +682,6 @@ ## Examples The following example shows a class named `Pet` that contains a field that has a default value set to "Dog". However, the example also creates an object, and sets its property to a new default value ("Cat"). This overrides the original default value. Thus, if the field value is set to "Cat", the treats it as the default value, and not serialize it. If it is set to any other value, the serializes the value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlDefaultValue/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlDefaultValue Example/VB/source.vb" id="Snippet1"::: @@ -757,7 +750,6 @@ ## Examples The following example serializes the `Transportation` class, which contains a single field named `Vehicles` that returns an . The example applies two attributes to the `Vehicles` field. The example creates two objects and adds them to the collection of an object. To allow the array to accept different object types, the object is added to the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlElements/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlElements Example/VB/source.vb" id="Snippet1"::: @@ -827,7 +819,6 @@ ## Examples The following example serializes two classes named `Food` and `FoodType`. The `FoodType` class contains two enumerations that are overridden and, for each enumeration, the example creates an object that it assigns to the property of an object. The example then adds the object to an object, which is used to create an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlEnum/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlEnum Example/VB/source.vb" id="Snippet1"::: @@ -901,7 +892,6 @@ ## Examples The following example serializes a class named `Group`, which contains a member named `Comment` to which the is applied. The example creates an object, and sets the property to `false`, thereby overriding the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlIgnore/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlIgnore Example/VB/source.vb" id="Snippet1"::: @@ -969,7 +959,6 @@ ## Examples The following example contains a class named `Student`. The class contains a member named `MyNamespaces` that returns an object. The example creates an object that is added to an instance of the class. The property is set to `true`, which instructs the to preserve the namespaces when the serialization of the `Student` object is overridden. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/CPP/xmlns.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/Xmlns/xmlns.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlAttributes.Xmlns property example/VB/xmlns.vb" id="Snippet1"::: @@ -1036,7 +1025,6 @@ ## Examples The following example creates an object, an object, and an object. The example assigns the to the property of the object, and adds the object to the object. Lastly, the example gets the object by passing the of the serialized class to the object. (In this example, the is `Group`.) - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlRoot/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlRoot Example/VB/source.vb" id="Snippet1"::: @@ -1111,7 +1099,6 @@ ## Examples The following example serializes the class named `Group`, which contains a field named `Comment`. To override the default way the serializes the field, the example creates an and an object. The example then creates an object, which it assigns to the property, and adds the object (with the name of the field to be serialized as XML text) to the object. Lastly the example creates an using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlText/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlText Example/VB/source.vb" id="Snippet1"::: @@ -1181,7 +1168,6 @@ ## Examples The following example creates an object, and assigns it to the property of an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributes/XmlType/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlAttributes.XmlType Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/XmlChoiceIdentifierAttribute.xml b/xml/System.Xml.Serialization/XmlChoiceIdentifierAttribute.xml index 7b2a65d7dfc..3835a711151 100644 --- a/xml/System.Xml.Serialization/XmlChoiceIdentifierAttribute.xml +++ b/xml/System.Xml.Serialization/XmlChoiceIdentifierAttribute.xml @@ -61,113 +61,112 @@ Specifies that the member can be further detected by using an enumeration. - - - - - - - - -``` - - The allows you to assign a special enumeration value to each instance of the member. You must either create the enumeration yourself or it can be generated by the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The following C# code shows how the is applied to an `Item` field; the property identifies the field that contains the enumeration that is further used to detect the choice. - -``` -public class Choices{ - [XmlChoiceIdentifier("ItemType")] - [XmlChoiceIdentifier("ChoiceOne")] - [XmlChoiceIdentifier("ChoiceTwo")] - public string MyChoice; - - // Do not serialize this next field: - [XmlIgnore] - public ItemChoiceType ItemType; -} -// Do not include this enumeration in the XML schema. -[XmlType(IncludeInSchema = false)] -public enum ItemChoiceType{ - ChoiceOne, - ChoiceTwo, -} -``` - - When this code is in place, you can serialize and deserialize this class by setting the `ItemType` field to an appropriate enumeration. For example, to serialize the `Choice` class, the C# code resembles the following. - -``` -Choices mc = new Choices(); -mc.MyChoice = "Item Choice One"; -mc.ItemType = ItemChoiceType.ChoiceOne; -``` - - When deserializing, the C# code resembles the following: - -``` -MyChoice mc = (MyChoice) myXmlSerializer.Deserialize(myReader); -if(mc.ItemType == ItemChoiceType.ChoiceOne) - { - // Handle choice one. - } -if(mc.ItemType == ItemChoiceType.ChoiceTwo) - { - // Handle choice two. - } -if(mc.ItemType != null) - { - throw CreateUnknownTypeException(mc.Item); - } -``` - - There is a second scenario when the is used. In the following schema, the member is a field that returns an array of items (maxOccurs="unbounded"). The array can contain objects of the first choice ("D-a-t-a"), and of the second choice ("MoreData"). - -``` - - - - - - - - -``` - - The resulting class then uses a field to return an array of items. For each item in the array, a corresponding `ItemChoiceType` enumeration must also be found. The matching enumerations are contained in the array returned by the `ItemsElementName` field. - -``` -public class MyChoice { - [System.Xml.Serialization.XmlElementAttribute("D-a-t-a", typeof(string), IsNullable=false)] - [System.Xml.Serialization.XmlElementAttribute("MoreData", typeof(string), IsNullable=false)] - [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")] - public string[] Items; - [System.Xml.Serialization.XmlElementAttribute(IsNullable=false)] - [System.Xml.Serialization.XmlIgnoreAttribute()] - public ItemsChoiceType[] ItemsElementName; -} -[System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)] -public enum ItemsChoiceType { - [System.Xml.Serialization.XmlEnumAttribute("D-a-t-a")] - Data, - MoreData, -} -``` - - When deserializing an object that includes a range of choices, use a control structure (such as an if...then...else structure) to determine how to deserialize a particular value. In the control structure, check the enumeration value and deserialize the value accordingly. - - - -## Examples - The following example serializes a class named `Choices` that includes two fields, `MyChoice` and `ManyChoices`. The is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp" id="Snippet1"::: + + + + + + + + +``` + + The allows you to assign a special enumeration value to each instance of the member. You must either create the enumeration yourself or it can be generated by the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The following C# code shows how the is applied to an `Item` field; the property identifies the field that contains the enumeration that is further used to detect the choice. + +``` +public class Choices{ + [XmlChoiceIdentifier("ItemType")] + [XmlChoiceIdentifier("ChoiceOne")] + [XmlChoiceIdentifier("ChoiceTwo")] + public string MyChoice; + + // Do not serialize this next field: + [XmlIgnore] + public ItemChoiceType ItemType; +} +// Do not include this enumeration in the XML schema. +[XmlType(IncludeInSchema = false)] +public enum ItemChoiceType{ + ChoiceOne, + ChoiceTwo, +} +``` + + When this code is in place, you can serialize and deserialize this class by setting the `ItemType` field to an appropriate enumeration. For example, to serialize the `Choice` class, the C# code resembles the following. + +``` +Choices mc = new Choices(); +mc.MyChoice = "Item Choice One"; +mc.ItemType = ItemChoiceType.ChoiceOne; +``` + + When deserializing, the C# code resembles the following: + +``` +MyChoice mc = (MyChoice) myXmlSerializer.Deserialize(myReader); +if(mc.ItemType == ItemChoiceType.ChoiceOne) + { + // Handle choice one. + } +if(mc.ItemType == ItemChoiceType.ChoiceTwo) + { + // Handle choice two. + } +if(mc.ItemType != null) + { + throw CreateUnknownTypeException(mc.Item); + } +``` + + There is a second scenario when the is used. In the following schema, the member is a field that returns an array of items (maxOccurs="unbounded"). The array can contain objects of the first choice ("D-a-t-a"), and of the second choice ("MoreData"). + +``` + + + + + + + + +``` + + The resulting class then uses a field to return an array of items. For each item in the array, a corresponding `ItemChoiceType` enumeration must also be found. The matching enumerations are contained in the array returned by the `ItemsElementName` field. + +``` +public class MyChoice { + [System.Xml.Serialization.XmlElementAttribute("D-a-t-a", typeof(string), IsNullable=false)] + [System.Xml.Serialization.XmlElementAttribute("MoreData", typeof(string), IsNullable=false)] + [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")] + public string[] Items; + [System.Xml.Serialization.XmlElementAttribute(IsNullable=false)] + [System.Xml.Serialization.XmlIgnoreAttribute()] + public ItemsChoiceType[] ItemsElementName; +} +[System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)] +public enum ItemsChoiceType { + [System.Xml.Serialization.XmlEnumAttribute("D-a-t-a")] + Data, + MoreData, +} +``` + + When deserializing an object that includes a range of choices, use a control structure (such as an if...then...else structure) to determine how to deserialize a particular value. In the control structure, check the enumeration value and deserialize the value accordingly. + + + +## Examples + The following example serializes a class named `Choices` that includes two fields, `MyChoice` and `ManyChoices`. The is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlChoiceIdentifierAttribute/Overview/choice.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: + ]]> @@ -233,15 +232,14 @@ public enum ItemsChoiceType { Initializes a new instance of the class. - is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp" id="Snippet1"::: + is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlChoiceIdentifierAttribute/Overview/choice.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: + ]]> @@ -347,20 +345,19 @@ public enum ItemsChoiceType { Gets or sets the name of the field that returns the enumeration to use when detecting types. The name of a field that returns an enumeration. - value. By default, that enumeration name takes the name of the field that the is applied to. - - - -## Examples - The following example serializes a class named `Choices` that includes two fields, `MyChoice` and `ManyChoices`. The is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/CPP/choice.cpp" id="Snippet1"::: + value. By default, that enumeration name takes the name of the field that the is applied to. + + + +## Examples + The following example serializes a class named `Choices` that includes two fields, `MyChoice` and `ManyChoices`. The is applied to each field that specifies (through the property) another class member that gets or sets an enumeration that detects the member value. The `MyChoice` field can be set to a single value, with a corresponding enumeration member found in the `EnumType` field. The `ManyChoices` field returns an array of objects. The `ChoiceArray` field returns an array of enumeration values. For each array member in the `ManyChoices` field, a corresponding member is found in the array returned by the `ChoiceArray` field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlChoiceIdentifierAttribute/Overview/choice.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlChoiceIdentifierAttribute Example/VB/choice.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlElementAttribute.xml b/xml/System.Xml.Serialization/XmlElementAttribute.xml index baa7de0acd0..132dd255fac 100644 --- a/xml/System.Xml.Serialization/XmlElementAttribute.xml +++ b/xml/System.Xml.Serialization/XmlElementAttribute.xml @@ -73,59 +73,58 @@ Indicates that a public field or property represents an XML element when the serializes or deserializes the object that contains it. - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - An XML document usually contains XML elements, each of which consists of three parts: an opening tag with possible attributes, a closing tag, and the data between the tags. XML tags can be nested--that is, the data between tags can also be XML elements. This capacity of one element to enclose another allows the document to contain hierarchies of data. An XML element can also include attributes. - - Apply the to public fields or public read/write properties to control characteristics of the XML elements such as the element name and namespace. - - The can be applied multiple times to a field that returns an array of objects. The purpose of this is to specify (through the property) different types that can be inserted into the array. For example, the array in the following C# code accepts both strings and integers. - -``` -public class Things{ - [XmlElement(Type = typeof(string)), - XmlElement(Type = typeof(int))] - public object[] StringsAndInts; -} -``` - - This results in XML that might resemble the following. - -``` - - Hello - 999 - World - -``` - - Note that when you apply the multiple times without specifying an property value, the elements are named after the type of the acceptable objects. - - If you apply the to a field or property that returns an array, the items in the array are encoded as a sequence of XML elements. - - In contrast if an is not applied to such a field or property, the items in the array are encoded as a sequence of elements, nested under an element named after the field or property. (Use the and attributes to control how an array is serialized.) - - You can set the property to specify a type that is derived from the type of the original field or property--that is, the field or property to which you have applied the . - - If a field or property returns an , you can apply multiple instances of the to the member. For each instance, set the property to a type of object that can be inserted into the array. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + An XML document usually contains XML elements, each of which consists of three parts: an opening tag with possible attributes, a closing tag, and the data between the tags. XML tags can be nested--that is, the data between tags can also be XML elements. This capacity of one element to enclose another allows the document to contain hierarchies of data. An XML element can also include attributes. + + Apply the to public fields or public read/write properties to control characteristics of the XML elements such as the element name and namespace. + + The can be applied multiple times to a field that returns an array of objects. The purpose of this is to specify (through the property) different types that can be inserted into the array. For example, the array in the following C# code accepts both strings and integers. + +``` +public class Things{ + [XmlElement(Type = typeof(string)), + XmlElement(Type = typeof(int))] + public object[] StringsAndInts; +} +``` + + This results in XML that might resemble the following. + +``` + + Hello + 999 + World + +``` + + Note that when you apply the multiple times without specifying an property value, the elements are named after the type of the acceptable objects. + + If you apply the to a field or property that returns an array, the items in the array are encoded as a sequence of XML elements. + + In contrast if an is not applied to such a field or property, the items in the array are encoded as a sequence of elements, nested under an element named after the field or property. (Use the and attributes to control how an array is serialized.) + + You can set the property to specify a type that is derived from the type of the original field or property--that is, the field or property to which you have applied the . + + If a field or property returns an , you can apply multiple instances of the to the member. For each instance, set the property to a type of object that can be inserted into the array. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlElement` in your code instead of the longer . - - - -## Examples - The following example serializes a class named `Group` and applies the to several of its members. The field named `Employees` returns an array of `Employee` objects. In this case, the specifies that the resulting XML will not be nested (which is the default behavior of items in an array). - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlElement` in your code instead of the longer . + + + +## Examples + The following example serializes a class named `Group` and applies the to several of its members. The field named `Employees` returns an array of `Employee` objects. In this case, the specifies that the resulting XML will not be nested (which is the default behavior of items in an array). + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -193,15 +192,14 @@ public class Things{ Initializes a new instance of the class. - to a class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/CPP/source.cpp" id="Snippet1"::: + to a class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -253,20 +251,19 @@ public class Things{ The XML element name of the serialized member. Initializes a new instance of the class and specifies the name of the XML element. - uses the member name as the XML element name when serializing a class instance. For example, a field named `Vehicle` generates an XML element named `Vehicle`. However if you need a different element, such as `Cars`, pass it in the `elementName` parameter. - - - -## Examples - The following example shows a simple class that contains a single field named `Vehicles`. The example applies the to the field and includes the `elementName` parameter, thereby instructing the to generate XML elements named "Cars" rather than "Vehicles". - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/CPP/source.cpp" id="Snippet1"::: + uses the member name as the XML element name when serializing a class instance. For example, a field named `Vehicle` generates an XML element named `Vehicle`. However if you need a different element, such as `Cars`, pass it in the `elementName` parameter. + + + +## Examples + The following example shows a simple class that contains a single field named `Vehicles`. The example applies the to the field and includes the `elementName` parameter, thereby instructing the to generate XML elements named "Cars" rather than "Vehicles". + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/.ctor/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -318,20 +315,19 @@ public class Things{ The of an object derived from the member's type. Initializes a new instance of the class and specifies a type for the member to which the is applied. This type is used by the when serializing or deserializing object that contains it. - to accept the `Mammal` class when it serializes the `MyAnimal` property, pass the of the `Mammal` class to the constructor. - - - -## Examples - The following example serializes a class named `Orchestra` that contains a single field named `Instruments`, which returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example applies the to the `Instruments` field, and specifies the `Brass` type, allowing the `Instruments` field to accept `Brass` objects. The example also specifies the name of the XML element by setting the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp" id="Snippet1"::: + to accept the `Mammal` class when it serializes the `MyAnimal` property, pass the of the `Mammal` class to the constructor. + + + +## Examples + The following example serializes a class named `Orchestra` that contains a single field named `Instruments`, which returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example applies the to the `Instruments` field, and specifies the `Brass` type, allowing the `Instruments` field to accept `Brass` objects. The example also specifies the name of the XML element by setting the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/.ctor/source2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -385,22 +381,21 @@ public class Things{ The of an object derived from the member's type. Initializes a new instance of the and specifies the name of the XML element and a derived type for the member to which the is applied. This member type is used when the serializes the object that contains it. - uses the member name as the XML element name when serializing a class instance. For example, a field named `Vehicle` generates an XML element named `Vehicle`. However, if you need a different element, such as `Cars`, pass it in the `elementName` parameter. - - Use the `type` parameter to specify a type that is derived from a base class. For example, suppose a property named `MyAnimal` returns an `Animal` object. You want to enhance the object, so you create a new class named `Mammal` that inherits from the `Animal` class. To instruct the to accept the `Mammal` class when it serializes the `MyAnimal` property, pass the of the `Mammal` class to the constructor. - - - -## Examples - The following example serializes a class named `Orchestra` that contains a single field named `Instruments`, which returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example applies the to the `Instruments` field, and specifies the `Brass` type, allowing the `Instruments` field to accept `Brass` objects. The example also specifies the name of the XML element by setting the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/CPP/source.cpp" id="Snippet1"::: + uses the member name as the XML element name when serializing a class instance. For example, a field named `Vehicle` generates an XML element named `Vehicle`. However, if you need a different element, such as `Cars`, pass it in the `elementName` parameter. + + Use the `type` parameter to specify a type that is derived from a base class. For example, suppose a property named `MyAnimal` returns an `Animal` object. You want to enhance the object, so you create a new class named `Mammal` that inherits from the `Animal` class. To instruct the to accept the `Mammal` class when it serializes the `MyAnimal` property, pass the of the `Mammal` class to the constructor. + + + +## Examples + The following example serializes a class named `Orchestra` that contains a single field named `Instruments`, which returns an array of `Instrument` objects. A second class named `Brass` inherits from the `Instrument` class. The example applies the to the `Instruments` field, and specifies the `Brass` type, allowing the `Instruments` field to accept `Brass` objects. The example also specifies the name of the XML element by setting the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/.ctor/source2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.XmlElementAttribute2 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -461,79 +456,78 @@ public class Things{ Gets or sets the XML Schema definition (XSD) data type of the XML element generated by the . An XML Schema data type. - structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XML Schema type that is mapped to a string, apply the with its property set to the XML Schema type. It is possible that this can change the serialization format, not only the schema for the member. - + structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XML Schema type that is mapped to a string, apply the with its property set to the XML Schema type. It is possible that this can change the serialization format, not only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. - +> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient than passing it as an XML Schema attribute. - - For more information about XML data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - The following example serializes a class named `Group` that contains a field named `ExtraInfo`, which returns an . The example applies two instances of the to the field and specifies different values for each instance. Each instance enables the to serialize the specified types inserted into the array. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/CPP/source.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient than passing it as an XML Schema attribute. + + For more information about XML data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples + The following example serializes a class named `Group` that contains a field named `ExtraInfo`, which returns an . The example applies two instances of the to the field and specifies different values for each instance. Each instance enables the to serialize the specified types inserted into the array. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/DataType/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.DataType Example/VB/source.vb" id="Snippet1"::: + ]]> The XML Schema data type you have specified cannot be mapped to the.NET data type. @@ -595,22 +589,21 @@ public class Things{ Gets or sets the name of the generated XML element. The name of the generated XML element. The default is the member identifier. - if you want the name of the generated XML element to differ from the member's identifier. - - You can set the same value to more than one class member if the generated XML document uses XML namespaces to distinguish between the identically named members. For details on how to use namespaces and prefixed names in the XML document, see the class. - - - -## Examples - The following example sets the property of an to a new value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/CPP/source.cpp" id="Snippet1"::: + if you want the name of the generated XML element to differ from the member's identifier. + + You can set the same value to more than one class member if the generated XML document uses XML namespaces to distinguish between the identically named members. For details on how to use namespaces and prefixed names in the XML document, see the class. + + + +## Examples + The following example sets the property of an to a new value. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/ElementName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.ElementName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -672,32 +665,31 @@ public class Things{ Gets or sets a value that indicates whether the element is qualified. One of the values. The default is . - property determines whether an XML element is qualified or unqualified. The property conforms to the World Wide Web Consortium 1999 specification, [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). - - If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: - -``` - - - - -``` - - When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. - - - -## Examples - The following example sets the property to `XmlSchemaForm.Unqualified`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/CPP/source.cpp" id="Snippet1"::: + property determines whether an XML element is qualified or unqualified. The property conforms to the World Wide Web Consortium 1999 specification, [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). + + If the property is set to any value, attempting to set the property to `XmlSchemaForm.Unqualified` throws an exception. The default setting, `XmlSchemaForm.None`, instructs the to check the schema for the XML document to determine whether the namespace is qualified. If the schema does not specify a value for an individual element or attribute, the uses the `elementFormDefault` and `attributeFormDefault` values to determine whether an element or attribute is qualified. The following XML code shows a schema: + +``` + + + + +``` + + When the reads the schema, the value for both the `Name` and `Number` is `XmlSchemaForm.None`, but the `Name` element is qualified, while the `Number` element is unqualified. + + + +## Examples + The following example sets the property to `XmlSchemaForm.Unqualified`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/Form/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.Form Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -755,31 +747,30 @@ attributeFormDefault="unqualified"... > if the generates the attribute; otherwise, . - property is set to `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example if you set a field named `MyStringArray` to `null`, the generates the following XML code. - -``` - -``` - - If the property is `false`, no XML element is generated for class members that have been set to `null`. - + + If the property is set to `true`, the `xsi:nil` attribute is generated for class members that have been set to `null`. For example if you set a field named `MyStringArray` to `null`, the generates the following XML code. + +``` + +``` + + If the property is `false`, no XML element is generated for class members that have been set to `null`. + > [!NOTE] -> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. Additionally, you cannot set this property to `false` for nullable value types. When such types are `null`, they will be serialized by setting `xsi:nil` to `true`. - - - -## Examples - The following example shows a field with the applied to it, and the property set to `false`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/CPP/source.cpp" id="Snippet1"::: +> You cannot apply the property to a member typed as a value type because a value type cannot contain `null`. Additionally, you cannot set this property to `false` for nullable value types. When such types are `null`, they will be serialized by setting `xsi:nil` to `true`. + + + +## Examples + The following example shows a field with the applied to it, and the property set to `false`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/IsNullable/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -841,13 +832,13 @@ attributeFormDefault="unqualified"... > Gets or sets the namespace assigned to the XML element that results when the class is serialized. The namespace of the XML element. - property conforms to the World Wide Web Consortium specification, [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). - - To create namespaces that are associated with a prefix, you must create an that contains the namespaces and prefixes used in the XML document. As you set the namespace for each , it must match one of the namespaces in the . When the XML is generated, each array is correctly prefixed with the prefix associated with the specified namespace. - + property conforms to the World Wide Web Consortium specification, [Namespaces in XML](https://www.w3.org/TR/1999/REC-xml-names-19990114/). + + To create namespaces that are associated with a prefix, you must create an that contains the namespaces and prefixes used in the XML document. As you set the namespace for each , it must match one of the namespaces in the . When the XML is generated, each array is correctly prefixed with the prefix associated with the specified namespace. + ]]> @@ -903,14 +894,14 @@ attributeFormDefault="unqualified"... > Gets or sets the explicit order in which the elements are serialized or deserialized. The order of the code generation. - enumeration to instruct the to generate code that sets the property. - + enumeration to instruct the to generate code that sets the property. + > [!IMPORTANT] -> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. - +> Once the property has been used on one public property or field in a type, it must be applied to all public properties and fields for that type and all inherited types. + ]]> @@ -972,22 +963,21 @@ attributeFormDefault="unqualified"... > Gets or sets the object type used to represent the XML element. The of the member. - property to specify a derived type for a field or property. - - If a field or property returns an , you can apply multiple instances of the to the member. For each instance, set the property to a type of object that can be inserted into the array. - - - -## Examples - The following example uses the property to specify a derived object for an . The example also applies three instances of the to a field that returns an . Each instance specifies a type allowed in the field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/CPP/source.cpp" id="Snippet1"::: + property to specify a derived type for a field or property. + + If a field or property returns an , you can apply multiple instances of the to the member. For each instance, set the property to a type of object that can be inserted into the array. + + + +## Examples + The following example uses the property to specify a derived object for an . The example also applies three instances of the to a field that returns an . Each instance specifies a type allowed in the field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttribute/Type/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttribute.Type Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlElementAttributes.xml b/xml/System.Xml.Serialization/XmlElementAttributes.xml index c712b7cf210..17a9070436f 100644 --- a/xml/System.Xml.Serialization/XmlElementAttributes.xml +++ b/xml/System.Xml.Serialization/XmlElementAttributes.xml @@ -73,20 +73,19 @@ Represents a collection of objects used by the to override the default way it serializes a class. - is returned by the property of the class. By using the class and the class, you can override the default way that the serializes a class. - - - -## Examples - The following example serializes the `Transportation` class, which contains a single field named `Vehicles` that returns an . The example first applies two instances of the class to the `Vehicles` field that specifies the types of objects the inserts into the array. The example then creates two objects to override the behavior of the attributes applied to the `Vehicles` property. The two overriding objects are added to the collection of an . Lastly, the example adds the to an , allowing the to insert the new object types into the returned by the `Vehicles` field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes Example/CPP/source.cpp" id="Snippet1"::: + is returned by the property of the class. By using the class and the class, you can override the default way that the serializes a class. + + + +## Examples + The following example serializes the `Transportation` class, which contains a single field named `Vehicles` that returns an . The example first applies two instances of the class to the `Vehicles` field that specifies the types of objects the inserts into the array. The example then creates two objects to override the behavior of the attributes applied to the `Vehicles` property. The two overriding objects are added to the collection of an . Lastly, the example adds the to an , allowing the to insert the new object types into the returned by the `Vehicles` field. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttributes/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttributes Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttributes Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -192,15 +191,14 @@ Adds an to the collection. The zero-based index of the newly added item. - objects and calls the method to add them to an . The example then adds the to an , which is used to create an that can serialize an instance of the `Transportation` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/CPP/source.cpp" id="Snippet1"::: + objects and calls the method to add them to an . The example then adds the to an , which is used to create an that can serialize an instance of the `Transportation` class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementAttributes/Add/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlElementAttributes.Add Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlElementEventArgs.xml b/xml/System.Xml.Serialization/XmlElementEventArgs.xml index 1bd7bcbc624..1f0b5c8d75a 100644 --- a/xml/System.Xml.Serialization/XmlElementEventArgs.xml +++ b/xml/System.Xml.Serialization/XmlElementEventArgs.xml @@ -50,32 +50,31 @@ Provides data for the event. - event occurs only when you call the method. - - - -## Examples - The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: + event occurs only when you call the method. + + + +## Examples + The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: + ]]> @@ -125,25 +124,24 @@ Gets the object that represents the unknown XML element. The object that represents the unknown XML element. - event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: + event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: + ]]> @@ -233,30 +231,29 @@ Gets the line number where the unknown element was encountered if the XML reader is an . The line number where the unknown element was encountered if the XML reader is an ; otherwise, -1. - property returns a value only if the underlying XML reader is an . - - - -## Examples - The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: + property returns a value only if the underlying XML reader is an . + + + +## Examples + The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: + ]]> @@ -306,25 +303,24 @@ Gets the place in the line where the unknown element occurs if the XML reader is an . The number in the line where the unknown element occurs if the XML reader is an ; otherwise, -1. - event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: + event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: + ]]> @@ -379,23 +375,23 @@ Gets the object the is deserializing. The object that is being deserialized by the . - event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - XmlSerializer.UnknownElement Example#1 - + event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + + XmlSerializer.UnknownElement Example#1 + ]]> diff --git a/xml/System.Xml.Serialization/XmlElementEventHandler.xml b/xml/System.Xml.Serialization/XmlElementEventHandler.xml index 0c1a1583a59..ea6a8dec8fe 100644 --- a/xml/System.Xml.Serialization/XmlElementEventHandler.xml +++ b/xml/System.Xml.Serialization/XmlElementEventHandler.xml @@ -60,32 +60,31 @@ A that contains the event data. Represents the method that handles the event of an . - delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - The event occurs only when you call the method. - - - -## Examples - The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. - -``` - - - MyGroup - Large - 444 - West - -``` - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: + delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + The event occurs only when you call the method. + + + +## Examples + The following example deserializes a class named `Group` from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml. + +``` + + + MyGroup + Large + 444 + West + +``` + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlEnumAttribute.xml b/xml/System.Xml.Serialization/XmlEnumAttribute.xml index 71fa2c60017..e0aa2e47953 100644 --- a/xml/System.Xml.Serialization/XmlEnumAttribute.xml +++ b/xml/System.Xml.Serialization/XmlEnumAttribute.xml @@ -73,30 +73,29 @@ Controls how the serializes an enumeration member. - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - Use the to change the enumeration that the generates or recognizes (when it serializes or deserializes a class, respectively). For example, if an enumeration contains a member named `One`, but you prefer that the XML output be named `Single`, apply the to the enumeration member and set the property to "Single". - - You can override the property value of an by creating an instance of the class and assigning it to the property of an object. For details, see the class. - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + Use the to change the enumeration that the generates or recognizes (when it serializes or deserializes a class, respectively). For example, if an enumeration contains a member named `One`, but you prefer that the XML output be named `Single`, apply the to the enumeration member and set the property to "Single". + + You can override the property value of an by creating an instance of the class and assigning it to the property of an object. For details, see the class. + > [!NOTE] -> You can use the word `XmlEnum` in your code instead of the longer . - - - -## Examples - The following example applies the to the members of an enumeration. When the generates XML data for this enumeration, the data conforms to the values of the properties. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlEnum` in your code instead of the longer . + + + +## Examples + The following example applies the to the members of an enumeration. When the generates XML data for this enumeration, the data conforms to the values of the properties. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlEnumAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute Example/VB/source.vb" id="Snippet1"::: + > [!NOTE] -> You can use the word `XmlEnum` in your code instead of the longer . - +> You can use the word `XmlEnum` in your code instead of the longer . + ]]> @@ -169,23 +168,22 @@ Initializes a new instance of the class. - to override an existing enumeration. - + to override an existing enumeration. + > [!NOTE] -> You can use the word `XmlEnum` in your code instead of the longer . - - - -## Examples - The following example serializes two classes named `Food` and `FoodType`. The `FoodType` class contains two enumerations that are overridden and, for each enumeration, the example creates an object that is assigned to the property of an object. The example then adds the object to an object, which is used to create an . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlEnum` in your code instead of the longer . + + + +## Examples + The following example serializes two classes named `Food` and `FoodType`. The `FoodType` class contains two enumerations that are overridden and, for each enumeration, the example creates an object that is assigned to the property of an object. The example then adds the object to an object, which is used to create an . + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlEnumAttribute/.ctor/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.XmlEnumAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -246,22 +244,21 @@ The overriding name of the enumeration member. Initializes a new instance of the class, and specifies the XML value that the generates or recognizes (when it serializes or deserializes the enumeration, respectively). - [!NOTE] -> You can use the word `XmlEnum` in your code instead of the longer . - - - -## Examples - The following example applies the to the members of an enumeration. When the generates XML data for this enumeration, the data conforms to the values of the properties. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlEnum` in your code instead of the longer . + + + +## Examples + The following example applies the to the members of an enumeration. When the generates XML data for this enumeration, the data conforms to the values of the properties. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlEnumAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -326,23 +323,22 @@ Gets or sets the value generated in an XML-document instance when the serializes an enumeration, or the value recognized when it deserializes the enumeration member. The value generated in an XML-document instance when the serializes the enumeration, or the value recognized when it is deserializes the enumeration member. - when you want the generated XML data to differ from the enumeration identifier. - + when you want the generated XML data to differ from the enumeration identifier. + > [!NOTE] -> You can use the word `XmlEnum` in your code instead of the longer . - - - -## Examples - The following example applies the attribute to members of an enumeration. The generated XML data conforms to the values set for the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlEnum` in your code instead of the longer . + + + +## Examples + The following example applies the attribute to members of an enumeration. The generated XML data conforms to the values set for the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlEnumAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlEnumAttribute.Name Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlIgnoreAttribute.xml b/xml/System.Xml.Serialization/XmlIgnoreAttribute.xml index 3e0940d42c4..00fa03b8401 100644 --- a/xml/System.Xml.Serialization/XmlIgnoreAttribute.xml +++ b/xml/System.Xml.Serialization/XmlIgnoreAttribute.xml @@ -69,29 +69,28 @@ Instructs the method of the not to serialize the public field or public read/write property value. - belongs to a family of attributes that controls how the serializes or deserializes an object. If you apply the to any member of a class, the ignores the member when serializing or deserializing an instance of the class. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - You can override the behavior caused by the by creating an object, and setting its property to `false`. You must the object to an instance of the class. Lastly, you must use the object to construct an instance of the class before you call the or methods. - - The [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) occasionally generates the when creating classes from a schema file (.xsd). This behavior occurs because value types cannot be set to `null`, but all XML data types can be. Therefore, the tool creates two fields when it encounters an XML type that maps to a value type: one to hold the value and another special field that takes the form of `fieldnameSpecified`, where the `fieldname` is replaced by the name of the field or property. Notice, however, that this special field is generated only when the schema specifies that the element has no minimum occurrence (minOccurs = "0") and that the element has no default value. The sets and checks this special field to determine whether a value has been set for the field or property. Because the special field must not be serialized, the tool applies the to it. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + belongs to a family of attributes that controls how the serializes or deserializes an object. If you apply the to any member of a class, the ignores the member when serializing or deserializing an instance of the class. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + You can override the behavior caused by the by creating an object, and setting its property to `false`. You must the object to an instance of the class. Lastly, you must use the object to construct an instance of the class before you call the or methods. + + The [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) occasionally generates the when creating classes from a schema file (.xsd). This behavior occurs because value types cannot be set to `null`, but all XML data types can be. Therefore, the tool creates two fields when it encounters an XML type that maps to a value type: one to hold the value and another special field that takes the form of `fieldnameSpecified`, where the `fieldname` is replaced by the name of the field or property. Notice, however, that this special field is generated only when the schema specifies that the element has no minimum occurrence (minOccurs = "0") and that the element has no default value. The sets and checks this special field to determine whether a value has been set for the field or property. Because the special field must not be serialized, the tool applies the to it. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlIgnore` in your code instead of the longer . - - - -## Examples - The following example shows a class named `Group`, which contains a field named `Comment`. The example assigns the to the field, thereby instructing the to ignore the field when serializing or deserializing an instance of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlIgnore` in your code instead of the longer . + + + +## Examples + The following example shows a class named `Group`, which contains a field named `Comment`. The example assigns the to the field, thereby instructing the to ignore the field when serializing or deserializing an instance of the class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlIgnoreAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -153,15 +152,14 @@ Initializes a new instance of the class. - to the field, thereby instructing the to ignore the field when serializing or deserializing an instance of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/CPP/source.cpp" id="Snippet1"::: + to the field, thereby instructing the to ignore the field when serializing or deserializing an instance of the class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlIgnoreAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIgnoreAttribute.XmlIgnoreAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlIncludeAttribute.xml b/xml/System.Xml.Serialization/XmlIncludeAttribute.xml index 1ae4f82d0f0..dbed8356f55 100644 --- a/xml/System.Xml.Serialization/XmlIncludeAttribute.xml +++ b/xml/System.Xml.Serialization/XmlIncludeAttribute.xml @@ -65,24 +65,24 @@ Allows the to recognize a type when it serializes or deserializes an object. - when you call the or method of the class. - - When applying the , specify the of the derived class. When the serializes objects that include both the base and the derived class, it can then recognize both object types. - - You can use the to include derived classes in service description documents that are written in the Web Services Description Language (WSDL). For example, if a method returns an , apply the to the method and specify the actual types to return. - - For more information on the WSDL, see [Web Services Description Language (WSDL) 1.1](https://www.w3.org/TR/2001/NOTE-wsdl-20010315). - - - -## Examples - The following example shows three classes, two of which inherit from the third. The example applies the to a method that returns an instance of one of the derived classes. - + when you call the or method of the class. + + When applying the , specify the of the derived class. When the serializes objects that include both the base and the derived class, it can then recognize both object types. + + You can use the to include derived classes in service description documents that are written in the Web Services Description Language (WSDL). For example, if a method returns an , apply the to the method and specify the actual types to return. + + For more information on the WSDL, see [Web Services Description Language (WSDL) 1.1](https://www.w3.org/TR/2001/NOTE-wsdl-20010315). + + + +## Examples + The following example shows three classes, two of which inherit from the third. The example applies the to a method that returns an instance of one of the derived classes. + :::code language="aspx-csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlIncludeAttribute/Overview/sourcecs.asmx"::: - + ]]> @@ -144,15 +144,14 @@ The of the object to include. Initializes a new instance of the class. - to a method that returns an instance of one of the two derived classes. The example sets the property to the type of the returned object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/CPP/source.cpp" id="Snippet1"::: + to a method that returns an instance of one of the two derived classes. The example sets the property to the type of the returned object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlIncludeAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIncludeAttribute.XmlIncludeAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -211,15 +210,14 @@ Gets or sets the type of the object to include. The of the object to include. - to the `Employee` class. When the example creates a `Group` object, it inserts a `Manager` object into the `Employee` array. Lastly, the example serializes the `Group` object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/CPP/source.cpp" id="Snippet1"::: + to the `Employee` class. When the example creates a `Group` object, it inserts a `Manager` object into the `Employee` array. Lastly, the example serializes the `Group` object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlIncludeAttribute/Type/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlIncludeAttribute.Type Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlNodeEventArgs.xml b/xml/System.Xml.Serialization/XmlNodeEventArgs.xml index d35e18f184b..1165792d6d7 100644 --- a/xml/System.Xml.Serialization/XmlNodeEventArgs.xml +++ b/xml/System.Xml.Serialization/XmlNodeEventArgs.xml @@ -50,22 +50,21 @@ Provides data for the event. - event can occur only when you call the method. - - - -## Examples - The following example uses the event of the to print various properties of an unknown XML node that is encountered when calling the class's method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp" id="Snippet1"::: + event can occur only when you call the method. + + + +## Examples + The following example uses the event of the to print various properties of an unknown XML node that is encountered when calling the class's method. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -118,13 +117,12 @@ Gets the line number of the unknown XML node. The line number of the unknown XML node. - @@ -174,13 +172,12 @@ Gets the position in the line of the unknown XML node. The position number of the unknown XML node. - @@ -224,20 +221,19 @@ Gets the XML local name of the XML node being deserialized. The XML local name of the node being deserialized. - property returns the local name (also known as a local part) of an XML qualified name. The property conforms to the 1999 http://www.w3.org specification `Namespaces in XML`. - - - -## Examples - The following example prints the of an unknown XML node that is encountered when calling the class's method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/CPP/source.cpp" id="Snippet1"::: + property returns the local name (also known as a local part) of an XML qualified name. The property conforms to the 1999 http://www.w3.org specification `Namespaces in XML`. + + + +## Examples + The following example prints the of an unknown XML node that is encountered when calling the class's method. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/LocalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.LocalName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -283,15 +279,14 @@ Gets the name of the XML node being deserialized. The name of the node being deserialized. - event to occur. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/CPP/source.cpp" id="Snippet1"::: + event to occur. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/Name/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Name Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -337,15 +332,14 @@ Gets the namespace URI that is associated with the XML node being deserialized. The namespace URI that is associated with the XML node being deserialized. - event to occur. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/CPP/source.cpp" id="Snippet1"::: + event to occur. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/NamespaceURI/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NamespaceURI Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -391,20 +385,19 @@ Gets the type of the XML node being deserialized. The that represents the XML node being deserialized. - enumeration returns a description of the node being deserialized. For example, it returns "Comment" if the node is a comment. - - - -## Examples - The following example prints a description of the unknown node that caused the event to occur. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/CPP/source.cpp" id="Snippet1"::: + enumeration returns a description of the node being deserialized. For example, it returns "Comment" if the node is a comment. + + + +## Examples + The following example prints a description of the unknown node that caused the event to occur. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/NodeType/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.NodeType Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -461,15 +454,14 @@ Gets the object being deserialized. The being deserialized. - method when the method encounters an unknown XML node. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/CPP/source.cpp" id="Snippet1"::: + method when the method encounters an unknown XML node. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/ObjectBeingDeserialized/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.ObjectBeingDeserialized Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -522,15 +514,14 @@ Gets the text of the XML node being deserialized. The text of the XML node being deserialized. - event to occur. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/CPP/source.cpp" id="Snippet1"::: + event to occur. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/Text/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventArgs.Text Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlNodeEventHandler.xml b/xml/System.Xml.Serialization/XmlNodeEventHandler.xml index b7bfcf39415..cbf78cafeea 100644 --- a/xml/System.Xml.Serialization/XmlNodeEventHandler.xml +++ b/xml/System.Xml.Serialization/XmlNodeEventHandler.xml @@ -60,22 +60,21 @@ An that contains the event data. Represents the method that handles the event of an . - delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - The event occurs only when you call the method. - - - -## Examples - The following example creates an , adds an event handler for the event, and deserializes an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/CPP/source.cpp" id="Snippet1"::: + delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + + The event occurs only when you call the method. + + + +## Examples + The following example creates an , adds an event handler for the event, and deserializes an object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventHandler/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlNodeEventHandler Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlRootAttribute.xml b/xml/System.Xml.Serialization/XmlRootAttribute.xml index 20c54d37730..fbb46893a41 100644 --- a/xml/System.Xml.Serialization/XmlRootAttribute.xml +++ b/xml/System.Xml.Serialization/XmlRootAttribute.xml @@ -73,29 +73,28 @@ Controls XML serialization of the attribute target as an XML root element. - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - You can apply the to a class, structure, enumeration, or interface. You can also apply the attribute to the return value of an XML Web service method. - - Every XML document must have a single root element that contains all the other elements. The allows you to control how the generates the root element by setting certain properties. For example, specify the name of the generated XML element by setting the property. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + You can apply the to a class, structure, enumeration, or interface. You can also apply the attribute to the return value of an XML Web service method. + + Every XML document must have a single root element that contains all the other elements. The allows you to control how the generates the root element by setting certain properties. For example, specify the name of the generated XML element by setting the property. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlRoot` in your code instead of the longer . - - - -## Examples - The following example applies the to a class. The attribute specifies the element name, namespace, and whether the element is qualified, and whether the `xsi:nil` attribute is generated if the class is set to `null`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlRoot` in your code instead of the longer . + + + +## Examples + The following example applies the to a class. The attribute specifies the element name, namespace, and whether the element is qualified, and whether the `xsi:nil` attribute is generated if the class is set to `null`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlRootAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -160,15 +159,14 @@ Initializes a new instance of the class. - and assigns it to the property of an object. When the serializes the `MyClass` object, it uses the object to override the default root element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/CPP/source.cpp" id="Snippet1"::: + and assigns it to the property of an object. When the serializes the `MyClass` object, it uses the object to override the default root element. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlRootAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.XmlRootAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -221,15 +219,14 @@ The name of the XML root element. Initializes a new instance of the class and specifies the name of the XML root element. - @@ -287,71 +284,71 @@ Gets or sets the XSD data type of the XML root element. An XSD (XML Schema Document) data type. - structures, and apply a with the property set to "base64Binary" or "hexBinary", as appropriate. For the XSD `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XSD type that is mapped to a string, apply the with its property set to the XSD type. However, this does not change the serialization format, only the schema for the member. - + structures, and apply a with the property set to "base64Binary" or "hexBinary", as appropriate. For the XSD `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XSD type that is mapped to a string, apply the with its property set to the XSD type. However, this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XSD data types. - +> The property is case-sensitive, so you must set it exactly to one of the XSD data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient than passing it as an XML attribute. - - For more information about XML data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|recurringDate|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - +> Passing binary data as an XML element is more efficient than passing it as an XML attribute. + + For more information about XML data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|recurringDate|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + ]]> @@ -408,20 +405,19 @@ Gets or sets the name of the XML element that is generated and recognized by the class's and methods, respectively. The name of the XML root element that is generated and recognized in an XML-document instance. The default is the name of the serialized class. - if you want the name of the generated XML element to differ from the class name. - - - -## Examples - The following example creates an instance of the class and sets the property to a new value. The object is then used to create an object used to override the serialization of an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XMLRootAttribute_ElementName/CPP/xmlrootattribute_elementname.cpp" id="Snippet1"::: + if you want the name of the generated XML element to differ from the class name. + + + +## Examples + The following example creates an instance of the class and sets the property to a new value. The object is then used to create an object used to override the serialization of an object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlRootAttribute/ElementName/xmlrootattribute_elementname.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLRootAttribute_ElementName/VB/xmlrootattribute_elementname.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLRootAttribute_ElementName/VB/xmlrootattribute_elementname.vb" id="Snippet1"::: + ]]> @@ -479,36 +475,35 @@ if the generates the attribute; otherwise, . - property is set to `true`, the `xsi:nil` attribute is generated as shown in the following XML: - -``` - - -``` - - If the property is `false`, an empty element is created as shown in the following code: - -``` - - -``` - - - -## Examples - The following example serializes a class named `Group`. The example applies the to the class, and sets the property to `false`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/CPP/source.cpp" id="Snippet1"::: + + If the property is set to `true`, the `xsi:nil` attribute is generated as shown in the following XML: + +``` + + +``` + + If the property is `false`, an empty element is created as shown in the following code: + +``` + + +``` + + + +## Examples + The following example serializes a class named `Group`. The example applies the to the class, and sets the property to `false`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlRootAttribute/IsNullable/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.IsNullable Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -574,22 +569,21 @@ xmlns:xsd="http://www.w3.org/2001/XMLSchema" /> Gets or sets the namespace for the XML root element. The namespace for the XML element. - property conforms to the World Wide Web Consortium specification named [Namespaces in XML](https://www.w3.org/TR/xml-names/). - - To create prefixed namespaces in the XML document, create an object that contains all the prefix-namespace pairs. The namespace you set for each must be contained in the object. When the generates the document, it correctly prefixes the element name for each array item. - - - -## Examples - The following example applies the to a class and sets the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/CPP/source.cpp" id="Snippet1"::: + property conforms to the World Wide Web Consortium specification named [Namespaces in XML](https://www.w3.org/TR/xml-names/). + + To create prefixed namespaces in the XML document, create an object that contains all the prefix-namespace pairs. The namespace you set for each must be contained in the object. When the generates the document, it correctly prefixes the element name for each array item. + + + +## Examples + The following example applies the to a class and sets the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlRootAttribute/Namespace/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlRootAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlSerializer.xml b/xml/System.Xml.Serialization/XmlSerializer.xml index eb73609a3d3..2dc892c28cd 100644 --- a/xml/System.Xml.Serialization/XmlSerializer.xml +++ b/xml/System.Xml.Serialization/XmlSerializer.xml @@ -62,7 +62,6 @@ @@ -199,7 +198,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example constructs an that serializes an object named `Widget`. The example sets various properties of the object before calling the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source5.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer6 Example/VB/source.vb" id="Snippet1"::: @@ -277,7 +275,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes a class named `Group`. The serialization of the `GroupName`, `IgnoreThis` fields, and the members of the `GroupType` enumeration are overridden. In the `CreateOverrideSerializer` method, a object is created, and for each overridden member or enumeration, a object is created with the appropriate property set and added to the object. An object is created using the object, and that object is used to create the that overrides the default serialization. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapAttributesOverrides/CPP/soapover.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributeOverrides/Overview/soapover.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapAttributesOverrides/VB/SoapOver.vb" id="Snippet1"::: @@ -359,7 +356,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example constructs an that serializes an object named `Widget`. The example sets various properties of the object before calling the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer1 Example/VB/source.vb" id="Snippet1"::: @@ -452,7 +448,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an instance of a class that contains a public field that returns an array of objects. The `extraTypes` parameter of the constructor specifies the types of the objects that can be serialized in the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer3 Example/VB/source.vb" id="Snippet1"::: @@ -539,7 +534,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an instance of a class that is defined in a DLL and to do so, overrides the public members found in the DLL. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer4 Example/VB/source.vb" id="Snippet1"::: @@ -627,7 +621,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example constructs an that uses an that contains various properties of the XML root element, such as its namespace and element name. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer2 Example/VB/source.vb" id="Snippet1"::: @@ -735,7 +728,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an instance of a class that is defined in a DLL and to do so, overrides the public members found in the class. The example also specifies an array of extra types, the default namespace for all XML elements, and the class to use that provides the XML root element information. The example assumes that the code at the beginning has been compiled into a DLL named `HighSchool`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.XmlSerializer Example/VB/source.vb" id="Snippet1"::: @@ -941,7 +933,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example calls the method to check whether an XML document can be deserialized. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/CanDeserialize/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.CanDeserialize Example/VB/source.vb" id="Snippet1"::: @@ -1135,7 +1126,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example deserializes an object using a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Deserialize/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize Example/Common/simple.xml" id="Snippet1"::: @@ -1230,7 +1220,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example deserializes an object using a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Deserialize/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize1 Example/VB/source.vb" id="Snippet1"::: @@ -1375,7 +1364,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example deserializes an object using an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Deserialize/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Deserialize2 Example/Common/simple.xml" id="Snippet1"::: @@ -1916,7 +1904,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example uses the method to return an array of objects. The code includes three class definitions that are each used to create an array of objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/FromTypes/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.FromTypes Example/VB/source.vb" id="Snippet1"::: @@ -2272,7 +2259,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object using a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Serialize2 Example/Common/simple.xml" id="Snippet1"::: @@ -2380,7 +2366,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object using a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Serialize Example/Common/simple.xml" id="Snippet1"::: @@ -2538,7 +2523,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object using an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Serialize4 Example/Common/simple.xml" id="Snippet1"::: @@ -2648,7 +2632,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object with a object. The example also creates an and adds two namespaces to the object. The class that defines the serialized object is also attributed with attributes to specify the namespace for each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize3 Example/VB/source.vb" id="Snippet1"::: @@ -2749,7 +2732,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object with a . The example also creates an object and adds two namespaces to the object. The class that defines the serialized object is also attributed with attributes to specify the namespace for each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Serialize1 Example/Common/simple.xml" id="Snippet1"::: @@ -2850,7 +2832,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example serializes an object with an . The example also creates an and adds two namespaces to the object. Several instances of the class are applied to the class members to specify the namespace for each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializer/Serialize/source5.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/VB/source.vb" id="Snippet1"::: :::code language="xml" source="~/snippets/common/VS_Snippets_Remoting/Classic XmlSerializer.Serialize5 Example/Common/simple.xml" id="Snippet1"::: @@ -3095,7 +3076,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example prints information about any unknown attributes encountered while deserializing an XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlAttributeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownAttribute Example/VB/source.vb" id="Snippet1"::: @@ -3177,7 +3157,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/CPP/unknownelement.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlElementEventArgs/Overview/unknownelement.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializer.UnknownElement Example/VB/unknownelement.vb" id="Snippet1"::: @@ -3245,7 +3224,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ## Examples The following example prints the type of any encountered unknown node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlNodeEventArgs/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializer.UnknownNode Example/VB/source.vb" id="Snippet1"::: @@ -3344,7 +3322,6 @@ The following example contains two main classes: `PurchaseOrder` and `Test`. The ``` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UnreferencedObject Event Example/CPP/unrefobj.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/UnreferencedObjectEventArgs/Overview/unrefobj.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/UnreferencedObject Event Example/VB/unrefobj.vb" id="Snippet1"::: diff --git a/xml/System.Xml.Serialization/XmlSerializerNamespaces.xml b/xml/System.Xml.Serialization/XmlSerializerNamespaces.xml index e14e799929b..df33e199cde 100644 --- a/xml/System.Xml.Serialization/XmlSerializerNamespaces.xml +++ b/xml/System.Xml.Serialization/XmlSerializerNamespaces.xml @@ -69,61 +69,60 @@ Contains the XML namespaces and prefixes that the uses to generate qualified names in an XML-document instance. - contains a collection of XML namespaces, each with an associated prefix. The uses an instance of the class to create qualified names in an XML document. - - XML namespaces contained by the must conform to the W3C specification named [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/). - - XML namespaces provide a way to qualify the names of XML elements and attributes in XML documents. A qualified name consists of a prefix and a local name, separated by a colon. The prefix functions only as a placeholder; it is mapped to a URI that specifies a namespace. The combination of the universally-managed URI namespace and the local name produces a name that is guaranteed to be universally unique. - - To create qualified names in an XML document: - -1. Create an instance. - -2. each prefix and namespace pair that you want to the instance. - -3. Apply the appropriate.NET attribute to each property or class that the serializes into an XML document. The available attributes are: - -- - -- - -- - -- - -- - -- - -1. Set the `Namespace` property of each attribute to one of the namespace values from the object. - -2. Pass the to the method of the . - + contains a collection of XML namespaces, each with an associated prefix. The uses an instance of the class to create qualified names in an XML document. + + XML namespaces contained by the must conform to the W3C specification named [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/). + + XML namespaces provide a way to qualify the names of XML elements and attributes in XML documents. A qualified name consists of a prefix and a local name, separated by a colon. The prefix functions only as a placeholder; it is mapped to a URI that specifies a namespace. The combination of the universally-managed URI namespace and the local name produces a name that is guaranteed to be universally unique. + + To create qualified names in an XML document: + +1. Create an instance. + +2. each prefix and namespace pair that you want to the instance. + +3. Apply the appropriate.NET attribute to each property or class that the serializes into an XML document. The available attributes are: + +- + +- + +- + +- + +- + +- + +1. Set the `Namespace` property of each attribute to one of the namespace values from the object. + +2. Pass the to the method of the . + > [!NOTE] -> The creation of an empty namespace and prefix pair is not supported. That is, you cannot create a pair using the following code: - -```csharp -XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); -ns.Add("", ""); -``` - -```vb -Dim ns As XmlSerializerNamespaces ns = New XmlSerializerNamespaces() -ns.Add("", "") -``` +> The creation of an empty namespace and prefix pair is not supported. That is, you cannot create a pair using the following code: + +```csharp +XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); +ns.Add("", ""); +``` + +```vb +Dim ns As XmlSerializerNamespaces ns = New XmlSerializerNamespaces() +ns.Add("", "") +``` + + + +## Examples + The following example creates an object, and adds two prefix and namespace pairs to it. The example then passes the to the method, which serializes a `Books` object into an XML document. Using the object, the method qualifies each XML element and attribute with one of the two namespaces. - - -## Examples - The following example creates an object, and adds two prefix and namespace pairs to it. The example then passes the to the method, which serializes a `Books` object into an XML document. Using the object, the method qualifies each XML element and attribute with one of the two namespaces. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializerNamespaces/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -191,15 +190,14 @@ ns.Add("", "") Initializes a new instance of the class. - class, and adds a prefix and namespace pair to the object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/CPP/xmlserializernamespaces_constructor.cpp" id="Snippet1"::: + class, and adds a prefix and namespace pair to the object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializerNamespaces/.ctor/xmlserializernamespaces_constructor.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/VB/xmlserializernamespaces_constructor.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlSerializerNameSpaces_Constructor/VB/xmlserializernamespaces_constructor.vb" id="Snippet1"::: + ]]> @@ -250,15 +248,14 @@ ns.Add("", "") An instance of the containing the namespace and prefix pairs. Initializes a new instance of the class, using the specified instance of containing the collection of prefix and namespace pairs. - objects, and creates a new instance from them. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/CPP/source.cpp" id="Snippet1"::: + objects, and creates a new instance from them. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializerNamespaces/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.XmlSerializerNamespaces1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -370,22 +367,21 @@ ns.Add("", "") An XML namespace. Adds a prefix and namespace pair to an object. - to qualify the element and attribute names in an XML document, you must the prefix and namespace pairs to an object. - - Any namespaces that you add must conform to the W3C [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/) specification. - - - -## Examples - The following example creates an object, and adds three prefix and namespace pairs to it by calling the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/CPP/source.cpp" id="Snippet1"::: + to qualify the element and attribute names in an XML document, you must the prefix and namespace pairs to an object. + + Any namespaces that you add must conform to the W3C [Namespaces in XML](https://www.w3.org/TR/REC-xml-names/) specification. + + + +## Examples + The following example creates an object, and adds three prefix and namespace pairs to it by calling the method. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializerNamespaces/Add/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.Add Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -485,15 +481,14 @@ ns.Add("", "") Gets the array of prefix and namespace pairs in an object. An array of objects that are used as qualified names in an XML document. - and in an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/CPP/source.cpp" id="Snippet1"::: + and in an object. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlSerializerNamespaces/ToArray/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlSerializerNamespaces.ToArray Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlTextAttribute.xml b/xml/System.Xml.Serialization/XmlTextAttribute.xml index fb2114e1401..3ffb7071087 100644 --- a/xml/System.Xml.Serialization/XmlTextAttribute.xml +++ b/xml/System.Xml.Serialization/XmlTextAttribute.xml @@ -73,54 +73,53 @@ Indicates to the that the member must be treated as XML text when the class that contains it is serialized or deserialized. - belongs to a family of attributes that controls how the serializes and deserializes an object (through its and methods). For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - Only one instance of the class can be applied in a class. - - You can apply the to public fields and public read/write properties that return primitive and enumeration types. - - You can apply the to a field or property that returns an array of strings. You can also apply the attribute to an array of type but you must set the property to string. In that case, any strings inserted into the array are serialized as XML text. - - The can also be applied to a field that returns an or an array of objects. - - By default, the serializes a class member as an XML element. However, if you apply the to a member, the translates its value into XML text. This means that the value is encoded into the content of an XML element. - - The [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) occasionally generates the when creating classes from an XML Schema definition (XSD) file. This occurs when the schema contains a `complexType` with mixed content; in that case, the corresponding class contains a member that returns a string array to which the is applied. For example, when the `Xml Schema Definition` tool processes this schema: - -```xml - - - - - - - - - - -``` - - the following class is generated (extra spaces and remarks have been removed): - + belongs to a family of attributes that controls how the serializes and deserializes an object (through its and methods). For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + Only one instance of the class can be applied in a class. + + You can apply the to public fields and public read/write properties that return primitive and enumeration types. + + You can apply the to a field or property that returns an array of strings. You can also apply the attribute to an array of type but you must set the property to string. In that case, any strings inserted into the array are serialized as XML text. + + The can also be applied to a field that returns an or an array of objects. + + By default, the serializes a class member as an XML element. However, if you apply the to a member, the translates its value into XML text. This means that the value is encoded into the content of an XML element. + + The [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) occasionally generates the when creating classes from an XML Schema definition (XSD) file. This occurs when the schema contains a `complexType` with mixed content; in that case, the corresponding class contains a member that returns a string array to which the is applied. For example, when the `Xml Schema Definition` tool processes this schema: + +```xml + + + + + + + + + + +``` + + the following class is generated (extra spaces and remarks have been removed): + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/Overview/source1.cs" id="Snippet0"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTextAttribute/vb/source.vb" id="Snippet0"::: - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTextAttribute/vb/source.vb" id="Snippet0"::: + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlText` in your code instead of the longer . - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp" id="Snippet1"::: +> You can use the word `XmlText` in your code instead of the longer . + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -191,20 +190,19 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema"> Initializes a new instance of the class. - serializes a public field or public read/write property by creating an , and setting its property to an . For more details, see the class. - - - -## Examples - The following example serializes a class that contains a public field, named `Comment`. The example applies an to the field, thereby overriding its serialization as an XML element, and instead serializing it as XML text. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/CPP/source.cpp" id="Snippet1"::: + serializes a public field or public read/write property by creating an , and setting its property to an . For more details, see the class. + + + +## Examples + The following example serializes a class that contains a public field, named `Comment`. The example applies an to the field, thereby overriding its serialization as an XML element, and instead serializing it as XML text. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute.XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -262,18 +260,17 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema"> The of the member to be serialized. Initializes a new instance of the class. - serializes a public field or public read/write property by creating an , and setting its property to an . For more details, see the class. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp" id="Snippet1"::: + serializes a public field or public read/write property by creating an , and setting its property to an . For more details, see the class. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -334,81 +331,80 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema"> Gets or sets the XML Schema definition language (XSD) data type of the text generated by the . An XML Schema (XSD) data type. - property to an XML Schema simple data type affects the format of the generated XML. For example, setting the property to "date" causes the generated text to be formatted in the general date style, for example: 2001-08-31. By contrast, setting the property to "dateTime" results in a specific instant as defined by the International Organization for Standardization document 8601, "Representations of Dates and Times", for example: 2001-08-15T06:59:11.0508456-07:00. - - The effect of setting the property can also be seen when using the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) to generate the XML Schema for a compiled file. For more information on using the tool, see [The XML Schema Definition Tool and XML Serialization](/dotnet/standard/serialization/the-xml-schema-definition-tool-and-xml-serialization). - - The following table lists the XML Schema simple data types with their .NET equivalents. - - For the XML Schema `base64Binary` and `hexBinary` data types, use an array of structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". - - For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema data type. Note that this does not change the serialization format, only the schema for the member. - + property to an XML Schema simple data type affects the format of the generated XML. For example, setting the property to "date" causes the generated text to be formatted in the general date style, for example: 2001-08-31. By contrast, setting the property to "dateTime" results in a specific instant as defined by the International Organization for Standardization document 8601, "Representations of Dates and Times", for example: 2001-08-15T06:59:11.0508456-07:00. + + The effect of setting the property can also be seen when using the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) to generate the XML Schema for a compiled file. For more information on using the tool, see [The XML Schema Definition Tool and XML Serialization](/dotnet/standard/serialization/the-xml-schema-definition-tool-and-xml-serialization). + + The following table lists the XML Schema simple data types with their .NET equivalents. + + For the XML Schema `base64Binary` and `hexBinary` data types, use an array of structures, and apply a with the set to "base64Binary" or "hexBinary", as appropriate. For the XML Schema `time` and `date` data types, use the type and apply the with the set to "date" or "time". + + For every XML Schema data type that is mapped to a string, apply the with its property set to the XML Schema data type. Note that this does not change the serialization format, only the schema for the member. + > [!NOTE] -> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. - +> The property is case-sensitive, so you must set it exactly to one of the XML Schema data types. + > [!NOTE] -> Passing binary data as an XML element is more efficient than passing it as an XML attribute. - - For more information about XML Schema data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). - -|XSD data type|.NET data type| -|-------------------|--------------------| -|anyURI|| -|base64Binary|Array of objects| -|boolean|| -|byte|| -|date|| -|dateTime|| -|decimal|| -|double|| -|ENTITY|| -|ENTITIES|| -|float|| -|gDay|| -|gMonth|| -|gMonthDay|| -|gYear|| -|gYearMonth|| -|hexBinary|Array of objects| -|ID|| -|IDREF|| -|IDREFS|| -|int|| -|integer|| -|language|| -|long|| -|Name|| -|NCName|| -|negativeInteger|| -|NMTOKEN|| -|NMTOKENS|| -|normalizedString|| -|nonNegativeInteger|| -|nonPositiveInteger|| -|NOTATION|| -|positiveInteger|| -|QName|| -|duration|| -|string|| -|short|| -|time|| -|token|| -|unsignedByte|| -|unsignedInt|| -|unsignedLong|| -|unsignedShort|| - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp" id="Snippet1"::: +> Passing binary data as an XML element is more efficient than passing it as an XML attribute. + + For more information about XML Schema data types, see the World Wide Web Consortium document named [XML Schema Part 2: Datatypes](https://www.w3.org/TR/xmlschema-2/). + +|XSD data type|.NET data type| +|-------------------|--------------------| +|anyURI|| +|base64Binary|Array of objects| +|boolean|| +|byte|| +|date|| +|dateTime|| +|decimal|| +|double|| +|ENTITY|| +|ENTITIES|| +|float|| +|gDay|| +|gMonth|| +|gMonthDay|| +|gYear|| +|gYearMonth|| +|hexBinary|Array of objects| +|ID|| +|IDREF|| +|IDREFS|| +|int|| +|integer|| +|language|| +|long|| +|Name|| +|NCName|| +|negativeInteger|| +|NMTOKEN|| +|NMTOKENS|| +|normalizedString|| +|nonNegativeInteger|| +|nonPositiveInteger|| +|NOTATION|| +|positiveInteger|| +|QName|| +|duration|| +|string|| +|short|| +|time|| +|token|| +|unsignedByte|| +|unsignedInt|| +|unsignedLong|| +|unsignedShort|| + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> The XML Schema data type you have specified cannot be mapped to the .NET data type. @@ -472,22 +468,21 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema"> Gets or sets the type of the member. The of the member. - property can only be set to primitive types and enumerations. - - The can also be applied to a field that returns an or an array of objects. - - You can apply the to a field or property that returns an array of strings. You can also apply the attribute to an array of type but you must set the property to string. In that case, any strings inserted into the array are serialized as XML text. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTextAttribute Example/CPP/source.cpp" id="Snippet1"::: + property can only be set to primitive types and enumerations. + + The can also be applied to a field that returns an or an array of objects. + + You can apply the to a field or property that returns an array of strings. You can also apply the attribute to an array of type but you must set the property to string. In that case, any strings inserted into the array are serialized as XML text. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTextAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTextAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlTypeAttribute.xml b/xml/System.Xml.Serialization/XmlTypeAttribute.xml index 7d983d2066e..6c0bcc6a31d 100644 --- a/xml/System.Xml.Serialization/XmlTypeAttribute.xml +++ b/xml/System.Xml.Serialization/XmlTypeAttribute.xml @@ -61,32 +61,31 @@ Controls the XML schema that is generated when the attribute target is serialized by the . - belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). - - You can apply the to a class, structure, enumeration, or interface declaration. - - Apply the to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. - + belongs to a family of attributes that controls how the serializes or deserializes an object. For a complete list of similar attributes, see [Attributes That Control XML Serialization](/dotnet/standard/serialization/attributes-that-control-xml-serialization). + + You can apply the to a class, structure, enumeration, or interface declaration. + + Apply the to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. + > [!NOTE] -> If you set the property to `false`, the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) does not include the type in the schema. By default, for each public class, the XSD tool generates a `complexType` and an element of that type. - - For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). - +> If you set the property to `false`, the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe) does not include the type in the schema. By default, for each public class, the XSD tool generates a `complexType` and an element of that type. + + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). + > [!NOTE] -> You can use the word `XmlType` in your code instead of the longer . - - - -## Examples - The following example shows two classes to which the has been applied. +> You can use the word `XmlType` in your code instead of the longer . + + + +## Examples + The following example shows two classes to which the has been applied. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -148,15 +147,14 @@ Initializes a new instance of the class. - class that are used to override the serialization of the two classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp" id="Snippet2"::: + class that are used to override the serialization of the two classes. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/.ctor/xmltypeattribute1_2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLTypeAttribute1_2/VB/xmltypeattribute1_2.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLTypeAttribute1_2/VB/xmltypeattribute1_2.vb" id="Snippet2"::: + ]]> @@ -205,20 +203,19 @@ The name of the XML type that the generates when it serializes the class instance (and recognizes when it deserializes the class instance). Initializes a new instance of the class and specifies the name of the XML type. - to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. - - - -## Examples - The following example creates two instances of the class that are used to override the serialization of the two classes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XMLTypeAttribute1_2/CPP/xmltypeattribute1_2.cpp" id="Snippet2"::: + to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. + + + +## Examples + The following example creates two instances of the class that are used to override the serialization of the two classes. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/.ctor/xmltypeattribute1_2.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLTypeAttribute1_2/VB/xmltypeattribute1_2.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XMLTypeAttribute1_2/VB/xmltypeattribute1_2.vb" id="Snippet2"::: + ]]> @@ -332,20 +329,19 @@ to include the type in XML schema documents; otherwise, . - to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the XML Schema Definition tool (XSD.exe). The tool writes the schema, including the type definition. - - - -## Examples - The following example applies the to the `ExtraneousInfo` class, setting the property to `false`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/CPP/source.cpp" id="Snippet1"::: + to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the XML Schema Definition tool (XSD.exe). The tool writes the schema, including the type definition. + + + +## Examples + The following example applies the to the `ExtraneousInfo` class, setting the property to `false`. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/IncludeInSchema/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.IncludeInSchema Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -404,15 +400,14 @@ Gets or sets the namespace of the XML type. The namespace of the XML type. - to a class while setting the property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/CPP/source.cpp" id="Snippet1"::: + to a class while setting the property. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/Namespace/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.Namespace Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -470,20 +465,19 @@ Gets or sets the name of the XML type. The name of the XML type. - to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. - - - -## Examples - The following example applies the to the `Person` and `Job` classes. If you compile the class and pass the resulting executable file to the XML Schema Definition tool, the schema is displayed in the Output section. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/CPP/source.cpp" id="Snippet1"::: + to a class to specify the XML type's namespace, the XML type name, and whether to include the type in the XML schema document. To see the results of setting the properties of the class, compile your application as an executable or DLL, and pass the resulting file to the [XML Schema Definition Tool (Xsd.exe)](/dotnet/standard/serialization/xml-schema-definition-tool-xsd-exe). The tool writes the schema, including the type definition. + + + +## Examples + The following example applies the to the `Person` and `Job` classes. If you compile the class and pass the resulting executable file to the XML Schema Definition tool, the schema is displayed in the Output section. + :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeAttribute/TypeName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic XmlTypeAttribute.TypeName Example/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.Serialization/XmlTypeMapping.xml b/xml/System.Xml.Serialization/XmlTypeMapping.xml index ce399cb78f6..5d62c8a89f5 100644 --- a/xml/System.Xml.Serialization/XmlTypeMapping.xml +++ b/xml/System.Xml.Serialization/XmlTypeMapping.xml @@ -54,20 +54,19 @@ Contains a mapping of one type to another. - class is used to serialize an object as encoded SOAP XML. The resulting XML conforms to section 5 of the [World Wide Web Consortium](https://www.w3.org) document, "Simple Object Access Protocol (SOAP) 1.1". Create an by calling the method of the class. Use the to construct an instance of the class. To control the serialization, use one of the attributes listed in [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). - - - -## Examples - The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". + class is used to serialize an object as encoded SOAP XML. The resulting XML conforms to section 5 of the [World Wide Web Consortium](https://www.w3.org) document, "Simple Object Access Protocol (SOAP) 1.1". Create an by calling the method of the class. Use the to construct an instance of the class. To control the serialization, use one of the attributes listed in [Attributes That Control Encoded SOAP Serialization](/dotnet/standard/serialization/attributes-that-control-encoded-soap-serialization). + + + +## Examples + The following example serializes an instance of a class named `Transportation` that contains a field named `Vehicle`. A is applied to the field. When the field is serialized, the XML element name is "Wheels" instead of "Vehicle". The `SerializeOverride` method creates a and sets the property of a to the . The is added to a that is used to create an . An is constructed with the , and an instance of the `Transportation` class is again serialized. Because the is used to override the serialization, the generated XML element name is now "Truck" instead of "Wheels". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SoapElementOverrides/CPP/soapelementoverrides.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/SoapAttributes/SoapElement/soapelementoverrides.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SoapElementOverrides/VB/soapelementoverrides.vb" id="Snippet1"::: + ]]> Introducing XML Serialization @@ -135,12 +134,12 @@ Gets the XML namespace of the mapped object. The XML namespace of the mapped object. The default is an empty string (""). - to the class, and set the property to a new value. - + ]]> @@ -187,13 +186,12 @@ To set a namespace name of an object, apply a The fully qualified type name that includes the namespace (or namespaces) and type. The fully qualified type name. - @@ -240,20 +238,19 @@ To set a namespace name of an object, apply a Gets the type name of the mapped object. The type name of the mapped object. - property. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp" id="Snippet1"::: + property. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeMapping/TypeFullName/mapping.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: + ]]> @@ -306,18 +303,17 @@ To set a namespace name of an object, apply a Gets the XML element name of the mapped object. The XML element name of the mapped object. The default is the class name of the object. - to the class, and set the property to a new value. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp" id="Snippet1"::: + to the class, and set the property to a new value. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeMapping/TypeFullName/mapping.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: + ]]> @@ -370,18 +366,17 @@ To set a namespace name of an object, apply a Gets the XML namespace of the mapped object. The XML namespace of the mapped object. The default is an empty string (""). - to the class, and set the property to a new value. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/XmlTypeMapping Example/CPP/mapping.cpp" id="Snippet1"::: + to the class, and set the property to a new value. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Xml.Serialization/XmlTypeMapping/TypeFullName/mapping.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/XmlTypeMapping Example/VB/mapping.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Xml.XPath/XPathNavigator.xml b/xml/System.Xml.XPath/XPathNavigator.xml index f6d403470ce..2e1fb8ff515 100644 --- a/xml/System.Xml.XPath/XPathNavigator.xml +++ b/xml/System.Xml.XPath/XPathNavigator.xml @@ -281,7 +281,6 @@ ## Examples In the following example, a new `pages` child element is appended to the list of child elements of the first `book` element in the `contosoBooks.xml` file using the object returned from the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet1"::: @@ -385,7 +384,6 @@ ## Examples In the following example, a new `pages` child element is appended to the list of child elements of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet2"::: @@ -489,7 +487,6 @@ ## Examples In the following example, a new `pages` child element is appended to the list of child elements of the first `book` element in the `contosoBooks.xml` file using the object specified. The `http://www.contoso.com/books` namespace is specified so that the new child element is appended using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet3"::: @@ -596,7 +593,6 @@ ## Examples In the following example, a new `pages` child element is appended to the list of child elements of the first `book` element in the `contosoBooks.xml` file using the node contained in the specified. The `http://www.contoso.com/books` namespace is specified so that the new child element is appended using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet4"::: @@ -723,7 +719,6 @@ navigator.AppendChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navig ## Examples In the following example, a new `pages` child element is appended to the list of child elements of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet5"::: @@ -879,7 +874,6 @@ navigator.AppendChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navig ## Examples The following example uses the property to display the values of the and classes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet1"::: @@ -1043,7 +1037,6 @@ navigator.AppendChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navig ## Examples The following example gets all book titles authored by Herman Melville. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet6"::: @@ -1312,7 +1305,6 @@ editor.CreateAttribute(navigator.Prefix, "attributeName", LookupNamespace(naviga ## Examples In the following example, a new `discount` attribute is created on the `price` child element of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet7"::: @@ -1418,7 +1410,6 @@ editor.CreateAttribute(navigator.Prefix, "attributeName", LookupNamespace(naviga ## Examples In the following example, new `discount` and `currency` attributes are created on the `price` child element of the first `book` element in the `contosoBooks.xml` file using the object returned from the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet8"::: @@ -1575,7 +1566,6 @@ editor.CreateAttribute(navigator.Prefix, "attributeName", LookupNamespace(naviga ## Examples In the following example, the first and second `book` elements of the `contosoBooks.xml` file are deleted using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet52"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet52"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet52"::: @@ -1680,7 +1670,6 @@ editor.CreateAttribute(navigator.Prefix, "attributeName", LookupNamespace(naviga ## Examples In the following example the `price` element of the first `book` element of the `contosoBooks.xml` file is deleted using the method. The position of the object after the `price` element is deleted is on the parent `book` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet9"::: @@ -1796,7 +1785,6 @@ nav.Evaluate("Price/text()*10"); ## Examples The following example evaluates an XPath expression and returns a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet10"::: @@ -1911,7 +1899,6 @@ nav.Evaluate(expr); ## Examples The following example evaluates an and returns a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet11"::: @@ -2030,7 +2017,6 @@ nav.Evaluate(expr); ## Examples The following example evaluates an XPath expression and returns a using the object specified to resolve namespace prefixes in the XPath expression. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet12"::: @@ -2148,7 +2134,6 @@ nav.Evaluate(expr); ## Examples The following example evaluates an and returns a using the node of the as the context node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet13"::: @@ -2562,7 +2547,6 @@ nav.Evaluate(expr); ## Examples The following example uses the property to display the contents of the first `book` element in the `contosoBooks.xml` file and its child nodes in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet2"::: @@ -2670,7 +2654,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted after the `price` child element of the first `book` element in the `contosoBooks.xml` file using the object returned by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet14"::: @@ -2772,7 +2755,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted after the `price` child element of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet15"::: @@ -2876,7 +2858,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted after the `price` child element of the first `book` element in the `contosoBooks.xml` file using the object specified. The `http://www.contoso.com/books` namespace is specified so that the new sibling element is inserted using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet16"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet16"::: @@ -2981,7 +2962,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted after the `price` child element of the first `book` element in the `contosoBooks.xml` file using the node contained in the object specified. The `http://www.contoso.com/books` namespace is specified so that the new sibling element is inserted using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet17"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet17"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet17"::: @@ -3091,7 +3071,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted before the `price` child element of the first `book` element in the `contosoBooks.xml` file using the object returned by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet18"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet18"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet18"::: @@ -3193,7 +3172,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted before the `price` child element of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet19"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet19"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet19"::: @@ -3297,7 +3275,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted before the `price` child element of the first `book` element in the `contosoBooks.xml` file using the object specified. The `http://www.contoso.com/books` namespace is specified so that the new sibling element is inserted using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet20"::: @@ -3402,7 +3379,6 @@ nav.Evaluate(expr); ## Examples In the following example a new `pages` element is inserted before the `price` child element of the first `book` element in the `contosoBooks.xml` file using the node contained in the object specified. The `http://www.contoso.com/books` namespace is specified so that the new sibling element is inserted using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet21"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet21"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet21"::: @@ -3527,7 +3503,6 @@ navigator.InsertElementAfter(navigator.Prefix, "pages", LookupNamespaceURI(navig ## Examples In the following example a new `pages` element is inserted after the `price` child element of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet22"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet22"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet22"::: @@ -3651,7 +3626,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example a new `pages` element is inserted before the `price` child element of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet23"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet23"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet23"::: @@ -3997,7 +3971,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about and nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -4310,7 +4283,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example displays the titles of all novels. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet24"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet24"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet24"::: @@ -4725,7 +4697,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example uses the and methods to display all the attributes for each book in the `books.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet49"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet49"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet49"::: @@ -5070,7 +5041,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, the is moved from the root of the `contosoBooks.xml` file to the following `bookstore` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet25"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet25"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet25"::: @@ -5174,7 +5144,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, the is moved from the root of the `contosoBooks.xml` file to the first `price` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet26"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet26"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet26"::: @@ -5282,7 +5251,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, the is moved from the root of the `contosoBooks.xml` file to the following `price` element. A clone of the object is made using the method. The cloned , positioned on the `price` element, will be used as a boundary. Changes in the position of the cloned do not affect the original . The original is moved back to the root of the `contosoBooks.xml` file using the method. The title and first and last name of the author are retrieved using the method and an of . The method will return true until the `price` element boundary is reached. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet27"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet27"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet27"::: @@ -5397,7 +5365,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, the is moved from the root of the `contosoBooks.xml` file to the following `book` element. A clone of the object is made using the method and is moved from the `book` element to the following `first-name` element. The cloned , positioned on the `first-name` element, will be used as a boundary. Changes in the position of the cloned do not affect the original . The original then attempts to move to the following `price` element using the method with the boundary passed as a parameter. This move fails because the following `price` element is beyond the boundary. The original then attempts to move to the following `title` element which is before the boundary using the same method and succeeds. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet28"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet28"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet28"::: @@ -5626,7 +5593,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about element and text nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -5843,7 +5809,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example uses the and methods to display all the attributes for each book in the `books.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet49"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet49"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet49"::: @@ -6280,7 +6245,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about and nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -6378,7 +6342,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about and nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -6530,7 +6493,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example illustrates the use of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet3"::: @@ -6617,7 +6579,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about and nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -6716,7 +6677,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example uses the property to display the contents of the first `book` element in the `contosoBooks.xml` file, its child nodes, and its opening and closing tags in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet4"::: @@ -6808,7 +6768,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example iterates over the node tree recursively, and displays information about and nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet29"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet29"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet29"::: @@ -6917,7 +6876,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, a new `pages` child element is prepended to the beginning of the list of child elements of the first `book` element in the `contosoBooks.xml` file using the object returned from the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet30"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet30"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet30"::: @@ -7021,7 +6979,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, a new `pages` child element is prepended to the beginning of the list of child elements of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet31"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet31"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet31"::: @@ -7127,7 +7084,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, a new `pages` child element is prepended to the beginning of the list of child elements of the first `book` element in the `contosoBooks.xml` file using the object specified. The `http://www.contoso.com/books` namespace is specified so that the new child element is prepended using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet32"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet32"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet32"::: @@ -7234,7 +7190,6 @@ navigator.InsertElementBefore(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, a new `pages` child element is prepended to the beginning of the list of child elements of the first `book` element in the `contosoBooks.xml` file using the node contained in the object specified. The `http://www.contoso.com/books` namespace is specified so that the new child element is prepended using the same namespace as the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet33"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet33"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet33"::: @@ -7361,7 +7316,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, a new `pages` child element is prepended to the beginning of the list of child elements of the first `book` element in the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet34"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet34"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet34"::: @@ -7467,7 +7421,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples The following example illustrates using the method on the first `book` element of the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet35"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet35"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet35"::: @@ -7566,7 +7519,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example, the first and second `book` elements of the `contosoBooks.xml` file are replaced with a new empty `book` element using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet53"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet53"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet53"::: @@ -7680,7 +7632,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example the `price` element in the `contosoBooks.xml` file is replaced by a new `pages` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet36"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet36"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet36"::: @@ -7786,7 +7737,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example the `price` element in the `contosoBooks.xml` file is replaced by a new `pages` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet37"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet37"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet37"::: @@ -7893,7 +7843,6 @@ navigator.PrependChildElement(navigator.Prefix, "pages", LookupNamespaceURI(navi ## Examples In the following example the `price` element in the `contosoBooks.xml` file is replaced by a new `pages` element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet38"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet38"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet38"::: @@ -8079,7 +8028,6 @@ while (iterator.MoveNext()) ## Examples The following example uses the method to select a node set. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet39"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet39"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet39"::: @@ -8246,7 +8194,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example uses the method to select a node set. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet40"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet40"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet40"::: @@ -8353,7 +8300,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example illustrates selecting a node set using the method with the object specified to resolve namespace prefixes in the XPath expression. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet41"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet41"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet41"::: @@ -8532,7 +8478,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example illustrates selecting ancestor, child, and descendant nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet42"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet42"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet42"::: @@ -8942,7 +8887,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example selects a single node from the based on the XPath query specified. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet43"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet43"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet43"::: @@ -9046,7 +8990,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example selects a single node from the based on the XPath query contained in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet44"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet44"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet44"::: @@ -9156,7 +9099,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example selects a single node from the object based on the XPath query specified and uses the object specified to resolve namespace prefixes in the XPath query. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet45"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet45"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet45"::: @@ -9254,7 +9196,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples In the following example, the method is used to update all `price` elements in the `contosoBooks.xml` file using the object to resolve namespace prefixes in the XPath expression. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet46"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet46"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet46"::: @@ -9355,7 +9296,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples In the following example, the method is used to update all `price` elements in the `contosoBooks.xml` file using the object to resolve namespace prefixes in the XPath expression. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet47"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet47"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet47"::: @@ -9808,7 +9748,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples In the following example, the value of each element in the `valueas.xml` file is returned using the , , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet5"::: @@ -10123,7 +10062,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples In the following example, the `contosoBooks.xml` XML file and `contosoBooks.xsd` XML Schema definition language (XSD) schema are used to create an object. The typed value of the `price` element is displayed using the property and then returned as a string using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorProperties/CPP/xpathnavigatorproperties.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/CanEdit/xpathnavigatorproperties.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorProperties/VB/xpathnavigatorproperties.vb" id="Snippet6"::: @@ -10268,7 +10206,6 @@ XPathNodeIterator ni = nav.Select(expr); ## Examples The following example illustrates using the method on the first `book` element of the `contosoBooks.xml` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet48"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet48"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet48"::: diff --git a/xml/System.Xml.XPath/XPathNodeIterator.xml b/xml/System.Xml.XPath/XPathNodeIterator.xml index f3505445f6b..292a6b1eed5 100644 --- a/xml/System.Xml.XPath/XPathNodeIterator.xml +++ b/xml/System.Xml.XPath/XPathNodeIterator.xml @@ -81,82 +81,79 @@ Provides an iterator over a selected set of nodes. - object returned by the class is not positioned on the first node in a selected set of nodes. A call to the method of the class must be made to position the object on the first node in the selected set of nodes. - - When using the , if you edit the current node or any of its ancestors, your current position is lost. If you want to edit a number of nodes that you have selected, create a array, copy all of the nodes from the into the array, then iterate through the array and modify the nodes. - - There are two ways to iterate over an collection by using the class. - - One way is to use the method and then call to get the current instance, as in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet55"::: + object returned by the class is not positioned on the first node in a selected set of nodes. A call to the method of the class must be made to position the object on the first node in the selected set of nodes. + + When using the , if you edit the current node or any of its ancestors, your current position is lost. If you want to edit a number of nodes that you have selected, create a array, copy all of the nodes from the into the array, then iterate through the array and modify the nodes. + + There are two ways to iterate over an collection by using the class. + + One way is to use the method and then call to get the current instance, as in the following example: + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet55"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: - - Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: + + Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet56"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet56"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: - - You should either use and or use . Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. - - - -## Examples - The following example uses the method of the class to select a node set using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet39"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: + + You should either use and or use . Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. + + + +## Examples + The following example uses the method of the class to select a node set using the class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet39"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet39"::: - - The example takes the `books.xml` file as input. - -```xml - - - - - The Autobiography of Benjamin Franklin - - Benjamin - Franklin - - 8.99 - - - The Confidence Man - - Herman - Melville - - 11.99 - - - The Gorgias - - Plato - - 9.99 - - - -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet39"::: + + The example takes the `books.xml` file as input. + +```xml + + + + + The Autobiography of Benjamin Franklin + + Benjamin + Franklin + + 8.99 + + + The Confidence Man + + Herman + Melville + + 11.99 + + + The Gorgias + + Plato + + 9.99 + + + +``` + ]]> - When you inherit from the class, you must override the following members: - -- - -- - -- - + When you inherit from the class, you must override the following members: + +- + +- + +- + - @@ -200,11 +197,11 @@ Initializes a new instance of the class. - @@ -253,11 +250,11 @@ When overridden in a derived class, returns a clone of this object. A new object clone of this object. - object is positioned at the same node in the node set if calls have been made to the method. The cloned object is not affected by subsequent changes to this object. - + object is positioned at the same node in the node set if calls have been made to the method. The cloned object is not affected by subsequent changes to this object. + ]]> @@ -306,11 +303,11 @@ Gets the index of the last node in the selected set of nodes. The index of the last node in the selected set of nodes, or 0 if there are no selected nodes. - property does not affect the position of the . - + property does not affect the position of the . + ]]> @@ -365,59 +362,58 @@ When overridden in a derived class, gets the object for this , positioned on the current context node. An object positioned on the context node from which the node set was selected. The method must be called to move the to the first node in the selected set. - object to obtain information on the current node. However, the returned object should not be modified. The returned object cannot be moved away from the selected node set. - - Alternatively, you can clone the object using the method of the class. The cloned object can then be moved away from the selected node set. This method of cloning the object might affect the performance of the XPath query. - - If the , , and methods result in no nodes being selected, the property might not be pointing to the context node. - - To test whether nodes have been selected, use the property as shown in the following example. - - - -## Examples - The following example gets all book titles authored by Herman Melville using the property of the object and the method of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet6"::: + object to obtain information on the current node. However, the returned object should not be modified. The returned object cannot be moved away from the selected node set. + + Alternatively, you can clone the object using the method of the class. The cloned object can then be moved away from the selected node set. This method of cloning the object might affect the performance of the XPath query. + + If the , , and methods result in no nodes being selected, the property might not be pointing to the context node. + + To test whether nodes have been selected, use the property as shown in the following example. + + + +## Examples + The following example gets all book titles authored by Herman Melville using the property of the object and the method of the class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet6"::: - - The example takes the `contosoBooks.xml` file as input. - -```xml - - - - - The Autobiography of Benjamin Franklin - - Benjamin - Franklin - - 8.99 - - - The Confidence Man - - Herman - Melville - - 11.99 - - - The Gorgias - - Plato - - 9.99 - - - -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet6"::: + + The example takes the `contosoBooks.xml` file as input. + +```xml + + + + + The Autobiography of Benjamin Franklin + + Benjamin + Franklin + + 8.99 + + + The Confidence Man + + Herman + Melville + + 11.99 + + + The Gorgias + + Plato + + 9.99 + + + +``` + ]]> @@ -471,11 +467,11 @@ When overridden in a derived class, gets the index of the current position in the selected set of nodes. The index of the current position. - @@ -526,27 +522,25 @@ Returns an object to iterate through the selected node set. An object to iterate through the selected node set. - object. - - There are two ways to iterate over an collection by using the class. - - One way is to use the method and then call to get the current instance, as in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet55"::: + object. + + There are two ways to iterate over an collection by using the class. + + One way is to use the method and then call to get the current instance, as in the following example: + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet55"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: - - Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet56"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: + + Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet56"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: - - You should either use the method and or use the method. Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: + + You should either use the method and or use the method. Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. + ]]> @@ -597,69 +591,66 @@ if the object moved to the next node; if there are no more selected nodes. - object is positioned on the first node in the selected node set only after the initial call to the method. The node set is created in document order. Therefore, calling the method moves to the next node in document order. - - There are two ways to iterate over an collection by using the class. - - One way is to use the method and then call to get the current instance, as in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet55"::: + object is positioned on the first node in the selected node set only after the initial call to the method. The node set is created in document order. Therefore, calling the method moves to the next node in document order. + + There are two ways to iterate over an collection by using the class. + + One way is to use the method and then call to get the current instance, as in the following example: + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet55"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: - - Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet56"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet55"::: + + Another way is to use a `foreach` loop to call the method and use the returned interface to enumerate the nodes, as in the following example: + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet56"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: - - You should either use the method and or use the method. Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. - - - -## Examples - The following example uses the method of the class to select a node set using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XPathNavigatorMethods/CPP/xpathnavigatormethods.cpp" id="Snippet39"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet56"::: + + You should either use the method and or use the method. Combining these two approaches can cause unexpected results. For example, if the method is called first, and then the method is called in the `foreach` loop, the `foreach` loop will not start enumerating the results from the beginning of the collection, but from the position after the method. + + + +## Examples + The following example uses the method of the class to select a node set using the class. + :::code language="csharp" source="~/snippets/csharp/System.Xml.XPath/XPathNavigator/AppendChild/xpathnavigatormethods.cs" id="Snippet39"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet39"::: - - The example takes the `books.xml` file as input. - -```xml - - - - - The Autobiography of Benjamin Franklin - - Benjamin - Franklin - - 8.99 - - - The Confidence Man - - Herman - Melville - - 11.99 - - - The Gorgias - - Plato - - 9.99 - - - -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XPathNavigatorMethods/VB/xpathnavigatormethods.vb" id="Snippet39"::: + + The example takes the `books.xml` file as input. + +```xml + + + + + The Autobiography of Benjamin Franklin + + Benjamin + Franklin + + 8.99 + + + The Confidence Man + + Herman + Melville + + 11.99 + + + The Gorgias + + Plato + + 9.99 + + + +``` + ]]> @@ -717,11 +708,11 @@ Creates a new object that is a copy of the current instance. A new object that is a copy of this instance. - instance is cast to an interface. - + instance is cast to an interface. + ]]> diff --git a/xml/System.Xml.Xsl/XslTransform.xml b/xml/System.Xml.Xsl/XslTransform.xml index 877eebc7a3e..399e04611b6 100644 --- a/xml/System.Xml.Xsl/XslTransform.xml +++ b/xml/System.Xml.Xsl/XslTransform.xml @@ -283,7 +283,6 @@ ## Examples The following example transforms an XML document into an HTML document. It displays the ISBN, title, and price for each book in a table. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/VB/source.vb" id="Snippet1"::: @@ -376,7 +375,6 @@ ## Examples The following example transforms an XML file sorting all the books by title. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTransform.Load3/CPP/trans3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/trans3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load3/VB/trans3.vb" id="Snippet1"::: @@ -969,7 +967,6 @@ ## Examples The following example performs an XSLT transformation where `xsltReader` is an containing a style sheet and `secureURL` is a trusted URL that can be used to create . The method is used to create , which is applied to the style sheet. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTransform.Load4/CPP/trans_ev.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/trans_ev.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Load4/VB/trans_ev.vb" id="Snippet1"::: @@ -1228,7 +1225,6 @@ ## Examples The following example transforms the `books.xml` file using the `output.xsl` style sheet and outputs the results to the `books.html` file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/xsltransform.transform3/CPP/trans_snip2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/trans_snip2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/xsltransform.transform3/VB/trans_snip2.vb" id="Snippet1"::: @@ -1534,7 +1530,6 @@ Root node is book. ## Examples The following example performs an XSLT transformation and outputs to a file. An with default credentials is used resolve an external resources. See for details. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTRansform.Transform7/CPP/trans_snip4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/trans_snip4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTRansform.Transform7/VB/trans_snip4.vb" id="Snippet1"::: @@ -1945,7 +1940,6 @@ Root node is book. ## Examples The following example transforms an XML document and outputs the results to an `XmlReader`. An with the necessary credentials is used to process any XSLT `document()` functions. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTransform.Transform4/CPP/trans_snip3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Transform/trans_snip3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform4/VB/trans_snip3.vb" id="Snippet1"::: @@ -2859,7 +2853,6 @@ Root node is book. ## Examples The following example transforms an XML document into an HTML document. It displays the ISBN, title, and price for each book in a table. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml.Xsl/XslTransform/Load/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XslTransform.Transform7 Example/VB/source.vb" id="Snippet1"::: @@ -3157,7 +3150,6 @@ Root node is book. ## Examples The following example loads and edits an XML document before performing an XSLT transform. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTransform.Transform2/CPP/trans_snip.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/CreateNavigator/trans_snip.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform2/VB/trans_snip.vb" id="Snippet1"::: diff --git a/xml/System.Xml/IHasXmlNode.xml b/xml/System.Xml/IHasXmlNode.xml index 041fc598cff..bd3eaffd31d 100644 --- a/xml/System.Xml/IHasXmlNode.xml +++ b/xml/System.Xml/IHasXmlNode.xml @@ -42,24 +42,23 @@ Enables a class to return an from the current context or position. - from the current context or position. It is implemented by objects that operate over classes that have nodes. For example, if the `XPathNavigator` object is created by an , you can use the method to return the `XmlNode` representing the current position of the navigator. + + + +## Examples + The following example uses the `GetNode` method to retrieve and modify the selected node. -## Remarks - The `IHasXmlNode` interface provides an interface that enables a class to return an from the current context or position. It is implemented by objects that operate over classes that have nodes. For example, if the `XPathNavigator` object is created by an , you can use the method to return the `XmlNode` representing the current position of the navigator. - - - -## Examples - The following example uses the `GetNode` method to retrieve and modify the selected node. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/IHasXmlNode.GetNode/CPP/hasxmlnode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/IHasXmlNode/Overview/hasxmlnode.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/IHasXmlNode.GetNode/VB/hasxmlnode.vb" id="Snippet1"::: - - The example uses the file `books.xml` as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/IHasXmlNode.GetNode/XML/books.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/IHasXmlNode.GetNode/VB/hasxmlnode.vb" id="Snippet1"::: + + The example uses the file `books.xml` as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/IHasXmlNode.GetNode/XML/books.xml" id="Snippet2"::: + ]]> @@ -104,20 +103,20 @@ Returns the for the current position. The for the current position. - is currently positioned on. - -```csharp -XmlDocument doc = new XmlDocument(); -doc.Load("books.xml"); -XPathNavigator nav = doc.CreateNavigator(); -XmlNode node = ((IHasXmlNode)nav).GetNode(); -Console.WriteLine(node.LocalName); -//You can edit the returned XmlNode. -``` - + is currently positioned on. + +```csharp +XmlDocument doc = new XmlDocument(); +doc.Load("books.xml"); +XPathNavigator nav = doc.CreateNavigator(); +XmlNode node = ((IHasXmlNode)nav).GetNode(); +Console.WriteLine(node.LocalName); +//You can edit the returned XmlNode. +``` + ]]> diff --git a/xml/System.Xml/IXmlLineInfo.xml b/xml/System.Xml/IXmlLineInfo.xml index 4f49381ceb1..e8db612e4c5 100644 --- a/xml/System.Xml/IXmlLineInfo.xml +++ b/xml/System.Xml/IXmlLineInfo.xml @@ -46,15 +46,14 @@ Provides an interface to enable a class to return line and position information. - @@ -147,11 +146,11 @@ Gets the current line number. The current line number or 0 if no line information is available (for example, returns ). - , a value of 1,1 indicates the start of a document. - + , a value of 1,1 indicates the start of a document. + ]]> @@ -198,11 +197,11 @@ Gets the current line position. The current line position or 0 if no line information is available (for example, returns ). - , a value of 1,1 indicates the start of a document. - + , a value of 1,1 indicates the start of a document. + ]]> diff --git a/xml/System.Xml/NameTable.xml b/xml/System.Xml/NameTable.xml index 77ce0e5d57c..fe637c1a872 100644 --- a/xml/System.Xml/NameTable.xml +++ b/xml/System.Xml/NameTable.xml @@ -54,22 +54,21 @@ Implements a single-threaded . - and , use the `NameTable` class internally to store attribute and element names. When an element or attribute name occurs multiple times in an XML document, it is stored only once in the `NameTable`. - - The names are stored as common language runtime (CLR) object types. This enables you to do object comparisons on these strings rather than a more expensive string comparison. These string objects are referred to as atomized strings. - - - -## Examples - The following example compares two element names. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/NameTable/CPP/nametable.cpp" id="Snippet1"::: + and , use the `NameTable` class internally to store attribute and element names. When an element or attribute name occurs multiple times in an XML document, it is stored only once in the `NameTable`. + + The names are stored as common language runtime (CLR) object types. This enables you to do object comparisons on these strings rather than a more expensive string comparison. These string objects are referred to as atomized strings. + + + +## Examples + The following example compares two element names. + :::code language="csharp" source="~/snippets/csharp/System.Xml/NameTable/Overview/nametable.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/NameTable/VB/nametable.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/NameTable/VB/nametable.vb" id="Snippet1"::: + ]]> @@ -112,11 +111,11 @@ Initializes a new instance of the class. - @@ -131,11 +130,11 @@ Atomizes the specified string and adds it to the . - . - + . + ]]> @@ -186,11 +185,11 @@ Atomizes the specified string and adds it to the . The atomized string or the existing string if it already exists in the . - . - + . + ]]> @@ -247,23 +246,23 @@ Atomizes the specified string and adds it to the . The atomized string or the existing string if one already exists in the . If is zero, String.Empty is returned. - . - + . + ]]> - 0 > - - -or- - - >= .Length - - -or- - - >= .Length - + 0 > + + -or- + + >= .Length + + -or- + + >= .Length + The above conditions do not cause an exception to be thrown if =0. < 0. @@ -279,11 +278,11 @@ Gets the atomized string. - . - + . + ]]> @@ -335,11 +334,11 @@ Gets the atomized string with the specified value. The atomized string object or if the string has not already been atomized. - . - + . + ]]> @@ -397,23 +396,23 @@ Gets the atomized string containing the same characters as the specified range of characters in the given array. The atomized string or if the string has not already been atomized. If is zero, String.Empty is returned. - . - + . + ]]> - 0 > - - -or- - - >= .Length - - -or- - - >= .Length - + 0 > + + -or- + + >= .Length + + -or- + + >= .Length + The above conditions do not cause an exception to be thrown if =0. < 0. diff --git a/xml/System.Xml/XmlAttribute.xml b/xml/System.Xml/XmlAttribute.xml index a45ab45461e..65873b838a9 100644 --- a/xml/System.Xml/XmlAttribute.xml +++ b/xml/System.Xml/XmlAttribute.xml @@ -64,13 +64,13 @@ Represents an attribute. Valid and default values for the attribute are defined in a document type definition (DTD) or schema. - property to get the to which the attribute belongs. - - The `XmlElement` class has several methods which allow you to access attribute nodes (, , , and so on). Additionally, you can call the property, which returns an enabling you to access attributes by name or index from the collection. - + property to get the to which the attribute belongs. + + The `XmlElement` class has several methods which allow you to access attribute nodes (, , , and so on). Additionally, you can call the property, which returns an enabling you to access attributes by name or index from the collection. + ]]> Accessing Attributes in the DOM @@ -143,11 +143,11 @@ The parent XML document. Initializes a new instance of the class. - directly; instead, use methods such as . - + directly; instead, use methods such as . + ]]> @@ -200,25 +200,25 @@ Adds the specified node to the end of the list of child nodes, of this node. The added. - to import the node to the current document. The imported node can then be inserted into the current document. - - - -## Examples - For an example of the method, see the method. - + to import the node to the current document. The imported node can then be inserted into the current document. + + + +## Examples + For an example of the method, see the method. + ]]> - This node is of a type that does not allow child nodes of the type of the node. - + This node is of a type that does not allow child nodes of the type of the node. + The is an ancestor of this node. - The was created from a different document than the one that created this node. - + The was created from a different document than the one that created this node. + This node is read-only. @@ -266,28 +266,27 @@ Gets the base Uniform Resource Identifier (URI) of the node. The location from which the node was loaded or String.Empty if the node has no base URI. Attribute nodes have the same base URI as their owner element. If an attribute node does not have an owner element, returns String.Empty. - . - - This property is a Microsoft extension to the Document Object Model (DOM). + . + + This property is a Microsoft extension to the Document Object Model (DOM). + + + +## Examples + The following example displays information on the attribute node, including its base URI. - - -## Examples - The following example displays information on the attribute node, including its base URI. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlAttribute/BaseURI/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/VB/source.vb" id="Snippet1"::: - - The sample uses the file, `baseuri.xml`, as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/VB/source.vb" id="Snippet1"::: + + The sample uses the file, `baseuri.xml`, as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlAttribute.BaseURI Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -342,26 +341,25 @@ Creates a duplicate of this node. The duplicate node. - returns `null`). - - Cloning an unspecified attribute returns a specified attribute ( returns `true`). - - - -## Examples - The following example uses `CloneNode` to add an attribute to two different element nodes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/CPP/source.cpp" id="Snippet1"::: + returns `null`). + + Cloning an unspecified attribute returns a specified attribute ( returns `true`). + + + +## Examples + The following example uses `CloneNode` to add an attribute to two different element nodes. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlAttribute/CloneNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/VB/source.vb" id="Snippet1"::: - - The example uses the file, `2elems.xml`, as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/VB/source.vb" id="Snippet1"::: + + The example uses the file, `2elems.xml`, as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlAttribute.CloneNode Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -414,13 +412,13 @@ Sets the concatenated values of the node and all its children. The concatenated values of the node and all its children. For attribute nodes, this property has the same functionality as the property. - @@ -474,11 +472,11 @@ Sets the value of the attribute. The attribute value. - The XML specified when setting this property is not well-formed. @@ -543,29 +541,29 @@ Inserts the specified node immediately after the specified reference node. The inserted. - object, its child nodes are inserted, in the same order, after `refChild`. If the `newChild` is already in the tree, it is first removed. - - If the node being inserted was created from another document, you can use to import the node to the current document. The imported node can then be inserted into the current document. - - This method is a Microsoft extension to the Document Object Model (DOM). - - - -## Examples - For an example of the method see the method. - + object, its child nodes are inserted, in the same order, after `refChild`. If the `newChild` is already in the tree, it is first removed. + + If the node being inserted was created from another document, you can use to import the node to the current document. The imported node can then be inserted into the current document. + + This method is a Microsoft extension to the Document Object Model (DOM). + + + +## Examples + For an example of the method see the method. + ]]> - This node is of a type that does not allow child nodes of the type of the node. - + This node is of a type that does not allow child nodes of the type of the node. + The is an ancestor of this node. - The was created from a different document than the one that created this node. - - The is not a child of this node. - + The was created from a different document than the one that created this node. + + The is not a child of this node. + This node is read-only. @@ -626,27 +624,27 @@ Inserts the specified node immediately before the specified reference node. The inserted. - object, its child nodes are inserted, in the same order, before `refChild`. If the `newChild` is already in the tree, it is first removed. - - If the node being inserted was created from another document, you can use to import the node to the current document. The imported node can then be inserted into the current document. - - - -## Examples - For an example of the method, see the method. - + object, its child nodes are inserted, in the same order, before `refChild`. If the `newChild` is already in the tree, it is first removed. + + If the node being inserted was created from another document, you can use to import the node to the current document. The imported node can then be inserted into the current document. + + + +## Examples + For an example of the method, see the method. + ]]> - The current node is of a type that does not allow child nodes of the type of the node. - + The current node is of a type that does not allow child nodes of the type of the node. + The is an ancestor of this node. - The was created from a different document than the one that created this node. - - The is not a child of this node. - + The was created from a different document than the one that created this node. + + The is not a child of this node. + This node is read-only. @@ -694,20 +692,19 @@ Gets the local name of the node. The name of the attribute node with the prefix removed. In the following example <book bk:genre= 'novel'>, the of the attribute is . - . - - - -## Examples - The following example displays information on each of the nodes in the attribute collection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/CPP/source.cpp" id="Snippet1"::: + . + + + +## Examples + The following example displays information on each of the nodes in the attribute collection. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlAttribute/LocalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttribute.NamespaceURI Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -756,15 +753,14 @@ Gets the qualified name of the node. The qualified name of the attribute node. - @@ -814,20 +810,19 @@ Gets the namespace URI of this node. The namespace URI of this node. If the attribute is not explicitly given a namespace, this property returns String.Empty. - @@ -923,15 +918,14 @@ Gets the to which this node belongs. An XML document to which this node belongs. - @@ -987,15 +981,14 @@ Gets the to which the attribute belongs. The that the attribute belongs to or if this attribute is not part of an . - @@ -1051,11 +1044,11 @@ Gets the parent of this node. For nodes, this property always returns . For nodes, this property always returns . - property to get the to which the attribute belongs. - + property to get the to which the attribute belongs. + ]]> @@ -1104,33 +1097,32 @@ Gets or sets the namespace prefix of this node. The namespace prefix of this node. If there is no prefix, this property returns String.Empty. - This node is read-only. - The specified prefix contains an invalid character. - - The specified prefix is malformed. - - The namespaceURI of this node is . - - The specified prefix is "xml", and the namespaceURI of this node is different from "http://www.w3.org/XML/1998/namespace". - - This node is an attribute, the specified prefix is "xmlns", and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/". - + The specified prefix contains an invalid character. + + The specified prefix is malformed. + + The namespaceURI of this node is . + + The specified prefix is "xml", and the namespaceURI of this node is different from "http://www.w3.org/XML/1998/namespace". + + This node is an attribute, the specified prefix is "xmlns", and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/". + This node is an attribute, and the qualifiedName of this node is "xmlns" [Namespaces]. @@ -1182,27 +1174,27 @@ Adds the specified node to the beginning of the list of child nodes for this node. The added. - to import the node to the current document. The imported node can then be inserted into the current document. - - This method is a Microsoft extension to the Document Object Model (DOM). - - - -## Examples - For an example of the method, see the method. - + to import the node to the current document. The imported node can then be inserted into the current document. + + This method is a Microsoft extension to the Document Object Model (DOM). + + + +## Examples + For an example of the method, see the method. + ]]> - This node is of a type that does not allow child nodes of the type of the node. - + This node is of a type that does not allow child nodes of the type of the node. + The is an ancestor of this node. - The was created from a different document than the one that created this node. - + The was created from a different document than the one that created this node. + This node is read-only. @@ -1253,11 +1245,11 @@ Removes the specified child node. The removed. - method, see the method. - + method, see the method. + ]]> The is not a child of this node. Or this node is read-only. @@ -1312,27 +1304,27 @@ Replaces the child node specified with the new child node specified. The replaced. - to import the node to the current document. - - - -## Examples - For an example of the method, see the method. - + to import the node to the current document. + + + +## Examples + For an example of the method, see the method. + ]]> - This node is of a type that does not allow child nodes of the type of the node. - + This node is of a type that does not allow child nodes of the type of the node. + The is an ancestor of this node. - The was created from a different document than the one that created this node. - - This node is read-only. - + The was created from a different document than the one that created this node. + + This node is read-only. + The is not a child of this node. @@ -1383,11 +1375,11 @@ Gets the post-schema-validation-infoset that has been assigned to this node as a result of schema validation. An containing the post-schema-validation-infoset of this node. - property is set when this node is validated. - + property is set when this node is validated. + ]]> @@ -1437,19 +1429,19 @@ if this attribute was explicitly given a value in the original instance document; otherwise, . A value of indicates that the value of the attribute came from the DTD. - @@ -1498,15 +1490,14 @@ Gets or sets the value of the node. The value returned depends on the of the node. For nodes, this property is the value of attribute. - The node is read-only and a set operation is called. @@ -1565,11 +1556,11 @@ The to which you want to save. Saves all the children of the node to the specified . - property. - + property. + ]]> @@ -1621,11 +1612,11 @@ The to which you want to save. Saves the node to the specified . - property. - + property. + ]]> diff --git a/xml/System.Xml/XmlAttributeCollection.xml b/xml/System.Xml/XmlAttributeCollection.xml index 1c921bfaf72..318a8ea8717 100644 --- a/xml/System.Xml/XmlAttributeCollection.xml +++ b/xml/System.Xml/XmlAttributeCollection.xml @@ -75,11 +75,11 @@ Represents a collection of attributes that can be accessed by name or index. - class by adding strongly typed helper methods. You can use this class to add, remove, or modify attributes in the collection. `XmlAttributeCollection` is returned by the property. - + class by adding strongly typed helper methods. You can use this class to add, remove, or modify attributes in the collection. `XmlAttributeCollection` is returned by the property. + ]]> @@ -142,22 +142,21 @@ Inserts the specified attribute as the last node in the collection. The to append to the collection. - @@ -213,20 +212,19 @@ The index in the array where copying begins. Copies all the objects from this collection into the given array. - @@ -294,22 +292,21 @@ Inserts the specified attribute immediately after the specified reference attribute. The to insert into the collection. - The was created from a document different from the one that created this collection. Or the is not a member of this collection. @@ -378,22 +375,21 @@ Inserts the specified attribute immediately before the specified reference attribute. The to insert into the collection. - The was created from a document different from the one that created this collection. Or the is not a member of this collection. @@ -459,20 +455,19 @@ Gets the attribute with the specified index. The attribute at the specified index. - . - - - -## Examples - The following example displays all the attributes in the collection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/CPP/source.cpp" id="Snippet1"::: + . + + + +## Examples + The following example displays all the attributes in the collection. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlAttributeCollection/ItemOf/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttributeCollection.this Example/VB/source.vb" id="Snippet1"::: + ]]> The index being passed in is out of range. @@ -537,20 +532,19 @@ Gets the attribute with the specified name. The attribute with the specified name. If the attribute does not exist, this property returns . - . - - - -## Examples - The following example removes an attribute from the document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/CPP/source.cpp" id="Snippet1"::: + . + + + +## Examples + The following example removes an attribute from the document. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlAttributeCollection/ItemOf/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlAttributeCollection.Remove Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -622,11 +616,11 @@ Gets the attribute with the specified local name and namespace Uniform Resource Identifier (URI). The attribute with the specified local name and namespace URI. If the attribute does not exist, this property returns . - . - + . + ]]> @@ -684,22 +678,21 @@ Inserts the specified attribute as the first node in the collection. The added to the collection. - @@ -758,20 +751,19 @@ Removes the specified attribute from the collection. The node removed or if it is not found in the collection. - @@ -825,20 +817,19 @@ Removes all attributes from the collection. - @@ -897,20 +888,19 @@ Removes the attribute corresponding to the specified index from the collection. Returns if there is no attribute at the specified index. - @@ -964,20 +954,19 @@ Adds a using its property. If the replaces an existing node with the same name, the old node is returned; otherwise, the added node is returned. - - was created from a different than the one that created this collection. - + was created from a different than the one that created this collection. + This is read-only. is an that is already an attribute of another object. To re-use attributes in other elements, you must clone the objects you want to re-use. @@ -1035,11 +1024,11 @@ The index in the array where copying begins. For a description of this member, see . - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1090,11 +1079,11 @@ For a description of this member, see . An that contains the count of the attributes. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1146,11 +1135,11 @@ if the collection is synchronized. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1201,11 +1190,11 @@ For a description of this member, see . The that is the root of the collection. - instance is cast to an interface. - + instance is cast to an interface. + ]]> diff --git a/xml/System.Xml/XmlConvert.xml b/xml/System.Xml/XmlConvert.xml index dc76605aed8..d41290f09e2 100644 --- a/xml/System.Xml/XmlConvert.xml +++ b/xml/System.Xml/XmlConvert.xml @@ -168,7 +168,6 @@ ## Examples The following example encodes and decodes names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/DecodeName/convert.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.EncodeName/VB/convert.vb" id="Snippet1"::: @@ -243,7 +242,6 @@ ## Examples The following example encodes and decodes names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/DecodeName/convert.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.EncodeName/VB/convert.vb" id="Snippet1"::: @@ -322,7 +320,6 @@ ## Examples The following example encodes and decodes names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.EncodeName/CPP/convert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/DecodeName/convert.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.EncodeName/VB/convert.vb" id="Snippet1"::: @@ -921,7 +918,6 @@ ## Examples The following example uses and `ToDateTime` to read strongly typed data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.ToDouble/CPP/readData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/ToDateTime/readdata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.ToDouble/VB/readdata.vb" id="Snippet1"::: @@ -1500,7 +1496,6 @@ ## Examples The following example uses `ToDouble` and to read strongly typed data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.ToDouble/CPP/readData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/ToDateTime/readdata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.ToDouble/VB/readdata.vb" id="Snippet1"::: @@ -2238,7 +2233,6 @@ ## Examples The following example, converts data types to string and then writes the information out to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/ToString/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/VB/source.vb" id="Snippet1"::: @@ -2347,7 +2341,6 @@ ## Examples The following example, converts data types to string and then writes the information out to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/ToString/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/VB/source.vb" id="Snippet1"::: @@ -2828,7 +2821,6 @@ ## Examples The following example, converts data types to string and then writes the information out to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/ToString/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlConvert.ToString Example/VB/source.vb" id="Snippet1"::: @@ -3248,7 +3240,6 @@ catch(Exception e) ## Examples The following example uses the `VerifyName` method to write an element name. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlConvert.VerifyName/CPP/verifyname.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlConvert/VerifyName/verifyname.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlConvert.VerifyName/VB/verifyname.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlDataDocument.xml b/xml/System.Xml/XmlDataDocument.xml index 3cfc90d5e26..109f2f3d321 100644 --- a/xml/System.Xml/XmlDataDocument.xml +++ b/xml/System.Xml/XmlDataDocument.xml @@ -52,17 +52,17 @@ Allows structured data to be stored, retrieved, and manipulated through a relational . - . It enables you to load either relational data or XML data and manipulate that data using the World Wide Web Consortium (W3C) Document Object Model (DOM). The DOM presents data as a hierarchy of node objects. Because `XmlDataDocument` implements the interface, it can also be used as the source document for the class. - - `XmlDataDocument` has a close affiliation with the `DataSet` class, which provides a relational view of the loaded XML data. Any changes made to the `XmlDataDocument` are reflected in the `DataSet` and vice versa. - - To load a `DataSet` with XML data, use to build a relational mapping. The XML data can then be loaded using or . - - To load relational data, specify the `DataSet` containing the relational data as the parameter in the constructor. - + . It enables you to load either relational data or XML data and manipulate that data using the World Wide Web Consortium (W3C) Document Object Model (DOM). The DOM presents data as a hierarchy of node objects. Because `XmlDataDocument` implements the interface, it can also be used as the source document for the class. + + `XmlDataDocument` has a close affiliation with the `DataSet` class, which provides a relational view of the loaded XML data. Any changes made to the `XmlDataDocument` are reflected in the `DataSet` and vice versa. + + To load a `DataSet` with XML data, use to build a relational mapping. The XML data can then be loaded using or . + + To load relational data, specify the `DataSet` containing the relational data as the parameter in the constructor. + ]]> @@ -112,11 +112,11 @@ Initializes a new instance of the class. - is created and associated with the `XmlDataDocument`. - + is created and associated with the `XmlDataDocument`. + ]]> @@ -160,22 +160,21 @@ The to load into . Initializes a new instance of the class with the specified . - @@ -220,28 +219,27 @@ Creates a duplicate of the current node. The cloned node. - schema. - - If `deep` is set to `false`, the cloned `DataSet` has no data; that is, no rows. - - If `deep` is set to `true`, the cloned `DataSet` is set with the schema and then populated with the data. - - See in the `XmlNode` class to see a table describing how this method behaves with each of the different node types. - - - -## Examples - The following example loads a `DataSet` into an `XmlDataDocument` and then creates a shallow clone of the `XmlDataDocument`. - - The example uses the SQL Server 2000 Northwind database. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/CPP/source.cpp" id="Snippet1"::: + schema. + + If `deep` is set to `false`, the cloned `DataSet` has no data; that is, no rows. + + If `deep` is set to `true`, the cloned `DataSet` is set with the schema and then populated with the data. + + See in the `XmlNode` class to see a table describing how this method behaves with each of the different node types. + + + +## Examples + The following example loads a `DataSet` into an `XmlDataDocument` and then creates a shallow clone of the `XmlDataDocument`. + + The example uses the SQL Server 2000 Northwind database. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDataDocument/CloneNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDataDocument.CloneNode Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -302,22 +300,22 @@ Creates an element with the specified , , and . A new . - @@ -359,11 +357,11 @@ class MyXmlDataDocument : XmlDataDocument { Creates an with the specified name. An with the specified name. - nodes cannot be created for objects. Calling this method throws an exception. - + nodes cannot be created for objects. Calling this method throws an exception. + ]]> Calling this method. @@ -413,16 +411,16 @@ class MyXmlDataDocument : XmlDataDocument { Creates a new object for navigating this document. The is positioned on the node specified in the parameter. An used to navigate the document. - method. - - - -## Examples - To see an XSLT transformation using `XmlDataDocument` and an `XPathNavigator`, see the method. - + method. + + + +## Examples + To see an XSLT transformation using `XmlDataDocument` and an `XPathNavigator`, see the method. + ]]> @@ -461,30 +459,29 @@ class MyXmlDataDocument : XmlDataDocument { Gets a that provides a relational representation of the data in the . A that can be used to access the data in the using a relational model. - @@ -535,11 +532,11 @@ class MyXmlDataDocument : XmlDataDocument { Gets the with the specified ID. This method is not supported by the class. Calling this method throws an exception. An with the specified ID. - class. - + class. + ]]> Calling this method. @@ -582,17 +579,16 @@ class MyXmlDataDocument : XmlDataDocument { Retrieves the associated with the specified . The containing a representation of the specified . - @@ -635,13 +631,13 @@ class MyXmlDataDocument : XmlDataDocument { Returns an containing a list of all descendant elements that match the specified . An containing a list of all matching nodes. - [!NOTE] -> It is recommended that you use the or method instead of the method. - +> It is recommended that you use the or method instead of the method. + ]]> @@ -684,25 +680,24 @@ class MyXmlDataDocument : XmlDataDocument { Retrieves the associated with the specified . The containing a representation of the ; if there is no associated with the . - @@ -716,15 +711,15 @@ class MyXmlDataDocument : XmlDataDocument { Loads the using the specified data source and synchronizes the with the loaded data. - [!NOTE] -> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. - - `XmlDataDocument` does not support creating entity references. If the data includes entity references, the `Load` method resolves and expands any entity references. However, if you are using the `Load` overload that takes a as an argument, you must specify an `XmlReader` that can resolve entities. - +> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. + + `XmlDataDocument` does not support creating entity references. If the data includes entity references, the `Load` method resolves and expands any entity references. However, if you are using the `Load` overload that takes a as an argument, you must specify an `XmlReader` that can resolve entities. + ]]> @@ -765,14 +760,14 @@ class MyXmlDataDocument : XmlDataDocument { The stream containing the XML document to load. Loads the from the specified stream. - [!NOTE] -> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. - +> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. + ]]> @@ -813,14 +808,14 @@ class MyXmlDataDocument : XmlDataDocument { The used to feed the XML data into the document. Loads the from the specified . - [!NOTE] -> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. - +> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. + ]]> @@ -861,14 +856,14 @@ class MyXmlDataDocument : XmlDataDocument { The URL of the file containing the XML document to load. Loads the using the specified URL. - [!NOTE] -> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. - +> In order to view the XML data relationally, you must first specify a schema to use for data mapping. This can be done either by calling the method or by creating the tables and columns within the `DataSet` manually. This step must be done before calling `Load`. + ]]> @@ -909,53 +904,52 @@ class MyXmlDataDocument : XmlDataDocument { The containing the XML document to load. Loads the from the specified . - with the property set to EntityHandling.ExpandEntities (this is the default behavior) and pass the `XmlValidatingReader` to the `Load` method. If you do not use an `XmlValidatingReader`, the `Load` method throws an exception. - - The `Load` method always preserves significant white space. The property determines whether or not white space is preserved. The default is `false`, white space is not preserved. - - If the reader is in the initial state (that is, ReadState=ReadState.Initial), `Load` consumes the entire contents of the reader and builds the DOM from what it finds. - - If the reader is already positioned on some node at depth "n", then this method loads that node and all subsequent siblings up to the end tag that closes depth "n". This has the following results. - - If the current node and its following siblings look similar to the following: - -```xml -onetwo -``` - - `Load` throws an exception, because a document cannot have two root-level elements. If the current node and its following siblings look similar to the following: - -```xml - -``` - - `Load` will succeed; however, you will have an incomplete DOM tree, because there is no root-level element. You have to add a root-level element before you save the document; otherwise, the method throws an exception. - - If the reader is positioned on a leaf node that is invalid for the root level of a document (for example, a white space or attribute node), the reader continues to read until it is positioned on a node that can be used for the root. The document begins loading at this point. - - - -## Examples - The following example modifies the price of a book using the `DataSet` methods. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlDataDocument.Load/CPP/loadrdr.cpp" id="Snippet1"::: + with the property set to EntityHandling.ExpandEntities (this is the default behavior) and pass the `XmlValidatingReader` to the `Load` method. If you do not use an `XmlValidatingReader`, the `Load` method throws an exception. + + The `Load` method always preserves significant white space. The property determines whether or not white space is preserved. The default is `false`, white space is not preserved. + + If the reader is in the initial state (that is, ReadState=ReadState.Initial), `Load` consumes the entire contents of the reader and builds the DOM from what it finds. + + If the reader is already positioned on some node at depth "n", then this method loads that node and all subsequent siblings up to the end tag that closes depth "n". This has the following results. + + If the current node and its following siblings look similar to the following: + +```xml +onetwo +``` + + `Load` throws an exception, because a document cannot have two root-level elements. If the current node and its following siblings look similar to the following: + +```xml + +``` + + `Load` will succeed; however, you will have an incomplete DOM tree, because there is no root-level element. You have to add a root-level element before you save the document; otherwise, the method throws an exception. + + If the reader is positioned on a leaf node that is invalid for the root level of a document (for example, a white space or attribute node), the reader continues to read until it is positioned on a node that can be used for the root. The document begins loading at this point. + + + +## Examples + The following example modifies the price of a book using the `DataSet` methods. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDataDocument/Load/loadrdr.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.Load/VB/loadrdr.vb" id="Snippet1"::: - - The example uses the following two input files. - - `2books.xml` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.Load/XML/2books.xml" id="Snippet2"::: - - `store.xsd` - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.Load/XML/test.xsd" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlDataDocument.Load/VB/loadrdr.vb" id="Snippet1"::: + + The example uses the following two input files. + + `2books.xml` + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.Load/XML/2books.xml" id="Snippet2"::: + + `store.xsd` + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/XmlDataDocument.Load/XML/test.xsd" id="Snippet3"::: + ]]> The XML being loaded contains entity references, and the reader cannot resolve entities. diff --git a/xml/System.Xml/XmlDeclaration.xml b/xml/System.Xml/XmlDeclaration.xml index 443055e32b8..109c744b505 100644 --- a/xml/System.Xml/XmlDeclaration.xml +++ b/xml/System.Xml/XmlDeclaration.xml @@ -64,11 +64,11 @@ Represents the XML declaration node <?xml version='1.0'...?>. - @@ -140,11 +140,11 @@ The parent XML document. Initializes a new instance of the class. - directly; instead, use methods such as . - + directly; instead, use methods such as . + ]]> @@ -198,13 +198,13 @@ Creates a duplicate of this node. The cloned node. - . - - The cloned node has no parent ( returns `null`). - + . + + The cloned node has no parent ( returns `null`). + ]]> @@ -257,48 +257,47 @@ Gets or sets the encoding level of the XML document. - The valid character encoding name. The most commonly supported character encoding names for XML are the following: - - Category - - Encoding Names - - Unicode - - UTF-8, UTF-16 - - ISO 10646 - - ISO-10646-UCS-2, ISO-10646-UCS-4 - - ISO 8859 - - ISO-8859-n (where "n" is a digit from 1 to 9) - - JIS X-0208-1997 - - ISO-2022-JP, Shift_JIS, EUC-JP - - + The valid character encoding name. The most commonly supported character encoding names for XML are the following: + + Category + + Encoding Names + + Unicode + + UTF-8, UTF-16 + + ISO 10646 + + ISO-10646-UCS-2, ISO-10646-UCS-4 + + ISO 8859 + + ISO-8859-n (where "n" is a digit from 1 to 9) + + JIS X-0208-1997 + + ISO-2022-JP, Shift_JIS, EUC-JP + + + + This value is optional. If a value is not set, this property returns String.Empty. - This value is optional. If a value is not set, this property returns String.Empty. - If an encoding attribute is not included, UTF-8 encoding is assumed when the document is written or saved out. - @@ -538,15 +537,14 @@ Gets or sets the value of the standalone attribute. Valid values are if all entity declarations required by the XML document are contained within the document or if an external document type definition (DTD) is required. If a standalone attribute is not present in the XML declaration, this property returns String.Empty. - @@ -756,11 +754,11 @@ The to which you want to save. Saves the node to the specified . - and properties. If either of the properties is not set, the corresponding attribute is not written. The version attribute is always written out with a value of 1.0. - + and properties. If either of the properties is not set, the corresponding attribute is not written. The version attribute is always written out with a value of 1.0. + ]]> diff --git a/xml/System.Xml/XmlDocumentFragment.xml b/xml/System.Xml/XmlDocumentFragment.xml index 0126077e919..7cf3bdc5935 100644 --- a/xml/System.Xml/XmlDocumentFragment.xml +++ b/xml/System.Xml/XmlDocumentFragment.xml @@ -112,11 +112,11 @@ The XML document that is the source of the fragment. Initializes a new instance of the class. - directly; instead, use methods such as . - + directly; instead, use methods such as . + ]]> @@ -170,22 +170,21 @@ Creates a duplicate of this node. The cloned node. - . - - The cloned node has no parent ( returns `null`). - - - -## Examples - The following example shows the difference between a deep and shallow clone. + . + + The cloned node has no parent ( returns `null`). + + + +## Examples + The following example shows the difference between a deep and shallow clone. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocumentFragment/CloneNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDocumentFragment.CloneNode Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -234,22 +233,21 @@ Gets or sets the markup representing the children of this node. The markup of the children of this node. - The XML specified when setting this property is not well-formed. @@ -438,20 +436,19 @@ Gets the to which this node belongs. The to which this node belongs. - @@ -505,8 +502,8 @@ Gets the parent of this node (for nodes that can have parents). - The parent of this node. - + The parent of this node. + For nodes, this property is always . To be added. @@ -558,11 +555,11 @@ The to which you want to save. Saves all the children of the node to the specified . - @@ -614,11 +611,11 @@ The to which you want to save. Saves the node to the specified . - diff --git a/xml/System.Xml/XmlDocumentType.xml b/xml/System.Xml/XmlDocumentType.xml index 224a7c45666..a8df4d71c09 100644 --- a/xml/System.Xml/XmlDocumentType.xml +++ b/xml/System.Xml/XmlDocumentType.xml @@ -50,11 +50,11 @@ Represents the document type declaration. - class can be used to return information about a document type declaration. Use the method to create an object. - + class can be used to return information about a document type declaration. Use the method to create an object. + ]]> @@ -123,11 +123,11 @@ The parent document. Initializes a new instance of the class. - directly; instead, use members such as to obtain one. - + directly; instead, use members such as to obtain one. + ]]> @@ -176,13 +176,13 @@ Creates a duplicate of this node. The cloned node. - returns `null`). - - To see how this method behaves with other node types, see . - + returns `null`). + + To see how this method behaves with other node types, see . + ]]> @@ -226,24 +226,23 @@ Gets the collection of nodes declared in the document type declaration. An containing the nodes. The returned is read-only. - @@ -298,15 +297,14 @@ Gets the value of the document type definition (DTD) internal subset on the DOCTYPE declaration. The DTD internal subset on the DOCTYPE. If there is no DTD internal subset, String.Empty is returned. - @@ -349,28 +347,27 @@ Gets a value indicating whether the node is read-only. - if the node is read-only; otherwise, . - + if the node is read-only; otherwise, . + Because DocumentType nodes are read-only, this property always returns . - @@ -467,15 +464,14 @@ Gets the qualified name of the node. For DocumentType nodes, this property returns the name of the document type. - @@ -561,24 +557,23 @@ Gets the collection of nodes present in the document type declaration. An containing the nodes. The returned is read-only. - diff --git a/xml/System.Xml/XmlElement.xml b/xml/System.Xml/XmlElement.xml index 8565a947cb5..292655816e4 100644 --- a/xml/System.Xml/XmlElement.xml +++ b/xml/System.Xml/XmlElement.xml @@ -64,11 +64,11 @@ Represents an element. - , , , , and so on). You can also use the property which returns an enabling you to access attributes by name or index from the collection. - + , , , , and so on). You can also use the property which returns an enabling you to access attributes by name or index from the collection. + ]]> @@ -144,11 +144,11 @@ The parent XML document. Initializes a new instance of the class. - directly; instead, use methods such as . - + directly; instead, use methods such as . + ]]> @@ -198,15 +198,14 @@ containing the list of attributes for this node. - @@ -260,20 +259,19 @@ Creates a duplicate of this node. The cloned node. - returns `null`). - - - -## Examples - The following example creates a new element, clones it, and then adds both elements into an XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/CPP/source.cpp" id="Snippet1"::: + returns `null`). + + + +## Examples + The following example creates a new element, clones it, and then adds both elements into an XML document. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/CloneNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.CloneNode Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -335,15 +333,14 @@ Returns the value for the attribute with the specified name. The value of the specified attribute. An empty string is returned if a matching attribute is not found or if the attribute does not have a specified or default value. - @@ -466,15 +463,14 @@ Returns the with the specified name. The specified or if a matching attribute was not found. - @@ -596,27 +592,26 @@ Returns an containing a list of all descendant elements that match the specified . An containing a list of all matching nodes. The list is empty if there are no matching nodes. - tree. - + tree. + > [!NOTE] -> It is recommended that you use the or method instead of the method. - - - -## Examples - The following example gets and displays all the book titles. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp" id="Snippet1"::: +> It is recommended that you use the or method instead of the method. + + + +## Examples + The following example gets and displays all the book titles. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/GetElementsByTagName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: - - The example uses the file, `2books.xml`, as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: + + The example uses the file, `2books.xml`, as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -671,14 +666,14 @@ Returns an containing a list of all descendant elements that match the specified and . An containing a list of all matching nodes. The list is empty if there are no matching nodes. - [!NOTE] -> It is recommended that you use the or method instead of the method. - +> It is recommended that you use the or method instead of the method. + ]]> @@ -741,15 +736,14 @@ if the current node has the specified attribute; otherwise, . - @@ -860,20 +854,19 @@ if the current node has attributes; otherwise, . - @@ -922,22 +915,21 @@ Gets or sets the concatenated values of the node and all its children. The concatenated values of the node and all its children. - properties. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/CPP/source.cpp" id="Snippet1"::: + +This property is a Microsoft extension to the Document Object Model (DOM). + +## Examples + The following example compares the `InnerText` and properties. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/InnerText/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -986,22 +978,21 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets or sets the markup representing just the children of this node. The markup of the children of this node. - and `InnerXml` properties. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/CPP/source.cpp" id="Snippet1"::: + and `InnerXml` properties. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/InnerText/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.InnerXml Example/VB/source.vb" id="Snippet1"::: + ]]> The XML specified when setting this property is not well-formed. @@ -1050,26 +1041,25 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets or sets the tag format of the element. - if the element is to be serialized in the short tag format "<item/>"; for the long format "<item></item>". - - When setting this property, if set to , the children of the element are removed and the element is serialized in the short tag format. If set to , the value of the property is changed (regardless of whether or not the element has content); if the element is empty, it is serialized in the long format. - + if the element is to be serialized in the short tag format "<item/>"; for the long format "<item></item>". + + When setting this property, if set to , the children of the element are removed and the element is serialized in the short tag format. If set to , the value of the property is changed (regardless of whether or not the element has content); if the element is empty, it is serialized in the long format. + This property is a Microsoft extension to the Document Object Model (DOM). - @@ -1118,20 +1108,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets the local name of the current node. The name of the current node with the prefix removed. For example, is book for the element <bk:book>. - . - - - -## Examples - The following example displays information on the ISBN element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp" id="Snippet1"::: + . + + + +## Examples + The following example displays information on the ISBN element. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/LocalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1180,15 +1169,14 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets the qualified name of the node. The qualified name of the node. For nodes, this is the tag name of the element. - @@ -1238,20 +1226,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets the namespace URI of this node. The namespace URI of this node. If there is no namespace URI, this property returns String.Empty. - - - - -## Examples - The following example displays information on the ISBN element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp" id="Snippet1"::: + + + + +## Examples + The following example displays information on the ISBN element. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/LocalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1400,20 +1387,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets the to which this node belongs. The to which this element belongs. - @@ -1518,29 +1504,28 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets or sets the namespace prefix of this node. The namespace prefix of this node. If there is no prefix, this property returns String.Empty. - property, which holds the qualified name for an `XmlElement`. However, changing the prefix does not change the namespace URI of the element. - - - -## Examples - The following example displays information on the ISBN element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/CPP/source.cpp" id="Snippet1"::: + property, which holds the qualified name for an `XmlElement`. However, changing the prefix does not change the namespace URI of the element. + + + +## Examples + The following example displays information on the ISBN element. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/LocalName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.LocalName Example/VB/source.vb" id="Snippet1"::: + ]]> This node is read-only. - The specified prefix contains an invalid character. - - The specified prefix is malformed. - - The namespaceURI of this node is . - + The specified prefix contains an invalid character. + + The specified prefix is malformed. + + The namespaceURI of this node is . + The specified prefix is "xml" and the namespaceURI of this node is different from http://www.w3.org/XML/1998/namespace. @@ -1588,15 +1573,14 @@ This property is a Microsoft extension to the Document Object Model (DOM). Removes all specified attributes and children of the current node. Default attributes are not removed. - @@ -1645,20 +1629,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Removes all specified attributes from the element. Default attributes are not removed. - @@ -1719,20 +1702,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). The name of the attribute to remove. This is a qualified name. It is matched against the property of the matching node. Removes an attribute by name. - The node is read-only. @@ -1795,20 +1777,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). The namespace URI of the attribute to remove. Removes an attribute with the specified local name and namespace URI. (If the removed attribute has a default value, it is immediately replaced). - The node is read-only. @@ -1863,20 +1844,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Removes the attribute node with the specified index from the element. (If the removed attribute has a default value, it is immediately replaced). The attribute node removed or if there is no node at the given index. - @@ -2000,15 +1980,14 @@ This property is a Microsoft extension to the Document Object Model (DOM). Removes the specified by the local name and namespace URI. (If the removed attribute has a default value, it is immediately replaced). The removed or if the does not have a matching attribute node. - This node is read-only. @@ -2061,11 +2040,11 @@ This property is a Microsoft extension to the Document Object Model (DOM). Gets the post schema validation infoset that has been assigned to this node as a result of schema validation. An object containing the post schema validation infoset of this node. - property is set when this node is validated. - + property is set when this node is validated. + ]]> @@ -2136,11 +2115,11 @@ This property is a Microsoft extension to the Document Object Model (DOM). The value to set for the attribute. Sets the value of the attribute with the specified name. - node plus any and nodes, build the appropriate subtree and use to assign it as the value of an attribute. - + node plus any and nodes, build the appropriate subtree and use to assign it as the value of an attribute. + ]]> The specified name contains an invalid character. @@ -2267,11 +2246,11 @@ This property is a Microsoft extension to the Document Object Model (DOM). Adds the specified . If the attribute replaces an existing attribute with the same name, the old is returned; otherwise, is returned. - The was created from a different document than the one that created this node. Or this node is read-only. @@ -2336,20 +2315,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). Adds the specified . The to add. - to assign a text value to the attribute or use (or a similar method) to add children to the attribute. - - - -## Examples - The following example adds an attribute to an element. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/CPP/source.cpp" id="Snippet1"::: + to assign a text value to the attribute or use (or a similar method) to add children to the attribute. + + + +## Examples + The following example adds an attribute to an element. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/SetAttributeNode/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.SetAttributeNode1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2401,20 +2379,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). The to which you want to save. Saves all the children of the node to the specified . - @@ -2467,20 +2444,19 @@ This property is a Microsoft extension to the Document Object Model (DOM). The to which you want to save. Saves the current node to the specified . - diff --git a/xml/System.Xml/XmlEntity.xml b/xml/System.Xml/XmlEntity.xml index 8822b038235..7a20bd3557a 100644 --- a/xml/System.Xml/XmlEntity.xml +++ b/xml/System.Xml/XmlEntity.xml @@ -99,68 +99,68 @@ Gets the base Uniform Resource Identifier (URI) of the current node. The location from which the node was loaded. - -]> -&xyz; -``` - - where the external entity `a/b.xml` contains the XML text `123`. - - If the document is loaded from `http://server/mydata.xml`, `BaseURI` returns the following: - -|NodeType|Name|BaseURI| -|--------------|----------|-------------| -|Attribute|num|`http://server/mydata.xml`| -|Document|#document|`http://server/mydata.xml`| -|DocumentType|item|`http://server/mydata.xml`| -|Entity|xyz|`http://server/mydata.xml`| -|Element|item|`http://server/mydata.xml`| -|EntityReference|xyz|`http://server/mydata.xml`| -|Element|test|`http://server/a/b.xml`| -|Text|#text|`http://server/a/b.xml`| - - `BaseURI` looks for entity reference boundaries, so if entities are expanded, this information is not preserved and this property returns the location of the `XmlDocument` object in all cases. - - As a second example, given the following XML document: - -```xml - -&xyz; -``` - - where the document type definition (DTD) file contains the following: - -``` -My Data"> - - -``` - - If the XML document is loaded from http://localhost/mydata.xml, `BaseURI` returns the following for each of the nodes: - -|NodeType|Name|BaseURI| -|--------------|----------|-------------| -|Document|#document|http://localhost/mydata.xml| -|DocumentType|Mydata|http://localhost/doctype.dtd| -|Element|baa|http://localhost/mydata.xml| -|Entity|xyz|http://localhost/doctype.dtd| -|EntityReference|xyz|http://localhost/mydata.xml| -|Attribute|woof|http://localhost/mydata.xml| - + +]> +&xyz; +``` + + where the external entity `a/b.xml` contains the XML text `123`. + + If the document is loaded from `http://server/mydata.xml`, `BaseURI` returns the following: + +|NodeType|Name|BaseURI| +|--------------|----------|-------------| +|Attribute|num|`http://server/mydata.xml`| +|Document|#document|`http://server/mydata.xml`| +|DocumentType|item|`http://server/mydata.xml`| +|Entity|xyz|`http://server/mydata.xml`| +|Element|item|`http://server/mydata.xml`| +|EntityReference|xyz|`http://server/mydata.xml`| +|Element|test|`http://server/a/b.xml`| +|Text|#text|`http://server/a/b.xml`| + + `BaseURI` looks for entity reference boundaries, so if entities are expanded, this information is not preserved and this property returns the location of the `XmlDocument` object in all cases. + + As a second example, given the following XML document: + +```xml + +&xyz; +``` + + where the document type definition (DTD) file contains the following: + +``` +My Data"> + + +``` + + If the XML document is loaded from http://localhost/mydata.xml, `BaseURI` returns the following for each of the nodes: + +|NodeType|Name|BaseURI| +|--------------|----------|-------------| +|Document|#document|http://localhost/mydata.xml| +|DocumentType|Mydata|http://localhost/doctype.dtd| +|Element|baa|http://localhost/mydata.xml| +|Entity|xyz|http://localhost/doctype.dtd| +|EntityReference|xyz|http://localhost/mydata.xml| +|Attribute|woof|http://localhost/mydata.xml| + > [!NOTE] -> The base URI of a default attribute is the same as the base URI of the element to which they belong. - - This property is a Microsoft extension to the Document Object Model (DOM). - +> The base URI of a default attribute is the same as the base URI of the element to which they belong. + + This property is a Microsoft extension to the Document Object Model (DOM). + ]]> @@ -251,13 +251,13 @@ Gets the concatenated values of the entity node and all its children. The concatenated values of the node and all its children. - Attempting to set the property. @@ -308,13 +308,13 @@ Gets the markup representing the children of this node. For nodes, String.Empty is returned. - Attempting to set the property. @@ -358,15 +358,15 @@ Gets a value indicating whether the node is read-only. - if the node is read-only; otherwise, . - + if the node is read-only; otherwise, . + Because nodes are read-only, this property always returns . - @@ -463,19 +463,18 @@ Gets the name of the node. The name of the entity. - @@ -520,19 +519,18 @@ Gets the type of the node. The node type. For nodes, the value is XmlNodeType.Entity. - @@ -588,19 +586,18 @@ Gets the name of the optional NDATA attribute on the entity declaration. The name of the NDATA attribute. If there is no NDATA, is returned. - @@ -651,11 +648,11 @@ Gets the markup representing this node and all its children. For nodes, String.Empty is returned. - @@ -710,19 +707,18 @@ Gets the value of the public identifier on the entity declaration. The public identifier on the entity. If there is no public identifier, is returned. - @@ -778,19 +774,18 @@ Gets the value of the system identifier on the entity declaration. The system identifier on the entity. If there is no system identifier, is returned. - @@ -838,11 +833,11 @@ The to which you want to save. Saves all the children of the node to the specified . For nodes, this method has no effect. - @@ -889,11 +884,11 @@ The to which you want to save. Saves the node to the specified . For nodes, this method has no effect. - diff --git a/xml/System.Xml/XmlEntityReference.xml b/xml/System.Xml/XmlEntityReference.xml index 1f18f861a10..56141994186 100644 --- a/xml/System.Xml/XmlEntityReference.xml +++ b/xml/System.Xml/XmlEntityReference.xml @@ -95,11 +95,11 @@ The parent XML document. Initializes a new instance of the class. - directly; instead, use methods such as . - + directly; instead, use methods such as . + ]]> Creating New Entity References @@ -144,32 +144,31 @@ Gets the base Uniform Resource Identifier (URI) of the current node. The location from which the node was loaded. - is returned. - - `BaseURI` walks the node tree looking for entity reference boundaries, so if entities are expanded, this information is not preserved and this property returns the location of the XmlDocument in all cases. - - For additional information on `BaseURI` and how it behaves with other node types, see . - - This property is a Microsoft extension to the Document Object Model (DOM). - - - -## Examples - The following example displays information on entity reference node, including its base URI. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/CPP/source.cpp" id="Snippet1"::: + is returned. + + `BaseURI` walks the node tree looking for entity reference boundaries, so if entities are expanded, this information is not preserved and this property returns the location of the XmlDocument in all cases. + + For additional information on `BaseURI` and how it behaves with other node types, see . + + This property is a Microsoft extension to the Document Object Model (DOM). + + + +## Examples + The following example displays information on entity reference node, including its base URI. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlEntityReference/BaseURI/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/VB/source.vb" id="Snippet1"::: - - The sample uses the file, `uri.xml`, as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/XML/source.xml" id="Snippet2"::: - - The `style.xml` file contains the XML string ``. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/VB/source.vb" id="Snippet1"::: + + The sample uses the file, `uri.xml`, as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlEntityReference.BaseURI Example/XML/source.xml" id="Snippet2"::: + + The `style.xml` file contains the XML string ``. + ]]> @@ -218,11 +217,11 @@ Creates a duplicate of this node. The cloned node. - returns `null`). - + returns `null`). + ]]> @@ -265,26 +264,25 @@ Gets a value indicating whether the node is read-only. - if the node is read-only; otherwise . - + if the node is read-only; otherwise . + Because nodes are read-only, this property always returns . - @@ -381,15 +379,14 @@ Gets the name of the node. The name of the entity referenced. - @@ -528,11 +525,11 @@ The to which you want to save. Saves all the children of the node to the specified . - @@ -579,11 +576,11 @@ The to which you want to save. Saves the node to the specified . - diff --git a/xml/System.Xml/XmlImplementation.xml b/xml/System.Xml/XmlImplementation.xml index 34ffacc853a..dd791d10ef3 100644 --- a/xml/System.Xml/XmlImplementation.xml +++ b/xml/System.Xml/XmlImplementation.xml @@ -64,13 +64,13 @@ Defines the context for a set of objects. - . This enables users to compare attribute and element names between the objects more efficiently. - - Although the `XmlDocument` objects share the same implementation, to move nodes from one document to another, you must use the method. - + . This enables users to compare attribute and element names between the objects more efficiently. + + Although the `XmlDocument` objects share the same implementation, to move nodes from one document to another, you must use the method. + ]]> @@ -222,22 +222,21 @@ Creates a new . The new object. - method. + + + +## Examples + The following example creates two `XmlDocument` objects from the same implementation. - Although the `XmlDocument` objects share the same implementation, to move nodes from one document to another, you must use the method. - - - -## Examples - The following example creates two `XmlDocument` objects from the same implementation. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlImplementation/CreateDocument/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlImplementation.CreateDocument Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -292,22 +291,22 @@ This is the version number of the package name to test. If the version is not specified (), supporting any version of the feature causes the method to return . Tests if the Document Object Model (DOM) implementation implements a specific feature. - if the feature is implemented in the specified version; otherwise, . - - The following table shows the combinations that cause to return . - - strFeature - - strVersion - - XML - - 1.0 - - XML - - 2.0 - + if the feature is implemented in the specified version; otherwise, . + + The following table shows the combinations that cause to return . + + strFeature + + strVersion + + XML + + 1.0 + + XML + + 2.0 + To be added. diff --git a/xml/System.Xml/XmlLinkedNode.xml b/xml/System.Xml/XmlLinkedNode.xml index e627847786d..ead542e7c1e 100644 --- a/xml/System.Xml/XmlLinkedNode.xml +++ b/xml/System.Xml/XmlLinkedNode.xml @@ -111,15 +111,14 @@ Gets the node immediately following this node. The immediately following this node or if one does not exist. - @@ -170,15 +169,14 @@ Gets the node immediately preceding this node. The preceding or if one does not exist. - diff --git a/xml/System.Xml/XmlNamedNodeMap.xml b/xml/System.Xml/XmlNamedNodeMap.xml index bbb13220a3d..ec6aed7bc4b 100644 --- a/xml/System.Xml/XmlNamedNodeMap.xml +++ b/xml/System.Xml/XmlNamedNodeMap.xml @@ -68,17 +68,17 @@ Represents a collection of nodes that can be accessed by name or index. - - Returns , a class which inherits from `XmlNamedNodeMap`. - -- - Returns an `XmlNamedNodeMap` containing objects. The `XmlNamedNodeMap` is read-only. - -- - Returns an `XmlNamedNodeMap` containing objects. The `XmlNamedNodeMap` is read-only. - + - Returns , a class which inherits from `XmlNamedNodeMap`. + +- - Returns an `XmlNamedNodeMap` containing objects. The `XmlNamedNodeMap` is read-only. + +- - Returns an `XmlNamedNodeMap` containing objects. The `XmlNamedNodeMap` is read-only. + ]]> @@ -138,15 +138,14 @@ Gets the number of nodes in the . The number of nodes. - class (which inherits from `XmlNamedNodeMap`) to display all the attributes of a book. + class (which inherits from `XmlNamedNodeMap`) to display all the attributes of a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamedNodeMap/Count/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -199,15 +198,14 @@ Provides support for the "foreach" style iteration over the collection of nodes in the . An enumerator object. - @@ -270,15 +268,14 @@ Retrieves an specified by name. An with the specified name or if a matching node is not found. - class (which inherits from `XmlNamedNodeMap`) to modify an attribute. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/CPP/source.cpp" id="Snippet1"::: + class (which inherits from `XmlNamedNodeMap`) to modify an attribute. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamedNodeMap/GetNamedItem/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.GetNamedItem Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -392,15 +389,14 @@ Retrieves the node at the specified index in the . The at the specified index. If is less than 0 or greater than or equal to the property, is returned. - class (which inherits from `XmlNamedNodeMap`) to display all the attributes of a book. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/CPP/source.cpp" id="Snippet1"::: + class (which inherits from `XmlNamedNodeMap`) to display all the attributes of a book. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamedNodeMap/Count/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.Count Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -463,15 +459,14 @@ Removes the node from the . The removed from this or if a matching node was not found. - class (which inherits from `XmlNamedNodeMap`) to remove an attribute. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/CPP/source.cpp" id="Snippet1"::: + class (which inherits from `XmlNamedNodeMap`) to remove an attribute. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamedNodeMap/RemoveNamedItem/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.RemoveNamedItem1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -585,15 +580,14 @@ Adds an using its property. If the replaces an existing node with the same name, the old node is returned; otherwise, is returned. - class (which inherits from `XmlNamedNodeMap`) to add an attribute to the collection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/CPP/source.cpp" id="Snippet1"::: + class (which inherits from `XmlNamedNodeMap`) to add an attribute to the collection. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamedNodeMap/SetNamedItem/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamedNodeMap.SetNamedItem Example/VB/source.vb" id="Snippet1"::: + ]]> The was created from a different than the one that created the ; or the is read-only. diff --git a/xml/System.Xml/XmlNamespaceManager.xml b/xml/System.Xml/XmlNamespaceManager.xml index 6bc13aef348..d1d5befd41c 100644 --- a/xml/System.Xml/XmlNamespaceManager.xml +++ b/xml/System.Xml/XmlNamespaceManager.xml @@ -212,7 +212,6 @@ while (reader.Read()) ## Examples The following example creates an using the name table of the reader. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.XmlNamespaceManager Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.XmlNamespaceManager Example/VB/source.vb" id="Snippet1"::: @@ -366,7 +365,6 @@ while (reader.Read()) ## Examples The following example displays the default namespace, if one exists. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/DefaultNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/VB/source.vb" id="Snippet1"::: @@ -570,7 +568,6 @@ Loop ## Examples The following example displays the default namespace, if one exists. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/DefaultNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.DefaultNamespace Example/VB/source.vb" id="Snippet1"::: @@ -637,7 +634,6 @@ Loop ## Examples The following example adds prefix/namespace pairs to the , and then displays all the pairs in the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/LookupNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/VB/source.vb" id="Snippet1"::: @@ -879,7 +875,6 @@ writer.WriteEndElement() ## Examples The following example adds prefix/namespace pairs to the and then displays all the pairs in the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/LookupNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/VB/source.vb" id="Snippet1"::: @@ -942,7 +937,6 @@ writer.WriteEndElement() ## Examples The following example adds prefix/namespace pairs to the and then displays all the pairs in the collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNamespaceManager/LookupNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNamespaceManager.PopScope Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlNode.xml b/xml/System.Xml/XmlNode.xml index 3a5dd281656..3d19d1e592a 100644 --- a/xml/System.Xml/XmlNode.xml +++ b/xml/System.Xml/XmlNode.xml @@ -159,7 +159,6 @@ ## Examples The following example adds a new node to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.AppendChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/AppendChild/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.AppendChild Example/VB/source.vb" id="Snippet1"::: @@ -246,7 +245,6 @@ Display the modified XML... ## Examples The following example adds a new attribute to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/Attributes/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/VB/source.vb" id="Snippet1"::: @@ -420,7 +418,6 @@ Where the DTD file contains the following: ## Examples The following example displays all the child nodes of the root element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocument/Overview/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/VB/source.vb" id="Snippet1"::: @@ -512,7 +509,6 @@ Where the DTD file contains the following: ## Examples The following example clones the root node of the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.Clone Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/Clone/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.Clone Example/VB/source.vb" id="Snippet1"::: @@ -601,7 +597,6 @@ Where the DTD file contains the following: ## Examples The following example shows the difference between a deep and shallow clone. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.CloneNode Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/CloneNode/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.CloneNode Example/VB/source.vb" id="Snippet1"::: @@ -671,7 +666,6 @@ Where the DTD file contains the following: ## Examples The following example loads and edits an XML document before performing an XSLT transform. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XslTransform.Transform2/CPP/trans_snip.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/CreateNavigator/trans_snip.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XslTransform.Transform2/VB/trans_snip.vb" id="Snippet1"::: @@ -745,7 +739,6 @@ Where the DTD file contains the following: ## Examples The following example displays the title element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.FirstChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/FirstChild/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.FirstChild Example/VB/source.vb" id="Snippet1"::: @@ -810,7 +803,6 @@ Where the DTD file contains the following: ## Examples The following example displays all the books in the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetEnumerator Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/GetEnumerator/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.GetEnumerator Example/VB/source.vb" id="Snippet1"::: @@ -880,7 +872,6 @@ Where the DTD file contains the following: ## Examples The following example adds a new attribute to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/Attributes/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/VB/source.vb" id="Snippet1"::: @@ -946,7 +937,6 @@ Where the DTD file contains the following: ## Examples The following example adds a new element to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetPrefixOfNamespace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/GetPrefixOfNamespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.GetPrefixOfNamespace Example/VB/source.vb" id="Snippet1"::: @@ -1009,7 +999,6 @@ Where the DTD file contains the following: ## Examples The following example displays all the child nodes of the root element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocument/Overview/source2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.HasChildNodes Example/VB/source.vb" id="Snippet1"::: @@ -1075,7 +1064,6 @@ Where the DTD file contains the following: ## Examples The following example compares the `InnerText` and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/InnerText/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/VB/source.vb" id="Snippet1"::: @@ -1152,7 +1140,6 @@ d. ## Examples The following example compares the and `InnerXml` properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/InnerText/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.InnerText Example/VB/source.vb" id="Snippet1"::: @@ -1234,7 +1221,6 @@ d. ## Examples The following example adds a new node to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertAfter Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/InsertAfter/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.InsertAfter Example/VB/source.vb" id="Snippet1"::: @@ -1325,7 +1311,6 @@ d. ## Examples The following example adds a new node to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.InsertBefore Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/InsertBefore/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.InsertBefore Example/VB/source.vb" id="Snippet1"::: @@ -1482,7 +1467,6 @@ d. ## Examples The following example displays the title element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.this Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/Item/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.this Example/VB/source.vb" id="Snippet1"::: @@ -1616,7 +1600,6 @@ d. ## Examples The following example displays the price element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.LastChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocument/Overview/source3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.LastChild Example/VB/source.vb" id="Snippet1"::: @@ -1976,7 +1959,6 @@ d. ## Examples The following example displays all the books in the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.NextSibling Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocument/Overview/source4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.NextSibling Example/VB/source.vb" id="Snippet1"::: @@ -2142,7 +2124,6 @@ d. ## Examples The following example compares output from the and `OuterXml` properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.OuterXml Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/OuterXml/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.OuterXml Example/VB/source.vb" id="Snippet1"::: @@ -2450,7 +2431,6 @@ d. ## Examples The following example adds a new node to the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PrependChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/PrependChild/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.PrependChild Example/VB/source.vb" id="Snippet1"::: @@ -2525,7 +2505,6 @@ d. ## Examples The following example displays all the books in the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.PreviousSibling Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlLinkedNode/PreviousSibling/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.PreviousSibling Example/VB/source.vb" id="Snippet1"::: @@ -2653,7 +2632,6 @@ d. ## Examples The following example removes all child and attribute nodes from the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveAll Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/RemoveAll/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.RemoveAll Example/VB/source.vb" id="Snippet1"::: @@ -2717,7 +2695,6 @@ d. ## Examples The following example removes a node from the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.RemoveChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/RemoveChild/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.RemoveChild Example/VB/source.vb" id="Snippet1"::: @@ -2791,7 +2768,6 @@ d. ## Examples The following example replaces the title element in the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.ReplaceChild Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/ReplaceChild/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.ReplaceChild Example/VB/source.vb" id="Snippet1"::: @@ -2981,7 +2957,6 @@ nodeList = root.SelectNodes("//book[contains(title,""'Emma'"")]") ## Examples The following example selects all books where the author's last name is Austen, and then changes the price of those books. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectNodes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlDocument/Overview/source6.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.SelectNodes Example/VB/source.vb" id="Snippet1"::: @@ -3108,7 +3083,6 @@ nodeList = root.SelectNodes("//ab:book[contains(ab:title,""'Emma'"")]", nsmgr) ## Examples The following example displays the values of each of the ISBN attributes. This example uses an object, which inherits from the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlNode.SelectNodes1/CPP/selectnodes1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/SelectNodes/selectnodes1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlNode.SelectNodes1/VB/selectnodes1.vb" id="Snippet1"::: @@ -3145,7 +3119,6 @@ nodeList = root.SelectNodes("//ab:book[contains(ab:title,""'Emma'"")]", nsmgr) ## Examples The following example returns the first book with the matching author name. The `XmlNamespaceManager` resolves the default namespace in the XPath expression. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode2/CPP/XmlNode.SelectSingleNode2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/SelectSingleNode/selectsingnode2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlNode.SelectSingleNode2/VB/selectsingnode2.vb" id="Snippet1"::: @@ -3244,7 +3217,6 @@ book = root.SelectSingleNode("descendant::book[title=""'Emma'""]") ## Examples The following example changes the price of the first Jane Austen book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.SelectSingleNode Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/SelectSingleNode/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.SelectSingleNode Example/VB/source.vb" id="Snippet1"::: @@ -3369,7 +3341,6 @@ book = root.SelectSingleNode("descendant::ab:book[ab:title=""'Emma'""]", nsmgr) ## Examples The following example selects the book with the matching ISBN value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlNode.SelectSingleNode1/CPP/selectsingnode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/SelectSingleNode/selectsingnode.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlNode.SelectSingleNode1/VB/selectsingnode.vb" id="Snippet1"::: @@ -3691,7 +3662,6 @@ book = root.SelectSingleNode("descendant::ab:book[ab:title=""'Emma'""]", nsmgr) ## Examples The following example adds a new attribute to the XML document and sets the property of the new attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/Attributes/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.GetNamespaceOfPrefix Example/VB/source.vb" id="Snippet1"::: @@ -3758,7 +3728,6 @@ book = root.SelectSingleNode("descendant::ab:book[ab:title=""'Emma'""]", nsmgr) ## Examples The following example displays the contents of the root node to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteContentTo Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/WriteContentTo/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.WriteContentTo Example/VB/source.vb" id="Snippet1"::: @@ -3824,7 +3793,6 @@ book = root.SelectSingleNode("descendant::ab:book[ab:title=""'Emma'""]", nsmgr) ## Examples The following example displays the root node to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNode.WriteTo Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNode/WriteTo/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNode.WriteTo Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlNodeChangedEventHandler.xml b/xml/System.Xml/XmlNodeChangedEventHandler.xml index 7f3610f242f..4d77b572f49 100644 --- a/xml/System.Xml/XmlNodeChangedEventHandler.xml +++ b/xml/System.Xml/XmlNodeChangedEventHandler.xml @@ -66,24 +66,23 @@ An containing the event data. Represents the method that handles , , , , and events. - diff --git a/xml/System.Xml/XmlNodeList.xml b/xml/System.Xml/XmlNodeList.xml index 6681b2df939..3940256750e 100644 --- a/xml/System.Xml/XmlNodeList.xml +++ b/xml/System.Xml/XmlNodeList.xml @@ -70,19 +70,19 @@ Represents an ordered collection of nodes. - collection was created from are immediately reflected in the nodes returned by the `XmlNodeList` properties and methods. `XmlNodeList` supports iteration and indexed access. - - `XmlNodeList` is returned by the following properties and methods. - -- - Returns an `XmlNodeList` containing all the children of the node. - -- - Returns an `XmlNodeList` containing a collection of nodes matching the XPath query. - -- `GetElementsByTagName` - Returns an `XmlNodeList` containing a list of all descendant elements that match the specified name. This method is available in both the and classes. - + collection was created from are immediately reflected in the nodes returned by the `XmlNodeList` properties and methods. `XmlNodeList` supports iteration and indexed access. + + `XmlNodeList` is returned by the following properties and methods. + +- - Returns an `XmlNodeList` containing all the children of the node. + +- - Returns an `XmlNodeList` containing a collection of nodes matching the XPath query. + +- `GetElementsByTagName` - Returns an `XmlNodeList` containing a list of all descendant elements that match the specified name. This method is available in both the and classes. + ]]> Ordered Node Retrieval by Index @@ -181,19 +181,18 @@ Gets the number of nodes in the . The number of nodes in the . - object and uses the method and the resulting `XmlNodeList` to display all the book titles. + object and uses the method and the resulting `XmlNodeList` to display all the book titles. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/GetElementsByTagName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: - - The example uses the file `2books.xml` as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: + + The example uses the file `2books.xml` as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: + ]]> @@ -246,24 +245,23 @@ Gets an enumerator that iterates through the collection of nodes. An enumerator used to iterate through the collection of nodes. - @@ -317,15 +315,14 @@ Retrieves a node at the given index. The with the specified index in the collection. If is greater than or equal to the number of nodes in the list, this returns . - @@ -389,19 +386,18 @@ Gets a node at the given index. The with the specified index in the collection. If index is greater than or equal to the number of nodes in the list, this returns . - object and uses the method and the resulting `XmlNodeList` to display all the book titles. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/CPP/source.cpp" id="Snippet1"::: + object and uses the method and the resulting `XmlNodeList` to display all the book titles. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlElement/GetElementsByTagName/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: - - The example uses the file `2books.xml` as input. - - :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/VB/source.vb" id="Snippet1"::: + + The example uses the file `2books.xml` as input. + + :::code language="xml" source="~/snippets/xml/VS_Snippets_Data/Classic WebData XmlElement.GetElementsByTagName Example/XML/source.xml" id="Snippet2"::: + ]]> diff --git a/xml/System.Xml/XmlNodeReader.xml b/xml/System.Xml/XmlNodeReader.xml index 58283892266..597055325b5 100644 --- a/xml/System.Xml/XmlNodeReader.xml +++ b/xml/System.Xml/XmlNodeReader.xml @@ -191,7 +191,6 @@ Output: ## Examples The following example reads all the attributes on the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/VB/source.vb" id="Snippet1"::: @@ -252,7 +251,6 @@ Output: ## Examples The following example parses a file and displays the base URI of each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.BaseURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/BaseURI/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.BaseURI Example/VB/source.vb" id="Snippet1"::: @@ -422,7 +420,6 @@ Output: ## Examples The following example parses a file and closes the reader. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -674,7 +671,6 @@ This method does not move the reader. ## Examples The following example gets the value of the ISBN attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.GetAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/GetAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.GetAttribute Example/VB/source.vb" id="Snippet1"::: @@ -820,7 +816,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example reads all the attributes on the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/VB/source.vb" id="Snippet1"::: @@ -894,7 +889,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example displays the value for every node that can have a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.HasValue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/HasValue/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.HasValue Example/VB/source.vb" id="Snippet1"::: @@ -1015,7 +1009,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example displays the text content of each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/IsEmptyElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/VB/source.vb" id="Snippet1"::: @@ -1196,7 +1189,6 @@ This property does not move the reader. ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/VB/source.vb" id="Snippet1"::: @@ -1339,7 +1331,6 @@ This property does not move the reader. ## Examples The following example reads all the attributes on the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/VB/source.vb" id="Snippet1"::: @@ -1527,7 +1518,6 @@ This property does not move the reader. ## Examples The following example reads all the attributes on the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.AttributeCount Example/VB/source.vb" id="Snippet1"::: @@ -1588,7 +1578,6 @@ This property does not move the reader. ## Examples The following example gets the value of the first attribute of the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToFirstAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/MoveToFirstAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToFirstAttribute Example/VB/source.vb" id="Snippet1"::: @@ -1651,7 +1640,6 @@ This property does not move the reader. ## Examples The following example reads a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToNextAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/MoveToNextAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.MoveToNextAttribute Example/VB/source.vb" id="Snippet1"::: @@ -1730,7 +1718,6 @@ This property does not move the reader. ## Examples The following example reads an XML and displays each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -1795,7 +1782,6 @@ This property does not move the reader. ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/VB/source.vb" id="Snippet1"::: @@ -1907,7 +1893,6 @@ This property does not move the reader. ## Examples The following example reads an XML and displays each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -1970,7 +1955,6 @@ This property does not move the reader. ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.NamespaceURI Example/VB/source.vb" id="Snippet1"::: @@ -2075,7 +2059,6 @@ This property does not move the reader. ## Examples The following example reads an XML and displays each node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -2146,7 +2129,6 @@ This property does not move the reader. ## Examples The following example reads an attribute with text and entity reference nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ReadAttributeValue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/ReadAttributeValue/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.ReadAttributeValue Example/VB/source.vb" id="Snippet1"::: @@ -2578,7 +2560,6 @@ This property does not move the reader. ## Examples The following example displays the text content of each of the elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/IsEmptyElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.IsEmptyElement Example/VB/source.vb" id="Snippet1"::: @@ -2642,7 +2623,6 @@ This property does not move the reader. ## Examples The following example uses `ResolveEntity` to expand a general entity. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.ResolveEntity Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/ResolveEntity/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.ResolveEntity Example/VB/source.vb" id="Snippet1"::: @@ -2779,7 +2759,6 @@ This property does not move the reader. ## Examples The following example reads the price element node in the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Skip Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Skip/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Skip Example/VB/source.vb" id="Snippet1"::: @@ -3030,7 +3009,6 @@ This property does not move the reader. ## Examples The following example reads an XML and displays each node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlNodeReader/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlNodeReader.Name Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlNotation.xml b/xml/System.Xml/XmlNotation.xml index 1aedf327d34..8748cbd16f0 100644 --- a/xml/System.Xml/XmlNotation.xml +++ b/xml/System.Xml/XmlNotation.xml @@ -146,13 +146,13 @@ Gets the markup representing the children of this node. For nodes, String.Empty is returned. - Attempting to set the property. @@ -196,17 +196,17 @@ Gets a value indicating whether the node is read-only. - if the node is read-only; otherwise, . - + if the node is read-only; otherwise, . + Because nodes are read-only, this property always returns . - @@ -303,19 +303,18 @@ Gets the name of the current node. The name of the notation. - @@ -360,19 +359,18 @@ Gets the type of the current node. The node type. For nodes, the value is XmlNodeType.Notation. - @@ -423,11 +421,11 @@ Gets the markup representing this node and all its children. For nodes, String.Empty is returned. - @@ -482,19 +480,18 @@ Gets the value of the public identifier on the notation declaration. The public identifier on the notation. If there is no public identifier, is returned. - @@ -550,19 +547,18 @@ Gets the value of the system identifier on the notation declaration. The system identifier on the notation. If there is no system identifier, is returned. - @@ -610,11 +606,11 @@ The to which you want to save. Saves the children of the node to the specified . This method has no effect on nodes. - @@ -661,11 +657,11 @@ The to which you want to save. Saves the node to the specified . This method has no effect on nodes. - diff --git a/xml/System.Xml/XmlReader.xml b/xml/System.Xml/XmlReader.xml index 6f5ce6beeff..0e631e139fe 100644 --- a/xml/System.Xml/XmlReader.xml +++ b/xml/System.Xml/XmlReader.xml @@ -3282,7 +3282,6 @@ public class Sample ## Examples This is useful when you want to write code that can skip over random XML markup without breaking. For example, suppose you have the following code: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.MoveToContent Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlReader/MoveToContent/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlReader.MoveToContent Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlReaderSettings.xml b/xml/System.Xml/XmlReaderSettings.xml index 691ed383a31..04bf4437a6a 100644 --- a/xml/System.Xml/XmlReaderSettings.xml +++ b/xml/System.Xml/XmlReaderSettings.xml @@ -144,7 +144,6 @@ The following example creates an that uses an is processing text data, it always checks tha object and the method to associate a schema with an XML document. The schema is added to the property of the object. The value of the property is an object. The schema is used to validate that the XML document conforms to the schema content model. Schema validation errors and warnings are handled by the defined in the object. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSchemaSetOverall Example/CPP/xmlschemasetexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlReaderSettings/Schemas/xmlschemasetexample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSchemaSetOverall Example/VB/xmlschemasetexample.vb" id="Snippet1"::: @@ -1601,7 +1594,6 @@ The output is as follows: ## Examples The following example validates using a schema stored in the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlReader_Validate_SchemaSet/CPP/XmlReader_Validate_SchemaSet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlReaderSettings/ValidationType/validschemaset.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlReader_Validate_SchemaSet/VB/validschemaset.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlSecureResolver.xml b/xml/System.Xml/XmlSecureResolver.xml index d68dd196201..fb8902d6b5f 100644 --- a/xml/System.Xml/XmlSecureResolver.xml +++ b/xml/System.Xml/XmlSecureResolver.xml @@ -126,7 +126,6 @@ See the constructor reference topics for examples of these types of restrictions ## Examples The following example constructs an object by using a customized permission set. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.cctor/CPP/secresolver.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlSecureResolver/.ctor/secresolver.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSecureResolver.cctor/VB/secresolver.vb" id="Snippet1"::: @@ -348,7 +347,6 @@ See the constructor reference topics for examples of these types of restrictions ## Examples The following example uses an with default credentials to resolve and open network resources needed by the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlSecureResolver.Credentials/CPP/secresolver2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlSecureResolver/Credentials/secresolver2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlSecureResolver.Credentials/VB/secresolver2.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlSignificantWhitespace.xml b/xml/System.Xml/XmlSignificantWhitespace.xml index 9340733ee93..c8de3b71085 100644 --- a/xml/System.Xml/XmlSignificantWhitespace.xml +++ b/xml/System.Xml/XmlSignificantWhitespace.xml @@ -64,11 +64,11 @@ Represents white space between markup in a mixed content node or white space within an xml:space= 'preserve' scope. This is also referred to as significant white space. - @@ -128,11 +128,11 @@ The object. Initializes a new instance of the class. - @@ -186,13 +186,13 @@ Creates a duplicate of this node. The cloned node. - . - - The cloned node has no parent. returns `null`. - + . + + The cloned node has no parent. returns `null`. + ]]> @@ -333,15 +333,14 @@ Gets the type of the current node. For nodes, this value is XmlNodeType.SignificantWhitespace. - @@ -501,11 +500,11 @@ Gets or sets the value of the node. The white space characters found in the node. - Setting to invalid white space characters. @@ -558,11 +557,11 @@ The to which you want to save. Saves all the children of the node to the specified . - @@ -614,11 +613,11 @@ The to which you want to save. Saves the node to the specified . - diff --git a/xml/System.Xml/XmlTextReader.xml b/xml/System.Xml/XmlTextReader.xml index f1d0a82c8d6..87185ba5447 100644 --- a/xml/System.Xml/XmlTextReader.xml +++ b/xml/System.Xml/XmlTextReader.xml @@ -240,7 +240,6 @@ ## Examples The following example loads an XML string into the `XmlTextReader` object using the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.cctor1/CPP/rdrcctor1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/rdrcctor1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.cctor1/VB/rdrcctor1.vb" id="Snippet1"::: @@ -324,7 +323,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example reads an XML file and displays each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -1003,7 +1001,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example parses an XML fragment. It uses the `XmlParserContext` and its to handle namespace resolution. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.Cctor/CPP/readfrag.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/readfrag.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.Cctor/VB/readfrag.vb" id="Snippet1"::: @@ -1070,7 +1067,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example displays all attributes on the current node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/VB/source.vb" id="Snippet1"::: @@ -1133,7 +1129,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example displays the base URI for each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.BaseURI Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/BaseURI/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.BaseURI Example/VB/source.vb" id="Snippet1"::: @@ -1411,7 +1406,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example displays each node including its depth, line number, and line position. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/Depth/readlinenum.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.LineNum/VB/readlinenum.vb" id="Snippet1"::: @@ -1799,7 +1793,6 @@ XmlTextReader reader = new XmlTextReader(s); ## Examples The following example gets the value of the ISBN attribute. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetAttribute1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/GetAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.GetAttribute1 Example/VB/source.vb" id="Snippet1"::: @@ -2019,7 +2012,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example reads the first part of an XML document and then uses `GetRemainder` to complete reading the document using a second reader. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.GetRemainder Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/GetRemainder/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.GetRemainder Example/VB/source.vb" id="Snippet1"::: @@ -2153,7 +2145,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example displays the value for every node that can have a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.HasValue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/HasValue/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.HasValue Example/VB/source.vb" id="Snippet1"::: @@ -2281,7 +2272,6 @@ String dt4 = reader.GetAttribute("dt",http://www.w3.org/2000/xmlns/); ## Examples The following example displays the text content of each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/IsEmptyElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/VB/source.vb" id="Snippet1"::: @@ -2457,7 +2447,6 @@ If the reader is positioned on a `DocumentType` node, this method can be used to ## Examples The following example displays each node including its depth, line number, and line position. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/Depth/readlinenum.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.LineNum/VB/readlinenum.vb" id="Snippet1"::: @@ -2533,7 +2522,6 @@ abc ## Examples The following example displays each node including its depth, line number, and line position. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.LineNum/CPP/readlinenum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/Depth/readlinenum.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.LineNum/VB/readlinenum.vb" id="Snippet1"::: @@ -2595,7 +2583,6 @@ abc ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/VB/source.vb" id="Snippet1"::: @@ -2755,7 +2742,6 @@ abc ## Examples The following example displays all attributes on the current node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/VB/source.vb" id="Snippet1"::: @@ -2946,7 +2932,6 @@ abc ## Examples The following example displays all attributes on the current node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/AttributeCount/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToElement Example/VB/source.vb" id="Snippet1"::: @@ -3008,7 +2993,6 @@ abc ## Examples The following example gets the value of the first attribute of the root node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToFirstAttribute Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/MoveToFirstAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.MoveToFirstAttribute Example/VB/source.vb" id="Snippet1"::: @@ -3076,7 +3060,6 @@ abc ## Examples The following example displays all attributes on the current node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.HasAttributes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/MoveToNextAttribute/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlReader.HasAttributes Example/VB/source.vb" id="Snippet1"::: @@ -3156,7 +3139,6 @@ abc ## Examples The following example reads an XML file and displays each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -3279,7 +3261,6 @@ abc ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/VB/source.vb" id="Snippet1"::: @@ -3399,7 +3380,6 @@ abc ## Examples The following example reads an XML file and displays each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -3487,7 +3467,6 @@ abc ## Examples The following example shows reader behavior with normalization turned on and then off. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.Normalization/CPP/readnormal.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/Normalization/readnormal.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.Normalization/VB/readnormal.vb" id="Snippet1"::: @@ -3548,7 +3527,6 @@ abc ## Examples The following example displays the local name of each node, and, if they exist, the prefix and namespace URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/LocalName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.LocalName Example/VB/source.vb" id="Snippet1"::: @@ -3737,7 +3715,6 @@ abc ## Examples The following example reads an XML file and displays each node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -3811,7 +3788,6 @@ abc ## Examples The following example reads an attribute with text and entity nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.ReadAttributeValue/CPP/readattrval.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/ReadAttributeValue/readattrval.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.ReadAttributeValue/VB/readattrval.vb" id="Snippet1"::: @@ -3881,7 +3857,6 @@ abc ## Examples The following example reads a file containing Base64 and BinHex data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/ReadBase64/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/VB/source.vb" id="Snippet1"::: @@ -3960,7 +3935,6 @@ abc ## Examples The following example reads a file containing `Base64` and `BinHex` data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/ReadBase64/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.ReadBase64 Example/VB/source.vb" id="Snippet1"::: @@ -4081,7 +4055,6 @@ if (XmlNodeType.Element == reader.NodeType && "thing" == reader.Name) ## Examples The following example reads in XML using `ReadChars`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.ReadChars Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/ReadChars/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.ReadChars Example/VB/source.vb" id="Snippet1"::: @@ -4524,7 +4497,6 @@ if (XmlNodeType.Element == reader.NodeType && "thing" == reader.Name) ## Examples The following example displays the text content of each element. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/IsEmptyElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlReader.IsStartElement Example/VB/source.vb" id="Snippet1"::: @@ -4605,7 +4577,6 @@ if (XmlNodeType.Element == reader.NodeType && "thing" == reader.Name) ## Examples The following example parses two XML documents in a single stream. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.ResetState/CPP/resetstate.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/ResetState/resetstate.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.ResetState/VB/resetstate.vb" id="Snippet1"::: @@ -5044,7 +5015,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example reads an XML file and displays each node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/.ctor/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.Name Example/VB/source.vb" id="Snippet1"::: @@ -5112,7 +5082,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example reads an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextReader.WhitespaceHandling Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/WhitespaceHandling/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextReader.WhitespaceHandling Example/VB/source.vb" id="Snippet1"::: @@ -5184,7 +5153,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example displays the `xml:lang` value for each of the nodes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlLang/CPP/readlang.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/XmlLang/readlang.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.XmlLang/VB/readlang.vb" id="Snippet1"::: @@ -5263,7 +5231,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example uses the `XmlResolver` property to specify the credentials necessary to access the networked file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlResolver/CPP/rdr_resolver.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/XmlResolver/rdr_resolver.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.XmlResolver/VB/rdr_resolver.vb" id="Snippet1"::: @@ -5327,7 +5294,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example parses a file and returns significant white space if an `xml:space='preserve'` scope is found. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextReader.XmlSpace/CPP/readspace.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextReader/XmlSpace/readspace.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextReader.XmlSpace/VB/readspace.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlTextWriter.xml b/xml/System.Xml/XmlTextWriter.xml index 20fa1a11814..043afe2a880 100644 --- a/xml/System.Xml/XmlTextWriter.xml +++ b/xml/System.Xml/XmlTextWriter.xml @@ -372,7 +372,6 @@ ## Examples The following example writes an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/VB/source.vb" id="Snippet1"::: @@ -433,7 +432,6 @@ ## Examples The following example writes out two XML fragments. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlTextWriter.Flush/CPP/write2docs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/Flush/write2docs.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlTextWriter.Flush/VB/write2docs.vb" id="Snippet1"::: @@ -524,7 +522,6 @@ XmlTextWriter w = new XmlTextWriter(Console.Out); ## Examples The following example writes an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/VB/source.vb" id="Snippet1"::: @@ -607,7 +604,6 @@ tw.WriteDocType(name, pubid, sysid, subset); ## Examples The following example writes an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/VB/source.vb" id="Snippet1"::: @@ -744,7 +740,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/LookupPrefix/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/VB/source.vb" id="Snippet1"::: @@ -931,7 +926,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example encodes an input file using `WriteBase64` and generates a temporary XML file. The temporary XML file is decoded using the method and compared to the original file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteBase64/CPP/writebase64.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteBase64/writebase64.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteBase64/VB/writebase64.vb" id="Snippet1"::: @@ -1065,7 +1059,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1131,7 +1124,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example uses the `WriteCharEntity` method to write an email address. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteTimeSpan Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCharEntity/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteTimeSpan Example/VB/source.vb" id="Snippet1"::: @@ -1275,7 +1267,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1358,7 +1349,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1428,7 +1418,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/LookupPrefix/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/VB/source.vb" id="Snippet1"::: @@ -1487,7 +1476,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1555,7 +1543,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteEndElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteEndElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteEndElement Example/VB/source.vb" id="Snippet1"::: @@ -1617,7 +1604,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1685,7 +1671,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes out an element with no content. It uses WriteFullEndElement to write the full end element tag. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteFullEndElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteFullEndElement/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteFullEndElement Example/VB/source.vb" id="Snippet1"::: @@ -1871,7 +1856,6 @@ The `XmlTextWriter` allows you to set this property to any character. To ensure ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -1978,7 +1962,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes out a portion of a XSD schema. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteQualifiedName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteQualifiedName/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteQualifiedName Example/VB/source.vb" id="Snippet1"::: @@ -2069,7 +2052,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes a string using the `WriteRaw` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteRaw1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteRaw/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteRaw1 Example/VB/source.vb" id="Snippet1"::: @@ -2218,7 +2200,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/LookupPrefix/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/VB/source.vb" id="Snippet1"::: @@ -2312,7 +2293,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes an XML file representing a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteCData/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartDocument Example/VB/source.vb" id="Snippet1"::: @@ -2449,7 +2429,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/LookupPrefix/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.WriteStartElement Example/VB/source.vb" id="Snippet1"::: @@ -2573,7 +2552,6 @@ writer.WriteStartElement("root"); ## Examples The following example writes an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/Close/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.Formatting Example/VB/source.vb" id="Snippet1"::: @@ -2703,7 +2681,6 @@ writer.WriteStartElement("root"); ## Examples The following example uses the `WriteWhitespace` method to control how the file is formatted. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteWhitespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/VB/source.vb" id="Snippet1"::: @@ -2843,7 +2820,6 @@ writer.WriteStartElement("root"); ## Examples The following example uses the `WriteWhitespace` method to control how the file is formatted. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlTextWriter/WriteWhitespace/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlTextWriter.XmlSpace Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Xml/XmlUrlResolver.xml b/xml/System.Xml/XmlUrlResolver.xml index 9a5f3ebde45..86cd54a6f4a 100644 --- a/xml/System.Xml/XmlUrlResolver.xml +++ b/xml/System.Xml/XmlUrlResolver.xml @@ -50,48 +50,48 @@ Resolves external XML resources named by a Uniform Resource Identifier (URI). - is used to resolve external XML resources such as entities, document type definitions (DTDs) or schemas. It is also used to process include and import elements found in Extensible StyleSheet Language (XSL) style sheets or XML Schema definition language (XSD) schemas. - - is the default resolver for all classes in the namespace. It supports the `file://` and `http://` protocols and requests from the class. - + is used to resolve external XML resources such as entities, document type definitions (DTDs) or schemas. It is also used to process include and import elements found in Extensible StyleSheet Language (XSL) style sheets or XML Schema definition language (XSD) schemas. + + is the default resolver for all classes in the namespace. It supports the `file://` and `http://` protocols and requests from the class. + > [!IMPORTANT] -> objects can contain sensitive information such as user credentials. You should be careful when you cache objects and should not pass objects to an untrusted component. - -## Resolving DTDs - If an XML reader () is reading an XML file that contains an external DTD, it calls the method to get a stream representation of the DTD. If the URI of the DTD is a relative URI, the XML reader calls the method and returns an absolute URI for the given `relativeUri` and `baseURi` parameters. If the doesn't know how to resolve the URI, it returns `null`. - - The method uses the information in the property as appropriate to gain access to the resource. There is no `get` accessor to this property for security reasons. When overwriting , **GetEntity** is the method that utilizes the credential information in the **Credentials** property. - - Resolving all other XML resources is very similar to resolving DTDs. negotiates the connection with the external resource and returns a representation of the content. The object that is making the call to interprets the stream. - -## Extending the XmlUrlResolver class - The default behavior of the class is to resolve an XML data resource from its source, not from cache. In some cases, resolving a data resource from cache can improve the performance of an application by saving a trip to the data resource's server. The performance gains here must be weighed against the need for up-to-date content. - - The following example extends and builds a new class, `XmlCachingResolver`, to retrieve resources from the cache. This is done by overriding the property and the method. - +> objects can contain sensitive information such as user credentials. You should be careful when you cache objects and should not pass objects to an untrusted component. + +## Resolving DTDs + If an XML reader () is reading an XML file that contains an external DTD, it calls the method to get a stream representation of the DTD. If the URI of the DTD is a relative URI, the XML reader calls the method and returns an absolute URI for the given `relativeUri` and `baseURi` parameters. If the doesn't know how to resolve the URI, it returns `null`. + + The method uses the information in the property as appropriate to gain access to the resource. There is no `get` accessor to this property for security reasons. When overwriting , **GetEntity** is the method that utilizes the credential information in the **Credentials** property. + + Resolving all other XML resources is very similar to resolving DTDs. negotiates the connection with the external resource and returns a representation of the content. The object that is making the call to interprets the stream. + +## Extending the XmlUrlResolver class + The default behavior of the class is to resolve an XML data resource from its source, not from cache. In some cases, resolving a data resource from cache can improve the performance of an application by saving a trip to the data resource's server. The performance gains here must be weighed against the need for up-to-date content. + + The following example extends and builds a new class, `XmlCachingResolver`, to retrieve resources from the cache. This is done by overriding the property and the method. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlUrlResolver/Overview/XmlCachingResolver_ex.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlCachingResolver_ex/VB/XmlCachingResolver_ex.vb" id="Snippet1"::: - - The caching behavior of the `XmlCachingResolver` class is implemented in the `GetEntity` method. This is done by creating new and objects. The object is created using the member of the enumeration. - - The property of the object is set with the object. - - An instance of the `XmlCachingResolver` class is created with the `Boolean` `enableHttpCaching`. When this value is set to `true`, the instance resolves a resource from the default cache if possible. When `enableHttpCaching` is set to `false`, the instance uses the default behavior and resolves resources from their source. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlCachingResolver_ex/VB/XmlCachingResolver_ex.vb" id="Snippet1"::: + + The caching behavior of the `XmlCachingResolver` class is implemented in the `GetEntity` method. This is done by creating new and objects. The object is created using the member of the enumeration. + + The property of the object is set with the object. + + An instance of the `XmlCachingResolver` class is created with the `Boolean` `enableHttpCaching`. When this value is set to `true`, the instance resolves a resource from the default cache if possible. When `enableHttpCaching` is set to `false`, the instance uses the default behavior and resolves resources from their source. + > [!NOTE] -> This example leverages the extensibility of the XML classes in the .NET Framework. Other classes can be extended and customized to suit the needs of a particular application. - - - -## Examples - The following example creates an that uses an with default credentials. - +> This example leverages the extensibility of the XML classes in the .NET Framework. Other classes can be extended and customized to suit the needs of a particular application. + + + +## Examples + The following example creates an that uses an with default credentials. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlUrlResolver/Overview/XmlResolver_Samples.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlResolver_Samples/VB/XmlResolver_Samples.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlResolver_Samples/VB/XmlResolver_Samples.vb" id="Snippet1"::: + ]]> XML Documents and Data @@ -238,32 +238,32 @@ Sets credentials used to authenticate web requests. The credentials to be used to authenticate web requests. If this property is not set, the value defaults to ; that is, the has no user credentials. - property to a credential cache. - -```csharp -NetworkCredential myCred = new NetworkCredential(UserName,SecurelyStoredPassword,Domain); -CredentialCache myCache = new CredentialCache(); -myCache.Add(new Uri("http://www.contoso.com/"), "Basic", myCred); -myCache.Add(new Uri("http://app.contoso.com/"), "Basic", myCred); -XmlUrlResolver resolver = new XmlUrlResolver(); -resolver.Credentials = myCache; -``` - - - -## Examples - The following example creates an object with credentials. The uses the credentials on the object to access a network resource. - + property to a credential cache. + +```csharp +NetworkCredential myCred = new NetworkCredential(UserName,SecurelyStoredPassword,Domain); +CredentialCache myCache = new CredentialCache(); +myCache.Add(new Uri("http://www.contoso.com/"), "Basic", myCred); +myCache.Add(new Uri("http://app.contoso.com/"), "Basic", myCred); +XmlUrlResolver resolver = new XmlUrlResolver(); +resolver.Credentials = myCache; +``` + + + +## Examples + The following example creates an object with credentials. The uses the credentials on the object to access a network resource. + :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlUrlResolver/Overview/XmlResolver_Samples.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlResolver_Samples/VB/XmlResolver_Samples.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlResolver_Samples/VB/XmlResolver_Samples.vb" id="Snippet2"::: + ]]> @@ -325,25 +325,24 @@ resolver.Credentials = myCache; Maps a URI to an object that contains the actual resource. A stream object or if a type other than stream is specified. - . - + . + > [!IMPORTANT] -> Your application can mitigate memory denial of service threats to the method by implementing IStream to limit the number of bytes read. This helps guard against situations where malicious code attempts to pass an infinite stream of bytes to the method. - - +> Your application can mitigate memory denial of service threats to the method by implementing IStream to limit the number of bytes read. This helps guard against situations where malicious code attempts to pass an infinite stream of bytes to the method. + + + +## Examples + The following example demonstrates the `GetEntity` and methods. -## Examples - The following example demonstrates the `GetEntity` and methods. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlUrlResolver/GetEntity/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlUrlResolver.ResolveUri Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -523,11 +522,11 @@ resolver.Credentials = myCache; Resolves the absolute URI from the base and relative URIs. The absolute URI, or if the relative URI cannot be resolved. - diff --git a/xml/System.Xml/XmlWhitespace.xml b/xml/System.Xml/XmlWhitespace.xml index 91a2fe19f2a..9d5ea9c1f7d 100644 --- a/xml/System.Xml/XmlWhitespace.xml +++ b/xml/System.Xml/XmlWhitespace.xml @@ -64,11 +64,11 @@ Represents white space in element content. - @@ -128,11 +128,11 @@ The object. Initializes a new instance of the class. - @@ -186,13 +186,13 @@ Creates a duplicate of this node. The cloned node. - serves as a copy constructor for nodes. To see how this method behaves with other node types, see . - - The cloned node has no parent. returns `null`. - + serves as a copy constructor for nodes. To see how this method behaves with other node types, see . + + The cloned node has no parent. returns `null`. + ]]> @@ -333,15 +333,14 @@ Gets the type of the node. For nodes, the value is . - @@ -501,11 +500,11 @@ Gets or sets the value of the node. The white space characters found in the node. - Setting to invalid white space characters. @@ -558,11 +557,11 @@ The to which you want to save. Saves all the children of the node to the specified . - @@ -614,11 +613,11 @@ The to which you want to save. Saves the node to the specified . - diff --git a/xml/System.Xml/XmlWriter.xml b/xml/System.Xml/XmlWriter.xml index d33382fd843..776a3cf7b1f 100644 --- a/xml/System.Xml/XmlWriter.xml +++ b/xml/System.Xml/XmlWriter.xml @@ -199,7 +199,6 @@ ## Examples The following example writes an XML node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Close/writeelems.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.Close/VB/writeelems.vb" id="Snippet1"::: @@ -1251,7 +1250,6 @@ An method was called before a previous asy ## Examples The following example writes two XML fragments. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.Flush/CPP/write2docs_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Flush/write2docs_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.Flush/VB/write2docs_v2.vb" id="Snippet1"::: @@ -1371,7 +1369,6 @@ An asynchronous method was called without ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/LookupPrefix/writeelemstring_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteElementString/VB/writeelemstring_v2.vb" id="Snippet1"::: @@ -1549,7 +1546,6 @@ This member may behave differently when it is used in a Portable Class Library p ## Examples The following example copies all the elements to the output, changes the tag names to upper case, and copies all the attributes unchanged. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributes/CPP/writeattrs_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/WriteAttributes/writeattrs_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteAttributes/VB/writeattrs_v2.vb" id="Snippet1"::: @@ -1729,7 +1725,6 @@ An asynchronous method was called without ## Examples The following example writes out a book. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/LookupPrefix/writeelemstring_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteElementString/VB/writeelemstring_v2.vb" id="Snippet1"::: @@ -1826,7 +1821,6 @@ An method was called before a previous asy ## Examples The following example uses the method to write a namespace declaration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributeString/CPP/writeattrstring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/WriteAttributeString/writeattrstring.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteAttributeString/VB/writeattrstring.vb" id="Snippet1"::: @@ -1919,7 +1913,6 @@ An method was called before a previous asy ## Examples The following example uses the method to write a namespace declaration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteAttributeString/CPP/writeattrstring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/WriteAttributeString/writeattrstring.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteAttributeString/VB/writeattrstring.vb" id="Snippet1"::: @@ -3105,7 +3098,6 @@ An asynchronous method was called without ## Examples The following example uses several write methods to create an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/LookupPrefix/writeelemstring_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteElementString/VB/writeelemstring_v2.vb" id="Snippet1"::: @@ -3187,7 +3179,6 @@ An asynchronous method was called without ## Examples The following example uses several write methods to create an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/LookupPrefix/writeelemstring_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteElementString/VB/writeelemstring_v2.vb" id="Snippet1"::: @@ -4353,7 +4344,6 @@ while (!reader.EOF){ ## Examples The following example writes the first and last book nodes out to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteNode/CPP/writenode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/WriteNode/writenode.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteNode/VB/writenode.vb" id="Snippet1"::: @@ -5940,7 +5930,6 @@ An asynchronous method was called without ## Examples The following example writes an XML node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Close/writeelems.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.Close/VB/writeelems.vb" id="Snippet1"::: @@ -6111,7 +6100,6 @@ An method was called before a previous asy ## Examples The following example writes out an XML fragment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.WriteElementString/CPP/writeelemstring_v2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/LookupPrefix/writeelemstring_v2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.WriteElementString/VB/writeelemstring_v2.vb" id="Snippet1"::: @@ -6325,7 +6313,6 @@ test<item>test ## Examples The following example writes an XML node. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Data/XmlWriter.Close/CPP/XmlWriter.Close.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Xml/XmlWriter/Close/writeelems.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Data/XmlWriter.Close/VB/writeelems.vb" id="Snippet1"::: diff --git a/xml/ns-System.Drawing.Drawing2D.xml b/xml/ns-System.Drawing.Drawing2D.xml index ba141f8a2d7..8fa569d4fad 100644 --- a/xml/ns-System.Drawing.Drawing2D.xml +++ b/xml/ns-System.Drawing.Drawing2D.xml @@ -23,6 +23,6 @@ ]]> - Coordinate Systems and Transformations + Coordinate Systems and Transformations diff --git a/xml/ns-System.Drawing.Imaging.xml b/xml/ns-System.Drawing.Imaging.xml index 03c4bb7ebed..b664e7c5984 100644 --- a/xml/ns-System.Drawing.Imaging.xml +++ b/xml/ns-System.Drawing.Imaging.xml @@ -15,10 +15,10 @@ ]]> - Graphics and Drawing in Windows Forms - Images, Bitmaps, and Metafiles + Graphics and Drawing in Windows Forms + Images, Bitmaps, and Metafiles Working with Images, Bitmaps, Icons, and Metafiles - Using Image Encoders and Decoders in Managed GDI+ - Recoloring Images + Using Image Encoders and Decoders in Managed GDI+ + Recoloring Images diff --git a/xml/ns-System.Drawing.Printing.xml b/xml/ns-System.Drawing.Printing.xml index 517158fca32..65c6d14e42d 100644 --- a/xml/ns-System.Drawing.Printing.xml +++ b/xml/ns-System.Drawing.Printing.xml @@ -24,6 +24,6 @@ ]]> - Windows Forms Print Support + Windows Forms Print Support diff --git a/xml/ns-System.Drawing.Text.xml b/xml/ns-System.Drawing.Text.xml index 42e356ceebf..13f78eed83c 100644 --- a/xml/ns-System.Drawing.Text.xml +++ b/xml/ns-System.Drawing.Text.xml @@ -12,6 +12,6 @@ ]]> - Using Fonts and Text + Using Fonts and Text diff --git a/xml/ns-System.Windows.Forms.VisualStyles.xml b/xml/ns-System.Windows.Forms.VisualStyles.xml index 424beaae6b2..22398c600b7 100644 --- a/xml/ns-System.Windows.Forms.VisualStyles.xml +++ b/xml/ns-System.Windows.Forms.VisualStyles.xml @@ -17,6 +17,6 @@ ]]> - Rendering Controls with Visual Styles + Rendering Controls with Visual Styles
ProductIdName